Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use forall in a function definition?

Tags:

idris

banana : Type
banana = forall x . x -> x

gives

While processing right hand side of banana. x is not accessible in this context.

However,

banana : Type
banana = {x : Type} -> x -> x

apple : forall x . x -> x
apple t = t

work.

How can I use universal quantification as the output of a function? If it's not possible, why not?

like image 421
otah007 Avatar asked Oct 24 '25 03:10

otah007


1 Answers

forall x . means {0 x : _} -> i.e. there are no xs at runtime. Since you use x in the definition, there can be no bananas at runtime

0 banana : Type
banana : forall x . x -> x
like image 160
joel Avatar answered Oct 25 '25 19:10

joel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!