-- Strict counterparts to common data structures,
-- e.g. tuples, lists, maybes, etc.
--
-- Import this module qualified as Strict.

{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveTraversable #-}

module GHC.Data.Strict (
    Maybe(Nothing, Just),
    fromMaybe,
    Pair(And),

    -- Not used at the moment:
    --
    -- Either(Left, Right),
    -- List(Nil, Cons),
  ) where

import GHC.Prelude hiding (Maybe(..), Either(..))
import Control.Applicative
import Data.Semigroup
import Data.Data

data Maybe a = Nothing | Just !a
  deriving (Maybe a -> Maybe a -> Bool
(Maybe a -> Maybe a -> Bool)
-> (Maybe a -> Maybe a -> Bool) -> Eq (Maybe a)
forall a. Eq a => Maybe a -> Maybe a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall a. Eq a => Maybe a -> Maybe a -> Bool
== :: Maybe a -> Maybe a -> Bool
$c/= :: forall a. Eq a => Maybe a -> Maybe a -> Bool
/= :: Maybe a -> Maybe a -> Bool
Eq, Eq (Maybe a)
Eq (Maybe a) =>
(Maybe a -> Maybe a -> Ordering)
-> (Maybe a -> Maybe a -> Bool)
-> (Maybe a -> Maybe a -> Bool)
-> (Maybe a -> Maybe a -> Bool)
-> (Maybe a -> Maybe a -> Bool)
-> (Maybe a -> Maybe a -> Maybe a)
-> (Maybe a -> Maybe a -> Maybe a)
-> Ord (Maybe a)
Maybe a -> Maybe a -> Bool
Maybe a -> Maybe a -> Ordering
Maybe a -> Maybe a -> Maybe a
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall a. Ord a => Eq (Maybe a)
forall a. Ord a => Maybe a -> Maybe a -> Bool
forall a. Ord a => Maybe a -> Maybe a -> Ordering
forall a. Ord a => Maybe a -> Maybe a -> Maybe a
$ccompare :: forall a. Ord a => Maybe a -> Maybe a -> Ordering
compare :: Maybe a -> Maybe a -> Ordering
$c< :: forall a. Ord a => Maybe a -> Maybe a -> Bool
< :: Maybe a -> Maybe a -> Bool
$c<= :: forall a. Ord a => Maybe a -> Maybe a -> Bool
<= :: Maybe a -> Maybe a -> Bool
$c> :: forall a. Ord a => Maybe a -> Maybe a -> Bool
> :: Maybe a -> Maybe a -> Bool
$c>= :: forall a. Ord a => Maybe a -> Maybe a -> Bool
>= :: Maybe a -> Maybe a -> Bool
$cmax :: forall a. Ord a => Maybe a -> Maybe a -> Maybe a
max :: Maybe a -> Maybe a -> Maybe a
$cmin :: forall a. Ord a => Maybe a -> Maybe a -> Maybe a
min :: Maybe a -> Maybe a -> Maybe a
Ord, Int -> Maybe a -> ShowS
[Maybe a] -> ShowS
Maybe a -> String
(Int -> Maybe a -> ShowS)
-> (Maybe a -> String) -> ([Maybe a] -> ShowS) -> Show (Maybe a)
forall a. Show a => Int -> Maybe a -> ShowS
forall a. Show a => [Maybe a] -> ShowS
forall a. Show a => Maybe a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall a. Show a => Int -> Maybe a -> ShowS
showsPrec :: Int -> Maybe a -> ShowS
$cshow :: forall a. Show a => Maybe a -> String
show :: Maybe a -> String
$cshowList :: forall a. Show a => [Maybe a] -> ShowS
showList :: [Maybe a] -> ShowS
Show, (forall a b. (a -> b) -> Maybe a -> Maybe b)
-> (forall a b. a -> Maybe b -> Maybe a) -> Functor Maybe
forall a b. a -> Maybe b -> Maybe a
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall a b. (a -> b) -> Maybe a -> Maybe b
fmap :: forall a b. (a -> b) -> Maybe a -> Maybe b
$c<$ :: forall a b. a -> Maybe b -> Maybe a
<$ :: forall a b. a -> Maybe b -> Maybe a
Functor, (forall m. Monoid m => Maybe m -> m)
-> (forall m a. Monoid m => (a -> m) -> Maybe a -> m)
-> (forall m a. Monoid m => (a -> m) -> Maybe a -> m)
-> (forall a b. (a -> b -> b) -> b -> Maybe a -> b)
-> (forall a b. (a -> b -> b) -> b -> Maybe a -> b)
-> (forall b a. (b -> a -> b) -> b -> Maybe a -> b)
-> (forall b a. (b -> a -> b) -> b -> Maybe a -> b)
-> (forall a. (a -> a -> a) -> Maybe a -> a)
-> (forall a. (a -> a -> a) -> Maybe a -> a)
-> (forall a. Maybe a -> [a])
-> (forall a. Maybe a -> Bool)
-> (forall a. Maybe a -> Int)
-> (forall a. Eq a => a -> Maybe a -> Bool)
-> (forall a. Ord a => Maybe a -> a)
-> (forall a. Ord a => Maybe a -> a)
-> (forall a. Num a => Maybe a -> a)
-> (forall a. Num a => Maybe a -> a)
-> Foldable Maybe
forall a. Eq a => a -> Maybe a -> Bool
forall a. Num a => Maybe a -> a
forall a. Ord a => Maybe a -> a
forall m. Monoid m => Maybe m -> m
forall a. Maybe a -> Bool
forall a. Maybe a -> Int
forall a. Maybe a -> [a]
forall a. (a -> a -> a) -> Maybe a -> a
forall m a. Monoid m => (a -> m) -> Maybe a -> m
forall b a. (b -> a -> b) -> b -> Maybe a -> b
forall a b. (a -> b -> b) -> b -> Maybe a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
$cfold :: forall m. Monoid m => Maybe m -> m
fold :: forall m. Monoid m => Maybe m -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> Maybe a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> Maybe a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> Maybe a -> m
foldMap' :: forall m a. Monoid m => (a -> m) -> Maybe a -> m
$cfoldr :: forall a b. (a -> b -> b) -> b -> Maybe a -> b
foldr :: forall a b. (a -> b -> b) -> b -> Maybe a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> Maybe a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> Maybe a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> Maybe a -> b
foldl :: forall b a. (b -> a -> b) -> b -> Maybe a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> Maybe a -> b
foldl' :: forall b a. (b -> a -> b) -> b -> Maybe a -> b
$cfoldr1 :: forall a. (a -> a -> a) -> Maybe a -> a
foldr1 :: forall a. (a -> a -> a) -> Maybe a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> Maybe a -> a
foldl1 :: forall a. (a -> a -> a) -> Maybe a -> a
$ctoList :: forall a. Maybe a -> [a]
toList :: forall a. Maybe a -> [a]
$cnull :: forall a. Maybe a -> Bool
null :: forall a. Maybe a -> Bool
$clength :: forall a. Maybe a -> Int
length :: forall a. Maybe a -> Int
$celem :: forall a. Eq a => a -> Maybe a -> Bool
elem :: forall a. Eq a => a -> Maybe a -> Bool
$cmaximum :: forall a. Ord a => Maybe a -> a
maximum :: forall a. Ord a => Maybe a -> a
$cminimum :: forall a. Ord a => Maybe a -> a
minimum :: forall a. Ord a => Maybe a -> a
$csum :: forall a. Num a => Maybe a -> a
sum :: forall a. Num a => Maybe a -> a
$cproduct :: forall a. Num a => Maybe a -> a
product :: forall a. Num a => Maybe a -> a
Foldable, Functor Maybe
Foldable Maybe
(Functor Maybe, Foldable Maybe) =>
(forall (f :: * -> *) a b.
 Applicative f =>
 (a -> f b) -> Maybe a -> f (Maybe b))
-> (forall (f :: * -> *) a.
    Applicative f =>
    Maybe (f a) -> f (Maybe a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> Maybe a -> m (Maybe b))
-> (forall (m :: * -> *) a. Monad m => Maybe (m a) -> m (Maybe a))
-> Traversable Maybe
forall (t :: * -> *).
(Functor t, Foldable t) =>
(forall (f :: * -> *) a b.
 Applicative f =>
 (a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a. Monad m => Maybe (m a) -> m (Maybe a)
forall (f :: * -> *) a. Applicative f => Maybe (f a) -> f (Maybe a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Maybe a -> m (Maybe b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Maybe a -> f (Maybe b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Maybe a -> f (Maybe b)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Maybe a -> f (Maybe b)
$csequenceA :: forall (f :: * -> *) a. Applicative f => Maybe (f a) -> f (Maybe a)
sequenceA :: forall (f :: * -> *) a. Applicative f => Maybe (f a) -> f (Maybe a)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Maybe a -> m (Maybe b)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Maybe a -> m (Maybe b)
$csequence :: forall (m :: * -> *) a. Monad m => Maybe (m a) -> m (Maybe a)
sequence :: forall (m :: * -> *) a. Monad m => Maybe (m a) -> m (Maybe a)
Traversable, Typeable (Maybe a)
Typeable (Maybe a) =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> Maybe a -> c (Maybe a))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (Maybe a))
-> (Maybe a -> Constr)
-> (Maybe a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (Maybe a)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Maybe a)))
-> ((forall b. Data b => b -> b) -> Maybe a -> Maybe a)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Maybe a -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Maybe a -> r)
-> (forall u. (forall d. Data d => d -> u) -> Maybe a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Maybe a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Maybe a -> m (Maybe a))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Maybe a -> m (Maybe a))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Maybe a -> m (Maybe a))
-> Data (Maybe a)
Maybe a -> Constr
Maybe a -> DataType
(forall b. Data b => b -> b) -> Maybe a -> Maybe a
forall a. Data a => Typeable (Maybe a)
forall a. Data a => Maybe a -> Constr
forall a. Data a => Maybe a -> DataType
forall a.
Data a =>
(forall b. Data b => b -> b) -> Maybe a -> Maybe a
forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> Maybe a -> u
forall a u.
Data a =>
(forall d. Data d => d -> u) -> Maybe a -> [u]
forall a r r'.
Data a =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Maybe a -> r
forall a r r'.
Data a =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Maybe a -> r
forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> Maybe a -> m (Maybe a)
forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Maybe a -> m (Maybe a)
forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Maybe a)
forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Maybe a -> c (Maybe a)
forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Maybe a))
forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Maybe a))
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Maybe a -> u
forall u. (forall d. Data d => d -> u) -> Maybe a -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Maybe a -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Maybe a -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Maybe a -> m (Maybe a)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Maybe a -> m (Maybe a)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Maybe a)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Maybe a -> c (Maybe a)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Maybe a))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Maybe a))
$cgfoldl :: forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Maybe a -> c (Maybe a)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Maybe a -> c (Maybe a)
$cgunfold :: forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Maybe a)
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Maybe a)
$ctoConstr :: forall a. Data a => Maybe a -> Constr
toConstr :: Maybe a -> Constr
$cdataTypeOf :: forall a. Data a => Maybe a -> DataType
dataTypeOf :: Maybe a -> DataType
$cdataCast1 :: forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Maybe a))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Maybe a))
$cdataCast2 :: forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Maybe a))
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Maybe a))
$cgmapT :: forall a.
Data a =>
(forall b. Data b => b -> b) -> Maybe a -> Maybe a
gmapT :: (forall b. Data b => b -> b) -> Maybe a -> Maybe a
$cgmapQl :: forall a r r'.
Data a =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Maybe a -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Maybe a -> r
$cgmapQr :: forall a r r'.
Data a =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Maybe a -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Maybe a -> r
$cgmapQ :: forall a u.
Data a =>
(forall d. Data d => d -> u) -> Maybe a -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> Maybe a -> [u]
$cgmapQi :: forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> Maybe a -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Maybe a -> u
$cgmapM :: forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> Maybe a -> m (Maybe a)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Maybe a -> m (Maybe a)
$cgmapMp :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Maybe a -> m (Maybe a)
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Maybe a -> m (Maybe a)
$cgmapMo :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Maybe a -> m (Maybe a)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Maybe a -> m (Maybe a)
Data)

