Quantcast

[GHC] #8581: Add support for explicitly-bidirectional pattern synonyms

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
48 messages Options
123
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[GHC] #8581: Add support for explicitly-bidirectional pattern synonyms

GHC - devs mailing list
#8581: Add support for explicitly-bidirectional pattern synonyms
------------------------------------+-------------------------------------
       Reporter:  cactus            |             Owner:  cactus
           Type:  feature request   |            Status:  new
       Priority:  normal            |         Milestone:
      Component:  Compiler          |           Version:
       Keywords:                    |  Operating System:  Unknown/Multiple
   Architecture:  Unknown/Multiple  |   Type of failure:  None/Unknown
     Difficulty:  Unknown           |         Test Case:
     Blocked By:  5144              |          Blocking:
Related Tickets:                    |
------------------------------------+-------------------------------------
 Some patterns cannot, by themselves, be turned over into an expression, so
 they have to be defined as unidirectional. Maybe the most trivial example
 would be

 {{{
 pattern P -> _
 }}}

 Sometimes, however, it would be desirable to give an explicit way of
 turning these pattern synonyms into expressions. The PatternSynonyms wiki
 page has this example:

 {{{
 import qualified Data.Sequence as Seq

 pattern Empty -> (Seq.viewl -> Seq.EmptyL)
 pattern x :< xs -> (Seq.viewl -> x Seq.:< xs)
 pattern xs :> x -> (Seq.viewr -> xs Seq.:> x)

 }}}

 It would make a ton of sense to be able to use this cons/snoc notation as
 "constructors" for `Seq`s.

 The proposed syntax for this

 {{{
 pattern x :< xs -> (Seq.viewl -> x Seq.:< xs) where
     x :< xs = x Seq.<| xs
 }}}

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8581>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
ghc-tickets mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [GHC] #8581: Add support for explicitly-bidirectional pattern synonyms

GHC - devs mailing list
#8581: Add support for explicitly-bidirectional pattern synonyms
-------------------------------------+------------------------------------
        Reporter:  cactus            |            Owner:  cactus
            Type:  feature request   |           Status:  new
        Priority:  normal            |        Milestone:
       Component:  Compiler          |          Version:
      Resolution:                    |         Keywords:
Operating System:  Unknown/Multiple  |     Architecture:  Unknown/Multiple
 Type of failure:  None/Unknown      |       Difficulty:  Unknown
       Test Case:                    |       Blocked By:  5144
        Blocking:                    |  Related Tickets:
-------------------------------------+------------------------------------

Comment (by ntc2):

 I've often wished that `_` in expressions was a shorthand for `undefined`.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8581#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
ghc-tickets mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [GHC] #8581: Add support for explicitly-bidirectional pattern synonyms

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#8581: Add support for explicitly-bidirectional pattern synonyms
-------------------------------------+------------------------------------
        Reporter:  cactus            |            Owner:  cactus
            Type:  feature request   |           Status:  new
        Priority:  normal            |        Milestone:
       Component:  Compiler          |          Version:
      Resolution:                    |         Keywords:
Operating System:  Unknown/Multiple  |     Architecture:  Unknown/Multiple
 Type of failure:  None/Unknown      |       Difficulty:  Unknown
       Test Case:                    |       Blocked By:  5144
        Blocking:                    |  Related Tickets:
-------------------------------------+------------------------------------

Comment (by Iceland_jack):

 This would be very nice to have, +1.

 The possibility of `_` being a shorthand for `undefined` is intriguing. It
 allows `_` to be a run-of-the-mill pattern exported by `Prelude` that may
 be redefined by users! The regular wildcard meaning where the expression
 is `undefined` could be defined as such with the proposed syntax:

 {{{
 pattern _ <- a where
   _ = undefined

 failure :: a -> b
 failure _ = _
 }}}

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8581#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
ghc-tickets mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [GHC] #8581: Add support for explicitly-bidirectional pattern synonyms

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#8581: Add support for explicitly-bidirectional pattern synonyms
-------------------------------------+------------------------------------
        Reporter:  cactus            |            Owner:  cactus
            Type:  feature request   |           Status:  new
        Priority:  normal            |        Milestone:
       Component:  Compiler          |          Version:
      Resolution:                    |         Keywords:
