Agda-2.6.2.2: A dependently typed functional programming language and proof assistant

Safe Haskell | Safe-Inferred
Language | Haskell2010

Agda.Utils.Maybe.Strict

Contents

- Orphan instances

Description

A strict version of the `Maybe` type.

Import qualified, as in `import qualified Agda.Utils.Maybe.Strict as Strict`

Copyright : (c) 2006-2007 Roman Leshchinskiy (c) 2013 Simon Meier License : BSD-style (see the file LICENSE)

Copyright : (c) 2014 Andreas Abel

Synopsis

- fromJust :: Maybe a -> a
- fromMaybe :: a -> Maybe a -> a
- isJust :: Maybe a -> Bool
- isNothing :: Maybe a -> Bool
- maybe :: b -> (a -> b) -> Maybe a -> b
- data Maybe a
  - = Nothing
  - | Just !a
- toStrict :: Maybe a -> Maybe a
- toLazy :: Maybe a -> Maybe a
- listToMaybe :: [a] -> Maybe a
- maybeToList :: Maybe a -> [a]
- catMaybes :: [Maybe a] -> [a]
- mapMaybe :: (a -> Maybe b) -> [a] -> [b]
- unionMaybeWith :: (a -> a -> a) -> Maybe a -> Maybe a -> Maybe a
- unzipMaybe :: Maybe (a, b) -> (Maybe a, Maybe b)
- filterMaybe :: (a -> Bool) -> a -> Maybe a
- forMaybe :: [a] -> (a -> Maybe b) -> [b]
- caseMaybe :: Maybe a -> b -> (a -> b) -> b
- maybeM :: Monad m => m b -> (a -> m b) -> m (Maybe a) -> m b
- fromMaybeM :: Monad m => m a -> m (Maybe a) -> m a
- caseMaybeM :: Monad m => m (Maybe a) -> m b -> (a -> m b) -> m b
- ifJustM :: Monad m => m (Maybe a) -> (a -> m b) -> m b -> m b
- whenJust :: Monad m => Maybe a -> (a -> m ()) -> m ()
- whenJustM :: Monad m => m (Maybe a) -> (a -> m ()) -> m ()

# Documentation

fromJust :: Maybe a -> a #

fromMaybe :: a -> Maybe a -> a #

isJust :: Maybe a -> Bool #

isNothing :: Maybe a -> Bool #

maybe :: b -> (a -> b) -> Maybe a -> b #

data Maybe a #

Constructors

Nothing |
Just !a |

#### Instances

Instances details

