{-# OPTIONS --without-K --safe #-}
open import Algebra
module Data.FingerTree.Measures
{r m}
(β³ : Monoid r m)
where
open import Level using (_β_)
open Monoid β³ renaming (Carrier to π‘)
open import Data.List as List using (List; _β·_; [])
open import Data.Product
open import Function
record Ο {a} (Ξ£ : Set a) : Set (a β r) where field ΞΌ : Ξ£ β π‘
open Ο β¦ ... β¦
{-# DISPLAY Ο.ΞΌ _ = ΞΌ #-}
instance
Ο-List : β {a} {Ξ£ : Set a} β β¦ _ : Ο Ξ£ β¦ β Ο (List Ξ£)
ΞΌ β¦ Ο-List β¦ = List.foldr (_β_ β ΞΌ) Ξ΅
infixl 2 _β[_]
record ΞΌβ¨_β©β_ {a} (Ξ£ : Set a) β¦ _ : Ο Ξ£ β¦ (π : π‘) : Set (a β r β m) where
constructor _β[_]
field
π’ : Ξ£
π» : ΞΌ π’ β π
open ΞΌβ¨_β©β_ public
infixl 2 _β
_β : β {a} {Ξ£ : Set a} β¦ _ : Ο Ξ£ β¦ (π’ : Ξ£) β ΞΌβ¨ Ξ£ β©β ΞΌ π’
π’ (x β) = x
π» (x β) = refl
{-# INLINE _β #-}
infixl 2 _β[_] β-rev
_β[_] : β {a} {Ξ£ : Set a} β¦ _ : Ο Ξ£ β¦ {x : π‘} β ΞΌβ¨ Ξ£ β©β x β β {y} β x β y β ΞΌβ¨ Ξ£ β©β y
π’ (xs β[ yβz ]) = π’ xs
π» (xs β[ yβz ]) = trans (π» xs) yβz
{-# INLINE _β[_] #-}
β-rev : β {a} {Ξ£ : Set a} β¦ _ : Ο Ξ£ β¦ {x : π‘} β β {y} β x β y β ΞΌβ¨ Ξ£ β©β x β ΞΌβ¨ Ξ£ β©β y
π’ (β-rev yβz xs) = π’ xs
π» (β-rev yβz xs) = trans (π» xs) yβz
{-# INLINE β-rev #-}
syntax β-rev yβz xβ¦y = xβ¦y β[ yβz ]β²
infixr 2 β-right
β-right : β {a} {Ξ£ : Set a} β¦ _ : Ο Ξ£ β¦ {x : π‘} β ΞΌβ¨ Ξ£ β©β x β β {y} β x β y β ΞΌβ¨ Ξ£ β©β y
β-right (x β[ xβy ]) yβz = x β[ trans xβy yβz ]
syntax β-right x xβ = [ xβ ]β x
infixr 1 _β€_
record βͺ_β« {a} (Ξ£ : Set a) β¦ _ : Ο Ξ£ β¦ : Set (a β r β m) where
constructor _β€_
field
π : π‘
π : ΞΌβ¨ Ξ£ β©β π
open βͺ_β« public
βͺ_ββ« : β {a} {Ξ£ : Set a} β¦ _ : Ο Ξ£ β¦ β Ξ£ β βͺ Ξ£ β«
π βͺ x ββ« = ΞΌ x
π βͺ x ββ« = x β
instance
Ο-βͺβ« : β {a} {Ξ£ : Set a} β¦ _ : Ο Ξ£ β¦ β Ο βͺ Ξ£ β«
ΞΌ β¦ Ο-βͺβ« β¦ = π
open import Algebra.FunctionProperties _β_
infixl 2 arg-syntax
record Arg {a} (Ξ£ : Set a) β¦ _ : Ο Ξ£ β¦ (π : π‘) (f : π‘ β π‘) : Set (m β r β a) where
constructor arg-syntax
field
β¨fβ© : Congruentβ f
arg : ΞΌβ¨ Ξ£ β©β π
open Arg
syntax arg-syntax (Ξ» sz β eβ) xs = xs [ eβ βΏ sz ]
infixl 1 _>>=_
_>>=_ : β {a b} {Ξ£β : Set a} {Ξ£β : Set b} β¦ _ : Ο Ξ£β β¦ β¦ _ : Ο Ξ£β β¦ {π f}
β Arg Ξ£β π f
β ((x : Ξ£β) β β¦ xβ : ΞΌ x β π β¦ β ΞΌβ¨ Ξ£β β©β f (ΞΌ x))
β ΞΌβ¨ Ξ£β β©β f π
arg-syntax cng xs >>= k = k (π’ xs) β¦ π» xs β¦ β[ cng (π» xs) ]
{-# INLINE _>>=_ #-}
_β?_ : β x y β β¦ xβy : x β y β¦ β x β y
_β?_ _ _ β¦ xβy β¦ = xβy