Consider the following function
tryMove : (diskNumber : Nat) -> (from: Peg) -> (to: Peg)-> {default Oh prf: So (from /= to)} -> Disposition diskNumber -> Maybe (Disposition diskNumber)
tryMove Z from to [] = Nothing
tryMove (S k) from to (smallestDiskPosition :: restOfTheDisposition) =
map (smallestDiskPosition ::) (tryMove k from to restOfTheDisposition)
Trying to compile I get the following error:
When checking argument prf to Hanoi.tryMove:
Type mismatch between
So True (Type of Oh)
and
So (from /= to) (Expected type)
Specifically:
Type mismatch between
True
and
not (Hanoi.Peg implementation of Prelude.Interfaces.Eq, method == from to)
on the recurvise invocation of tryMove.
If I explicitely pass {prf} as in
tryMove : (diskNumber : Nat) -> (from: Peg) -> (to: Peg)-> {default Oh prf: So (from /= to)} -> Disposition diskNumber -> Maybe (Disposition diskNumber)
tryMove Z from to [] = Nothing
tryMove (S k) from to {prf} (smallestDiskPosition :: restOfTheDisposition) =
map (smallestDiskPosition ::) (tryMove k from to {prf} restOfTheDisposition)
It compiles correctly.
Why is that that Idris can not detect automatically the proof in the inductive step, while it is able to do it in a normal invocation of the function?
EDIT:
here is a complete gist to use: https://gist.github.com/marcosh/d51479ea08e8522560713fd1e5ca9624