Re: [Haskell-cafe] Bundle patterns with type aliases

These are great ideas! Could you please create a ghc tracker ticket with a
tiny examples or two?
There may be specific technical reasons we might not be able to do so for
type synonyms in ghc, but I don’t see any obvious barriers in the case of
David’s excellent idea, I’ve def seen lots of great code out there where
you’d really want either associated pattern synonyms or to bundle pattern
synonyms with the exported public interface for a type class.
I’m sure there’s some devil in the details but these sound lovely. Step -1
is making up 1-2 toy examples and explaining what and why you want it on a
ghc ticket!
On Wed, Sep 8, 2021 at 1:25 PM David Feuer
I would like that, along with the ability to bundle patterns with classes.
On Wed, Sep 8, 2021, 1:13 PM Keith
wrote: Is there currently a way to 'bundle' a pattern with a type alias? And if not, could that capability be added to the PatternSynonyms GHC extension? (Is this the right place to ask, or should I be asking a GHC list?)
--Keith Sent from my phone with K-9 Mail. _______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.

Here's an example:
pattern State :: (s -> (a, s)) -> State s a
pattern State f <- (coerce . runStateT -> f) where
State = state
This would be very nice to bundle with the State type synonym.
On Thu, Sep 16, 2021, 2:22 PM Carter Schonwald
These are great ideas! Could you please create a ghc tracker ticket with a tiny examples or two?
There may be specific technical reasons we might not be able to do so for type synonyms in ghc, but I don’t see any obvious barriers in the case of David’s excellent idea, I’ve def seen lots of great code out there where you’d really want either associated pattern synonyms or to bundle pattern synonyms with the exported public interface for a type class.
I’m sure there’s some devil in the details but these sound lovely. Step -1 is making up 1-2 toy examples and explaining what and why you want it on a ghc ticket!
On Wed, Sep 8, 2021 at 1:25 PM David Feuer
wrote: I would like that, along with the ability to bundle patterns with classes.
On Wed, Sep 8, 2021, 1:13 PM Keith
wrote: Is there currently a way to 'bundle' a pattern with a type alias? And if not, could that capability be added to the PatternSynonyms GHC extension? (Is this the right place to ask, or should I be asking a GHC list?)
--Keith Sent from my phone with K-9 Mail. _______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.

Here's a class example:
class (MFoldable t, Monoid t) => Sequence t where
singleton :: Elem t -> t
....
One might wish to write pattern synonyms for viewing the ends of a
sequence, like the ones in Data.Sequence, and bundle them with this class.
On Thu, Sep 16, 2021, 2:22 PM Carter Schonwald
These are great ideas! Could you please create a ghc tracker ticket with a tiny examples or two?
There may be specific technical reasons we might not be able to do so for type synonyms in ghc, but I don’t see any obvious barriers in the case of David’s excellent idea, I’ve def seen lots of great code out there where you’d really want either associated pattern synonyms or to bundle pattern synonyms with the exported public interface for a type class.
I’m sure there’s some devil in the details but these sound lovely. Step -1 is making up 1-2 toy examples and explaining what and why you want it on a ghc ticket!
On Wed, Sep 8, 2021 at 1:25 PM David Feuer
wrote: I would like that, along with the ability to bundle patterns with classes.
On Wed, Sep 8, 2021, 1:13 PM Keith
wrote: Is there currently a way to 'bundle' a pattern with a type alias? And if not, could that capability be added to the PatternSynonyms GHC extension? (Is this the right place to ask, or should I be asking a GHC list?)
--Keith Sent from my phone with K-9 Mail. _______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.
participants (2)
-
Carter Schonwald
-
David Feuer