[GHC] #12767: Pattern synonyms for Cont, Writer, Reader, State, ...

GHC ghc-devs at haskell.org
Thu Oct 27 05:56:42 UTC 2016


#12767: Pattern synonyms for Cont, Writer, Reader, State, ...
-------------------------------------+-------------------------------------
           Reporter:  Iceland_jack   |             Owner:
               Type:  feature        |            Status:  new
  request                            |
           Priority:  normal         |         Milestone:
          Component:  Core           |           Version:  8.0.1
  Libraries                          |
           Keywords:                 |  Operating System:  Unknown/Multiple
  PatternSynonyms                    |
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:  #12001
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 Made this its own ticket, rather than using #12001. Are these worth
 adding?

 {{{#!hs
 pattern Cont :: ((a -> r) -> r) -> Cont r a
 pattern Cont a <- (runCont -> a)
   where Cont a = cont a

 pattern Writer :: (a, w) -> Writer w a
 pattern Writer a <- (runWriter -> a)
   where Writer a = WriterT (Identity a)

 pattern Reader :: (r -> a) -> Reader r a
 pattern Reader a <- (runReader -> a)
   where Reader a = reader a

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

 The mtl API was changed way back when (before advent of pattern synonyms)
 which caused some [http://stackoverflow.com/questions/14157090/has-the-
 control-monad-state-api-changed-recently confusion],
 [http://learnyouahaskell.com/for-a-few-monads-more LYAH] still uses
 `Writer`, `State` in their examples.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12767>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list