Here is my code to solve the fractional knapsack problem, input to knap should be in the form 

```
[("label 1", value, weight), ("label 2", value, weight), ...]

```

And output should be in the form

```
[("label 1", value, solution_weight), ("label 2", value, solution_weight), ...]

```

Code:

```
import Data.List {- Need for the sortBy function -}
{- Input "how much can the knapsack hole <- x" "Possible items in sack [(label, value, weight), ...] <- y" -}
{-knap x [([Char], Integer, Integer), ... ] = -}
knap x [] = []
knap x y = if length y == 1 
    then 
        if x > last3 (head y)
            then y
            else [(frst3 (head y), scnd3 (head y), x)]
    else 
        knap2 x y []
{- x is the knap max, y is the sorted frac list, z is the solution list -}
knap2 x y z = if x == 0
    then z
    else
        if thrd4 (head y) > x
            then [((frst4 (head y)), (scnd4 (head y)), x)]
            else knap2 (x-(thrd4 (head y))) (tail y) (z++[((frst4 (head y)), (scnd4 (head y)), (thrd4 (head y)))]) 

{- take a list of labels, values, and weights and return list of labels and fractions -}
fraclist :: (Fractional t1) => [(t, t1, t1)] -> [(t, t1, t1, t1)]
fraclist xs = [(x, y, z, y/z) | (x, y, z) <- xs]

{- Sort the list -}
sortList x = sortBy comparator x
    where comparator (_,_,_,d) (_,_,_,h) = if d > h then LT else GT

{- helper func to get values from tuples -}
frst3 (a,b,c) = a
scnd3 (a,b,c) = b
last3 (a,b,c) = c
frst4 (a,b,c,d) = a
scnd4 (a,b,c,d) = b
thrd4 (a,b,c,d) = c
last4 (a,b,c,d) = d

```

Here is the error I am getting

```
Couldn't match expected type `(t1, t0, t2, t3)'
            with actual type `(t1, t0, t2)'
Expected type: [(t1, t0, t2, t3)]
  Actual type: [(t1, t0, t2)]
In the second argument of `knap2', namely `y'
In the expression: knap2 x y []

```

I am not quite sure what else I can do. before I sit here and bang my head on the wall for an hour maybe someone could point out an obvious mistake if there are any?