diff options
author | Helmut Grohne <helmut@subdivi.de> | 2013-07-21 20:46:18 +0200 |
---|---|---|
committer | Helmut Grohne <helmut@subdivi.de> | 2013-07-21 20:46:18 +0200 |
commit | ffbdebbced2cbd32f7e121f19c1c0360be2053b8 (patch) | |
tree | d05940e7f0d483c36e5e07ffee49d4054a23b193 /BFF.agda | |
parent | dd95d0924df51daeac7176d4010a30d34bae2b02 (diff) | |
download | bidiragda-ffbdebbced2cbd32f7e121f19c1c0360be2053b8.tar.gz |
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.
Diffstat (limited to 'BFF.agda')
-rw-r--r-- | BFF.agda | 19 |
1 files changed, 9 insertions, 10 deletions
@@ -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′ |