repl.it
@Pzixel/

ChiefLumpyDebugging

Haskell

No description

fork
loading
Files
  • main.hs
main.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
listMonad :: [Int]
listMonad = do
           x <- [1,2,3]
           y <- [10,20,30]
           return $ x + y

maybe15Monad :: Maybe Int
maybe15Monad = do
           x <- Just 5
           y <- Just 10
           return $ x + y
           
maybe25Monad :: Maybe Int
maybe25Monad = do
           x <- Just 25
           y <- Nothing
           return $ x + y

result15Monad :: Either Int Int           
result15Monad = do
           x <- Right 5
           y <- Right 10
           return $ x + y

           
result25Monad :: Either String Int           
result25Monad = do
           x <- Right 5
           y <- Left "Something went wrong"
           return $ x + y

main :: IO ()
main = do
  print "RUNNING OUR MONADS!"
  print $ replicate 40 '-' 
  print listMonad  
  print maybe15Monad   
  print maybe25Monad  
  print result15Monad  
  print result25Monad  
GHCi, version 8.6.5