Mercurial > hg > Members > atton > similar_monad
comparison similer.hs @ 6:5e367a167382
Define samples
author | Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 02 Sep 2014 11:06:49 +0900 |
parents | 051c663a4af2 |
children | 6e0285628ead |
comparison
equal
deleted
inserted
replaced
5:051c663a4af2 | 6:5e367a167382 |
---|---|
22 plusTwo :: Int -> Similer Int (Similer Int Int) | 22 plusTwo :: Int -> Similer Int (Similer Int Int) |
23 plusTwo x = Similer x double (Similer (x + 2) id (x + 2)) | 23 plusTwo x = Similer x double (Similer (x + 2) id (x + 2)) |
24 | 24 |
25 same :: Eq b => Similer a b -> b | 25 same :: Eq b => Similer a b -> b |
26 same (Similer x f y) = if (f x) == y then y else undefined | 26 same (Similer x f y) = if (f x) == y then y else undefined |
27 | |
28 | |
29 -- samples | |
30 | |
31 sameExample :: [Int] | |
32 sameExample = map same $ map (fmap same) $ fmap twicePlus [1..10] | |
33 | |
34 nonSameExample :: [Int] | |
35 nonSameExample = map same $ map (fmap same) $ fmap plusTwo [1..10] | |
36 | |
37 nonSameExampleSpecific :: [Int] | |
38 nonSameExampleSpecific = map same $ map (fmap same) $ fmap plusTwo [2] |