
23 Nov
2006
23 Nov
'06
10:20 p.m.
On Thu, Nov 16, 2006 at 10:44:59PM +0200, isto wrote:
I'll guess the reason it didn't compile was different types at case branches (am I wrong?) Anyhow, do you know that is it possible to choose the return type somehow in the spirit above?
GADTs let you do this. And they even omit the run time type check. though, the type class solution is the correct way to do this sort of thing. data Value a where IntLike :: Int -> Value Int CharLike :: Char -> Value Char f :: Value a -> a f x = case x of IntLike x -> x + 1 CharLike x -> x:" plus one" there is also Data.Dynamic and existential types which are related to the task. John -- John Meacham - ⑆repetae.net⑆john⑈