fromMaybe :: a -> Maybe a -> a
fromMaybe :: forall a. a -> Maybe a -> a
fromMaybe a
d Maybe a
Nothing = a
d
fromMaybe a
_ (Just a
x) = a
x

apMaybe :: Maybe (a -> b) -> Maybe a -> Maybe b
apMaybe :: forall a b. Maybe (a -> b) -> Maybe a -> Maybe b
apMaybe (Just a -> b
f) (Just a
x) = b -> Maybe b
forall a. a -> Maybe a
Just (a -> b
f a
x)
apMaybe Maybe (a -> b)
_ Maybe a
_ = Maybe b
forall a. Maybe a
Nothing

altMaybe :: Maybe a -> Maybe a -> Maybe a
altMaybe :: forall a. Maybe a -> Maybe a -> Maybe a
altMaybe Maybe a
Nothing Maybe a
r = Maybe a
r
altMaybe Maybe a
l Maybe a
_ = Maybe a
l

instance Semigroup a => Semigroup (Maybe a) where
  Maybe a
Nothing <> :: Maybe a -> Maybe a -> Maybe a
<> Maybe a
b       = Maybe a
b
  Maybe a
a       <> Maybe a
Nothing = Maybe a
a
  Just a
a  <> Just a
b  = a -> Maybe a
forall a. a -> Maybe a
Just (a
a a -> a -> a
forall a. Semigroup a => a -> a -> a
<> a
b)

