From ffbdebbced2cbd32f7e121f19c1c0360be2053b8 Mon Sep 17 00:00:00 2001 From: Helmut Grohne Date: Sun, 21 Jul 2013 20:46:18 +0200 Subject: import _>>=_ and fmap from Data.Maybe Also rename fmap to _<$>_ to match Agda naming conventions. The imported _>>=_ appears to have different binding, so some braces were necessary. --- BFF.agda | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'BFF.agda') diff --git a/BFF.agda b/BFF.agda index 2888a3d..cbb36d3 100644 --- a/BFF.agda +++ b/BFF.agda @@ -2,7 +2,12 @@ module BFF where open import Data.Nat using (ℕ) open import Data.Fin using (Fin) +import Level +import Category.Monad +import Category.Functor open import Data.Maybe using (Maybe ; just ; nothing ; maybe′) +open Category.Monad.RawMonad {Level.zero} Data.Maybe.monad using (_>>=_) +open Category.Functor.RawFunctor {Level.zero} Data.Maybe.functor using (_<$>_) open import Data.List using (List ; [] ; _∷_ ; map ; length) open import Data.Vec using (Vec ; toList ; fromList ; tabulate ; allFin) renaming (lookup to lookupV ; map to mapV ; [] to []V ; _∷_ to _∷V_) open import Function using (id ; _∘_ ; flip) @@ -12,12 +17,6 @@ open import FinMap import CheckInsert import FreeTheorems -_>>=_ : {A B : Set} → Maybe A → (A → Maybe B) → Maybe B -_>>=_ = flip (flip maybe′ nothing) - -fmap : {A B : Set} → (A → B) → Maybe A → Maybe B -fmap f = maybe′ (λ a → just (f a)) nothing - module ListBFF (Carrier : Set) (deq : Decidable {A = Carrier} _≡_) where open FreeTheorems.ListList public using (get-type) open CheckInsert Carrier deq @@ -37,8 +36,8 @@ module ListBFF (Carrier : Set) (deq : Decidable {A = Carrier} _≡_) where bff get s v = let s′ = enumerate s g = fromFunc (denumerate s) h = assoc (get s′) v - h′ = fmap (flip union g) h - in fmap (flip map s′ ∘ flip lookup) h′ + h′ = (flip union g) <$> h + in (flip map s′ ∘ flip lookup) <$> h′ module VecBFF (Carrier : Set) (deq : Decidable {A = Carrier} _≡_) where open FreeTheorems.VecVec public using (get-type) @@ -58,5 +57,5 @@ module VecBFF (Carrier : Set) (deq : Decidable {A = Carrier} _≡_) where bff get s v = let s′ = enumerate s g = fromFunc (denumerate s) h = assoc (get s′) v - h′ = fmap (flip union g) h - in fmap (flip mapV s′ ∘ flip lookupV) h′ + h′ = (flip union g) <$> h + in (flip mapV s′ ∘ flip lookupV) <$> h′ -- cgit v1.2.3