mirror of
https://github.com/sdiehl/write-you-a-haskell.git
synced 2024-08-16 07:00:36 +03:00
Added Alternative
constraint to inline code
This commit is contained in:
parent
1e26e8fa23
commit
1e9b0fba91
@ -105,14 +105,14 @@ itself if there is not at least a single match.
|
||||
|
||||
```haskell
|
||||
-- | One or more.
|
||||
some :: f a -> f [a]
|
||||
some :: Alternative f => f a -> f [a]
|
||||
some v = some_v
|
||||
where
|
||||
many_v = some_v <|> pure []
|
||||
some_v = (:) <$> v <*> many_v
|
||||
|
||||
-- | Zero or more.
|
||||
many :: f a -> f [a]
|
||||
many :: Alternative f => f a -> f [a]
|
||||
many v = many_v
|
||||
where
|
||||
many_v = some_v <|> pure []
|
||||
|
Loading…
Reference in New Issue
Block a user