Operating System:  Unknown/Multiple  |     Architecture:  Unknown/Multiple
 Type of failure:  None/Unknown      |       Difficulty:  Unknown
       Test Case:                    |       Blocked By:  5144
        Blocking:                    |  Related Tickets:
-------------------------------------+------------------------------------

Comment (by dfranke):

 `_` in expressions is already in use for typed holes
 (http://www.haskell.org/ghc/docs/latest/html/users_guide/typed-
 holes.html).

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8581#comment:3>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
ghc-tickets mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [GHC] #8581: Add support for explicitly-bidirectional pattern synonyms

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#8581: Add support for explicitly-bidirectional pattern synonyms
-------------------------------------+------------------------------------
        Reporter:  cactus            |            Owner:  cactus
            Type:  feature request   |           Status:  new
        Priority:  normal            |        Milestone:
       Component:  Compiler          |          Version:
      Resolution:                    |         Keywords:
Operating System:  Unknown/Multiple  |     Architecture:  Unknown/Multiple
 Type of failure:  None/Unknown      |       Difficulty:  Unknown
       Test Case:                    |       Blocked By:  5144
        Blocking:                    |  Related Tickets:
-------------------------------------+------------------------------------

Comment (by cactus):

 I have a working version of this in the `wip/pattern-synonyms` branch. It
 still needs some finishing (mostly, adding tests).

 The only difficult part of this work was ensuring that the following works
 (and is not regarded as a recursive pattern synonym):


 {{{
 pattern P x <- (x:_) where
   P x = foo [x]

 foo (P x) = [x, x]
 }}}

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8581#comment:4>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
ghc-tickets mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [GHC] #8581: Add support for explicitly-bidirectional pattern synonyms

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#8581: Add support for explicitly-bidirectional pattern synonyms
-------------------------------------+------------------------------------
        Reporter:  cactus            |            Owner:  cactus
            Type:  feature request   |           Status:  patch
        Priority:  normal            |        Milestone:
       Component:  Compiler          |          Version:
      Resolution:                    |         Keywords:
Operating System:  Unknown/Multiple  |     Architecture:  Unknown/Multiple
 Type of failure:  None/Unknown      |       Difficulty:  Unknown
       Test Case:                    |       Blocked By:  5144
        Blocking:                    |  Related Tickets:
-------------------------------------+------------------------------------
Changes (by cactus):

 * status:  new => patch


Comment:

 Pushed `576f461` to `wip/pattern-synonyms`, please review for `HEAD`. It
 validates and has a test case for bidirectional pattern synonyms.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8581#comment:5>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
ghc-tickets mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [GHC] #8581: Add support for explicitly-bidirectional pattern synonyms

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#8581: Add support for explicitly-bidirectional pattern synonyms
-------------------------------------+------------------------------------
        Reporter:  cactus            |            Owner:  cactus
            Type:  feature request   |           Status:  patch
        Priority:  normal            |        Milestone:  7.10.1
       Component:  Compiler          |          Version:
      Resolution:                    |         Keywords:
Operating System:  Unknown/Multiple  |     Architecture:  Unknown/Multiple
 Type of failure:  None/Unknown      |       Difficulty:  Unknown
       Test Case:                    |       Blocked By:  5144
        Blocking:                    |  Related Tickets:
-------------------------------------+------------------------------------
Changes (by cactus):

 * milestone:   => 7.10.1


--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8581#comment:6>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
ghc-tickets mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [GHC] #8581: Add support for explicitly-bidirectional pattern synonyms

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#8581: Add support for explicitly-bidirectional pattern synonyms
-------------------------------------+-------------------------------------
              Reporter:  cactus      |            Owner:  cactus
                  Type:  feature     |           Status:  closed
  request                            |        Milestone:  7.10.1
              Priority:  normal      |          Version:
             Component:  Compiler    |         Keywords:
            Resolution:  fixed       |     Architecture:  Unknown/Multiple
      Operating System:              |       Difficulty:  Unknown
  Unknown/Multiple                   |       Blocked By:  5144
       Type of failure:              |  Related Tickets:
  None/Unknown                       |
             Test Case:              |
              Blocking:              |
Differential Revisions:              |
-------------------------------------+-------------------------------------
Changes (by cactus):

 * status:  patch => closed
 * resolution:   => fixed


