add SnocVect.select

This commit is contained in:
rhiannon morris 2023-06-24 14:28:08 +02:00
parent 33abbf659e
commit 124637c946
1 changed files with 11 additions and 0 deletions

View File

@ -3,6 +3,7 @@ module Quox.Thin.View
import public Quox.Thin.Base
import Quox.NatExtra
import Data.Singleton
import Data.SnocVect
%default total
@ -90,3 +91,13 @@ export
view (Keep {mask} ope eq) = KeepV mask ope
viewKeep ope eq with (view (Keep ope eq))
viewKeep ope Refl | KeepV _ ope = Refl
namespace SnocVect
export
select : {n, mask : Nat} -> (0 ope : OPE m n mask) ->
SnocVect n a -> SnocVect m a
select ope sx with (view ope)
select _ [<] | StopV = [<]
select _ (sx :< x) | DropV _ ope = select ope sx
select _ (sx :< x) | KeepV _ ope = select ope sx :< x