0 | module Core.Name.CompatibleVars
3 | data CompatibleVars : (xs, ys : SnocList a) -> Type where
4 | Pre : CompatibleVars xs xs
5 | Ext : CompatibleVars xs ys -> CompatibleVars (xs :< n) (ys :< m)
8 | invertExt : CompatibleVars (xs :< n) (ys :< m) -> CompatibleVars xs ys
10 | invertExt (Ext p) = p
13 | extendCompats : (args : SnocList a) ->
14 | CompatibleVars xs ys ->
15 | CompatibleVars (xs ++ args) (ys ++ args)
16 | extendCompats args Pre = Pre
17 | extendCompats args prf = go args prf where
19 | go : (args : SnocList a) ->
20 | CompatibleVars xs ys ->
21 | CompatibleVars (xs ++ args) (ys ++ args)
23 | go (xs :< x) prf = Ext (go xs prf)
26 | decCompatibleVars : (xs, ys : SnocList a) -> Dec (CompatibleVars xs ys)
27 | decCompatibleVars [<] [<] = Yes Pre
28 | decCompatibleVars [<] (xs :< x) = No (\case p impossible)
29 | decCompatibleVars (xs :< x) [<] = No (\case p impossible)
30 | decCompatibleVars (xs :< x) (ys :< y) = case decCompatibleVars xs ys of
31 | Yes prf => Yes (Ext prf)
32 | No nprf => No (nprf . invertExt)
35 | areCompatibleVars : (xs, ys : SnocList a) ->
36 | Maybe (CompatibleVars xs ys)
37 | areCompatibleVars [<] [<] = pure Pre
38 | areCompatibleVars (xs :< x) (ys :< y)
39 | = do compat <- areCompatibleVars xs ys
41 | areCompatibleVars _ _ = Nothing