[Haskell-cafe] generalized newtype deriving allows the definition of otherwise undefinable functions

Jan-Willem Maessen jmaessen at alum.mit.edu
Tue Mar 9 09:56:45 EST 2010


On Mar 9, 2010, at 5:26 AM, Simon Peyton-Jones wrote:
> ...
> Stephanie Weirich, Steve Zdancewic, Dimitrios Vytiniotis and I have been working hard on a development of the FC intermediate language, and hence of the source language, that will close this (embarrassing) loophole, and allow some new expressiveness.  Nothing written down in a form that someone other than us can make sense of, but there will be!  In brief, though, we're going to end up with kinds looking like
> 	* => *
> as well as the existing
> 	* -> *
> The new form means "a type-indexed function" whereas the latter means "a type-parametric function". 
> 
> John Meacham's example is also very interesting. Even if the data type doesn't use type functions, it might have invariants concerning type classes (his example is Set), and converting all the elements might destroy the invariants.  Excellent point!  There's no type-soundness issue (no run-time seg fault) but something nearly as bad.  Will have to think about that.  Probably declaring Set to have kind (* => *) will do the job.

It occurs to me to observe: if we give class constraints in data types some force, and write:

data Ord a => Set a = ...[internals go here]...

Would this be enough to cue us that Set has a more interesting kind than just * -> * ?

-Jan-Willem Maessen



More information about the Haskell-Cafe mailing list