instance Semigroup a => Monoid (Maybe a) where
  mempty :: Maybe a
mempty = Maybe a
forall a. Maybe a
Nothing

instance Applicative Maybe where
  pure :: forall a. a -> Maybe a
pure = a -> Maybe a
forall a. a -> Maybe a
Just
  <*> :: forall a b. Maybe (a -> b) -> Maybe a -> Maybe b
(<*>) = Maybe (a -> b) -> Maybe a -> Maybe b
forall a b. Maybe (a -> b) -> Maybe a -> Maybe b
apMaybe

instance Alternative Maybe where
  empty :: forall a. Maybe a
empty = Maybe a
forall a. Maybe a
Nothing
  <|> :: forall a. Maybe a -> Maybe a -> Maybe a
(<|>) = Maybe a -> Maybe a -> Maybe a
forall a. Maybe a -> Maybe a -> Maybe a
altMaybe

data Pair a b = !a `And` !b
  deriving (Pair a b -> Pair a b -> Bool
(Pair a b -> Pair a b -> Bool)
-> (Pair a b -> Pair a b -> Bool) -> Eq (Pair a b)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall a b. (Eq a, Eq b) => Pair a b -> Pair a b -> Bool
$c== :: forall a b. (Eq a, Eq b) => Pair a b -> Pair a b -> Bool
== :: Pair a b -> Pair a b -> Bool
$c/= :: forall a b. (Eq a, Eq b) => Pair a b -> Pair a b -> Bool
/= :: Pair a b -> Pair a b -> Bool
Eq, Eq (Pair a b)
Eq (Pair a b) =>
(Pair a b -> Pair a b -> Ordering)
-> (Pair a b -> Pair a b -> Bool)
-> (Pair a b -> Pair a b -> Bool)
-> (Pair a b -> Pair a b -> Bool)
-> (Pair a b -> Pair a b -> Bool)
-> (Pair a b -> Pair a b -> Pair a b)
-> (Pair a b -> Pair a b -> Pair a b)
-> Ord (Pair a b)
Pair a b -> Pair a b -> Bool
Pair a b -> Pair a b -> Ordering
Pair a b -> Pair a b -> Pair a b
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall a b. (Ord a, Ord b) => Eq (Pair a b)
forall a b. (Ord a, Ord b) => Pair a b -> Pair a b -> Bool
forall a b. (Ord a, Ord b) => Pair a b -> Pair a b -> Ordering
forall a b. (Ord a, Ord b) => Pair a b -> Pair a b -> Pair a b
$ccompare :: forall a b. (Ord a, Ord b) => Pair a b -> Pair a b -> Ordering
compare :: Pair a b -> Pair a b -> Ordering
$c< :: forall a b. (Ord a, Ord b) => Pair a b -> Pair a b -> Bool
< :: Pair a b -> Pair a b -> Bool
$c<= :: forall a b. (Ord a, Ord b) => Pair a b -> Pair a b -> Bool
<= :: Pair a b -> Pair a b -> Bool
$c> :: forall a b. (Ord a, Ord b) => Pair a b -> Pair a b -> Bool
> :: Pair a b -> Pair a b -> Bool
$c>= :: forall a b. (Ord a, Ord b) => Pair a b -> Pair a b -> Bool
>= :: Pair a b -> Pair a b -> Bool
$cmax :: forall a b. (Ord a, Ord b) => Pair a b -> Pair a b -> Pair a b
max :: Pair a b -> Pair a b -> Pair a b
$cmin :: forall a b. (Ord a, Ord b) => Pair a b -> Pair a b -> Pair a b
min :: Pair a b -> Pair a b -> Pair a b
Ord, Int -> Pair a b -> ShowS
[Pair a b] -> ShowS
Pair a b -> String
(Int -> Pair a b -> ShowS)
-> (Pair a b -> String) -> ([Pair a b] -> ShowS) -> Show (Pair a b)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall a b. (Show a, Show b) => Int -> Pair a b -> ShowS
forall a b. (Show a, Show b) => [Pair a b] -> ShowS
forall a b. (Show a, Show b) => Pair a b -> String
$cshowsPrec :: forall a b. (Show a, Show b) => Int -> Pair a b -> ShowS
showsPrec :: Int -> Pair a b -> ShowS
$cshow :: forall a b. (Show a, Show b) => Pair a b -> String
show :: Pair a b -> String
$cshowList :: forall a b. (Show a, Show b) => [Pair a b] -> ShowS
showList :: [Pair a b] -> ShowS
Show, (forall a b. (a -> b) -> Pair a a -> Pair a b)
-> (forall a b. a -> Pair a b -> Pair a a) -> Functor (Pair a)
forall a b. a -> Pair a b -> Pair a a
forall a b. (a -> b) -> Pair a a -> Pair a b
forall a a b. a -> Pair a b -> Pair a a
forall a a b. (a -> b) -> Pair a a -> Pair a b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall a a b. (a -> b) -> Pair a a -> Pair a b
fmap :: forall a b. (a -> b) -> Pair a a -> Pair a b
$c<$ :: forall a a b. a -> Pair a b -> Pair a a
<$ :: forall a b. a -> Pair a b -> Pair a a
Functor, (forall m. Monoid m => Pair a m -> m)
-> (forall m a. Monoid m => (a -> m) -> Pair a a -> m)
-> (forall m a. Monoid m => (a -> m) -> Pair a a -> m)
-> (forall a b. (a -> b -> b) -> b -> Pair a a -> b)
-> (forall a b. (a -> b -> b) -> b -> Pair a a -> b)
-> (forall b a. (b -> a -> b) -> b -> Pair a a -> b)
-> (forall b a. (b -> a -> b) -> b -> Pair a a -> b)
-> (forall a. (a -> a -> a) -> Pair a a -> a)
-> (forall a. (a -> a -> a) -> Pair a a -> a)
-> (forall a. Pair a a -> [a])
-> (forall a. Pair a a -> Bool)
-> (forall a. Pair a a -> Int)
-> (forall a. Eq a => a -> Pair a a -> Bool)
-> (forall a. Ord a => Pair a a -> a)
-> (forall a. Ord a => Pair a a -> a)
-> (forall a. Num a => Pair a a -> a)
-> (forall a. Num a => Pair a a -> a)
-> Foldable (Pair a)
forall a. Eq a => a -> Pair a a -> Bool
forall a. Num a => Pair a a -> a
forall a. Ord a => Pair a a -> a
forall m. Monoid m => Pair a m -> m
forall a. Pair a a -> Bool
forall a. Pair a a -> Int
forall a. Pair a a -> [a]
forall a. (a -> a -> a) -> Pair a a -> a
forall a a. Eq a => a -> Pair a a -> Bool
forall a a. Num a => Pair a a -> a
forall a a. Ord a => Pair a a -> a
forall m a. Monoid m => (a -> m) -> Pair a a -> m
forall a m. Monoid m => Pair a m -> m
forall a a. Pair a a -> Bool
forall a a. Pair a a -> Int
forall a a. Pair a a -> [a]
forall b a. (b -> a -> b) -> b -> Pair a a -> b
forall a b. (a -> b -> b) -> b -> Pair a a -> b
forall a a. (a -> a -> a) -> Pair a a -> a
forall a m a. Monoid m => (a -> m) -> Pair a a -> m
forall a b a. (b -> a -> b) -> b -> Pair a a -> b
forall a a b. (a -> b -> b) -> b -> Pair a a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
$cfold :: forall a m. Monoid m => Pair a m -> m
fold :: forall m. Monoid m => Pair a m -> m
$cfoldMap :: forall a m a. Monoid m => (a -> m) -> Pair a a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> Pair a a -> m
$cfoldMap' :: forall a m a. Monoid m => (a -> m) -> Pair a a -> m
foldMap' :: forall m a. Monoid m => (a -> m) -> Pair a a -> m
$cfoldr :: forall a a b. (a -> b -> b) -> b -> Pair a a -> b
foldr :: forall a b. (a -> b -> b) -> b -> Pair a a -> b
$cfoldr' :: forall a a b. (a -> b -> b) -> b -> Pair a a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> Pair a a -> b
$cfoldl :: forall a b a. (b -> a -> b) -> b -> Pair a a -> b
foldl :: forall b a. (b -> a -> b) -> b -> Pair a a -> b
$cfoldl' :: forall a b a. (b -> a -> b) -> b -> Pair a a -> b
foldl' :: forall b a. (b -> a -> b) -> b -> Pair a a -> b
$cfoldr1 :: forall a a. (a -> a -> a) -> Pair a a -> a
foldr1 :: forall a. (a -> a -> a) -> Pair a a -> a
$cfoldl1 :: forall a a. (a -> a -> a) -> Pair a a -> a
foldl1 :: forall a. (a -> a -> a) -> Pair a a -> a
$ctoList :: forall a a. Pair a a -> [a]
toList :: forall a. Pair a a -> [a]
$cnull :: forall a a. Pair a a -> Bool
null :: forall a. Pair a a -> Bool
$clength :: forall a a. Pair a a -> Int
length :: forall a. Pair a a -> Int
$celem :: forall a a. Eq a => a -> Pair a a -> Bool
elem :: forall a. Eq a => a -> Pair a a -> Bool
$cmaximum :: forall a a. Ord a => Pair a a -> a
maximum :: forall a. Ord a => Pair a a -> a
$cminimum :: forall a a. Ord a => Pair a a -> a
minimum :: forall a. Ord a => Pair a a -> a
$csum :: forall a a. Num a => Pair a a -> a
sum :: forall a. Num a => Pair a a -> a
$cproduct :: forall a a. Num a => Pair a a -> a
product :: forall a. Num a => Pair a a -> a
Foldable, Functor (Pair a)
Foldable (Pair a)
(Functor (Pair a), Foldable (Pair a)) =>
(forall (f :: * -> *) a b.
 Applicative f =>
 (a -> f b) -> Pair a a -> f (Pair a b))
-> (forall (f :: * -> *) a.
    Applicative f =>
    Pair a (f a) -> f (Pair a a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> Pair a a -> m (Pair a b))
-> (forall (m :: * -> *) a.
    Monad m =>
    Pair a (m a) -> m (Pair a a))
-> Traversable (Pair a)
forall a. Functor (Pair a)
forall a. Foldable (Pair a)
forall a (m :: * -> *) a. Monad m => Pair a (m a) -> m (Pair a a)
forall a (f :: * -> *) a.
Applicative f =>
Pair a (f a) -> f (Pair a a)
forall a (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Pair a a -> m (Pair a b)
forall a (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Pair a a -> f (Pair a b)
forall (t :: * -> *).
(Functor t, Foldable t) =>
(forall (f :: * -> *) a b.
 Applicative f =>
 (a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a. Monad m => Pair a (m a) -> m (Pair a a)
forall (f :: * -> *) a.
Applicative f =>
Pair a (f a) -> f (Pair a a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Pair a a -> m (Pair a b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Pair a a -> f (Pair a b)
$ctraverse :: forall a (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Pair a a -> f (Pair a b)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Pair a a -> f (Pair a b)
$csequenceA :: forall a (f :: * -> *) a.
Applicative f =>
Pair a (f a) -> f (Pair a a)
sequenceA :: forall (f :: * -> *) a.
Applicative f =>
Pair a (f a) -> f (Pair a a)
$cmapM :: forall a (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Pair a a -> m (Pair a b)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Pair a a -> m (Pair a b)
$csequence :: forall a (m :: * -> *) a. Monad m => Pair a (m a) -> m (Pair a a)
sequence :: forall (m :: * -> *) a. Monad m => Pair a (m a) -> m (Pair a a)
Traversable, Typeable (Pair a b)
Typeable (Pair a b) =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> Pair a b -> c (Pair a b))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (Pair a b))
-> (Pair a b -> Constr)
-> (Pair a b -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (Pair a b)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (Pair a b)))
-> ((forall b. Data b => b -> b) -> Pair a b -> Pair a b)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Pair a b -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Pair a b -> r)
-> (forall u. (forall d. Data d => d -> u) -> Pair a b -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Pair a b -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Pair a b -> m (Pair a b))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Pair a b -> m (Pair a b))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Pair a b -> m (Pair a b))
-> Data (Pair a b)
Pair a b -> Constr
Pair a b -> DataType
(forall b. Data b => b -> b) -> Pair a b -> Pair a b
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Pair a b -> u
forall u. (forall d. Data d => d -> u) -> Pair a b -> [u]
forall a b. (Data a, Data b) => Typeable (Pair a b)
forall a b. (Data a, Data b) => Pair a b -> Constr
forall a b. (Data a, Data b) => Pair a b -> DataType
forall a b.
(Data a, Data b) =>
(forall b. Data b => b -> b) -> Pair a b -> Pair a b
forall a b u.
(Data a, Data b) =>
Int -> (forall d. Data d => d -> u) -> Pair a b -> u
forall a b u.
(Data a, Data b) =>
(forall d. Data d => d -> u) -> Pair a b -> [u]
forall a b r r'.
(Data a, Data b) =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Pair a b -> r
forall a b r r'.
(Data a, Data b) =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Pair a b -> r
forall a b (m :: * -> *).
(Data a, Data b, Monad m) =>
(forall d. Data d => d -> m d) -> Pair a b -> m (Pair a b)
forall a b (m :: * -> *).
(Data a, Data b, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Pair a b -> m (Pair a b)
forall a b (c :: * -> *).
(Data a, Data b) =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Pair a b)
forall a b (c :: * -> *).
(Data a, Data b) =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Pair a b -> c (Pair a b)
forall a b (t :: * -> *) (c :: * -> *).
(Data a, Data b, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Pair a b))
forall a b (t :: * -> * -> *) (c :: * -> *).
(Data a, Data b, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Pair a b))
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Pair a b -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Pair a b -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Pair a b -> m (Pair a b)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Pair a b -> m (Pair a b)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Pair a b)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Pair a b -> c (Pair a b)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Pair a b))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Pair a b))
$cgfoldl :: forall a b (c :: * -> *).
(Data a, Data b) =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Pair a b -> c (Pair a b)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Pair a b -> c (Pair a b)
$cgunfold :: forall a b (c :: * -> *).
(Data a, Data b) =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Pair a b)
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Pair a b)
$ctoConstr :: forall a b. (Data a, Data b) => Pair a b -> Constr
toConstr :: Pair a b -> Constr
$cdataTypeOf :: forall a b. (Data a, Data b) => Pair a b -> DataType
dataTypeOf :: Pair a b -> DataType
$cdataCast1 :: forall a b (t :: * -> *) (c :: * -> *).
(Data a, Data b, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Pair a b))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Pair a b))
$cdataCast2 :: forall a b (t :: * -> * -> *) (c :: * -> *).
(Data a, Data b, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Pair a b))
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Pair a b))
$cgmapT :: forall a b.
(Data a, Data b) =>
(forall b. Data b => b -> b) -> Pair a b -> Pair a b
gmapT :: (forall b. Data b => b -> b) -> Pair a b -> Pair a b
$cgmapQl :: forall a b r r'.
(Data a, Data b) =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Pair a b -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Pair a b -> r
$cgmapQr :: forall a b r r'.
(Data a, Data b) =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Pair a b -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Pair a b -> r
$cgmapQ :: forall a b u.
(Data a, Data b) =>
(forall d. Data d => d -> u) -> Pair a b -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> Pair a b -> [u]
$cgmapQi :: forall a b u.
(Data a, Data b) =>
Int -> (forall d. Data d => d -> u) -> Pair a b -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Pair a b -> u
$cgmapM :: forall a b (m :: * -> *).
(Data a, Data b, Monad m) =>
(forall d. Data d => d -> m d) -> Pair a b -> m (Pair a b)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Pair a b -> m (Pair a b)
$cgmapMp :: forall a b (m :: * -> *).
(Data a, Data b, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Pair a b -> m (Pair a b)
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Pair a b -> m (Pair a b)
$cgmapMo :: forall a b (m :: * -> *).
(Data a, Data b, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Pair a b -> m (Pair a b)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Pair a b -> m (Pair a b)
Data)

-- The definitions below are commented out because they are
-- not used anywhere in the compiler, but are useful to showcase
-- the intent behind this module (i.e. how it may evolve).
--
-- data Either a b = Left !a | Right !b
--   deriving (Eq, Ord, Show, Functor, Foldable, Traversable, Data)
--
-- data List a = Nil | !a `Cons` !(List a)
--   deriving (Eq, Ord, Show, Functor, Foldable, Traversable, Data)