Skip to content

Instantly share code, notes, and snippets.

View graninas's full-sized avatar
😊
My Twitter: graninas

Alexander Granin graninas

😊
My Twitter: graninas
View GitHub Profile
@graninas
graninas / ChurchState.hs
Created September 13, 2023 18:53
Some thoughts on merging Church Free and State monad
-- 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)
@graninas
graninas / StateLangSpec.hs
Created September 14, 2023 15:24
Church Free monad based State
module StateLangSpec where
import Test.Hspec
import Data.IORef
import Control.Monad.Free.Church
data StateMethod s next
= Put s (() -> next)
| Get (s -> next)