Interpreting Haskell monad example
问题 I have this Haskell code that triples input value. triple :: Int -> Int triple = do n <- id d <- (n+) (d+) How does this code work? With an example triple 10 , how the argument 10 is mapped/assigned to id , n and d to get the return value of 30? My understandig is as follows: We can decompose triple function with two subfunctions tripleA and tripleB as follows: triple :: Int -> Int triple = tripleA >>= (\d -> tripleB d) tripleA :: Int -> Int tripleA = id >>= (\n -> (n+)) tripleB :: Int -> Int