Closed edsko closed 1 year ago
Related suggestion from @phadej for a monad-law-preserving
data Freer f a where
Pure :: a -> Freer f a
Bind :: f b -> (b -> Freer f a) -> Freer f a
newtype Prim a = Prim (SMGen -> a)
interpret :: SMGen -> Freer Prim a -> a
interpret _ (Pure x) = x
interpret g (Bind (Prim f) k = case split g of
(g1, g2) -> interpret g2 (k (f g1))
Note that Prim
can capture the SMGen
here, which would enable us to define promote
. If we can make something like this work, that would be nice, but it requires some thought.
Some references:
Argument
class in the presentation is calledFunction
in modern QuickCheck.)Pretty sure that at least
promote
is not definable, because it relies on capturing the PRNG. Would it make sense to have an additional constructor inGen
for this...?perhaps...? How would that then shrink...?