{-# LANGUAGE CPP #-}
#include "containers.h"
{-# OPTIONS_HADDOCK hide #-}
module Utils.Containers.Internal.StrictMaybe (MaybeS (..), maybeS, toMaybe, toMaybeS) where
#if !MIN_VERSION_base(4,8,0)
import Data.Foldable (Foldable (..))
import Data.Monoid (Monoid (..))
#endif
data MaybeS a = NothingS | JustS !a
instance Foldable MaybeS where
foldMap :: forall m a. Monoid m => (a -> m) -> MaybeS a -> m
foldMap a -> m
_ MaybeS a
NothingS = m
forall a. Monoid a => a
mempty
foldMap a -> m
f (JustS a
a) = a -> m
f a
a
maybeS :: r -> (a -> r) -> MaybeS a -> r
maybeS :: forall r a. r -> (a -> r) -> MaybeS a -> r
maybeS r
n a -> r
_ MaybeS a
NothingS = r
n
maybeS r
_ a -> r
j (JustS a
a) = a -> r
j a
a
toMaybe :: MaybeS a -> Maybe a
toMaybe :: forall a. MaybeS a -> Maybe a
toMaybe MaybeS a
NothingS = Maybe a
forall a. Maybe a
Nothing
toMaybe (JustS a
a) = a -> Maybe a
forall a. a -> Maybe a
Just a
a
toMaybeS :: Maybe a -> MaybeS a
toMaybeS :: forall a. Maybe a -> MaybeS a
toMaybeS Maybe a
Nothing = MaybeS a
forall a. MaybeS a
NothingS
toMaybeS (Just a
a) = a -> MaybeS a
forall a. a -> MaybeS a
JustS a
a