changeset 119:f2187ad63791

ReDefine DeltaM-mu in Haskell
author Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
date Mon, 02 Feb 2015 12:01:32 +0900
parents 53cb21845dea
children 0f9ecd118a03
files delta.hs
diffstat 1 files changed, 6 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/delta.hs	Mon Feb 02 11:54:23 2015 +0900
+++ b/delta.hs	Mon Feb 02 12:01:32 2015 +0900
@@ -95,6 +95,9 @@
 
 -- DeltaM utils
 
+unDeltaM :: DeltaM m a -> Delta (m a)
+unDeltaM (DeltaM d) = d
+
 headDeltaM :: DeltaM m a -> m a
 headDeltaM (DeltaM d) = headDelta d
 
@@ -125,9 +128,9 @@
 
 
 mu' :: (Functor m, Monad m) => DeltaM m (DeltaM m a) -> DeltaM m a
-mu' (DeltaM (Mono x))    = DeltaM $ Mono $ (>>= id) $ fmap headDeltaM x
-mu' (DeltaM (Delta x d)) = appendDeltaM (mu' $ DeltaM $ Mono x)
-                                        (mu' $ fmap tailDeltaM $ DeltaM d )
+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