EncodeTCM Range Source # |
Instance details Defined in Agda.Interaction.JSONTop Methods encodeTCM :: Range -> TCM Value Source #
HasRange Interval Source # |
Instance details Defined in Agda.Syntax.Position Methods getRange :: Interval -> Range Source #
HasRange Range Source # |
Instance details Defined in Agda.Syntax.Position Methods getRange :: Range -> Range Source #
KillRange Range Source # |
Instance details Defined in Agda.Syntax.Position Methods killRange :: KillRangeT Range Source #
SetRange Range Source # |
Instance details Defined in Agda.Syntax.Position Methods setRange :: Range -> Range -> Range Source #
FreshName Range Source # |
Instance details Defined in Agda.TypeChecking.Monad.Base Methods freshName_ :: MonadFresh NameId m => Range -> m Name Source #
PrettyTCM Range Source # |
Instance details Defined in Agda.TypeChecking.Pretty Methods prettyTCM :: MonadPretty m => Range -> m Doc Source #
EmbPrj Range Source # | Ranges are always deserialised as `noRange`.
Instance details Defined in Agda.TypeChecking.Serialise.Instances.Common Methods icode :: Range -> S Int32 Source # icod_ :: Range -> S Int32 Source # value :: Int32 -> R Range Source #
Subst Range Source # |
Instance details Defined in Agda.TypeChecking.Substitute Associated Types type SubstArg Range Source # Methods applySubst :: Substitution' (SubstArg Range) -> Range -> Range Source #
FromJSON1 Maybe |
Instance details Defined in Data.Aeson.Types.FromJSON Methods liftParseJSON :: (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser (Maybe a) # liftParseJSONList :: (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser [Maybe a] #
ToJSON Range Source # |
Instance details Defined in Agda.Interaction.JSONTop Methods toJSON :: Range -> Value # toEncoding :: Range -> Encoding # toJSONList :: [Range] -> Value # toEncodingList :: [Range] -> Encoding #
ToJSON1 Maybe |
Instance details Defined in Data.Aeson.Types.ToJSON Methods liftToJSON :: (a -> Value) -> ([a] -> Value) -> Maybe a -> Value # liftToJSONList :: (a -> Value) -> ([a] -> Value) -> [Maybe a] -> Value # liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> Maybe a -> Encoding # liftToEncodingList :: (a -> Encoding) -> ([a] -> Encoding) -> [Maybe a] -> Encoding #
Foldable Maybe |

Instance details

Defined in Data.Strict.Maybe

Methods

fold :: Monoid m => Maybe m -> m Source #

foldMap :: Monoid m => (a -> m) -> Maybe a -> m Source #

foldMap' :: Monoid m => (a -> m) -> Maybe a -> m Source #

foldr :: (a -> b -> b) -> b -> Maybe a -> b Source #

foldr' :: (a -> b -> b) -> b -> Maybe a -> b Source #

foldl :: (b -> a -> b) -> b -> Maybe a -> b Source #

foldl' :: (b -> a -> b) -> b -> Maybe a -> b Source #

foldr1 :: (a -> a -> a) -> Maybe a -> a Source #

foldl1 :: (a -> a -> a) -> Maybe a -> a Source #

toList :: Maybe a -> [a] Source #

null :: Maybe a -> Bool Source #

length :: Maybe a -> Int Source #

elem :: Eq a => a -> Maybe a -> Bool Source #

maximum :: Ord a => Maybe a -> a Source #

minimum :: Ord a => Maybe a -> a Source #

sum :: Num a => Maybe a -> a Source #

product :: Num a => Maybe a -> a Source #

Eq1 Maybe |
Instance details Defined in Data.Strict.Maybe Methods liftEq :: (a -> b -> Bool) -> Maybe a -> Maybe b -> Bool Source #
Ord1 Maybe |
Instance details Defined in Data.Strict.Maybe Methods liftCompare :: (a -> b -> Ordering) -> Maybe a -> Maybe b -> Ordering Source #
Read1 Maybe |
Instance details Defined in Data.Strict.Maybe Methods liftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (Maybe a) Source # liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [Maybe a] Source # liftReadPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec (Maybe a) Source # liftReadListPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec [Maybe a] Source #
Show1 Maybe |
Instance details Defined in Data.Strict.Maybe Methods liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Maybe a -> ShowS Source # liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Maybe a] -> ShowS Source #
Traversable Maybe |
Instance details Defined in Data.Strict.Maybe Methods traverse :: Applicative f => (a -> f b) -> Maybe a -> f (Maybe b) Source # sequenceA :: Applicative f => Maybe (f a) -> f (Maybe a) Source # mapM :: Monad m => (a -> m b) -> Maybe a -> m (Maybe b) Source # sequence :: Monad m => Maybe (m a) -> m (Maybe a) Source #
Applicative Maybe Source # | Note that strict Maybe is an `Applicative` only modulo strictness. The laws only hold in the strict semantics. Eg. `pure f * pure _|_ = _|_`, but according to the laws for `Applicative` it should be `pure (f _|_)`. We ignore this issue here, it applies also to `Foldable` and `Traversable`.
Instance details Defined in Agda.Utils.Maybe.Strict Methods pure :: a -> Maybe a Source # (<*>) :: Maybe (a -> b) -> Maybe a -> Maybe b Source # liftA2 :: (a -> b -> c) -> Maybe a -> Maybe b -> Maybe c Source # (*>) :: Maybe a -> Maybe b -> Maybe b Source # (<*) :: Maybe a -> Maybe b -> Maybe a Source #
Functor Maybe |
Instance details Defined in Data.Strict.Maybe Methods fmap :: (a -> b) -> Maybe a -> Maybe b Source # (<$) :: a -> Maybe b -> Maybe a Source #
NFData Interval Source # |
Instance details Defined in Agda.Syntax.Position Methods rnf :: Interval -> () Source #
NFData Position Source # |
Instance details Defined in Agda.Syntax.Position Methods rnf :: Position -> () Source #
NFData1 Maybe |
Instance details Defined in Data.Strict.Maybe Methods liftRnf :: (a -> ()) -> Maybe a -> () Source #
Hashable1 Maybe |
Instance details Defined in Data.Strict.Maybe Methods liftHashWithSalt :: (Int -> a -> Int) -> Int -> Maybe a -> Int Source #
LensClosure Range MetaInfo Source # |
Instance details Defined in Agda.TypeChecking.Monad.Base Methods lensClosure :: Lens' (Closure Range) MetaInfo Source #
LensClosure Range MetaVariable Source # |
Instance details Defined in Agda.TypeChecking.Monad.Base Methods lensClosure :: Lens' (Closure Range) MetaVariable Source #
KillRange a => KillRange (Maybe a) Source # |
Instance details Defined in Agda.Syntax.Position Methods killRange :: KillRangeT (Maybe a) Source #
Instantiate t => Instantiate (Maybe t) Source # |
Instance details Defined in Agda.TypeChecking.Reduce Methods instantiate' :: Maybe t -> ReduceM (Maybe t) Source #
InstantiateFull t => InstantiateFull (Maybe t) Source # |
Instance details Defined in Agda.TypeChecking.Reduce Methods instantiateFull' :: Maybe t -> ReduceM (Maybe t) Source #
Normalise t => Normalise (Maybe t) Source # |
Instance details Defined in Agda.TypeChecking.Reduce Methods normalise' :: Maybe t -> ReduceM (Maybe t) Source #
Simplify t => Simplify (Maybe t) Source # |
Instance details Defined in Agda.TypeChecking.Reduce Methods simplify' :: Maybe t -> ReduceM (Maybe t) Source #
EmbPrj a => EmbPrj (Maybe a) Source # |
Instance details Defined in Agda.TypeChecking.Serialise.Instances.Common Methods icode :: Maybe a -> S Int32 Source # icod_ :: Maybe a -> S Int32 Source # value :: Int32 -> R (Maybe a) Source #
Apply t => Apply (Maybe t) Source # |
Instance details Defined in Agda.TypeChecking.Substitute Methods apply :: Maybe t -> Args -> Maybe t Source # applyE :: Maybe t -> Elims -> Maybe t Source #
Null (Maybe a) Source # |
Instance details Defined in Agda.Utils.Maybe.Strict Methods empty :: Maybe a Source # null :: Maybe a -> Bool Source #
Pretty a => Pretty (Interval' (Maybe a)) Source # |
Instance details Defined in Agda.Syntax.Position Methods pretty :: Interval' (Maybe a) -> Doc Source # prettyPrec :: Int -> Interval' (Maybe a) -> Doc Source # prettyList :: [Interval' (Maybe a)] -> Doc Source #
Pretty a => Pretty (Position' (Maybe a)) Source # |
Instance details Defined in Agda.Syntax.Position Methods pretty :: Position' (Maybe a) -> Doc Source # prettyPrec :: Int -> Position' (Maybe a) -> Doc Source # prettyList :: [Position' (Maybe a)] -> Doc Source #
Pretty a => Pretty (Range' (Maybe a)) Source # |
Instance details Defined in Agda.Syntax.Position Methods pretty :: Range' (Maybe a) -> Doc Source # prettyPrec :: Int -> Range' (Maybe a) -> Doc Source # prettyList :: [Range' (Maybe a)] -> Doc Source #
FromJSON a => FromJSON (Maybe a) |
Instance details Defined in Data.Aeson.Types.FromJSON Methods parseJSON :: Value -> Parser (Maybe a) # parseJSONList :: Value -> Parser [Maybe a] #
ToJSON a => ToJSON (Maybe a) |
Instance details Defined in Data.Aeson.Types.ToJSON Methods toJSON :: Maybe a -> Value # toEncoding :: Maybe a -> Encoding # toJSONList :: [Maybe a] -> Value # toEncodingList :: [Maybe a] -> Encoding #
Data a => Data (Maybe a) |

Instance details

Defined in Data.Strict.Maybe

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Maybe a -> c (Maybe a) Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Maybe a) Source #

toConstr :: Maybe a -> Constr Source #

dataTypeOf :: Maybe a -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe0 (c (Maybe a)) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe0 (c (Maybe a)) Source #

gmapT :: (forall b. Data b => b -> b) -> Maybe a -> Maybe a Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Maybe a -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Maybe a -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> Maybe a -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Maybe a -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Maybe a -> m (Maybe a) Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Maybe a -> m (Maybe a) Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Maybe a -> m (Maybe a) Source #

Semigroup a => Monoid (Maybe a) |
Instance details Defined in Data.Strict.Maybe Methods mempty :: Maybe a Source # mappend :: Maybe a -> Maybe a -> Maybe a Source # mconcat :: [Maybe a] -> Maybe a Source #
Semigroup a => Semigroup (Maybe a) |
Instance details Defined in Data.Strict.Maybe Methods (<>) :: Maybe a -> Maybe a -> Maybe a Source # sconcat :: NonEmpty (Maybe a) -> Maybe a Source # stimes :: Integral b => b -> Maybe a -> Maybe a Source #
Generic (Maybe a) |
Instance details Defined in Data.Strict.Maybe Associated Types type Rep (Maybe a) :: Type -> Type Source # Methods from :: Maybe a -> Rep (Maybe a) x Source # to :: Rep (Maybe a) x -> Maybe a Source #
Read a => Read (Maybe a) |
Instance details Defined in Data.Strict.Maybe Methods readsPrec :: Int -> ReadS (Maybe a) Source # readList :: ReadS [Maybe a] Source # readPrec :: ReadPrec (Maybe a) Source # readListPrec :: ReadPrec [Maybe a] Source #
Show a => Show (Maybe a) |
Instance details Defined in Data.Strict.Maybe Methods showsPrec :: Int -> Maybe a -> ShowS Source # show :: Maybe a -> String Source # showList :: [Maybe a] -> ShowS Source #
Binary a => Binary (Maybe a) |
Instance details Defined in Data.Strict.Maybe Methods put :: Maybe a -> Put Source # get :: Get (Maybe a) Source # putList :: [Maybe a] -> Put Source #
NFData a => NFData (Maybe a) |
Instance details Defined in Data.Strict.Maybe Methods rnf :: Maybe a -> () Source #
Eq a => Eq (Maybe a) |
Instance details Defined in Data.Strict.Maybe Methods (==) :: Maybe a -> Maybe a -> Bool Source # (/=) :: Maybe a -> Maybe a -> Bool Source #
Ord a => Ord (Maybe a) |
Instance details Defined in Data.Strict.Maybe Methods compare :: Maybe a -> Maybe a -> Ordering Source # (<) :: Maybe a -> Maybe a -> Bool Source # (<=) :: Maybe a -> Maybe a -> Bool Source # (>) :: Maybe a -> Maybe a -> Bool Source # (>=) :: Maybe a -> Maybe a -> Bool Source # max :: Maybe a -> Maybe a -> Maybe a Source # min :: Maybe a -> Maybe a -> Maybe a Source #
Hashable a => Hashable (Maybe a) |
Instance details Defined in Data.Strict.Maybe Methods hashWithSalt :: Int -> Maybe a -> Int Source # hash :: Maybe a -> Int Source #
Generic1 Maybe |
Instance details Defined in Data.Strict.Maybe Associated Types type Rep1 Maybe :: k -> Type Source # Methods from1 :: forall (a :: k). Maybe a -> Rep1 Maybe a Source # to1 :: forall (a :: k). Rep1 Maybe a -> Maybe a Source #
FreshName (Range, String) Source # |
Instance details Defined in Agda.TypeChecking.Monad.Base Methods freshName_ :: MonadFresh NameId m => (Range, String) -> m Name Source #
type SubstArg Range Source # |
Instance details Defined in Agda.TypeChecking.Substitute type SubstArg Range = Term
type Rep (Maybe a) |
Instance details Defined in Data.Strict.Maybe type Rep (Maybe a) = D1 ('MetaData "Maybe" "Data.Strict.Maybe" "strict-0.4.0.1-Ea4amCg8WDe8GyT6LOvusk" 'False) (C1 ('MetaCons "Nothing" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Just" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 a)))
type Rep1 Maybe |
Instance details Defined in Data.Strict.Maybe type Rep1 Maybe = D1 ('MetaData "Maybe" "Data.Strict.Maybe" "strict-0.4.0.1-Ea4amCg8WDe8GyT6LOvusk" 'False) (C1 ('MetaCons "Nothing" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Just" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) Par1))

toStrict :: Maybe a -> Maybe a Source #

toLazy :: Maybe a -> Maybe a Source #

listToMaybe :: [a] -> Maybe a Source #

Analogous to `listToMaybe` in Data.Maybe.

maybeToList :: Maybe a -> [a] Source #

Analogous to `maybeToList` in Data.Maybe.

catMaybes :: [Maybe a] -> [a] Source #

Analogous to `catMaybes` in Data.Maybe.

mapMaybe :: (a -> Maybe b) -> [a] -> [b] Source #

Analogous to `mapMaybe` in Data.Maybe.

unionMaybeWith :: (a -> a -> a) -> Maybe a -> Maybe a -> Maybe a Source #

`unionWith` for collections of size <= 1.

unzipMaybe :: Maybe (a, b) -> (Maybe a, Maybe b) Source #

Unzipping a list of length <= 1.

filterMaybe :: (a -> Bool) -> a -> Maybe a Source #

Filtering a singleton list.

    filterMaybe p a = listToMaybe (filter p [a])

forMaybe :: [a] -> (a -> Maybe b) -> [b] Source #

Version of `mapMaybe` with different argument ordering.

caseMaybe :: Maybe a -> b -> (a -> b) -> b Source #

Version of `maybe` with different argument ordering. Often, we want to case on a `Maybe`, do something interesting in the `Just` case, but only a default action in the `Nothing` case. Then, the argument ordering of `caseMaybe` is preferable.

    caseMaybe m err f = flip (maybe err) m f

maybeM :: Monad m => m b -> (a -> m b) -> m (Maybe a) -> m b Source #

Monadic version of `maybe`.

fromMaybeM :: Monad m => m a -> m (Maybe a) -> m a Source #

Monadic version of `fromMaybe`.

caseMaybeM :: Monad m => m (Maybe a) -> m b -> (a -> m b) -> m b Source #

Monadic version of `caseMaybe`. That is, `maybeM` with a different argument ordering.

ifJustM :: Monad m => m (Maybe a) -> (a -> m b) -> m b -> m b Source #

`caseMaybeM` with flipped branches.

whenJust :: Monad m => Maybe a -> (a -> m ()) -> m () Source #

A more telling name for `forM` for the `Maybe` collection type. Or: `caseMaybe` without the `Nothing` case.

whenJustM :: Monad m => m (Maybe a) -> (a -> m ()) -> m () Source #

`caseMaybeM` without the `Nothing` case.

# Orphan instances

Applicative Maybe Source # | Note that strict Maybe is an `Applicative` only modulo strictness. The laws only hold in the strict semantics. Eg. `pure f * pure _|_ = _|_`, but according to the laws for `Applicative` it should be `pure (f _|_)`. We ignore this issue here, it applies also to `Foldable` and `Traversable`.
Instance details Methods pure :: a -> Maybe a Source # (<*>) :: Maybe (a -> b) -> Maybe a -> Maybe b Source # liftA2 :: (a -> b -> c) -> Maybe a -> Maybe b -> Maybe c Source # (*>) :: Maybe a -> Maybe b -> Maybe b Source # (<*) :: Maybe a -> Maybe b -> Maybe a Source #
Null (Maybe a) Source # |
Instance details Methods empty :: Maybe a Source # null :: Maybe a -> Bool Source #