Edwin Brady
unread,Oct 21, 2012, 7:44:57 PM10/21/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to idris...@googlegroups.com
Hi all,
I've just added the "parameters" feature which used to exist in Idris 0.1, by request, and it'll be available from Idris 0.9.5, or in the github repository from now. It works like so:
parameters (n1 : Ty1, n2 : Ty2, …)
f : a -> b -> c
f x y = z
data Foo : a -> Set where
MkFoo : Foo a
n1, n2, etc, will be added as explicit arguments to f, Foo and MkFoo. Inside the block, they are omitted, outside the block, they must be given explicitly. Class and Instance declarations can also appear, but no parameters will be added. "parameters" blocks can be nested, and are scoped by indentation or {}s, whichever you prefer.
This is the same machinery that makes "where" clauses work. So an interesting side effect is that you can now have local data declarations if you want, such as in this contrived example, in which MyLT is only visible in the where block:
foo : Int -> Int
foo x = case isLT of
Yes => x*2
No => x*4
where
data MyLT = Yes | No
isLT : MyLT
isLT = if x < 20 then Yes else No
I have not been properly evil to this feature in testing yet (merely slightly evil), so please shout if anything doesn't work as you'd expect.
Cheers,
Edwin.