[Haskell-cafe] Aren't type system
extensions fun? [Further analysis]
Isaac Dupree
isaacdupree at charter.net
Thu May 29 15:03:57 EDT 2008
>>>> foo :: (Char -> a /\ Bool -> b) -> (a,b)
>>>
>>> a.k.a. find some value that matches both Char->a and Bool->b for some a and b. Could use type-classes to do it.
>> Uhmm... you mean something like (neglecting TC-related issues here)
>>
>> class C a b where
>> fromChar :: Char -> a
>> fromBool :: Bool -> b
>
> Oops: i meant something like
>
> class C x a b | x -> a,b where
> fromChar :: x -> Char -> a
> fromBool :: x -> Bool -> b
no... let me figure out what I meant. Just somehow to have a single
function that takes an argument of two different types without
completely ignoring it.
class Arg a where
whatYouPass :: a -> Something
instance Arg Char where
whatYouPass = ...
instance Arg Bool where
whatYouPass = ...
Then (foo whatYouPass) :: (Something, Something).
Or if it was
class Arg a where
whatYouPass :: a -> a
then (foo whatYouPass) :: (Char, Bool).
And I'm sure there are ways to make the return type different if you
want to think about FDs etc.
>
>
> Zun.
>
More information about the Haskell-Cafe
mailing list