[Haskell-cafe] Are casts required?

Patrick Browne patrick.browne at dit.ie
Mon Jun 6 09:45:59 CEST 2011

Are casts required to run the code below?
If so why?

-- Idetifiers for objects
class (Integral i) => IDs i where
 startId :: i
 newId :: i -> i
 newId i = succ i
 sameId, notSameId :: i -> i -> Bool
-- Assertion is not easily expressible in Haskell
-- notSameId i newId i  = True
 sameId i j = i == j
 notSameId i j = not (sameId i j)
 startId = 1

instance IDs Integer where

-- are casts need here?
sameId (newId startId::Integer) 3
sameId (3::Integer) (4::Integer)
notSameId (3::Integer) (newId (3::Integer))

This message has been scanned for content and viruses by the DIT Information Services E-Mail Scanning Service, and is believed to be clean. http://www.dit.ie

More information about the Haskell-Cafe mailing list