Problem description

Say I have an AST with constructor FuncCall : ID * List(Expr) -> Expr. Now I have some built-in functions, that I want to put into the type rules. So I try something like this:

 Func("strEq", a*) : BoolTy()
   where a* : ty* // yes you can write this in one line, but that doesn't make a difference
     and ty* == [StringTy(),StringTy()]

Type-checking a FuncCall("strEq",[..., ...]) will always fail.
For the case where you compare to an empty list (ty* == []), it’s quite clear where things go wrong. Inspecting the index will show that a choose task is generated without things to choose like so:

 task 123456

The type-checking will depend on that task and therefore fail.
For a non-empty list it’s a little less clear where things go wrong.

The way it looks to me is that the code generation works well enough, but a type-task on lists doesn’t work correctly.


I’ve found a workaround, which is to always wrap a things in a double list:

 Func("strEq", a*) : BoolTy()
   where a* : ty*
     and ty* == [[StringTy(),StringTy()]]

This is also required when comparing with an empty list, it has to be [[]] to work correctly.


In the newest version of the master branch, it looks like you only need the double list if you’re matching an empty list.

Submitted by Jeff Smits on 22 May 2015 at 18:28

Log in to post comments