Commit 63eaecb7 authored by Kai-Oliver Prott's avatar Kai-Oliver Prott
Browse files

Optimize default implementations in Alternative class

parent f4aaf9ba
...@@ -1234,14 +1234,14 @@ class Applicative f => Alternative f where ...@@ -1234,14 +1234,14 @@ class Applicative f => Alternative f where
some v = some_v some v = some_v
where where
many_v = some_v <|> pure [] many_v = some_v <|> pure []
some_v = liftA2 (:) v many_v some_v = (:) <$> v <*> many_v
-- | Zero or more. -- | Zero or more.
many :: f a -> f [a] many :: f a -> f [a]
many v = many_v many v = many_v
where where
many_v = some_v <|> pure [] many_v = some_v <|> pure []
some_v = liftA2 (:) v many_v some_v = (:) <$> v <*> many_v
instance Alternative [] where instance Alternative [] where
empty = [] empty = []
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment