S. Alexander Jacobson wrote:

>   data MyExistantialType=forall v.(Show v)=>EType v
>
>   class MyExistentialTypeable a where
>    toMyType::String->MyExistantialType
>
>   instance MyExistentialTypeable String where
>    toMyType "String" = EType "foo"
>
>   instance MyExistentialTypeable Int where
>    toMyType "Int" = EType "bar"
>
>   tVal (EType v)=show v
>   main = print $ tVal $ toMyType "String"

The type class isn't necessary here, since toMyType has the same type in every instance anyway (namely String->MyExistentialType). You can simply write

  data MyExistantialType=forall v.(Show v)=>EType v

  toMyType "String" = EType "foo"
  toMyType "Int" = EType "bar"

  tVal (EType v)=show v
  main = print $ tVal $ toMyType "String"

-- Ben

_______________________________________________
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell

Reply via email to