Re: Rewrapping with simple bidirectional pattern synonyms
I'm glad to see I'm not the only one who wants this! On Wed, Aug 24, 2016 at 6:13 PM, Edward Z. Yangwrote: > I filed a ticket for precisely this: > > https://ghc.haskell.org/trac/ghc/ticket/12203 > > Edward > > Excerpts from David Feuer's message of 2016-08-24 18:11:16 -0400: >> I'm trying to write a bidirectional pattern synonym which is morally >> simple, but as far as I can tell there's no way to write it as a >> simple bidirectional pattern synonym. >> >> What I want to say is >> >> pattern TSnoc (TSnocList xs) x = TSnocList (CL.TCons (Dual x) xs) >> >> (where TSnocList and Dual are both newtype constructors) >> >> But I don't see a way to do it without being explicitly bidirectional: >> >> pattern TSnoc xs x <- (tsViewR -> ViewR xs x) where >> TSnoc (TSnocList xs) x = TSnocList (CL.TCons (Dual x) xs) >> >> tsViewR :: TSnocList c x y -> ViewR c (TSnocList c) x y >> tsViewR (TSnocList CL.TNil) = EmptyR >> tsViewR (TSnocList (CL.TCons (Dual x) xs)) = ViewR (TSnocList xs) x >> >> Would it be possible to make this simple thing simple? ___ ghc-devs mailing list ghc-devs@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
Re: Rewrapping with simple bidirectional pattern synonyms
I filed a ticket for precisely this: https://ghc.haskell.org/trac/ghc/ticket/12203 Edward Excerpts from David Feuer's message of 2016-08-24 18:11:16 -0400: > I'm trying to write a bidirectional pattern synonym which is morally > simple, but as far as I can tell there's no way to write it as a > simple bidirectional pattern synonym. > > What I want to say is > > pattern TSnoc (TSnocList xs) x = TSnocList (CL.TCons (Dual x) xs) > > (where TSnocList and Dual are both newtype constructors) > > But I don't see a way to do it without being explicitly bidirectional: > > pattern TSnoc xs x <- (tsViewR -> ViewR xs x) where > TSnoc (TSnocList xs) x = TSnocList (CL.TCons (Dual x) xs) > > tsViewR :: TSnocList c x y -> ViewR c (TSnocList c) x y > tsViewR (TSnocList CL.TNil) = EmptyR > tsViewR (TSnocList (CL.TCons (Dual x) xs)) = ViewR (TSnocList xs) x > > Would it be possible to make this simple thing simple? ___ ghc-devs mailing list ghc-devs@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
Re: Rewrapping with simple bidirectional pattern synonyms
The relevant ticket is - https://ghc.haskell.org/trac/ghc/ticket/12203 On Wed, Aug 24, 2016 at 11:11 PM, David Feuerwrote: > I'm trying to write a bidirectional pattern synonym which is morally > simple, but as far as I can tell there's no way to write it as a > simple bidirectional pattern synonym. > > What I want to say is > > pattern TSnoc (TSnocList xs) x = TSnocList (CL.TCons (Dual x) xs) > > (where TSnocList and Dual are both newtype constructors) > > But I don't see a way to do it without being explicitly bidirectional: > > pattern TSnoc xs x <- (tsViewR -> ViewR xs x) where > TSnoc (TSnocList xs) x = TSnocList (CL.TCons (Dual x) xs) > > tsViewR :: TSnocList c x y -> ViewR c (TSnocList c) x y > tsViewR (TSnocList CL.TNil) = EmptyR > tsViewR (TSnocList (CL.TCons (Dual x) xs)) = ViewR (TSnocList xs) x > > Would it be possible to make this simple thing simple? > ___ > ghc-devs mailing list > ghc-devs@haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs ___ ghc-devs mailing list ghc-devs@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
Rewrapping with simple bidirectional pattern synonyms
I'm trying to write a bidirectional pattern synonym which is morally simple, but as far as I can tell there's no way to write it as a simple bidirectional pattern synonym. What I want to say is pattern TSnoc (TSnocList xs) x = TSnocList (CL.TCons (Dual x) xs) (where TSnocList and Dual are both newtype constructors) But I don't see a way to do it without being explicitly bidirectional: pattern TSnoc xs x <- (tsViewR -> ViewR xs x) where TSnoc (TSnocList xs) x = TSnocList (CL.TCons (Dual x) xs) tsViewR :: TSnocList c x y -> ViewR c (TSnocList c) x y tsViewR (TSnocList CL.TNil) = EmptyR tsViewR (TSnocList (CL.TCons (Dual x) xs)) = ViewR (TSnocList xs) x Would it be possible to make this simple thing simple? ___ ghc-devs mailing list ghc-devs@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs