BSD-3-Clause licensed by Fumiaki Kinoshita
Maintained by Fumiaki Kinoshita
This version can be pinned in stack with:monad-skeleton-0.2@sha256:1768220a01d010020adfd7a8e435998c8e5e1a6a562866dd54b3af23e08e123f,1053

Module documentation for 0.2

Depends on 1 package(full list with versions):

monad-skeleton

Build Status Hackage

This package provides Skeleton, an operational monad (i.e. free monad that does not require the Functor implementation). The internal encoding gives O(1) bind and monadic reflection.

Skeleton promotes unit instructions to a monad. It is isomorphic to MonadView (Skeleton t):

data MonadView t m x where
  Return :: a -> MonadView t m a
  (:>>=) :: !(t a) -> (a -> m b) -> MonadView t m b

boned :: MonadView t (Skeleton t) a -> Skeleton t a
debone :: Skeleton t a -> MonadView t (Skeleton t) a

GADTs are handy to define instructions:

data Interaction x where
  Get :: Interaction String
  Put :: String -> Interaction ()

echo :: Skeleton Interaction ()
echo = bone Get >>= bone . Put

Use debone to interpret a computation.

interpret :: Skeleton Interaction a -> IO a
interpret m = case debone m of
  Return a -> return a
  Get :>>= k -> getLine >>= interpret . k
  Put s :>>= k -> putStrLn s >>= interpret . k

Changes

0.2

  • Removed unbone

0.1.4

  • Changed the representation of Skeleton for performance optimisation