I made two pattern views for a list-like class.
infixr 5 :<
pattern (:<) :: Stream s => Token s -> s -> s
pattern b :< bs <- (uncons -> Just (b, bs))
where b :< bs = cons b bs
pattern Nil :: Stream s => s
pattern Nil <- (uncons -> Nothing)
where Nil = empty
uncons
signature: uncons :: (Stream s) => s -> Maybe (Token s, s)
.
Suppose I also have function that uses these patterns like that:
foo (b:<bs) = …
foo Nil = …
It's obvious in this case that pattern matches are exhaustive, and I would like to specify that.
So I tried using a COMPLETE pragma like that: {-# COMPLETE Nil, (:<) :: Stream #-}
.
That didn't work, warning didn't go anywhere. Why didn't it? Is it possible to do what I want?
COMPLETE
pragmas can only be attached to types, not type classes. There is currently no way to specify a complete set of patterns that works for all types of a given class.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With