-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCore.agda
28 lines (22 loc) · 985 Bytes
/
Core.agda
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
{-# OPTIONS --cubical-compatible #-}
module Class.Monoid.Core where
open import Class.Prelude
open import Class.Semigroup
record Monoid (A : Type ℓ) ⦃ _ : Semigroup A ⦄ : Type ℓ where
field ε : A
open Monoid ⦃...⦄ public
module _ (A : Type ℓ) ⦃ _ : Semigroup A ⦄ ⦃ _ : Monoid A ⦄ where
record MonoidLaws (_≈_ : Rel A ℓ′) : Type (ℓ ⊔ ℓ′) where
open Alg _≈_
field ε-identity : Identity ε _◇_
ε-identityˡ = LeftIdentity ε _◇_ ∋ ε-identity .proj₁
ε-identityʳ = RightIdentity ε _◇_ ∋ ε-identity .proj₂
open MonoidLaws ⦃...⦄ public
MonoidLaws≡ : Type ℓ
MonoidLaws≡ = MonoidLaws _≡_
open MonoidLaws ⦃...⦄ public
renaming ( ε-identity to ε-identity≡
; ε-identityˡ to ε-identityˡ≡; ε-identityʳ to ε-identityʳ≡ )
mconcat : {M : Type ℓ} → ⦃ _ : Semigroup M ⦄ → ⦃ Monoid M ⦄ -> List M -> M
mconcat [] = ε
mconcat (x ∷ l) = x ◇ mconcat l