some

One or more.

Examples

>>> some (putStr "la")
lalalalalalalalala... * goes on forever *
>>> some Nothing
nothing
>>> take 5 <$> some (Just 1)
* hangs forever *
Note that this function can be used with Parsers based on Applicatives. In that case some parser will attempt to parse parser one or more times until it fails.
One or more.
some p applies the parser p one or more times and returns a list of the values returned by p.
word = some letter
some p applies the parser p one or more times and returns a list of the values returned by p.
word = some letter
some p applies the parser p one or more times and returns a list of the values returned by p.
word = some letter
Existential type: Some This library defines an existential type Some.
data Some f where
Some :: f a -> Some f
in few variants, and utilities to work with it. If you are unsure which variant to use, use the one in Data.Some module.
Deprecated: Renamed as just.
Deprecated: Renamed as just.
One or more.
some m = (:) <$> m <*> many m
Collect one or more parses. Apply the supplied parser repeatedly on the input stream and push the parse results to a downstream fold. Stops: when the downstream fold stops or the parser fails. Fails: if it stops without producing a single result.
>>> some p f = Parser.manyP p (Parser.takeGE 1 f)

>>> some = Parser.countBetween 1 maxBound
Compare with some.
Choose a value that satisfies the given predicate. This is Hillbert's choice, essentially. Note that if the predicate given is not satisfiable (for instance const sFalse), then the element returned will be arbitrary. The only guarantee is that if there's at least one element that satisfies the predicate, then the returned element will be one of those that do. The returned element is not guaranteed to be unique, least, greatest etc, unless there happens to be exactly one satisfying element.
Build a Some c from some thing that satisfies c.
Same as the usual some except a Format is no Functor, let alone Alternative.
Some e                                   ~  Some e
An existential type. The constructor is exported only on GHC-8 and later.
Existential. This is type is useful to hide GADTs' parameters.
>>> data Tag :: Type -> Type where TagInt :: Tag Int; TagBool :: Tag Bool

>>> instance GShow Tag where gshowsPrec _ TagInt = showString "TagInt"; gshowsPrec _ TagBool = showString "TagBool"

>>> classify s = case s of "TagInt" -> [mkGReadResult TagInt]; "TagBool" -> [mkGReadResult TagBool]; _ -> []

>>> instance GRead Tag where greadsPrec _ s = [ (r, rest) | (con, rest) <-  lex s, r <- classify con ]
You can either use PatternSynonyms (available with GHC >= 8.0)
>>> let x = Some TagInt

>>> x
Some TagInt
>>> case x of { Some TagInt -> "I"; Some TagBool -> "B" } :: String
"I"
or you can use functions
>>> let y = mkSome TagBool

>>> y
Some TagBool
>>> withSome y $ \y' -> case y' of { TagInt -> "I"; TagBool -> "B" } :: String
"B"
The implementation of mapSome is safe.
>>> let f :: Tag a -> Tag a; f TagInt = TagInt; f TagBool = TagBool

>>> mapSome f y
Some TagBool
but you can also use:
>>> withSome y (mkSome . f)
Some TagBool
>>> read "Some TagBool" :: Some Tag
Some TagBool
>>> read "mkSome TagInt" :: Some Tag
Some TagInt
Existential. This is type is useful to hide GADTs' parameters.
>>> data Tag :: * -> * where TagInt :: Tag Int; TagBool :: Tag Bool

>>> instance GShow Tag where gshowsPrec _ TagInt = showString "TagInt"; gshowsPrec _ TagBool = showString "TagBool"

>>> classify s = case s of "TagInt" -> [mkGReadResult TagInt]; "TagBool" -> [mkGReadResult TagBool]; _ -> []

>>> instance GRead Tag where greadsPrec _ s = [ (r, rest) | (con, rest) <-  lex s, r <- classify con ]
With Church-encoding youcan only use a functions:
>>> let y = mkSome TagBool

>>> y
mkSome TagBool
>>> withSome y $ \y' -> case y' of { TagInt -> "I"; TagBool -> "B" } :: String
"B"
or explicitly work with S
>>> let x = S $ \f -> f TagInt

>>> x
mkSome TagInt
>>> case x of S f -> f $ \x' -> case x' of { TagInt -> "I"; TagBool -> "B" } :: String
"I"
The implementation of mapSome is safe.
>>> let f :: Tag a -> Tag a; f TagInt = TagInt; f TagBool = TagBool

>>> mapSome f y
mkSome TagBool
but you can also use:
>>> withSome y (mkSome . f)
mkSome TagBool
>>> read "Some TagBool" :: Some Tag
mkSome TagBool
>>> read "mkSome TagInt" :: Some Tag
mkSome TagInt
Existential. This is type is useful to hide GADTs' parameters.
>>> data Tag :: Type -> Type where TagInt :: Tag Int; TagBool :: Tag Bool

>>> instance GShow Tag where gshowsPrec _ TagInt = showString "TagInt"; gshowsPrec _ TagBool = showString "TagBool"

>>> classify s = case s of "TagInt" -> [mkGReadResult TagInt]; "TagBool" -> [mkGReadResult TagBool]; _ -> []

>>> instance GRead Tag where greadsPrec _ s = [ (r, rest) | (con, rest) <-  lex s, r <- classify con ]
You can either use constructor:
>>> let x = Some TagInt

>>> x
Some TagInt
>>> case x of { Some TagInt -> "I"; Some TagBool -> "B" } :: String
"I"
or you can use functions
>>> let y = mkSome TagBool

>>> y
Some TagBool
>>> withSome y $ \y' -> case y' of { TagInt -> "I"; TagBool -> "B" } :: String
"B"
The implementation of mapSome is safe.
>>> let f :: Tag a -> Tag a; f TagInt = TagInt; f TagBool = TagBool

>>> mapSome f y
Some TagBool
but you can also use:
>>> withSome y (mkSome . f)
Some TagBool
>>> read "Some TagBool" :: Some Tag
Some TagBool
>>> read "mkSome TagInt" :: Some Tag
Some TagInt