add stripPrefix and Pattern for Data.List#120
Conversation
|
if you know a better place in the file for stripPrefix and Pattern let me know |
|
|
||
| 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.
not sure if this instance is correct
There was a problem hiding this comment.
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.
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) |
|
👍 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)