[Haskell-fr] Fractional etc...

Dupont Corentin corentin.dupont at gmail.com
Mon Oct 29 06:09:43 EDT 2007


Salut,
J'ai vraiment du mal à mettre au point un petit programme...
Il me sort souvent des problèmes du style :

  No instance for (Fractional Integer)
     arising from use of `/' at <interactive>:1:4-7
  Possible fix: add an instance declaration for (Fractional Integer)

Par exemple sous ghci si je fait:

map (/5) [0..10]

tout se passe bien.
Mais si je me dit "tiens je voudrais bien paramétrer le 5":

let m = 5
map (/m) [0..10]

il me sort:
    No instance for (Fractional Integer)
      arising from use of `/' at <interactive>:1:4-7
    Possible fix: add an instance declaration for (Fractional Integer)
    In the first argument of `map', namely `(/ m)'
    In the expression: map ((/ m)) ([0 .. 10])
    In the definition of `it': it = map ((/ m)) ([0 .. 10])


Pourtant les 2 codes me sembles assez équivalents!!!
Je peux utiliser des "fromInteger", ce qui résout temporairement le problème.

Je me retrouve par la suite avec des (de mémoire)
Infered type : Int
Expected type : Integer

Ce qui me laisse dans le flou...

a+
Corentin


More information about the Haskell-fr mailing list