This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE GADTs #-} | |
-- | Toy instructional example of GADTs: simple dynamic types. | |
-- | |
-- Before tackling this, skim the GHC docs section on GADTs: | |
-- | |
-- <http://www.haskell.org/ghc/docs/latest/html/users_guide/data-type-extensions.html#gadt> | |
-- | |
-- As you read this example keep in mind this quote from the | |
-- docs: "The key point about GADTs is that /pattern matching |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE GeneralizedNewtypeDeriving, DoRec #-} | |
module Control.Monad.Trans.Seer | |
( SeerT | |
, runSeerT -- :: MonadFix m => SeerT w m a -> m (a, w) | |
, evalSeerT -- :: MonadFix m => SeerT w m a -> m a | |
, execSeerT -- :: MonadFix m => SeerT w m a -> m w | |
, send -- :: (Monoid w, Monad m) => w -> SeerT w m () | |
, see -- :: (Monoid w, Monad m) => SeerT w m w |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE GeneralizedNewtypeDeriving, FlexibleInstances #-} | |
{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies #-} | |
module SeerA (SeerA, runSeerA, see, send, contact) where | |
import Control.Applicative | |
import Data.Functor.Constant | |
import Data.Functor.Product | |
import Data.Monoid (Monoid, mempty, (<>), Sum(..)) | |
import Data.Traversable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE RankNTypes, ScopedTypeVariables #-} | |
import Control.Monad.ST | |
import Data.Foldable as F | |
import Data.Array.ST | |
import Data.Sequence (Seq) | |
import qualified Data.Sequence as Seq | |
import Criterion.Main | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE GADTs, ConstraintKinds, KindSignatures, DeriveDataTypeable #-} | |
{-# LANGUAGE TypeOperators, ScopedTypeVariables, FlexibleInstances #-} | |
module Shape where | |
import Control.Applicative ((<$>), (<|>)) | |
import Data.Maybe (mapMaybe) | |
import Data.Typeable | |
import GHC.Exts (Constraint) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
i x = x s k | |
where s f g x = f x (g x) | |
k x y = x | |
-- Now this gives an epic compilation error... | |
k = i (i (i i)) | |
s = i (i (i (i i))) | |
{- | |
GHCi, version 7.10.2: http://www.haskell.org/ghc/ :? for help |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"$schema": "https://vega.github.io/schema/vega/v5.json", | |
"background": "white", | |
"padding": 5, | |
"style": "cell", | |
"data": [ | |
{ | |
"name": "example-data", | |
"values": [ | |
{"y": 5, "value": -1}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"$schema": "https://vega.github.io/schema/vega-lite/v4.json", | |
"data": {"url": "data/cars.json"}, | |
"transform": [ | |
{ | |
"aggregate": [{"op": "count", "as": "num_cars"}], | |
"groupby": ["Origin", "Cylinders"] | |
} | |
], | |
"encoding": { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"config": { | |
"axis": {"labelFontSize": 14, "titleFontSize": 14}, | |
"header": {"labelFontSize": 14, "titleFontSize": 14}, | |
"legend": {"labelFontSize": 14, "titleFontSize": 14}, | |
"title": {"align": "center", "fontSize": 20, "offset": 15} | |
}, | |
"data": {"name": "data-1a2ae6c5a330adb8d6b476cc8f14c107"}, | |
"mark": { | |
"type": "point", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"$schema": "https://vega.github.io/schema/vega-lite/v4.8.1.json", | |
"title": "Negative values in the size channel", | |
"data": { | |
"values": [-4, -3, -2, -1, 0, 1, 2, 3, 4] | |
}, | |
"transform": [ | |
{"calculate": "abs(datum.data)", "as": "abs"} | |
], | |
"repeat": ["data", "abs"], |
OlderNewer