instance Ord1 Var where
    liftCompare :: (a -> b -> Ordering) -> Var a -> Var b -> Ordering
    liftCompare cmp (FVar a) (FVar b) = a `cmp` b
    liftCompare _ (BVar n) (BVar m)   = n `compare` m
    liftCompare _ FVar{} BVar{}       = LT
    liftCompare _ BVar{} FVar{}       = GT

-- | Scope, optimizing 'lift'. Accessed via pattern synonyms
data Scope f a = Scope'
    { _scopeName :: !(IntMap Text)
    , _scopeVal  :: !(f (Var (f a)))
    }
    deriving (Functor, Foldable, Traversable, Generic, Generic1)
