packages feed

monad-skeleton 0.1.1 → 0.1.2

raw patch · 2 files changed

+23/−6 lines, 2 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Control.Monad.Skeleton: hoistMonadView :: (forall x. s x -> t x) -> (m a -> n a) -> MonadView s m a -> MonadView t n a
+ Control.Monad.Skeleton: boned :: MonadView t (Skeleton t) a -> Skeleton t a
+ Control.Monad.Skeleton: hoistMV :: (forall x. s x -> t x) -> (m a -> n a) -> MonadView s m a -> MonadView t n a
+ Control.Monad.Skeleton: iterMV :: Monad m => (t a -> MonadView m t a) -> t a -> m a

Files

monad-skeleton.cabal view
@@ -1,5 +1,5 @@ name:                monad-skeleton
-version:             0.1.1
+version:             0.1.2
 synopsis:            An undead monad
 description:         A simple operational monad based on Reflection without Remorse
 homepage:            https://github.com/fumieval/monad-skeleton
src/Control/Monad/Skeleton.hs view
@@ -1,5 +1,12 @@ {-# LANGUAGE Trustworthy, RankNTypes, GADTs, PolyKinds #-}-module Control.Monad.Skeleton (MonadView(..), hoistMonadView, Skeleton, bone, unbone, hoistSkeleton) where+module Control.Monad.Skeleton (MonadView(..)+  , hoistMV+  , iterMV+  , Skeleton+  , bone+  , unbone+  , boned+  , hoistSkeleton) where import qualified Data.Sequence as Seq import Unsafe.Coerce import Control.Category@@ -9,6 +16,10 @@ import GHC.Prim import Prelude hiding (id, (.)) +boned :: MonadView t (Skeleton t) a -> Skeleton t a+boned t = Skeleton t id+{-# INLINE boned #-}+ unbone :: Skeleton t a -> MonadView t (Skeleton t) a unbone (Skeleton (Return a) s) = case viewL s of   Empty -> Return a@@ -22,7 +33,7 @@ {-# INLINABLE bone #-}  hoistSkeleton :: (forall x. s x -> t x) -> Skeleton s a -> Skeleton t a-hoistSkeleton f (Skeleton v c) = Skeleton (hoistMonadView f (hoistSkeleton f) v)+hoistSkeleton f (Skeleton v c) = Skeleton (hoistMV f (hoistSkeleton f) v)   (transCat (transKleisli (hoistSkeleton f)) c)  data MonadView t m x where@@ -30,9 +41,15 @@   (:>>=) :: t a -> (a -> m b) -> MonadView t m b infixl 1 :>>= -hoistMonadView :: (forall x. s x -> t x) -> (m a -> n a) -> MonadView s m a -> MonadView t n a-hoistMonadView _ _ (Return a) = Return a-hoistMonadView f g (t :>>= k) = f t :>>= g . k+hoistMV :: (forall x. s x -> t x) -> (m a -> n a) -> MonadView s m a -> MonadView t n a+hoistMV _ _ (Return a) = Return a+hoistMV f g (t :>>= k) = f t :>>= g . k++iterMV :: Monad m => (t a -> MonadView m t a) -> t a -> m a+iterMV f = go where+  go t = case f t of+    m :>>= k -> m >>= go . k+    Return a -> return a  data Skeleton t a where   Skeleton :: MonadView t (Skeleton t) x -> Cat (Kleisli (Skeleton t)) x a -> Skeleton t a