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
{ | |
"nonce": "0xcafebabecafebabe", | |
"timestamp": "0x0", | |
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", | |
"extraData": "0x0", | |
"gasLimit": "0xfffffff", | |
"difficulty": "0x400", | |
"mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000", | |
"coinbase": "0x3333333333333333333333333333333333333333", | |
"alloc": { |
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 DeriveFunctor #-} | |
{-# LANGUAGE LambdaCase #-} | |
import Control.Applicative.Free | |
import Control.Monad | |
import Control.Monad.Free | |
import Control.Monad.Primitive | |
import System.Random.MWC.Probability (Prob) | |
import qualified System.Random.MWC.Probability as MWC |
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 LambdaCase #-} | |
{-# LANGUAGE TypeFamilies #-} | |
import Control.Comonad.Cofree | |
import Control.Monad.Free | |
import Data.Functor.Foldable | |
oddIndices :: [a] -> [a] | |
oddIndices = histo $ \case | |
Nil -> [] |
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 DeriveFunctor #-} | |
{-# LANGUAGE LambdaCase #-} | |
{-# LANGUAGE TypeFamilies #-} | |
import Data.Functor.Foldable hiding (Foldable, Unfoldable) | |
import qualified Data.Functor.Foldable as RS (Foldable, Unfoldable) | |
data Expr = | |
Num Int | |
| Sum Expr Expr |
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 DeriveFunctor #-} | |
{-# LANGUAGE TypeFamilies #-} | |
import Data.Functor.Foldable | |
data ListF a r = | |
ConsF a r | |
| NilF | |
deriving (Show, Functor) |
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 DeriveFunctor #-} | |
{-# LANGUAGE FlexibleContexts #-} | |
{-# LANGUAGE StandaloneDeriving #-} | |
{-# LANGUAGE UndecidableInstances #-} | |
data Program f a = Program { | |
annotation :: a | |
, running :: f (Program f a) | |
} |
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 DeriveFunctor #-} | |
{-# LANGUAGE FlexibleContexts #-} | |
{-# LANGUAGE StandaloneDeriving #-} | |
{-# LANGUAGE UndecidableInstances #-} | |
data Program f a = | |
Running (f (Program f a)) | |
| Terminated a | |
deriving instance (Show a, Show (f (Program f a))) => Show (Program f a) |
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 DeriveFunctor #-} | |
{-# LANGUAGE FlexibleContexts #-} | |
{-# LANGUAGE StandaloneDeriving #-} | |
{-# LANGUAGE UndecidableInstances #-} | |
data Program f = Running (f (Program f)) | |
deriving instance (Show (f (Program f))) => Show (Program f) | |
data Instruction r = |
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 DeriveFunctor #-} | |
{-# LANGUAGE FlexibleContexts #-} | |
{-# LANGUAGE StandaloneDeriving #-} | |
{-# LANGUAGE UndecidableInstances #-} | |
import Prelude hiding (succ) | |
newtype Fix f = Fix (f (Fix f)) | |
deriving instance (Show (f (Fix f))) => Show (Fix f) |
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 DeriveFunctor #-} | |
import Data.List.Ordered (merge) | |
import Data.Functor.Foldable | |
import Prelude hiding (Foldable, succ) | |
data NatF r = | |
ZeroF | |
| SuccF r | |
deriving (Show, Functor) |