A little trick to deal with cases on expressions #247
rigille
started this conversation in
Show and tell
Replies: 1 comment
-
that's really cool! It's been a while since I'm thinking about playing with some examples using dependent types. I'll try your challenge as a reference. Thanks for sharing it 💙 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Dependent types like the following are easy to deal with
Indeed to write a function
(n: Nat) -> TestType(n)
all you need to do is thisHowever you'll quickly find dependent types that look more like this
Now our usual approach doesn't work
Because the typechecker can't see that
TestType(n)
can be reduced to an expression that containsNat.eql(1000, n)
, the smart motive at the end of thecase
does nothing. The workaround is to include an annotation.where the
!!!
stand for the motive and the two cases. The annotation forces the typechecker to reduceTestType(n)
just enough for the smart motive to work. That trick has been sooo useful for me i needed to share it. Here's a problem for you to try it out:Tip: you might need more than one annotation and the annotations might include a
==
Beta Was this translation helpful? Give feedback.
All reactions