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

#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

#12767: Pattern synonyms for Cont, Writer, Reader, State, ... -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Core Libraries | Version: 8.0.1 Resolution: | Keywords: | PatternSynonyms Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #12001 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by ekmett): These types live in `transformers` so a more appropriate venue is a libraries@ request or just an email to Ross Paterson, the `transformers` maintainer. I personally think they'd be rather nice to have, as they'd fix one of the main problems users have coming in to modern Haskell from old tutorials at least based on the chatter on #haskell over the years. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12767#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12767: Pattern synonyms for Cont, Writer, Reader, State, ... -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Core Libraries | Version: 8.0.1 Resolution: | Keywords: | PatternSynonyms Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #12001 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by Iceland_jack): Replying to [comment:1 ekmett]:
''[...]'' email to Ross Paterson, the `transformers` maintainer.
I directed him to this ticket -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12767#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12767: Pattern synonyms for Cont, Writer, Reader, State, ... -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Core Libraries | Version: 8.0.1 Resolution: | Keywords: | PatternSynonyms Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #12001 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Description changed by Iceland_jack: @@ -5,0 +5,9 @@ + import qualified Control.Monad.Cont as C + import Control.Monad.Cont hiding (runCont) + import qualified Control.Monad.Writer as W + import Control.Monad.Writer hiding (runWriter) + import qualified Control.Monad.Reader as R + import Control.Monad.Reader hiding (runReader) + import qualified Control.Monad.State as S + import Control.Monad.State hiding (runState) + @@ -6,2 +15,2 @@ - pattern Cont a <- (runCont -> a) - where Cont a = cont a + pattern Cont {runCont} <- (C.runCont -> runCont) + where Cont a = cont a @@ -10,2 +19,2 @@ - pattern Writer a <- (runWriter -> a) - where Writer a = WriterT (Identity a) + pattern Writer {runWriter} <- (W.runWriter -> runWriter) + where Writer a = WriterT (Identity a) @@ -14,2 +23,2 @@ - pattern Reader a <- (runReader -> a) - where Reader a = reader a + pattern Reader {runReader} <- (R.runReader -> runReader) + where Reader a = reader a @@ -18,2 +27,2 @@ - pattern State a <- (runState -> a) - where State a = state a + pattern State {runState} <- (S.runState -> runState) + where State a = state a New description: Made this its own ticket, rather than using #12001. Are these worth adding? {{{#!hs import qualified Control.Monad.Cont as C import Control.Monad.Cont hiding (runCont) import qualified Control.Monad.Writer as W import Control.Monad.Writer hiding (runWriter) import qualified Control.Monad.Reader as R import Control.Monad.Reader hiding (runReader) import qualified Control.Monad.State as S import Control.Monad.State hiding (runState) pattern Cont :: ((a -> r) -> r) -> Cont r a pattern Cont {runCont} <- (C.runCont -> runCont) where Cont a = cont a pattern Writer :: (a, w) -> Writer w a pattern Writer {runWriter} <- (W.runWriter -> runWriter) where Writer a = WriterT (Identity a) pattern Reader :: (r -> a) -> Reader r a pattern Reader {runReader} <- (R.runReader -> runReader) where Reader a = reader a pattern State :: (s -> (a, s)) -> State s a pattern State {runState} <- (S.runState -> runState) 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#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12767: Pattern synonyms for Cont, Writer, Reader, State, ... -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Core Libraries | Version: 8.0.1 Resolution: | Keywords: | PatternSynonyms Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #12001 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by Iceland_jack): Started a [https://mail.haskell.org/pipermail/libraries/2016-November/027442.html discussion] on the library mailing list. See #12857 for associating pattern synonyms with a type synonym: {{{#!hs module State ( State (State, runState) ) where ... type State s = StateT s Identity pattern State { runState } <- ((runIdentity .) . runStateT -> runState) where State runState = StateT (Identity . runState) }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12767#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12767: Pattern synonyms for Cont, Writer, Reader, State, ... -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Core Libraries | Version: 8.0.1 Resolution: | Keywords: | PatternSynonyms Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #12001 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by Iceland_jack): There wasn't much of a response but what little it got was positive, how should I proceed -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12767#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12767: Pattern synonyms for Cont, Writer, Reader, State, ... -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Core Libraries | Version: 8.0.1 Resolution: | Keywords: | PatternSynonyms Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #12001 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by ekmett): I for one am enthusiastic about the idea. You may want to concoct a patch and see if you can get Ross to merge it as a next step. As he is the maintainer of `transformers`, it is ultimately up to him to decide what to do here. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12767#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12767: Pattern synonyms for Cont, Writer, Reader, State, ... -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Core Libraries | Version: 8.0.1 Resolution: | Keywords: | PatternSynonyms Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #12001 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by ekmett): FWIW- I'd be happy to merge a pull request to add similar pattern synonyms to on the `comonad` side. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12767#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12767: Pattern synonyms for Cont, Writer, Reader, State, ... -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Core Libraries | Version: 8.0.1 Resolution: | Keywords: | PatternSynonyms Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #12001 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by RyanGlScott): I too would like to see this! Iceland_jack, do you mind opening the pull request for `transformers`? The `transformers` repo is located [http://hub.darcs.net/ross/transformers/issues here]. It uses darcs, which can be a bit tricky to navigate if you haven't used it before. If you have any difficulties, feel free to ping me for help. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12767#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12767: Pattern synonyms for Cont, Writer, Reader, State, ... -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Core Libraries | Version: 8.0.1 Resolution: | Keywords: | PatternSynonyms Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #12001 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by rwbarton): Can this be closed as Not GHC then? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12767#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12767: Pattern synonyms for Cont, Writer, Reader, State, ... -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: Type: feature request | Status: closed Priority: normal | Milestone: Component: Core Libraries | Version: 8.0.1 Resolution: invalid | Keywords: | PatternSynonyms Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #12001 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * status: new => closed * resolution: => invalid Comment: Yes, I'd say so. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12767#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC