• # Haskell newbie

    Posté par . En réponse au journal Les types fantômes. Évalué à 1. Dernière modification le 25 août 2012 à 18:12.

    C'est comme ça ?

    data Nom
    data Prénom
    data T f = T String deriving (Eq)
    a = T "un prénom" :: T Prénom
    b = T "un nom" :: T Nom
    test = a == b
    
    
     Couldn't match expected type `Prénom' with actual type `Nom'
     Expected type: T Prénom
     Actual type: T Nom
     In the second argument of `(==)', namely `b'
     In the expression: a == b
    
    

    Les vrais haskeliens n'hésitez pas à corriger.

    (ya un petit bug dans la coloration syntaxique, haskell supporte très bien le code en utf-8)

    Please do not feed the trolls