Mercurial > hg > Members > atton > delta_monad
changeset 146:57601209eff3 default tip
Add an example used multi types on Delta
author | Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 24 Mar 2015 17:04:00 +0900 |
parents | b93e4b2aea9e |
children | |
files | haskell/Example/DynamicDelta.hs |
diffstat | 1 files changed, 19 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/haskell/Example/DynamicDelta.hs Tue Mar 24 17:04:00 2015 +0900 @@ -0,0 +1,19 @@ +module Example.DynamicDelta where + +import Delta +import Data.Dynamic + +val :: Delta Dynamic +val = Delta (toDyn True) (Mono (toDyn ([1,2,3,2,1] :: [Int]))) + +func :: Dynamic -> Delta Dynamic +func x = let funcToBool = toDyn not + funcToList = toDyn (sum :: [Int] -> Int) + in + Delta (dynApp funcToBool x) (Mono (dynApp funcToList x)) + +firstVal :: Delta Dynamic -> Maybe Bool +firstVal = fromDynamic . headDelta + +secondVal :: Delta Dynamic -> Maybe Int +secondVal = fromDynamic . headDelta . tailDelta