{-# complete #-} should be able to handle | like {-# minimal #-}
It'd be really convenient to be able to specify these like we can with minimal
pragmas, mixing ands and ors. I wind up with a combinatorial explosion of such annotations for the cases where it works when I have large numbers of patterns.
I have at least one use case where something that would be a trivial pattern to express with one (complicated) expression involving |
becomes 64 lines of complete pragmas, and every time I extend it this count doubles.
Consider what happens if you add a mix of actual and smart views of a data type:
{-# language ViewPatterns, PatternSynonyms, GeneralizedNewtypeDeriving #-}
newtype Delta = Delta Int deriving (Eq,Num)
instance Monoid Delta where
mempty = 0
mappend = (+)
data Exp = Var !Int | AP !Delta !Exp !Exp | LAM !Delta !Exp
rel 0 xs = xs
rel d (AP d' l r) = AP (d + d') l r
rel d (LAM d' b) = LAM (d + d') b
rel _ (Var n) = Var n
pattern Ap a b <- AP d (rel d -> a) (rel d -> b) where
Ap a b = AP 0 a b
pattern Lam b <- LAM d (rel d -> b) where
Lam b = LAM 0 b
{-# complete Var, AP, Lam #-}
{-# complete Var, Ap, LAM #-}
{-# complete Var, AP, LAM #-}
Every data constructor I add with a smart view adds to the powerset of complete pragmas I should supply.
On the other hand with |
patterns:
{-# complete Var, (Ap | AP), (Lam | LAM) #-}
extends linearly.
Trac metadata
Trac field | Value |
---|---|
Version | 8.2.1 |
Type | FeatureRequest |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler (Type checker) |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |