I'm trying to deriving Eq from data type with a function as a field but doesn't work as expected.
I also try to write te instance but still doesn't work
data Conf = Conf {
rule :: ([Char] -> Char),
start :: Int,
numLines :: Double,
window :: Int,
move :: Int,
actualLine :: Int,
lastLine :: String
} deriving (Eq)
It's a project that consist in print graphicaly the wolfram pyramids, for instance, the rules are for example:
rule30 :: [Char] -> Char
rule30 "***" = ' '
rule30 "** " = ' '
rule30 "* *" = ' '
rule30 "* " = '*'
rule30 " **" = '*'
rule30 " * " = '*'
rule30 " *" = '*'
rule30 " " = ' '
rule30 _ = ' '
There are many rules to follow, it's for that reason that I want to save the "function pointer" directly in Conf data type.
So, why I need the deriving(Eq)? I need it because in the main I check if is Nothing (error handling check, for example if the user puts a bad rule...)
Error Msg:
src/Wolf.hs:24:13: error:
• No instance for (Eq ([Char] -> Char))
arising from the first field of ‘Conf’ (type ‘[Char] -> Char’)
(maybe you haven't applied a function to enough arguments?)
Possible fix:
use a standalone 'deriving instance' declaration,
so you can specify the instance context yourself
• When deriving the instance for (Eq Conf)
|
24 | } deriving (Eq)
| ^^
What am I missing?x