{-# OPTIONS_GHC -fno-specialise #-}
{-# OPTIONS_GHC -fno-ignore-interface-pragmas #-}
{-# OPTIONS_GHC -fno-omit-interface-pragmas #-}
module PlutusTx.Monoid (Monoid (..), mappend, mconcat, Group (..), gsub) where
import Data.Monoid (First (..))
import Data.Semigroup (Dual (..), Endo (..))
import PlutusTx.Base (id)
import PlutusTx.Builtins qualified as Builtins
import PlutusTx.List
import PlutusTx.Maybe
import PlutusTx.Semigroup
class Semigroup a => Monoid a where
mempty :: a
{-# INLINABLE mappend #-}
mappend :: Monoid a => a -> a -> a
mappend :: forall a. Monoid a => a -> a -> a
mappend = forall a. Semigroup a => a -> a -> a
(<>)
{-# INLINABLE mconcat #-}
mconcat :: Monoid a => [a] -> a
mconcat :: forall a. Monoid a => [a] -> a
mconcat = forall a b. (a -> b -> b) -> b -> [a] -> b
foldr forall a. Monoid a => a -> a -> a
mappend forall a. Monoid a => a
mempty
instance Monoid Builtins.BuiltinByteString where
{-# INLINABLE mempty #-}
mempty :: BuiltinByteString
mempty = BuiltinByteString
Builtins.emptyByteString
instance Monoid Builtins.BuiltinString where
{-# INLINABLE mempty #-}
mempty :: BuiltinString
mempty = BuiltinString
Builtins.emptyString
instance Monoid [a] where
{-# INLINABLE mempty #-}
mempty :: [a]
mempty = []
instance Semigroup a => Monoid (Maybe a) where
{-# INLINABLE mempty #-}
mempty :: Maybe a
mempty = forall a. Maybe a
Nothing
instance Monoid () where
{-# INLINABLE mempty #-}
mempty :: ()
mempty = ()
instance (Monoid a, Monoid b) => Monoid (a, b) where
{-# INLINABLE mempty #-}
mempty :: (a, b)
mempty = (forall a. Monoid a => a
mempty, forall a. Monoid a => a
mempty)
instance Monoid a => Monoid (Dual a) where
{-# INLINABLE mempty #-}
mempty :: Dual a
mempty = forall a. a -> Dual a
Dual forall a. Monoid a => a
mempty
instance Monoid (Endo a) where
{-# INLINABLE mempty #-}
mempty :: Endo a
mempty = forall a. (a -> a) -> Endo a
Endo forall a. a -> a
id
instance Monoid (First a) where
{-# INLINABLE mempty #-}
mempty :: First a
mempty = forall a. Maybe a -> First a
First forall a. Maybe a
Nothing
class Monoid a => Group a where
inv :: a -> a
{-# INLINABLE gsub #-}
gsub :: Group a => a -> a -> a
gsub :: forall a. Group a => a -> a -> a
gsub a
x a
y = a
x forall a. Semigroup a => a -> a -> a
<> forall a. Group a => a -> a
inv a
y