Created
June 12, 2017 18:20
-
-
Save furu/96119ca9ec5191ece457586ba5fb8207 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Control.Spoon (spoon) | |
import Control.DeepSeq (NFData) | |
predMay :: (Enum a, NFData a) => a -> Maybe a | |
predMay = spoon . pred | |
pred3 :: (Enum a, NFData a) => a -> Maybe a | |
pred3 x = return x >>= predMay >>= predMay >>= predMay | |
predN :: (Enum a, NFData a) => Int -> a -> Maybe a | |
predN 0 x = return x | |
predN n x = predN (n - 1) x >>= predMay | |
main :: IO () | |
main = do | |
putStrLn "hello world" | |
print $ pred3 True | |
print $ predN 256 'a' | |
print $ predN 32 'z' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment