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
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
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
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