Skip to content

Instantly share code, notes, and snippets.

@schar
Created September 12, 2016 20:37
Show Gist options
  • Save schar/10eed2835f22cc0f59587a89681af616 to your computer and use it in GitHub Desktop.
Save schar/10eed2835f22cc0f59587a89681af616 to your computer and use it in GitHub Desktop.
uncurrying reader and state
type R r a = r -> a
uncurryR :: R r (R s a) -> R (r, s) a -- an isomorphism
uncurryR m (r, s) = m r s
curryR :: R (r, s) a -> R r (R s a) -- another isomorphism
curryR m r s = m (r, s)
type S r a = r -> (a, r)
uncurryS :: S r (S s a) -> S (r, s) a -- not an isomorphism!
uncurryS m (r, s) = (v, (t, u))
where (n, t) = m r
(v, u) = n s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment