summaryrefslogtreecommitdiff
path: root/BFF.agda
diff options
context:
space:
mode:
authorHelmut Grohne <grohne@cs.uni-bonn.de>2014-02-14 16:35:25 +0100
committerHelmut Grohne <grohne@cs.uni-bonn.de>2014-02-14 16:35:25 +0100
commitf4e7869c1d203fcf406b01e34d6276adf49fb79a (patch)
tree02c8c43dd8aaf494bb9d74ce3677bd0bfc0941bc /BFF.agda
parent04b7bf8fabf64a2414d64cfb385f6a397da0a0fb (diff)
parent0ff83361e08eec6d6a5ab9a44f35b0b8590d2031 (diff)
downloadbidiragda-f4e7869c1d203fcf406b01e34d6276adf49fb79a.tar.gz
Merge branch feature-shape-update into master
The branch enables shape updates in variety of flavours: * explicitly passing the desired target shape * providing a plugin sput : ℕ → ℕ → Maybe ℕ * providing a right-inverse to getlen It also provides a backwards compatibility function to facilitate shape-retaining updates.
Diffstat (limited to 'BFF.agda')
-rw-r--r--BFF.agda14
1 files changed, 9 insertions, 5 deletions
diff --git a/BFF.agda b/BFF.agda
index 1770b5e..56ba359 100644
--- a/BFF.agda
+++ b/BFF.agda
@@ -30,14 +30,18 @@ module VecBFF (A : DecSetoid ℓ₀ ℓ₀) where
enumerate : {n : ℕ} → Vec Carrier n → Vec (Fin n) n
enumerate _ = tabulate id
+ enumeratel : (n : ℕ) → Vec (Fin n) n
+ enumeratel _ = tabulate id
+
denumerate : {n : ℕ} → Vec Carrier n → Fin n → Carrier
denumerate = flip lookupV
- bff : (G : Get) → ({n : ℕ} → Vec Carrier n → Vec Carrier (Get.getlen G n) → Maybe (Vec Carrier n))
- bff G s v = let s′ = enumerate s
+ bff : (G : Get) → {n : ℕ} → (m : ℕ) → Vec Carrier n → Vec Carrier (Get.getlen G m) → Maybe (Vec Carrier m)
+ bff G m s v = let s′ = enumerate s
t′ = Get.get G s′
g = fromFunc (denumerate s)
g′ = delete-many t′ g
- h = assoc t′ v
- h′ = (flip union g′) <$> h
- in h′ >>= flip mapMV s′ ∘ flip lookupM
+ t = enumeratel m
+ h = assoc (Get.get G t) v
+ h′ = (flip union (reshape g′ m)) <$> h
+ in h′ >>= flip mapMV t ∘ flip lookupM