Mercurial > hg > Papers > 2015 > atton-thesis
view paper/src/deltaM_definition.hs @ 60:1181b4facaf9
Move papers into directory
author | Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 16 Feb 2015 17:09:53 +0900 |
parents | src/deltaM_definition.hs@ba7f0b5454ab |
children |
line wrap: on
line source
data DeltaM m a = DeltaM (Delta (m a)) deriving (Show) -- DeltaM utils unDeltaM :: DeltaM m a -> Delta (m a) unDeltaM (DeltaM d) = d headDeltaM :: DeltaM m a -> m a headDeltaM (DeltaM d) = headDelta d tailDeltaM :: DeltaM m a -> DeltaM m a tailDeltaM (DeltaM d) = DeltaM $ tailDelta d -- DeltaM instance definitions mu :: (Functor m, Monad m) => DeltaM m (DeltaM m a) -> DeltaM m a mu d@(DeltaM (Mono _)) = DeltaM (Mono ((>>= id) (fmap headDeltaM (headDeltaM d)))) mu d@(DeltaM (Delta _ _)) = DeltaM (Delta ((>>= id) (fmap headDeltaM (headDeltaM d))) (unDeltaM (mu (fmap tailDeltaM (tailDeltaM d))))) instance (Functor m, Monad m) => Monad (DeltaM m) where return x = DeltaM (Mono (return x)) d >>= f = mu (fmap f d)