I have following code, that does not compile:
module Lib where
{-# LANGUAGE OverloadedStrings, TypeSynonymInstances, FlexibleInstances #-}
import Data.Text (Text)
class DoSomething a where
something :: a -> IO ()
instance DoSomething String where
something _ = putStrLn "String"
instance DoSomething Text where
something _ = putStrLn "Text"
and compiler shows following error message:
:l ./src/Lib.hs
[1 of 1] Compiling Lib ( src/Lib.hs, interpreted )
src/Lib.hs:10:10: error:
• Illegal instance declaration for ‘DoSomething String’
(All instance types must be of the form (T t1 ... tn)
where T is not a synonym.
Use TypeSynonymInstances if you want to disable this.)
• In the instance declaration for ‘DoSomething String’
|
10 | instance DoSomething String where
| ^^^^^^^^^^^^^^^^^^
Failed, no modules loaded.
What am I doing wrong?