Is it possible to create decidable properties for interfaces in Idris that can be used within the interface itself ?
For example - let's say we have a simple interface Foo and a datatype FooTypeEmpty representing a statement that a given foo object is 'empty ' (defined as 'is indexed by two zeros'):
interface Foo (foo : Nat -> Nat -> Type -> Type) where
mkEmpty : foo 0 0 a
isEmpty : (f : foo n m a) -> Bool
data FooTypeEmpty : (Foo foo) => foo n m a -> Type where
MkFooTypeEmpty : (Foo foo) => (f : foo 0 0 a) -> FooTypeEmpty f
Is it possible to give the isEmpty method the following type ?:
isEmpty : (f : foo n m a) -> Dec (FooTypeEmpty f)
That is, make use of FooTypeEmpty so that isEmpty returns a proof (or contradiction) that the given foo object is 'empty' ?
I tried it with a mutual block, but this won't typecheck:
mutual
interface Foo (foo : Nat -> Nat -> Type -> Type) where
mkEmpty : foo 0 0 a
isEmpty : (f : foo n m a) -> Dec (FooTypeEmpty f)
data FooTypeEmpty : (Foo foo) => foo n m a -> Type where
FTE : (Foo foo) => (f : foo 0 0 a) -> FooTypeEmpty f
More generally : Is it possible to incorporate proofs in interface methods that are valid/required for all implementations ?