-
-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create patterns for smooth pattern-matching #2
Labels
enhancement
New feature or request
Comments
I vote to create one bi-directional pattern for easy construction/deconstruction and also a pattern for the empty list {-# LANGUAGE PatternSynonyms, ViewPatterns, RecordWildCards #-}
infixr 5 :-
pattern x :- xs <- (uncons->(x,xs)) where
x :- Slist{..} = Slist (x : sList) (sSize + 1)
pattern Nil = Slist [] 0 Usage: myList = 1 :- 2 :- 3 :- Nil
head' (x:-_) = x
tail' (_:-x) = x
sum' (x:-xs) = x + sum' xs
sum' Nil = 0 |
@BlackCapCoder the patterns you're suggesting don't capture the size in any way; however, this issue is created because I was working a lot with pattern-matching on the size. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
No description provided.
The text was updated successfully, but these errors were encountered: