Skip to content

use NonEmptyList for some #5

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

Merged
merged 1 commit into from
Mar 18, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/Options/Applicative/Types.purs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ import Data.Generic.Rep (class Generic)
import Data.Generic.Rep.Show (genericShow)
import Data.List (List)
import Data.List as List
import Data.List.NonEmpty as NEL
import Data.List.Types (NonEmptyList)
import Data.Maybe (Maybe(..))
import Data.Newtype (class Newtype, over, un)
import Data.Tuple.Nested (Tuple3, (/\))
Expand Down Expand Up @@ -370,12 +372,12 @@ manyM p = tailRecM go List.Nil
aa <- oneM $ (Loop <$> p) <|> pure (Done unit)
pure $ bimap (_ List.: acc) (\_ -> List.reverse acc) aa

someM :: forall a. Parser a -> ParserM (List a)
someM p = List.Cons <$> oneM p <*> manyM p
someM :: forall a. Parser a -> ParserM (NonEmptyList a)
someM p = NEL.cons' <$> oneM p <*> manyM p

many :: forall a. Parser a -> Parser (List a)
many = manyM >>> fromM
some :: forall a. Parser a -> Parser (List a)
some :: forall a. Parser a -> Parser (NonEmptyList a)
some = someM >>> fromM

-- | optparse-applicative supplies a rich completion system for bash,
Expand Down