Impossible de compiler ce raytracer, je n’arrête pas de tomber sur des erreurs.
Par exemple (c’est la première) :
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| --Ne conserve que les intersections devant la caméra, et récupère la plus proche
getClosestIntersection :: [Intersection] -> Scene -> Maybe Intersection
getClosestIntersection intersections = return intersection
where
allowedIntersections = filter isAhead intersections
isAhead intersection@(_, distance, _) = distance > 0
compareZ a b = compare ad bd
where
(_, ad, _) = a
(_, bd, _) = b
closestIntersection = minimumBy compareZ allowedIntersections
intersection = if null allowedIntersections
then Nothing
else Just closestIntersection |
Me donne l’erreur :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| src/Raytracer.hs:62:40:
No instance for (Monad ((->) Scene))
arising from a use of `return'
Possible fix: add an instance declaration for (Monad ((->) Scene))
In the expression: return intersection
In an equation for `getClosestIntersection':
getClosestIntersection intersections
= return intersection
where
allowedIntersections = filter isAhead intersections
isAhead intersection@(_, distance, _) = distance > 0
compareZ a b
= compare ad bd
where
(_, ad, _) = a
(_, bd, _) = b
closestIntersection = minimumBy compareZ allowedIntersections
.... |
Qui me semble assez logique et que je corrige simplement en réécrivant la ligne qui pose problème :
getClosestIntersection intersections _ = intersection
Le truc c’est qu’il y en a d’autres... Alors quel est le problème : mauvais compilateur (GHC 7.4.2), mauvaise option, mauvaise compréhension ?
Partager