0
Ich schreibe einen Komparator, um an sortBy
übergeben, aber ich kann nicht die Typ-Deklaration richtig. Die Eingabe ist zwei Data.Vector
's, die jeweils zwei Nummern enthalten.Haskell-Vektor-Typ Erklärung
-- Comparator to sort a list of individuals by increasing order of fit-0
-- and for individuals with equal fit-0, with increasing order of fit-1
indCmp :: (Ord a, Num a, Vector a) => a -> a -> Ordering
indCmp x y
| (x ! 0) < (y ! 0) = LT
| (x ! 0) > (y ! 0) = GT
| (x ! 1) < (y ! 1) = LT -- Can assume (x ! 0) == (y ! 0) here and beneath
| (x ! 1) > (y ! 1) = GT
| (x ! 1) == (y ! 1) = EQ
GHCI klagt:
eine Einschränkung erwartet, aber 'Vector a' hat Art '*'
Ich vermute, das ist ein Duplikat von [diesem] (http://stackoverflow.com/questions/12018959/string-is-applied-to-too-many-type-arguments/12018975), aber mit 'Vector a' statt 'String'. Funktioniert die Lösung auch für Sie? –