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
-- Option 1: State as an eDSL | |
data StateMethod s next | |
= Put s (() -> next) | |
| Get (s -> next) | |
instance Functor (StateMethod s) where | |
fmap f (Put st next) = Put st (f . next) | |
fmap f (Get next) = Get (f . next) |
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
module StateLangSpec where | |
import Test.Hspec | |
import Data.IORef | |
import Control.Monad.Free.Church | |
data StateMethod s next | |
= Put s (() -> next) | |
| Get (s -> next) |
OlderNewer