|
|
|
|
|
by zengid
3318 days ago
|
|
Can anyone help me interpret the type signature Meijer used in his programming question? "Given a generic type: Cont r a = (a -> r) -> r
Prove that this type forms a monad."I'm reading it as 'Container' passed 'r' and 'a' performs 'a' to 'r' which returns 'r'. (I'm guessing on verbs here).. I've never come across a good way to read these type signatures. |
|
(a -> r) is the type of a function from a to r. For example, Int -> Bool is the type of a function from Int to Bool. (a -> r) -> r is the type of a function that takes a function from (a -> r) as its argument and returns an r. So Cont String Int takes a function from Int to String as its argument and finally returns a String.
http://www.haskellforall.com/2012/12/the-continuation-monad.... https://begriffs.com/posts/2015-06-03-haskell-continuations....