{-# LANGUAGE UnboxedTuples #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE UnliftedNewtypes #-}
module GHC.Data.Unboxed (
MaybeUB(JustUB, NothingUB),
fmapMaybeUB, fromMaybeUB, apMaybeUB, maybeUB
) where
import GHC.Prelude hiding (Maybe(..), Either(..))
newtype MaybeUB a = MaybeUB (# (# #) | a #)
pattern JustUB :: a -> MaybeUB a
pattern $bJustUB :: forall a. a -> MaybeUB a
$mJustUB :: forall {r} {a}. MaybeUB a -> (a -> r) -> ((# #) -> r) -> r
JustUB x = MaybeUB (# | x #)
pattern NothingUB :: MaybeUB a
pattern $bNothingUB :: (# #) -> forall a. MaybeUB a
$mNothingUB :: forall {r} {a}. MaybeUB a -> ((# #) -> r) -> ((# #) -> r) -> r
NothingUB = MaybeUB (# (# #) | #)
{-# COMPLETE NothingUB, JustUB #-}
fromMaybeUB :: a -> MaybeUB a -> a
fromMaybeUB :: forall a. a -> MaybeUB a -> a
fromMaybeUB a
d MaybeUB a
NothingUB = a
d
fromMaybeUB a
_ (JustUB a
x) = a
x
apMaybeUB :: MaybeUB (a -> b) -> MaybeUB a -> MaybeUB b
apMaybeUB :: forall a b. MaybeUB (a -> b) -> MaybeUB a -> MaybeUB b
apMaybeUB (JustUB a -> b
f) (JustUB a
x) = forall a. a -> MaybeUB a
JustUB (a -> b
f a
x)
apMaybeUB MaybeUB (a -> b)
_ MaybeUB a
_ = forall a. MaybeUB a
NothingUB
fmapMaybeUB :: (a -> b) -> MaybeUB a -> MaybeUB b
fmapMaybeUB :: forall a b. (a -> b) -> MaybeUB a -> MaybeUB b
fmapMaybeUB a -> b
_f MaybeUB a
NothingUB = forall a. MaybeUB a
NothingUB
fmapMaybeUB a -> b
f (JustUB a
x) = forall a. a -> MaybeUB a
JustUB forall a b. (a -> b) -> a -> b
$ a -> b
f a
x
maybeUB :: b -> (a -> b) -> MaybeUB a -> b
maybeUB :: forall b a. b -> (a -> b) -> MaybeUB a -> b
maybeUB b
_def a -> b
f (JustUB a
x) = a -> b
f a
x
maybeUB b
def a -> b
_f MaybeUB a
NothingUB = b
def