Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Semigroup
The class of semigroups (types with an associative binary operation).
Instances should satisfy the associativity law:
Since: base-4.9.0.0
(<>) :: a -> a -> a infixr 6 #
An associative operation.
Reduce a non-empty list with <>
The default definition should be sufficient, but this can be overridden for efficiency.
stimes :: Integral b => b -> a -> a #
Repeat a value n
times.
Given that this works on a Semigroup
it is allowed to fail if
you request 0 or fewer repetitions, and the default definition
will do so.
By making this a member of the class, idempotent semigroups
and monoids can upgrade this to execute in O(1) by
picking stimes =
or stimesIdempotent
stimes =
respectively.stimesIdempotentMonoid
Instances
gmappend :: (Generic a, GSemigroup (Rep a)) => a -> a -> a #
Newtypes
Use
to get the behavior of
Option
(First
a)First
from Data.Monoid.
Instances
Monad First | Since: base-4.9.0.0 |
Functor First | Since: base-4.9.0.0 |
MonadFix First | Since: base-4.9.0.0 |
Defined in Data.Semigroup | |
Applicative First | Since: base-4.9.0.0 |
Foldable First | Since: base-4.9.0.0 |
Defined in Data.Semigroup fold :: Monoid m => First m -> m # foldMap :: Monoid m => (a -> m) -> First a -> m # foldr :: (a -> b -> b) -> b -> First a -> b # foldr' :: (a -> b -> b) -> b -> First a -> b # foldl :: (b -> a -> b) -> b -> First a -> b # foldl' :: (b -> a -> b) -> b -> First a -> b # foldr1 :: (a -> a -> a) -> First a -> a # foldl1 :: (a -> a -> a) -> First a -> a # elem :: Eq a => a -> First a -> Bool # maximum :: Ord a => First a -> a # minimum :: Ord a => First a -> a # | |
Traversable First | Since: base-4.9.0.0 |
Distributive First | |
ToJSON1 First | |
Defined in Data.Aeson.Types.ToJSON liftToJSON :: (a -> Value) -> ([a] -> Value) -> First a -> Value # liftToJSONList :: (a -> Value) -> ([a] -> Value) -> [First a] -> Value # liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> First a -> Encoding # liftToEncodingList :: (a -> Encoding) -> ([a] -> Encoding) -> [First a] -> Encoding # | |
FromJSON1 First | |
NFData1 First | Since: deepseq-1.4.3.0 |
Defined in Control.DeepSeq | |
Apply First | |
Traversable1 First | |
Pointed First | |
Defined in Data.Pointed | |
Copointed First | |
Defined in Data.Copointed | |
Foldable1 First | |
Alt First | |
Bind First | |
Extend First | |
Bounded a => Bounded (First a) | |
Enum a => Enum (First a) | Since: base-4.9.0.0 |
Eq a => Eq (First a) | |
Data a => Data (First a) | |
Defined in Data.Semigroup gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> First a -> c (First a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (First a) # toConstr :: First a -> Constr # dataTypeOf :: First a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (First a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (First a)) # gmapT :: (forall b. Data b => b -> b) -> First a -> First a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> First a -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> First a -> r # gmapQ :: (forall d. Data d => d -> u) -> First a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> First a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> First a -> m (First a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> First a -> m (First a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> First a -> m (First a) # | |
Ord a => Ord (First a) | |
Read a => Read (First a) | |
Show a => Show (First a) | |
Generic (First a) | |
Semigroup (First a) | Since: base-4.9.0.0 |
Hashable a => Hashable (First a) | |
Defined in Data.Hashable.Class | |
ToJSON a => ToJSON (First a) | |
Defined in Data.Aeson.Types.ToJSON | |
FromJSON a => FromJSON (First a) | |
NFData a => NFData (First a) | Since: deepseq-1.4.2.0 |
Defined in Control.DeepSeq | |
Wrapped (First a) | |
Upper a => Upper (First a) | |
Defined in Data.Semilattice.Upper upperBound :: First a # | |
Lower a => Lower (First a) | |
Defined in Data.Semilattice.Lower lowerBound :: First a # | |
Serialise a => Serialise (First a) | Since: serialise-0.2.0.0 |
Generic1 First | |
t ~ First b => Rewrapped (First a) t | |
Defined in Control.Lens.Wrapped | |
type Rep (First a) | |
Defined in Data.Semigroup | |
type Unwrapped (First a) | |
Defined in Control.Lens.Wrapped | |
type Rep1 First | |
Defined in Data.Semigroup |
Use
to get the behavior of
Option
(Last
a)Last
from Data.Monoid
Instances
Monad Last | Since: base-4.9.0.0 |
Functor Last | Since: base-4.9.0.0 |
MonadFix Last | Since: base-4.9.0.0 |
Defined in Data.Semigroup | |
Applicative Last | Since: base-4.9.0.0 |
Foldable Last | Since: base-4.9.0.0 |
Defined in Data.Semigroup fold :: Monoid m => Last m -> m # foldMap :: Monoid m => (a -> m) -> Last a -> m # foldr :: (a -> b -> b) -> b -> Last a -> b # foldr' :: (a -> b -> b) -> b -> Last a -> b # foldl :: (b -> a -> b) -> b -> Last a -> b # foldl' :: (b -> a -> b) -> b -> Last a -> b # foldr1 :: (a -> a -> a) -> Last a -> a # foldl1 :: (a -> a -> a) -> Last a -> a # elem :: Eq a => a -> Last a -> Bool # maximum :: Ord a => Last a -> a # | |
Traversable Last | Since: base-4.9.0.0 |
Distributive Last | |
ToJSON1 Last | |
Defined in Data.Aeson.Types.ToJSON | |
FromJSON1 Last | |
NFData1 Last | Since: deepseq-1.4.3.0 |
Defined in Control.DeepSeq | |
Apply Last | |
Traversable1 Last | |
Pointed Last | |
Defined in Data.Pointed | |
Copointed Last | |
Defined in Data.Copointed | |
Foldable1 Last | |
Alt Last | |
Bind Last | |
Extend Last | |
Bounded a => Bounded (Last a) | |
Enum a => Enum (Last a) | Since: base-4.9.0.0 |
Defined in Data.Semigroup | |
Eq a => Eq (Last a) | |
Data a => Data (Last a) | |
Defined in Data.Semigroup gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Last a -> c (Last a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Last a) # toConstr :: Last a -> Constr # dataTypeOf :: Last a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Last a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Last a)) # gmapT :: (forall b. Data b => b -> b) -> Last a -> Last a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Last a -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Last a -> r # gmapQ :: (forall d. Data d => d -> u) -> Last a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Last a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Last a -> m (Last a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Last a -> m (Last a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Last a -> m (Last a) # | |
Ord a => Ord (Last a) | |
Read a => Read (Last a) | |
Show a => Show (Last a) | |
Generic (Last a) | |
Semigroup (Last a) | Since: base-4.9.0.0 |
Hashable a => Hashable (Last a) | |
Defined in Data.Hashable.Class | |
ToJSON a => ToJSON (Last a) | |
Defined in Data.Aeson.Types.ToJSON | |
FromJSON a => FromJSON (Last a) | |
NFData a => NFData (Last a) | Since: deepseq-1.4.2.0 |
Defined in Control.DeepSeq | |
Wrapped (Last a) | |
Upper a => Upper (Last a) | |
Defined in Data.Semilattice.Upper upperBound :: Last a # | |
Lower a => Lower (Last a) | |
Defined in Data.Semilattice.Lower lowerBound :: Last a # | |
Serialise a => Serialise (Last a) | Since: serialise-0.2.0.0 |
Generic1 Last | |
t ~ Last b => Rewrapped (Last a) t | |
Defined in Control.Lens.Wrapped | |
type Rep (Last a) | |
Defined in Data.Semigroup | |
type Unwrapped (Last a) | |
Defined in Control.Lens.Wrapped | |
type Rep1 Last | |
Defined in Data.Semigroup |
The dual of a Monoid
, obtained by swapping the arguments of mappend
.
>>>
getDual (mappend (Dual "Hello") (Dual "World"))
"WorldHello"
Instances
Monad Dual | Since: base-4.8.0.0 |
Functor Dual | Since: base-4.8.0.0 |
MonadFix Dual | Since: base-4.8.0.0 |
Defined in Control.Monad.Fix | |
Applicative Dual | Since: base-4.8.0.0 |
Foldable Dual | Since: base-4.8.0.0 |
Defined in Data.Foldable fold :: Monoid m => Dual m -> m # foldMap :: Monoid m => (a -> m) -> Dual a -> m # foldr :: (a -> b -> b) -> b -> Dual a -> b # foldr' :: (a -> b -> b) -> b -> Dual a -> b # foldl :: (b -> a -> b) -> b -> Dual a -> b # foldl' :: (b -> a -> b) -> b -> Dual a -> b # foldr1 :: (a -> a -> a) -> Dual a -> a # foldl1 :: (a -> a -> a) -> Dual a -> a # elem :: Eq a => a -> Dual a -> Bool # maximum :: Ord a => Dual a -> a # | |
Traversable Dual | Since: base-4.8.0.0 |
Distributive Dual | |
Representable Dual | |
ToJSON1 Dual | |
Defined in Data.Aeson.Types.ToJSON | |
FromJSON1 Dual | |
MonadZip Dual | Since: base-4.8.0.0 |
NFData1 Dual | Since: deepseq-1.4.3.0 |
Defined in Control.DeepSeq | |
Apply Dual | |
Traversable1 Dual | |
Pointed Dual | |
Defined in Data.Pointed | |
Copointed Dual | |
Defined in Data.Copointed | |
Foldable1 Dual | |
Bind Dual | |
Extend Dual | |
Bounded a => Bounded (Dual a) | |
Eq a => Eq (Dual a) | |
Data a => Data (Dual a) | Since: base-4.8.0.0 |
Defined in Data.Data gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Dual a -> c (Dual a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Dual a) # toConstr :: Dual a -> Constr # dataTypeOf :: Dual a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Dual a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Dual a)) # gmapT :: (forall b. Data b => b -> b) -> Dual a -> Dual a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Dual a -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Dual a -> r # gmapQ :: (forall d. Data d => d -> u) -> Dual a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Dual a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Dual a -> m (Dual a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Dual a -> m (Dual a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Dual a -> m (Dual a) # | |
Ord a => Ord (Dual a) | |
Read a => Read (Dual a) | |
Show a => Show (Dual a) | |
Generic (Dual a) | |
Semigroup a => Semigroup (Dual a) | Since: base-4.9.0.0 |
Monoid a => Monoid (Dual a) | Since: base-2.1 |
ToJSON a => ToJSON (Dual a) | |
Defined in Data.Aeson.Types.ToJSON | |
FromJSON a => FromJSON (Dual a) | |
NFData a => NFData (Dual a) | Since: deepseq-1.4.0.0 |
Defined in Control.DeepSeq | |
Wrapped (Dual a) | |
AsEmpty a => AsEmpty (Dual a) | |
Defined in Control.Lens.Empty | |
Upper a => Upper (Dual a) | |
Defined in Data.Semilattice.Upper upperBound :: Dual a # | |
Lower a => Lower (Dual a) | |
Defined in Data.Semilattice.Lower lowerBound :: Dual a # | |
Serialise a => Serialise (Dual a) | Since: serialise-0.2.0.0 |
Generic1 Dual | |
t ~ Dual b => Rewrapped (Dual a) t | |
Defined in Control.Lens.Wrapped | |
type Rep Dual | |
Defined in Data.Functor.Rep | |
type Rep (Dual a) | |
Defined in Data.Semigroup.Internal | |
type Unwrapped (Dual a) | |
Defined in Control.Lens.Wrapped | |
type Rep1 Dual | |
Defined in Data.Semigroup.Internal |