
I’m having difficulty to understand what phantom types are good for. Is this just for improving runtime performance? I read the wiki, and it says "this is useful if you want to increase the type-safety of your code", but the code below does not give a compiler error for the function test1, I get a runtime error, just like test2. Thanks, Peter -- CODE -- -- With phantom types data T1 a = TI1 Int | TS1 String deriving Show foo1 :: T1 String -> T1 String -> T1 String foo1 (TS1 x) (TS1 y) = TS1 (x++y) test1 = foo1 (TI1 1) (TI1 2) -- Shouldn't this give a compiler error instead of a runtime error? -- Without phantom types data T2 = TI2 Int | TS2 String deriving Show foo2 :: T2 -> T2 -> T2 foo2 (TS2 x) (TS2 y) = TS2 (x++y) test2 = foo2 (TI2 1) (TI2 2) No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.5.476 / Virus Database: 269.11.8/941 - Release Date: 07/08/2007 16:06