The following program yields an error in ghci:
{-# LANGUAGE NoImplicitPrelude #-}
import Prelude (Integer, Bool)
import qualified Prelude
class Discrete a where
(==) :: a -> a -> Bool
instance Discrete Integer where
(==) = (Prelude.==)
class Monoid a where
one :: a
(*) :: a -> a -> a
fromInteger :: Integer -> a
fromInteger 1 = one
Namely:
fromInteger.hs:17:16:
No instance for (Monoid Integer)
arising from the literal1' at fromInteger.hs:17:16
fromInteger': fromInteger 1 = one
Possible fix: add an instance declaration for (Monoid Integer)
In the pattern: 1
In the definition of
How can I fix it so that 1 can be converted to the value one
for Monoids? All other integers may (or should) yield Prelude.undefined
when being applied to (Monoid a) => fromInteger
.
Please be aware that I am a the opposite of an expert to Haskell so please forgive me in case the answer is obvious.