Data.Unfoldable.MaybeEmpty
- Package
- purescript-trivial-unfold
- Repository
- UnrelatedString/purescript-trivial-unfold
#MaybeEmpty Source
newtype MaybeEmpty :: forall k. (k -> Type) -> k -> Typenewtype MaybeEmpty f a
Lifts a nonempty container into a possibly-empty container by wrapping it in Maybe.
such that an empty sequence corresponds to Nothing and a nonempty sequence
corresponds to the nonempty container in a Just.
Constructors
MaybeEmpty (Maybe (f a))
Instances
Newtype (MaybeEmpty f a) _(Arbitrary (f a)) => Arbitrary (MaybeEmpty f a)(Coarbitrary (f a)) => Coarbitrary (MaybeEmpty f a)(Semigroup (f a)) => Semigroup (MaybeEmpty f a)(Semigroup (f a)) => Monoid (MaybeEmpty f a)(Bounded (f a)) => Bounded (MaybeEmpty f a)(Semiring (f a)) => Semiring (MaybeEmpty f a)Generic (MaybeEmpty f a) _(Eq1 f) => Eq1 (MaybeEmpty f)(Ord1 f) => Ord1 (MaybeEmpty f)(Show (f a)) => Show (MaybeEmpty f a)(Eq1 f, Eq a) => Eq (MaybeEmpty f a)(Ord1 f, Ord a) => Ord (MaybeEmpty f a)(Unfoldable1 f) => Unfoldable1 (MaybeEmpty f)(Unfoldable1 f) => Unfoldable (MaybeEmpty f)(Functor f) => Functor (MaybeEmpty f)(Apply f) => Apply (MaybeEmpty f)(Applicative f) => Applicative (MaybeEmpty f)(Bind f, Traversable f) => Bind (MaybeEmpty f)(Applicative f, Bind f, Traversable f) => Monad (MaybeEmpty f)(Functor f) => Invariant (MaybeEmpty f)(Alt f) => Alt (MaybeEmpty f)(Alt f) => Plus (MaybeEmpty f)empty = none. Does not usePlus fif it exists--and given that this is all about wrapping guaranteed non-empty containers, it probably doesn't.(Applicative f, Alt f) => Alternative (MaybeEmpty f)(Extend f) => Extend (MaybeEmpty f)(Foldable f) => Foldable (MaybeEmpty f)(Traversable f) => Traversable (MaybeEmpty f)
#maybeEmpty Source
maybeEmpty :: forall f a b. b -> (f a -> b) -> MaybeEmpty f a -> bConvenience wrapper for maybe on the inner Maybe,
to save you an un or toAlternative.
#maybeEmpty' Source
maybeEmpty' :: forall f a b. (Unit -> b) -> (f a -> b) -> MaybeEmpty f a -> b#justNonempty Source
justNonempty :: forall f a. f a -> MaybeEmpty f aWrap an existing container into a MaybeEmpty.
#distributeMaybes Source
distributeMaybes :: forall f a. Unfoldable1 f => Functor f => MaybeEmpty f a -> f (Maybe a)Create an f containing a single Nothing if empty.
Although Data.Unfoldable calls them "unfoldable functors", Functor isn't actually
a superclass of Unfoldable1. On the off chance that you for some reason do in fact
have an Unfoldable1 type which is not a Functor but also want to use this,
consider emptyIfNone from Data.Unfoldable.Trivial instead.
#distributeMaybesA Source
distributeMaybesA :: forall f a. Applicative f => MaybeEmpty f a -> f (Maybe a)Create an f containing Nothing if empty, using pure instead of singleton.
#toAlternative Source
toAlternative :: forall u f a. Alternative f => MaybeEmpty u a -> f (u a)Unwrap and convert the inner Maybe into an alternative Alternative. (ba dum tss)
#maybeOver Source
maybeOver :: forall f g a b. (f a -> g b) -> MaybeEmpty f a -> MaybeEmpty g bApply a function to the inner container if present.
Composes
Alt MaybewithAlt f. This does not seem likely to be particularly useful, but then again, what does?If you just want the first nonempty
MaybeEmpty f a,unwraportoAlternativeit toMaybe (f a).