Mercurial > hg > Members > atton > delta_monad
comparison delta.hs @ 94:bcd4fe52a504
Rewrite monad definitions for delta/deltaM
author | Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 19 Jan 2015 17:10:29 +0900 |
parents | a1723b3ea997 |
children | 0580e1642477 |
comparison
equal
deleted
inserted
replaced
93:8d92ed54a94f | 94:bcd4fe52a504 |
---|---|
126 (DeltaM (Delta f df)) <*> (DeltaM (Delta x dx)) = appendDeltaM (DeltaM $ Mono $ f <*> x) ((DeltaM df) <*> (DeltaM dx)) | 126 (DeltaM (Delta f df)) <*> (DeltaM (Delta x dx)) = appendDeltaM (DeltaM $ Mono $ f <*> x) ((DeltaM df) <*> (DeltaM dx)) |
127 | 127 |
128 instance (Monad m) => Monad (DeltaM m) where | 128 instance (Monad m) => Monad (DeltaM m) where |
129 return x = DeltaM $ Mono $ return x | 129 return x = DeltaM $ Mono $ return x |
130 (DeltaM (Mono x)) >>= f = DeltaM $ Mono $ (x >>= headDeltaM . f) | 130 (DeltaM (Mono x)) >>= f = DeltaM $ Mono $ (x >>= headDeltaM . f) |
131 (DeltaM (Delta x d)) >>= f = appendDeltaM ((DeltaM $ Mono x) >>= f) | 131 (DeltaM (Delta x d)) >>= f = appendDeltaM (DeltaM $ Mono $ (x >>= (headDeltaM . f))) |
132 ((DeltaM d) >>= tailDeltaM . f) | 132 ((DeltaM d) >>= tailDeltaM . f) |
133 | 133 |
134 | 134 |
135 -- DeltaM examples | 135 -- DeltaM examples |
136 | 136 |