this is my program (I realise it's not an entirely useful program):
data Temp a = Something1 | Something2 deriving (Show,Eq,Ord)
length :: Temp a -> Integer
Something1 = 0
Something2 = 1
and I keep getting the error message:
Haskellfile.lhs:3:3: The type signature for `length' lacks an accompanying binding (You cannot give a type signature for an imported value)
Can someone please help?
data Temp a = Something1 | Something2 deriving (Show,Eq,Ord)
length :: Temp a -> Integer
length Something1 = 0
length Something2 = 1
It's better to change length
to something else, to avoid clash with Prelude's length. If you want to use your length as "default", add
import Prelude hiding (length)
import qualified Prelude
on the beginning, and refer to Prelude's version with Prelude.length
. Not recommended.
By the way if your Temp
doesn't depend on a
, you might consider
data Temp = Something1 | Something2 deriving (Show,Eq,Ord)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With