Skip to content

Instantly share code, notes, and snippets.

@skatenerd
Last active August 29, 2015 14:02
Show Gist options
  • Save skatenerd/d8c3cba25699a3c196e9 to your computer and use it in GitHub Desktop.
Save skatenerd/d8c3cba25699a3c196e9 to your computer and use it in GitHub Desktop.
indirection
import Control.Monad.Instances
addStuff = do
a <- (*2)
b <- (+10)
return (a+b)
addStuffTwo =
(* 2) >>= (\a ->
(+ 10) >>= (\b ->
return (a + b)))
addStuffThree =
(* 2) >>= (\a ->
(\x -> x + 10) >>= (\b ->
return (a + b)))
addStuffFour =
(* 2) >>= (\a ->
(\z -> ((\b -> return (a + b)) (z + 10) z)))
addStuffFive =
(* 2) >>= (\a ->
(\z -> ((\_ -> a + z + 10) z)))
addStuffSix =
(* 2) >>= (\a -> (\z -> a + z + 10))
addStuffSeven =
(\i -> (\a -> (\z -> a + z + 10)) (i * 2) i)
addStuffEight =
(\i -> (i * 2) + i + 10)
main = (putStrLn $ show $ addStuffEight 7) >> (putStrLn $ show $ addStuff 7)
import Control.Monad.Instances
bootStrapStuff = do
a <- (*2)
b <- (+ a)
return (a * b)
bootStrapStuffTwo = do
a <- (*2)
b <- (+ a)
(\_ -> (a * b))
bootStrapStuffThree =
(*2) >>= (\a ->
(+ a) >>= (\b ->
(\_ -> (a * b))))
bootStrapStuffFour =
(*2) >>= (\a ->
(\x -> (\b -> return (a * b)) (x + a) x))
bootStrapStuffFive =
(*2) >>= (\a ->
(\x -> (a * (x + a))))
bootStrapStuffSix =
(\w ->
(\a -> (\x -> (a * (x + a))))
(w * 2)
w)
bootStrapStuffSeven w =
(\a -> (\x -> (a * (x + a))))
(w * 2)
w
bootStrapStuffEight w =
(\x -> ((w * 2) * (x + (2 * w))))
w
bootStrapStuffNine w = ((w * 2) * (w + (2 * w)))
main = (putStrLn $ show $ bootStrapStuff 5) >> (putStrLn $ show $ bootStrapStuffNine 5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment