Movatterモバイル変換


[0]ホーム

URL:


{-# LANGUAGE DeriveGeneric #-}{-# LANGUAGE GeneralizedNewtypeDeriving #-}{-# LANGUAGE NoImplicitPrelude #-}{-# LANGUAGE PolyKinds #-}{-# LANGUAGE ScopedTypeVariables #-}{-# LANGUAGE Trustworthy #-}------------------------------------------------------------------------------- |-- Module      :  Data.Functor.Const-- Copyright   :  Conor McBride and Ross Paterson 2005-- License     :  BSD-style (see the LICENSE file in the distribution)---- Maintainer  :  libraries@haskell.org-- Stability   :  experimental-- Portability :  portable-- The 'Const' functor.---- @since 4.9.0.0moduleData.Functor.Const(Const(..))whereimportData.Bits(Bits,FiniteBits)importData.Foldable(Foldable(foldMap))importForeign.Storable(Storable)importGHC.Ix(Ix)importGHC.BaseimportGHC.Enum(Bounded,Enum)importGHC.Float(Floating,RealFloat)importGHC.Generics(Generic,Generic1)importGHC.Num(Num)importGHC.Real(Fractional,Integral,Real,RealFrac)importGHC.Read(Read(readsPrec),readParen,lex)importGHC.Show(Show(showsPrec),showParen,showString)-- | The 'Const' functor.newtypeConstab=Const{Const a b -> agetConst::a}deriving(Bits-- ^ @since 4.9.0.0,Bounded-- ^ @since 4.9.0.0,Enum-- ^ @since 4.9.0.0,Eq-- ^ @since 4.9.0.0,FiniteBits-- ^ @since 4.9.0.0,Floating-- ^ @since 4.9.0.0,Fractional-- ^ @since 4.9.0.0,Generic-- ^ @since 4.9.0.0,Generic1-- ^ @since 4.9.0.0,Integral-- ^ @since 4.9.0.0,Ix-- ^ @since 4.9.0.0,Semigroup-- ^ @since 4.9.0.0,Monoid-- ^ @since 4.9.0.0,Num-- ^ @since 4.9.0.0,Ord-- ^ @since 4.9.0.0,Real-- ^ @since 4.9.0.0,RealFrac-- ^ @since 4.9.0.0,RealFloat-- ^ @since 4.9.0.0,Storable-- ^ @since 4.9.0.0)-- | This instance would be equivalent to the derived instances of the-- 'Const' newtype if the 'getConst' field were removed---- @since 4.8.0.0instanceReada=>Read(Constab)wherereadsPrec :: Int -> ReadS (Const a b)readsPrecIntd=Bool -> ReadS (Const a b) -> ReadS (Const a b)forall a. Bool -> ReadS a -> ReadS areadParen(IntdInt -> Int -> Boolforall a. Ord a => a -> a -> Bool>Int10)(ReadS (Const a b) -> ReadS (Const a b))-> ReadS (Const a b) -> ReadS (Const a b)forall a b. (a -> b) -> a -> b$\Stringr->[(a -> Const a bforall k a (b :: k). a -> Const a bConstax,Stringt)|(String"Const",Strings)<-ReadS StringlexStringr,(ax,Stringt)<-Int -> ReadS aforall a. Read a => Int -> ReadS areadsPrecInt11Strings]-- | This instance would be equivalent to the derived instances of the-- 'Const' newtype if the 'getConst' field were removed---- @since 4.8.0.0instanceShowa=>Show(Constab)whereshowsPrec :: Int -> Const a b -> ShowSshowsPrecIntd(Constax)=Bool -> ShowS -> ShowSshowParen(IntdInt -> Int -> Boolforall a. Ord a => a -> a -> Bool>Int10)(ShowS -> ShowS) -> ShowS -> ShowSforall a b. (a -> b) -> a -> b$String -> ShowSshowStringString"Const "ShowS -> ShowS -> ShowSforall b c a. (b -> c) -> (a -> b) -> a -> c.Int -> a -> ShowSforall a. Show a => Int -> a -> ShowSshowsPrecInt11ax-- | @since 4.7.0.0instanceFoldable(Constm)wherefoldMap :: (a -> m) -> Const m a -> mfoldMapa -> m_Const m a_=mforall a. Monoid a => amempty-- | @since 2.01instanceFunctor(Constm)wherefmap :: (a -> b) -> Const m a -> Const m bfmapa -> b_(Constmv)=m -> Const m bforall k a (b :: k). a -> Const a bConstmv-- | @since 2.0.1instanceMonoidm=>Applicative(Constm)wherepure :: a -> Const m apurea_=m -> Const m aforall k a (b :: k). a -> Const a bConstmforall a. Monoid a => amemptyliftA2 :: (a -> b -> c) -> Const m a -> Const m b -> Const m cliftA2a -> b -> c_(Constmx)(Constmy)=m -> Const m cforall k a (b :: k). a -> Const a bConst(mxm -> m -> mforall a. Monoid a => a -> a -> a`mappend`my)<*> :: Const m (a -> b) -> Const m a -> Const m b(<*>)=(m -> m -> m) -> Const m (a -> b) -> Const m a -> Const m bcoerce(m -> m -> mforall a. Monoid a => a -> a -> amappend::m->m->m)-- This is pretty much the same as-- Const f <*> Const v = Const (f `mappend` v)-- but guarantees that mappend for Const a b will have the same arity-- as the one for a; it won't create a closure to raise the arity-- to 2.

[8]ページ先頭

©2009-2025 Movatter.jp