-
Notifications
You must be signed in to change notification settings - Fork 50
add stripPrefix and Pattern for Data.List #120
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
Conversation
if you know a better place in the file for stripPrefix and Pattern let me know |
src/Data/List.purs
Outdated
|
||
derive instance eqPattern :: (Eq a) => Eq (Pattern a) | ||
derive instance ordPattern :: (Ord a) => Ord (Pattern a) | ||
derive instance newtypePattern :: Newtype (Pattern a) _ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure if this instance is correct
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, that's how deriving for Newtype
works.
src/Data/List.purs
Outdated
stripPrefix (Pattern p') s = tailRecM2 go p' s | ||
where | ||
go prefix input = case prefix, input of | ||
(Cons p ps), (Cons i is) | p == i -> Just $ Loop ({ a: ps, b: is }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parens are redundant in the patterns and in the value here.
src/Data/List.purs
Outdated
-- | A newtype used in cases where there is a list to be matched. | ||
newtype Pattern a = Pattern (List a) | ||
|
||
derive instance eqPattern :: (Eq a) => Eq (Pattern a) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant parens.
👍 Thanks! |
@garyb Do you want to use the This looks good to me. |
The name |
|
That works for sure, but if there's a chance any of the other string-ish functions will be replicated here then |
True ... ok, merging. |
purescript-contrib/purescript-parsing#62 (comment)