view src/delta_instance_monad.hs @ 56:398b42a1ac19

Fix layouts
author Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
date Mon, 16 Feb 2015 15:05:11 +0900
parents ba7f0b5454ab
children
line wrap: on
line source

headDelta :: Delta a -> a
headDelta (Mono  x)   = x
headDelta (Delta x _) = x

tailDelta :: Delta a -> Delta a
tailDelta (Mono x)     = Mono x
tailDelta (Delta _ ds) = ds


instance Monad Delta where
  return x = Mono x
  (Mono x) >>= f     = f x
  (Delta x d) >>= f  = Delta (headDelta (f x))
                             (d >>= (tailDelta . f))