Monday, April 29, 2013

[isjnkupe] Local types and imports

I have occasionally wanted this in Haskell.

let { newtype T = ... } in ...

Compiler signals error if any value of type T "escapes" the scope.

Type synonym types are allowed to escape.

Similarly, let { import ... } .  The compiler signals error if any imported type escapes the scope, unless it is also imported in the outer scope.

1 comment :

Ganesh Sittampalam said...

A slight generalisation would be to only signal an error if the type escapes in a type signature - so it's ok to return them in existentially typed ways