Module

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

Lift an Unfoldable1 into an Unfoldable by wrapping it in Maybe, such that an empty sequence gives Nothing and a nonempty sequence gives a nonempty Unfoldable1 in Just.

Constructors

Instances

#maybeEmpty Source

maybeEmpty :: forall f a b. b -> (f a -> b) -> MaybeEmpty f a -> b

Convenience wrapper for maybe on the inner Maybe. Can save an import Data.Newtype (un) if this is all you need from Data.Unfoldable.MaybeEmpty.

#maybeEmpty' Source

maybeEmpty' :: forall f a b. (Unit -> b) -> (f a -> b) -> MaybeEmpty f a -> b

#distributeMaybes Source

distributeMaybes :: forall f a. Unfoldable1 f => Functor f => MaybeEmpty f a -> f (Maybe a)

Creates 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)

Creates 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)

Unwraps and converts 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 b

Applies a function to the inner container if present.