Safe Haskell | None |
---|
Strict state effect
Example: implementing Fresh
runFresh' :: (Typeable i, Enum i, Num i) => Eff (Fresh i :> r) w -> i -> Eff r w runFresh' m s = fst <$> runState s (loop $ admin m) where loop (Val x) = return x loop (E u) = case decomp u of Right (Fresh k) -> do n <- get put (n + 1) loop (k n) Left u' -> send (\k -> unsafeReUnion $ k <$> u') >>= loop