--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8581#comment:7>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
ghc-tickets mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [GHC] #8581: Add support for explicitly-bidirectional pattern synonyms

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#8581: Add support for explicitly-bidirectional pattern synonyms
-------------------------------------+-------------------------------------
              Reporter:  cactus      |            Owner:  cactus
                  Type:  feature     |           Status:  closed
  request                            |        Milestone:  7.10.1
              Priority:  normal      |          Version:
             Component:  Compiler    |         Keywords:
            Resolution:  fixed       |     Architecture:  Unknown/Multiple
      Operating System:              |       Difficulty:  Unknown
  Unknown/Multiple                   |       Blocked By:  5144
       Type of failure:              |  Related Tickets:
  None/Unknown                       |
             Test Case:              |
              Blocking:              |
Differential Revisions:              |
-------------------------------------+-------------------------------------

Comment (by hvr):

 For the record: the commit-range 12644c3c0216edfcff33266f4f250e0c52004352
 to 535b37cbb5a11dd4c9d8260d1d00f4cb993af0e9 seems to be what was merged to
 address this ticket.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8581#comment:8>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
ghc-tickets mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [GHC] #8581: Add support for explicitly-bidirectional pattern synonyms

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#8581: Add support for explicitly-bidirectional pattern synonyms
-------------------------------------+-------------------------------------
              Reporter:  cactus      |            Owner:  cactus
                  Type:  feature     |           Status:  closed
  request                            |        Milestone:  7.10.1
              Priority:  normal      |          Version:
             Component:  Compiler    |         Keywords:
            Resolution:  fixed       |     Architecture:  Unknown/Multiple
      Operating System:              |       Difficulty:  Unknown
  Unknown/Multiple                   |       Blocked By:  5144
       Type of failure:              |  Related Tickets:
  None/Unknown                       |
             Test Case:              |
              Blocking:              |
Differential Revisions:              |
-------------------------------------+-------------------------------------

