Let's say I have a datatype:
data Term : Type -> Type where
Id : Term (a -> a)
...
App : Term (a -> b) -> Term a -> Term b
With a proof something is App
:
data So : Bool -> Type where
Oh : So True
isApp : Term a -> Bool
isApp (App x y) = True
isApp x = False
Is it possible to write a function that gets the first argument of an App
? I don't know how I'd type it, since the original argument type is lost:
getFn : (x : Term b) -> So (isApp x) -> ???
getFn (App f v) p = f
I could keep tags inside the Term
s indicating what types have been applied to it, but then I'd have to restrict myself to taggable types. Previously I'd have assume that's the only option, but so many magical things seems to happen in the land of dependent types that I thought I'd ask first.
(Agda examples would be welcome as well, though I'd prefer Idris ones!)