Copyright | Conor McBride and Ross Paterson 2005 |
---|---|
License | BSD-style (see the LICENSE file in the distribution) |
Maintainer | libraries@haskell.org |
Stability | stable |
Portability | portable |
Safe Haskell | Trustworthy |
Language | Haskell2010 |
Documentation
newtype Const a (b :: k) Source #
The Const
functor.
Examples
>>>
fmap (++ "World") (Const "Hello")
Const "Hello"
Because we ignore the second type parameter to Const
,
the Applicative instance, which has
essentially turns into (<*>)
:: Monoid m => Const m (a -> b) -> Const m a -> Const m bMonoid m => m -> m -> m
, which is (<>)
>>>
Const [1, 2, 3] <*> Const [4, 5, 6]
Const [1,2,3,4,5,6]
Instances
Generic1 (Const a :: k -> Type) Source # | |||||
Defined in GHC.Internal.Data.Functor.Const
| |||||
Monoid m => Applicative (Const m :: Type -> Type) Source # | @since base-2.0.1 | ||||
Defined in GHC.Internal.Data.Functor.Const | |||||
Functor (Const m :: Type -> Type) Source # | @since base-2.01 | ||||
Foldable (Const m :: Type -> Type) Source # | @since base-4.7.0.0 | ||||
Defined in GHC.Internal.Data.Functor.Const fold :: Monoid m0 => Const m m0 -> m0 Source # foldMap :: Monoid m0 => (a -> m0) -> Const m a -> m0 Source # foldMap' :: Monoid m0 => (a -> m0) -> Const m a -> m0 Source # foldr :: (a -> b -> b) -> b -> Const m a -> b Source # foldr' :: (a -> b -> b) -> b -> Const m a -> b Source # foldl :: (b -> a -> b) -> b -> Const m a -> b Source # foldl' :: (b -> a -> b) -> b -> Const m a -> b Source # foldr1 :: (a -> a -> a) -> Const m a -> a Source # foldl1 :: (a -> a -> a) -> Const m a -> a Source # toList :: Const m a -> [a] Source # null :: Const m a -> Bool Source # length :: Const m a -> Int Source # elem :: Eq a => a -> Const m a -> Bool Source # maximum :: Ord a => Const m a -> a Source # minimum :: Ord a => Const m a -> a Source # | |||||
Traversable (Const m :: Type -> Type) Source # | @since base-4.7.0.0 | ||||
Defined in GHC.Internal.Data.Traversable | |||||
Monoid a => Monoid (Const a b) Source # | @since base-4.9.0.0 | ||||
Semigroup a => Semigroup (Const a b) Source # | @since base-4.9.0.0 | ||||
Bits a => Bits (Const a b) Source # | @since base-4.9.0.0 | ||||
Defined in GHC.Internal.Data.Functor.Const (.&.) :: Const a b -> Const a b -> Const a b Source # (.|.) :: Const a b -> Const a b -> Const a b Source # xor :: Const a b -> Const a b -> Const a b Source # complement :: Const a b -> Const a b Source # shift :: Const a b -> Int -> Const a b Source # rotate :: Const a b -> Int -> Const a b Source # zeroBits :: Const a b Source # bit :: Int -> Const a b Source # setBit :: Const a b -> Int -> Const a b Source # clearBit :: Const a b -> Int -> Const a b Source # complementBit :: Const a b -> Int -> Const a b Source # testBit :: Const a b -> Int -> Bool Source # bitSizeMaybe :: Const a b -> Maybe Int Source # bitSize :: Const a b -> Int Source # isSigned :: Const a b -> Bool Source # shiftL :: Const a b -> Int -> Const a b Source # unsafeShiftL :: Const a b -> Int -> Const a b Source # shiftR :: Const a b -> Int -> Const a b Source # unsafeShiftR :: Const a b -> Int -> Const a b Source # rotateL :: Const a b -> Int -> Const a b Source # | |||||
FiniteBits a => FiniteBits (Const a b) Source # | @since base-4.9.0.0 | ||||
Defined in GHC.Internal.Data.Functor.Const finiteBitSize :: Const a b -> Int Source # countLeadingZeros :: Const a b -> Int Source # countTrailingZeros :: Const a b -> Int Source # | |||||
(Typeable k, Data a, Typeable b) => Data (Const a b) Source # | @since base-4.10.0.0 | ||||
Defined in GHC.Internal.Data.Data gfoldl :: (forall d b0. Data d => c (d -> b0) -> d -> c b0) -> (forall g. g -> c g) -> Const a b -> c (Const a b) Source # gunfold :: (forall b0 r. Data b0 => c (b0 -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Const a b) Source # toConstr :: Const a b -> Constr Source # dataTypeOf :: Const a b -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Const a b)) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Const a b)) Source # gmapT :: (forall b0. Data b0 => b0 -> b0) -> Const a b -> Const a b Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Const a b -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Const a b -> r Source # gmapQ :: (forall d. Data d => d -> u) -> Const a b -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> Const a b -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Const a b -> m (Const a b) Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Const a b -> m (Const a b) Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Const a b -> m (Const a b) Source # | |||||
IsString a => IsString (Const a b) Source # | @since base-4.9.0.0 | ||||
Defined in GHC.Internal.Data.String fromString :: String -> Const a b Source # | |||||
Bounded a => Bounded (Const a b) Source # | @since base-4.9.0.0 | ||||
Enum a => Enum (Const a b) Source # | @since base-4.9.0.0 | ||||
Defined in GHC.Internal.Data.Functor.Const succ :: Const a b -> Const a b Source # pred :: Const a b -> Const a b Source # toEnum :: Int -> Const a b Source # fromEnum :: Const a b -> Int Source # enumFrom :: Const a b -> [Const a b] Source # enumFromThen :: Const a b -> Const a b -> [Const a b] Source # enumFromTo :: Const a b -> Const a b -> [Const a b] Source # enumFromThenTo :: Const a b -> Const a b -> Const a b -> [Const a b] Source # | |||||
Floating a => Floating (Const a b) Source # | @since base-4.9.0.0 | ||||
Defined in GHC.Internal.Data.Functor.Const exp :: Const a b -> Const a b Source # log :: Const a b -> Const a b Source # sqrt :: Const a b -> Const a b Source # (**) :: Const a b -> Const a b -> Const a b Source # logBase :: Const a b -> Const a b -> Const a b Source # sin :: Const a b -> Const a b Source # cos :: Const a b -> Const a b Source # tan :: Const a b -> Const a b Source # asin :: Const a b -> Const a b Source # acos :: Const a b -> Const a b Source # atan :: Const a b -> Const a b Source # sinh :: Const a b -> Const a b Source # cosh :: Const a b -> Const a b Source # tanh :: Const a b -> Const a b Source # asinh :: Const a b -> Const a b Source # acosh :: Const a b -> Const a b Source # atanh :: Const a b -> Const a b Source # log1p :: Const a b -> Const a b Source # expm1 :: Const a b -> Const a b Source # | |||||
RealFloat a => RealFloat (Const a b) Source # | @since base-4.9.0.0 | ||||
Defined in GHC.Internal.Data.Functor.Const floatRadix :: Const a b -> Integer Source # floatDigits :: Const a b -> Int Source # floatRange :: Const a b -> (Int, Int) Source # decodeFloat :: Const a b -> (Integer, Int) Source # encodeFloat :: Integer -> Int -> Const a b Source # exponent :: Const a b -> Int Source # significand :: Const a b -> Const a b Source # scaleFloat :: Int -> Const a b -> Const a b Source # isNaN :: Const a b -> Bool Source # isInfinite :: Const a b -> Bool Source # isDenormalized :: Const a b -> Bool Source # isNegativeZero :: Const a b -> Bool Source # | |||||
Storable a => Storable (Const a b) Source # | @since base-4.9.0.0 | ||||
Defined in GHC.Internal.Data.Functor.Const sizeOf :: Const a b -> Int Source # alignment :: Const a b -> Int Source # peekElemOff :: Ptr (Const a b) -> Int -> IO (Const a b) Source # pokeElemOff :: Ptr (Const a b) -> Int -> Const a b -> IO () Source # peekByteOff :: Ptr b0 -> Int -> IO (Const a b) Source # pokeByteOff :: Ptr b0 -> Int -> Const a b -> IO () Source # | |||||
Generic (Const a b) Source # | |||||
Defined in GHC.Internal.Data.Functor.Const
| |||||
Ix a => Ix (Const a b) Source # | @since base-4.9.0.0 | ||||
Defined in GHC.Internal.Data.Functor.Const | |||||
Num a => Num (Const a b) Source # | @since base-4.9.0.0 | ||||
Defined in GHC.Internal.Data.Functor.Const (+) :: Const a b -> Const a b -> Const a b Source # (-) :: Const a b -> Const a b -> Const a b Source # (*) :: Const a b -> Const a b -> Const a b Source # negate :: Const a b -> Const a b Source # abs :: Const a b -> Const a b Source # signum :: Const a b -> Const a b Source # fromInteger :: Integer -> Const a b Source # | |||||
Read a => Read (Const a b) Source # | This instance would be equivalent to the derived instances of the
@since base-4.8.0.0 | ||||
Fractional a => Fractional (Const a b) Source # | @since base-4.9.0.0 | ||||
Integral a => Integral (Const a b) Source # | @since base-4.9.0.0 | ||||
Defined in GHC.Internal.Data.Functor.Const quot :: Const a b -> Const a b -> Const a b Source # rem :: Const a b -> Const a b -> Const a b Source # div :: Const a b -> Const a b -> Const a b Source # mod :: Const a b -> Const a b -> Const a b Source # quotRem :: Const a b -> Const a b -> (Const a b, Const a b) Source # divMod :: Const a b -> Const a b -> (Const a b, Const a b) Source # | |||||
Real a => Real (Const a b) Source # | @since base-4.9.0.0 | ||||
Defined in GHC.Internal.Data.Functor.Const toRational :: Const a b -> Rational Source # | |||||
RealFrac a => RealFrac (Const a b) Source # | @since base-4.9.0.0 | ||||
Defined in GHC.Internal.Data.Functor.Const | |||||
Show a => Show (Const a b) Source # | This instance would be equivalent to the derived instances of the
@since base-4.8.0.0 | ||||
Eq a => Eq (Const a b) Source # | @since base-4.9.0.0 | ||||
Ord a => Ord (Const a b) Source # | @since base-4.9.0.0 | ||||
Defined in GHC.Internal.Data.Functor.Const | |||||
type Rep1 (Const a :: k -> Type) Source # | @since base-4.9.0.0 | ||||
Defined in GHC.Internal.Data.Functor.Const | |||||
type Rep (Const a b) Source # | @since base-4.9.0.0 | ||||
Defined in GHC.Internal.Data.Functor.Const |