0 | module Libraries.Data.SnocList.Extra
4 | import Syntax.PreorderReasoning
16 | snocAppendFishAssociative :
17 | (sx, sy : SnocList a) -> (zs : List a) ->
18 | (sx ++ sy) <>< zs === sx ++ (sy <>< zs)
19 | snocAppendFishAssociative sx sy [] = Refl
20 | snocAppendFishAssociative sx sy (z :: zs)
21 | = snocAppendFishAssociative sx (sy :< z) zs
24 | snocAppendAsFish : (sx, sy : SnocList a) -> sx ++ sy === sx <>< (cast sy)
25 | snocAppendAsFish sx sy = sym
26 | $
trans (fishAsSnocAppend sx (sy <>> []))
27 | (cong (sx ++) (castToList sy))
30 | lookup : Eq a => a -> SnocList (a, b) -> Maybe b
31 | lookup n [<] = Nothing
32 | lookup n (ns :< (x, n')) = if x == n then Just n' else lookup n ns
34 | lengthDistributesOverAppend
35 | : (xs, ys : SnocList a)
36 | -> length (ys ++ xs) = length xs + length ys
37 | lengthDistributesOverAppend [<] ys = Refl
38 | lengthDistributesOverAppend (xs :< x) ys =
39 | cong S $
lengthDistributesOverAppend xs ys
42 | lengthDistributesOverFish : (sx : SnocList a) -> (ys : List a) ->
43 | length (sx <>< ys) === length sx + length ys
44 | lengthDistributesOverFish sx [] = sym $
plusZeroRightNeutral _
45 | lengthDistributesOverFish sx (y :: ys) = Calc $
46 | |~ length ((sx :< y) <>< ys)
47 | ~~ length (sx :< y) + length ys ...( lengthDistributesOverFish (sx :< y) ys )
48 | ~~ S (length sx) + length ys ...( Refl )
49 | ~~ length sx + S (length ys) ...( plusSuccRightSucc _ _ )
50 | ~~ length sx + length (y :: ys) ...( Refl )