Type error in application type does not match

173 Views Asked by At
nextMyStates :: MyState -> [MyState]
nextMyStates(s) =[up(s),down(s),left(s),right(s),collect(s)]
    
isGoal :: MyState -> Bool
isGoal (S (l) (al) d z) = if al == [] then True else False

search :: [MyState] -> MyState
search (s:sz) | isGoal s = s
              | otherwise = search (sz) ++ nextMyStates s

I am trying to run this but this type error comes up

Type error in application
*** Expression     : search sz ++ nextMyStates s
*** Term           : search sz
*** Type           : MyState
*** Does not match : [MyState]

I thought this notation (s:sz) meant the sz is a list consisting of the rest of the elements besides the head but it says it is a single element not a list

0

There are 0 best solutions below