Re: Suppressing False Incomplete Pattern Matching Warnings for Polymorphic Pattern Synonyms

2018-11-09 Thread Shayan Najd
I also realised the COMPLETE pragmas are even less helpful (at least for my case mentioned above) as they cannot be used when orphaned. For example, I tried to follow the partial solution of introducing multiple COMPLETE pragmas, one per a concrete instance of `HasSrcSpan`. I defined the pattern sy

Re: Suppressing False Incomplete Pattern Matching Warnings for Polymorphic Pattern Synonyms

2018-10-29 Thread Sylvain Henry
I've just found this related ticket: https://ghc.haskell.org/trac/ghc/ticket/14422 On 10/26/18 7:04 PM, Richard Eisenberg wrote: Aha. So you're viewing complete sets as a type-directed property, where we can take a type and look up what complete sets of patterns of that type might be. Then,

Re: Suppressing False Incomplete Pattern Matching Warnings for Polymorphic Pattern Synonyms

2018-10-28 Thread Richard Eisenberg
> On Oct 26, 2018, at 9:43 PM, Carter Schonwald > wrote: > > ORDER of the abstracted constructors matters! That's a very good point. So we don't have a set of sets -- we have a set of lists (where normal constructors -- which have no overlap -- would appear in the lists in every possible pe

Re: Suppressing False Incomplete Pattern Matching Warnings for Polymorphic Pattern Synonyms

2018-10-26 Thread Carter Schonwald
off hand, once we're in in viewpattern/ pattern synonym land, ORDER of the abstracted constructors matters! consider foo,bar,baz,quux,boom :: Nat -> String plus some pattern synonyms i name "PowerOfTwo", "Even" and "Odd" foo (PowerOfTwo x) = "power of two" foo (Even x) = "even" foo (Odd x) = "od

Re: Suppressing False Incomplete Pattern Matching Warnings for Polymorphic Pattern Synonyms

2018-10-26 Thread Richard Eisenberg
Aha. So you're viewing complete sets as a type-directed property, where we can take a type and look up what complete sets of patterns of that type might be. Then, when checking a pattern-match for completeness, we use the inferred type of the pattern, access its complete sets, and if these match

Re: Suppressing False Incomplete Pattern Matching Warnings for Polymorphic Pattern Synonyms

2018-10-26 Thread Sylvain Henry
Sorry I wasn't clear. I'm not an expert on the topic but it seems to me that there are two orthogonal concerns: 1) How does the checker retrieve COMPLETE sets. Currently it seems to "attach" them to data type constructors (e.g. Maybe). If instead it retrieved them by matching types (e.g. "Mayb

Re: Suppressing False Incomplete Pattern Matching Warnings for Polymorphic Pattern Synonyms

2018-10-25 Thread Richard Eisenberg
I'm afraid I don't understand what your new syntax means. And, while I know it doesn't work today, what's wrong (in theory) with {-# COMPLETE LL #-} No types! (That's a rare thing for me to extol...) I feel I must be missing something here. Thanks, Richard > On Oct 25, 2018, at 12:24 PM, Sylv

Re: Suppressing False Incomplete Pattern Matching Warnings for Polymorphic Pattern Synonyms

2018-10-25 Thread Sylvain Henry
In the case where all the patterns are polymorphic, a user must provide a type signature but we accept the definition regardless of the type signature they provide. Currently we can specify the type *constructor* in a COMPLETE pragma: pattern J :: a -> Maybe apattern J a = Just apattern N :: M

Re: Suppressing False Incomplete Pattern Matching Warnings for Polymorphic Pattern Synonyms

2018-10-25 Thread Shayan Najd
> [Ryan Scott:] > In other words, this would work provided that you'd be willing to list > every single instance of `HasSrcSpan` in its own COMPLETE set. It's > tedious, but possible. Yes, for the cases where `LL` is used monomorphically, we can use the per-instance COMPLETE pragma, but it does no

Re: Suppressing False Incomplete Pattern Matching Warnings for Polymorphic Pattern Synonyms

2018-10-25 Thread Ryan Scott
You *can* put `LL` into a COMPLETE set, but under the stipulation that you specify which type constructor it's monomorphized to. To quote the wiki page on COMPLETE sets: In the case where all the patterns are polymorphic, a user must provide a type signature but we accept the definition regard

Re: Suppressing False Incomplete Pattern Matching Warnings for Polymorphic Pattern Synonyms

2018-10-25 Thread Matthew Pickering
I think that `LL` is precisely intended for abstraction. If this `COMPLETE` pragma were possible to implement then a user shouldn't know the difference between the old and new representations. The reason that `COMPLETE` pragmas are designed like this is that it's how the pattern match checker is d

Re: Suppressing False Incomplete Pattern Matching Warnings for Polymorphic Pattern Synonyms

2018-10-25 Thread Richard Eisenberg
In a rare move, I disagree with Ryan here. Why don't we want LL to be abstract? I personally don't want to be thinking of some desugaring to a view pattern when I say LL. I want just to be pattern matching. Is there a reason we can't extend COMPLETE pragmas to cover this case? Richard > On Oct

Re: Suppressing False Incomplete Pattern Matching Warnings for Polymorphic Pattern Synonyms

2018-10-25 Thread Ryan Scott
The fact that `LL` can't be used in a COMPLETE pragma is a consequence of its current design. Per the users' guide [1]: To make things more formal, when the pattern-match checker requests a set of constructors for some data type constructor T, the checker returns: * The original set of da

Re: Suppressing False Incomplete Pattern Matching Warnings for Polymorphic Pattern Synonyms

2018-10-25 Thread Richard Eisenberg
This sounds like an infelicity in COMPLETE pragmas. Do we have a documented reason why fixing this is impossible? Richard > On Oct 25, 2018, at 7:36 AM, Shayan Najd wrote: > > Dear GHC hackers, > > On our work on the new front-end AST for GHC [0] based on TTG [1], we > would like to use a pat

Suppressing False Incomplete Pattern Matching Warnings for Polymorphic Pattern Synonyms

2018-10-25 Thread Shayan Najd
Dear GHC hackers, On our work on the new front-end AST for GHC [0] based on TTG [1], we would like to use a pattern synonym like the following [2]: {{{ pattern LL :: HasSrcSpan a => SrcSpan -> SrcSpanLess a -> a pattern LL s m <- (decomposeSrcSpan -> (m , s)) where LL s m = compose