diff options
author | Helmut Grohne <grohne@cs.uni-bonn.de> | 2014-02-14 16:35:25 +0100 |
---|---|---|
committer | Helmut Grohne <grohne@cs.uni-bonn.de> | 2014-02-14 16:35:25 +0100 |
commit | f4e7869c1d203fcf406b01e34d6276adf49fb79a (patch) | |
tree | 02c8c43dd8aaf494bb9d74ce3677bd0bfc0941bc /BFF.agda | |
parent | 04b7bf8fabf64a2414d64cfb385f6a397da0a0fb (diff) | |
parent | 0ff83361e08eec6d6a5ab9a44f35b0b8590d2031 (diff) | |
download | bidiragda-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.agda | 14 |
1 files changed, 9 insertions, 5 deletions
@@ -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 |