Comment (by mpickering):

 I just tried out this patch and it seems strange to me that the
 constructor synonym has the same class constraints as the pattern. Is this
 by design? Here is an example which would have worked really nicely if not
 for this restriction. I know you can get around this by defining your own
 constructors with the right types.

 Note that there is no `View` instance for `Holey` which makes sense but we
 can still define a `Construct` instance.


 {{{
 {-# LANGUAGE PatternSynonyms, ViewPatterns #-}

 data ExpF a = AddF a a | NumF Int deriving Show

 class Construct a where
   construct :: ExpF a -> a

 class View a where
   view :: a -> ExpF a

 newtype Exp = Exp (ExpF Exp) deriving (Show)

 instance Construct Exp where
   construct e = Exp e

 instance View Exp where
   view (Exp e) = e

 data Holey = Hole | NonHole (ExpF Holey)

 instance Construct Holey where
   construct = NonHole

 data AttrExpr = AttrExpr [String] (ExpF AttrExpr)

 pattern Add a b <- (view -> AddF a b) where
   Add a b = (construct (AddF a b))

 pattern Num n <- (view -> NumF n) where
   Num n = (construct (NumF n))

 }}}

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8581#comment:9>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
ghc-tickets mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [GHC] #8581: Add support for explicitly-bidirectional pattern synonyms

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#8581: Add support for explicitly-bidirectional pattern synonyms
-------------------------------------+-------------------------------------
              Reporter:  cactus      |            Owner:  cactus
                  Type:  feature     |           Status:  closed
  request                            |        Milestone:  7.10.1
              Priority:  normal      |          Version:
             Component:  Compiler    |         Keywords:
            Resolution:  fixed       |     Architecture:  Unknown/Multiple
      Operating System:              |       Difficulty:  Unknown
  Unknown/Multiple                   |       Blocked By:  5144
       Type of failure:              |  Related Tickets:
  None/Unknown                       |
             Test Case:              |
              Blocking:              |
Differential Revisions:              |
-------------------------------------+-------------------------------------

Comment (by simonpj):

 It's a bit hard to understand your example because you don't give any
 types, or any code that you think should work, but doesn't.

 But I ''think'' you mean this: the two directions of an explicitly-
 bidirectional pattern might have utterly different class constraints.
 After all, the two directions are specified by quite different code.
 Suppose that
  * Pattern `P` (used in a pattern) ''requires'' constraints `CR`, and
 ''provides'' constraints `CP`
  * Constructor `P` (used in an expression) requires constraints `CE`
 Then I think the only required relationship is this: `CP` must be provable
 from `CE` (since `CP` is packaged up in a P-object).

 Is this what you meant?  Then indeed I think that we have not really
 discussed this possibility at all.

 There is a tricky UI issue, which is how to say when you ask `:info P`.
 And, worse still, what it would mean to give a type signature to `P`.

 So it looks to me, on first impression, that what you want is do-able and
 sensible.  But there are some design issues to work out first.  Let's see
 what Gergo has to say.

 Simon

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8581#comment:10>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
ghc-tickets mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [GHC] #8581: Add support for explicitly-bidirectional pattern synonyms

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#8581: Add support for explicitly-bidirectional pattern synonyms
-------------------------------------+-------------------------------------
              Reporter:  cactus      |            Owner:  cactus
                  Type:  feature     |           Status:  closed
  request                            |        Milestone:  7.10.1
              Priority:  normal      |          Version:
             Component:  Compiler    |         Keywords:
            Resolution:  fixed       |     Architecture:  Unknown/Multiple
      Operating System:              |       Difficulty:  Unknown
  Unknown/Multiple                   |       Blocked By:  5144
       Type of failure:              |  Related Tickets:
  None/Unknown                       |
             Test Case:              |
              Blocking:              |
Differential Revisions:              |
-------------------------------------+-------------------------------------

Comment (by mpickering):

 That is exactly what I mean, thank you for taking the time to clarify
 my comment. To once again be more specific, the code example I posted
 fails to type check with the following error message.


 {{{

 fix.hs:27:14:
     Could not deduce (Construct a) arising from a use of ‘construct’
     from the context (View a)
       bound by the type signature for Main.$WAdd :: View a => a -> a -> a
       at fix.hs:1:1
     Possible fix:
       add (Construct a) to the context of
         the type signature for Main.$WAdd :: View a => a -> a -> a
     In the expression: (construct (AddF a b))
     In an equation for ‘$WAdd’: $WAdd a b = (construct (AddF a b))

 fix.hs:30:12:
     Could not deduce (Construct a) arising from a use of ‘construct’
     from the context (View a)
       bound by the type signature for Main.$WNum :: View a => Int -> a
       at fix.hs:1:1
     Possible fix:
       add (Construct a) to the context of
         the type signature for Main.$WNum :: View a => Int -> a
     In the expression: (construct (NumF n))
     In an equation for ‘$WNum’: $WNum n = (construct (NumF n))

 }}}

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8581#comment:11>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
ghc-tickets mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [GHC] #8581: Add support for explicitly-bidirectional pattern synonyms

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#8581: Add support for explicitly-bidirectional pattern synonyms
-------------------------------------+-------------------------------------
              Reporter:  cactus      |            Owner:  cactus
                  Type:  feature     |           Status:  closed
  request                            |        Milestone:  7.10.1
              Priority:  normal      |          Version:
             Component:  Compiler    |         Keywords:
            Resolution:  fixed       |     Architecture:  Unknown/Multiple
      Operating System:              |       Difficulty:  Unknown
  Unknown/Multiple                   |       Blocked By:  5144
       Type of failure:              |  Related Tickets:
  None/Unknown                       |
             Test Case:              |
              Blocking:              |
Differential Revisions:              |
-------------------------------------+-------------------------------------

Comment (by simonpj):

 Re-opening because of comment:9 and following.

 Simon

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8581#comment:12>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
ghc-tickets mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [GHC] #8581: Add support for explicitly-bidirectional pattern synonyms

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#8581: Add support for explicitly-bidirectional pattern synonyms
-------------------------------------+-------------------------------------
              Reporter:  cactus      |            Owner:
                  Type:  feature     |           Status:  new
  request                            |        Milestone:  7.10.1
              Priority:  normal      |          Version:
             Component:  Compiler    |         Keywords:
            Resolution:              |     Architecture:  Unknown/Multiple
      Operating System:              |       Difficulty:  Unknown
  Unknown/Multiple                   |       Blocked By:  5144
       Type of failure:              |  Related Tickets:
  None/Unknown                       |
             Test Case:              |
              Blocking:              |
Differential Revisions:              |
-------------------------------------+-------------------------------------
Changes (by simonpj):

 * owner:  cactus =>
 * status:  closed => new
 * resolution:  fixed =>


--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8581#comment:13>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
ghc-tickets mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [GHC] #8581: Add support for explicitly-bidirectional pattern synonyms

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#8581: Add support for explicitly-bidirectional pattern synonyms
-------------------------------------+-------------------------------------
              Reporter:  cactus      |            Owner:
                  Type:  feature     |           Status:  new
  request                            |        Milestone:  7.10.1
              Priority:  normal      |          Version:
             Component:  Compiler    |         Keywords:
            Resolution:              |     Architecture:  Unknown/Multiple
      Operating System:              |       Difficulty:  Unknown
  Unknown/Multiple                   |       Blocked By:  5144
       Type of failure:              |  Related Tickets:
  None/Unknown                       |
             Test Case:              |
              Blocking:              |
Differential Revisions:              |
-------------------------------------+-------------------------------------

Comment (by cactus):

 Hmm. Implementation-wise, there's no reason why `P`-as-an-expression and
 `P`-as-a-pattern  has to have the same constraints -- in fact, they could
 even have completely different types... But we check that they do have the
 same type so that they behave more like a real constructor. The reason `CE
 := CP + CR` at the moment is that this is how a GADT constructor is typed.

 So, ummm, how far do we want to let pattern synonym types wander from
 regular constructor types? That is the question here.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8581#comment:14>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
ghc-tickets mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [GHC] #8581: Add support for explicitly-bidirectional pattern synonyms

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#8581: Add support for explicitly-bidirectional pattern synonyms
-------------------------------------+-------------------------------------
              Reporter:  cactus      |            Owner:
                  Type:  feature     |           Status:  new
  request                            |        Milestone:  7.10.1
              Priority:  normal      |          Version:
             Component:  Compiler    |         Keywords:
            Resolution:              |     Architecture:  Unknown/Multiple
      Operating System:              |       Difficulty:  Unknown
  Unknown/Multiple                   |       Blocked By:  5144
       Type of failure:              |  Related Tickets:
  None/Unknown                       |
             Test Case:              |
              Blocking:              |
Differential Revisions:              |
-------------------------------------+-------------------------------------

Comment (by simonpj):

 Ideally, as far as the programer wants, provided CP is provable from CE.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8581#comment:15>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
ghc-tickets mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [GHC] #8581: Add support for explicitly-bidirectional pattern synonyms

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#8581: Add support for explicitly-bidirectional pattern synonyms
-------------------------------------+-------------------------------------
              Reporter:  cactus      |            Owner:
                  Type:  feature     |           Status:  new
  request                            |        Milestone:  7.10.1
              Priority:  normal      |          Version:
             Component:  Compiler    |         Keywords:
            Resolution:              |     Architecture:  Unknown/Multiple
      Operating System:              |       Difficulty:  Unknown
  Unknown/Multiple                   |       Blocked By:  5144
       Type of failure:              |  Related Tickets:
  None/Unknown                       |
             Test Case:              |
              Blocking:              |
Differential Revisions:              |
-------------------------------------+-------------------------------------

Comment (by simonpj):

 Question for mpickering.  How would it be if the pattern synonym had just
 ONE type, but it was the most constraining of the two directions.  Thus in
 your example,
 {{{
 pattern type Add a a :: (View a, Construct a) => a
 }}}
 rather than
 {{{
 pattern type Add a a :: (View a) => a
 }}}
 which is what we get from the pattern side, but which doesn't work on the
 expression side.

 The down-side is that pattern-matching would need a `(Construct a)`
 constraint that is not strictly necessary.  How bad would that be?

 Simon

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8581#comment:16>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
ghc-tickets mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [GHC] #8581: Add support for explicitly-bidirectional pattern synonyms

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#8581: Add support for explicitly-bidirectional pattern synonyms
-------------------------------------+-------------------------------------
              Reporter:  cactus      |            Owner:
                  Type:  feature     |           Status:  new
  request                            |        Milestone:  7.10.1
              Priority:  normal      |          Version:
             Component:  Compiler    |         Keywords:  pattern synonyms
            Resolution:              |     Architecture:  Unknown/Multiple
      Operating System:              |       Difficulty:  Unknown
  Unknown/Multiple                   |       Blocked By:  5144
       Type of failure:              |  Related Tickets:
  None/Unknown                       |
             Test Case:              |
              Blocking:              |
Differential Revisions:              |
-------------------------------------+-------------------------------------
Changes (by cactus):

 * keywords:   => pattern synonyms


--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8581#comment:17>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
ghc-tickets mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [GHC] #8581: Add support for explicitly-bidirectional pattern synonyms

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#8581: Add support for explicitly-bidirectional pattern synonyms
-------------------------------------+-------------------------------------
              Reporter:  cactus      |            Owner:
                  Type:  feature     |           Status:  new
  request                            |        Milestone:  7.10.1
              Priority:  normal      |          Version:
             Component:  Compiler    |         Keywords:  pattern synonyms
            Resolution:              |     Architecture:  Unknown/Multiple
      Operating System:              |       Difficulty:  Unknown
  Unknown/Multiple                   |       Blocked By:  5144
       Type of failure:              |  Related Tickets:
  None/Unknown                       |
             Test Case:              |
              Blocking:              |
Differential Revisions:              |
-------------------------------------+-------------------------------------

Comment (by mpickering):

 It does feel unnecessary to insist on the extra constraint. That being
 said, it does match up better with the original semantics of the
 constructor.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8581#comment:18>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
ghc-tickets mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/ghc-tickets
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [GHC] #8581: Add support for explicitly-bidirectional pattern synonyms

GHC - devs mailing list
In reply to this post by GHC - devs mailing list
#8581: Add support for explicitly-bidirectional pattern synonyms
-------------------------------------+-------------------------------------
              Reporter:  cactus      |            Owner:
                  Type:  feature     |           Status:  new
  request                            |        Milestone:  7.10.1
              Priority:  normal      |          Version:
             Component:  Compiler    |         Keywords:  pattern synonyms
            Resolution:              |     Architecture:  Unknown/Multiple
      Operating System:              |       Difficulty:  Unknown
  Unknown/Multiple                   |       Blocked By:  5144
       Type of failure:              |  Related Tickets:
  None/Unknown                       |
             Test Case:              |
              Blocking:              |
Differential Revisions:              |
-------------------------------------+-------------------------------------

Comment (by cactus):

 I think I like the `CE => CP` suggestion. Implementing it will be a bit
 tricky, because currently we typecheck pattern synonyms in two passes:

 * First we typecheck the pattern part, and build an internal
 representation `PatSyn`, which contains (among other things) the builder's
 `Id`, so it has to know its type. But currently that's not a problem,
 since the type is exactly known from the pattern part.

 * Then at a later point, the builder is typechecked against this type
 stored in `PatSyn`.

 So if we want to have any leeway in the builder type compared to the
 matcher type, we have to either typecheck the builder in the first stage
 as well, or not store its type in the `PatSyn`.

 To see why the first solution doesn't work, we need to look at the reason
 builders are typechecked in a separate pass: to support explicitly-
 bidirectional pattern synonyms where the builder refers to something which
 refers to the matcher, e.g. see `testsuite/tests/patsyn/should_run/bidir-
 explicit-scope.hs`:

 {{{
 pattern First x <- x:_ where
   First x = foo [x, x, x]

 foo :: [a] -> [a]
 foo xs@(First x) = replicate (length xs + 1) x

 }}}

 However, we also can't omit the type of the builder from the `PatSyn`
 representation for the same reason: suppose `First` occured in the right-
 hand side of `foo`; how would we know what type to give it, if all we have
 at hand is the `PatSyn` for `First`?

 Maybe there's a way out of all this if the builder type is initialized to
 a fresh skolem tyvar which is filled in when the builder is typechecked;
 but someone more knowledgeable about the typechecker's internals will have
 to chime in on that. I'm worried that, at the very least, it would lead to
 horrible error messages when something goes wrong, since the use sites of
 a pattern synonym builder could now influence the typechecking of the
 definition of said builder.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8581#comment:19>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
ghc-tickets mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/ghc-tickets
123
Loading...