21 lines
515 B
Haskell
21 lines
515 B
Haskell
module Object.Semigroup where
|
|
|
|
import Functor.Bifunctor
|
|
import Functor.Product
|
|
|
|
import Data.Kind (Constraint)
|
|
|
|
type Semigroup :: (k -> k -> k) -> k -> Constraint
|
|
class TensorProduct prod => Semigroup prod s where
|
|
append :: Cod1 prod (prod s s) s
|
|
|
|
type Cosemigroup :: (k -> k -> k) -> k -> Constraint
|
|
class TensorProduct prod => Cosemigroup prod s where
|
|
split :: Cod1 prod s (prod s s)
|
|
|
|
(<>) :: Semigroup (,) s => s -> s -> s
|
|
x <> y = append (x, y)
|
|
|
|
instance Cosemigroup (,) a where
|
|
split = \x -> (x, x)
|