[Haskell-cafe] Type system extension

Thomas Davie tom.davie at gmail.com
Sun May 15 11:26:11 EDT 2005


Hi,
   I'd just been writing some code and an interesting idea for an  
extension to Haskell's type system sprang into my head.  I have no  
idea if people have played with it, but it looked vaguely useful to  
me, so I thought I'd see what everyone else thought.

Supposing you have these types:

type Export = String

data SCode = SModule String [Export] | SUnknown

It would be useful to specify a function as so:
doSomethingToAModule :: SCode(SModule) -> SomeRandomOtherType

which would specify, not only that the first argument was of type  
SCode, but more specifically, that it used the SModule constructor.   
This would then allow you to safely only write a case for the SModule  
constructor, and not worry about a runtime error when pattern  
matching failed on an SUnknown (as this would be checked at compile  
time).

I hope this makes sense

What does anyone think of the idea, and is there an obvious flaw in  
the plan?

Thanks

Tom Davie



More information about the Haskell-Cafe mailing list