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

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Baldur Blöndal
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


_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

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

David Feuer

This sounds fantastic! I think it is very important to provide sufficient documentation in the source to allow newish users who click through to understand as much as they need.


On Nov 20, 2016 12:47 PM, "Baldur Blöndal" <[hidden email]> wrote:
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


_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries


_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

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

Baldur Blöndal

2016-11-20 17:56 GMT+00:00 David Feuer <[hidden email]>:

This sounds fantastic! I think it is very important to provide sufficient documentation in the source to allow newish users who click through to understand as much as they need.


On Nov 20, 2016 12:47 PM, "Baldur Blöndal" <[hidden email]> wrote:
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


_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries



_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries