Wadler's Document: How is a tuple function a function?

When reading the original Wadler Monads for Functional Programming paper (1992), I feel like I get it, but in the non-monadic description of the State handler, it shows a proto-monadic description of the state:

type M a = State -> (a, State) eval :: Term -> M Int eval (Con a) x = (a, x) 

And that again ceased to make sense. How should I read this? As I understand it, this means that eval takes int and state and returns a function that takes state and returns a new pair (Int, State)

But ... like (a, x), which, if I read this right, is a tuple of value and state, is-a "that takes state and returns a new pair (Int, State)"?

+5
source share
1 answer

Expand a synonym of the type: Term -> M Int equivalent to Term -> State -> (Int, State) .

Alternatively, consider defining a function as eval (Con a) = \x -> (a, x) .

+14
source

Source: https://habr.com/ru/post/1203016/


All Articles