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
Run Code Online (Sandbox Code Playgroud)
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 = …
Run Code Online (Sandbox Code Playgroud)
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?