Type:
data Command a = Command String (a -> IO a)
Function:
iofunc_ :: String -> (a -> IO ()) -> Command a
iofunc_ s f = Command s (\x -> do f x ; return x)
What does the semicolon do in the lambda expression (\x -> do f x ; return x)?
They just separate the two expression f x and return x in do notation. In fact these all are equivalent in your case:
iofunc_ s f = Command s (\x -> do f x ; return x)
iofunc_ s f = Command s (\x -> do {f x ; return x})
iofunc_ s f = Command s (\x -> do f x
return x)
iofunc_ s f = Command s (\x -> f x >> return x)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With