Pattern synonyms and record fields for Cont, Writer, Reader, State, ...

Baldur Blöndal baldurpet at gmail.com
Sun Nov 20 17:47:36 UTC 2016


This will look like the original definitions [1]

> newtype State s a = State { runState :: s -> (a, s) }

before they became type synonyms

> type State s = StateT s Identity

by defining pattern synonyms

> pattern State :: (s -> (a, s)) -> State s a
> pattern State {runState} <- S.runState -> runState
>   where State a           = state a

Trac ticket #12767 for further information. [2]

[1] http://book.realworldhaskell.org/read/monads.html#id643643
[2] https://ghc.haskell.org/trac/ghc/ticket/12767
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20161120/2fd3346e/attachment.html>


More information about the Libraries mailing list