Re: [Haskell-cafe] instance of String illegal

2006-09-28 Thread Stefan Holdermans
Adam, class Foo a where mkFoo :: a -> String instance Foo String where mkFoo x = x In addition to making use of language extensions or wrapper types, you could go with the following workaround in just plain Haskell 98: import List class MkFoo a where mkFoo :: a -> Str

Re: [Haskell-cafe] instance of String illegal

2006-09-28 Thread Bernie Pope
On 29/09/2006, at 12:44 PM, Donald Bruce Stewart wrote: Alternatively, use -fglasgow-exts :) instance Foo String where mkFoo = id $ ghci -fglasgow-exts A.hs *Main> mkFoo "foo" "foo" And just to follow up what Don said, this feature of GHC is described here: http://www.haskell

Re: [Haskell-cafe] instance of String illegal

2006-09-28 Thread Donald Bruce Stewart
adam: > I am trying to create an instance of a class for String types. I have > the following: > > class Foo a where > mkFoo :: a -> String > > instance Foo String where > mkFoo x = x > > and receive the following error: > > test.hs:9:0: > Illegal instance declaration for `Foo Stri

[Haskell-cafe] instance of String illegal

2006-09-28 Thread Adam Hupp
I am trying to create an instance of a class for String types. I have the following: class Foo a where mkFoo :: a -> String instance Foo String where mkFoo x = x and receive the following error: test.hs:9:0: Illegal instance declaration for `Foo String' (The instance type m