Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Meaning of a semicolon in lambda expression

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)?

like image 379
Stanko Avatar asked Oct 20 '25 23:10

Stanko


1 Answers

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)
like image 185
Sibi Avatar answered Oct 23 '25 19:10

Sibi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!