I have the following error for the cadr1
below, which makes sense
Could not deduce (BoolEq n ('Succ ('Succ n'0)) ~ 'True)
from the context (BoolEq n ('Succ ('Succ n')) ~ 'True)
The type variable ‘n'0’ is ambiguous
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeFamilies #-}
module DecidablePropositionalEquality where
data Nat = Zero | Succ Nat
data Vec :: * -> Nat -> * where
VNil :: Vec a Zero
VCons :: a -> Vec a n -> Vec a (Succ n)
type family Greater (a:: Nat) (b:: Nat) :: Bool where
Greater Zero Zero = True
Greater Zero (Succ x) = False
Greater (Succ x) Zero = True
Greater (Succ a) (Succ b) = Greater a b
op :: forall a n n'. (Greater n (Succ (Succ n')) ~ True) => Vec a n -> a
op v = undefined
I don't use n'
at the definition site, so it is ambiguous.
Is there anyway for me to existentially quantify over this n'
, so that ghc does not try to assign it to some type, and fails as nothing ties it to anything ?
More generally, how to control the scope of those type variables ?
edit : modified to remove Boolean type family