data Temp a = Something1 | Something2 deriving (Show,Eq,Ord) length :: Temp a -> Integer length Something1 = 0 length Something2 = 1
It is better to change length
to something else to avoid a collision with the Prelude length. If you want to use your length as "default", add
import Prelude hiding (length) import qualified Prelude
at the beginning and refer to the Prelude version using Prelude.length
. Not recommended.
By the way, if your Temp
is independent of a
, you can consider
data Temp = Something1 | Something2 deriving (Show,Eq,Ord)
source share