[Haskell-cafe] Re: exceptions vs. Either

MR K P SCHUPKE k.schupke at imperial.ac.uk
Thu Aug 5 07:57:19 EDT 2004


>specify that a sort function (say) returns an ordered list

Fistly this is already possible in Haskell - see Oleg, Ralf and
My paper: 

@misc{KLS04,
 author = "Oleg Kiselyov and Ralf L{\"a}mmel and Keean Schupke",
 title = "{Strongly typed heterogeneous collections}",
 booktitle = "{ACM SIGPLAN Workshop on Haskell}",
 year = 2004,
 month = sep,
 publisher = "ACM Press",
 notes = "To appear"
}

http://homepages.cwi.nl/~ralf/HList/

Here we show constrained heterogeneous lists (but you can also 
constrain the type in the list to turn it into a homogeneous list)
that includes the ability to impose ordering constraints...

Writing the constraint classes is a little involved but using it is
as simple as:

	sort :: (HList l,HOrderedList l') => l -> l'

and supposing you dont like having to write the complete type, you
can use:

	ordered :: HOrderedList l => l -> l
	ordered = id

	then you can use this in a function with no type given:

	sort = ordered . sort'


So my point is this can be added to haskell _without_ breaking
any existing functionality - it is not either/or it is both/and!

	Keean.


More information about the Haskell-Cafe mailing list