haskell - "Couldn't match expected type" error -


here code:

xandy :: element_w_coord cell -> coord xandy (e, (x, y)) = (x, y)  transition_world :: ordered_lists_2d cell -> element_w_coord cell -> ordered_lists_2d cell transition_world world (cell, (x, y)) = case (cell, (x, y)) of     (head, (x, y))-> map_ordered_lists_2d tail world     (tail, (x, y)) -> map_ordered_lists_2d conductor world     (empty, (x, y)) -> map_ordered_lists_2d empty world     (conductor, (x, y))  -> map_ordered_lists_2d head world 

and here error message:

sources/transitions/for_ordered_lists_2d.hs:33:43:     couldn't match expected type `element_w_coord e0 -> cell'                 actual type `cell'     in first argument of `map_ordered_lists_2d', namely `tail'     in expression: map_ordered_lists_2d tail world     in case alternative:         (head, (x, y)) -> map_ordered_lists_2d tail world 

anyone likes tell me what's wrong code pls?

btw, here definition

type ordered_lists_2d e = [sparse_line e]  data sparse_line e = sparse_line {y_pos :: y_coord, entries :: placed_elements e}  data placed_element  e = placed_element {x_pos :: x_coord, entry :: e} type placed_elements e = [placed_element e]   map_ordered_lists_2d :: (element_w_coord e -> b) -> ordered_lists_2d e -> ordered_lists_2d b map_ordered_lists_2d f world =  case world of    l: ls -> map_line f l: map_ordered_lists_2d f ls    []    -> []          map_line :: (element_w_coord e -> b) -> sparse_line e -> sparse_line b       map_line f line = sparse_line {y_pos = (y_pos line), entries = map_elements f (y_pos line) (entries line)}                       map_elements :: (element_w_coord e -> b) -> y_coord -> placed_elements e -> placed_elements b             map_elements f y elements = case elements of                c: cs -> placed_element {x_pos = (x_pos c), entry = f ((entry c), ((x_pos c), y))}: map_elements f y cs                []    -> [] 

thanks can me advice xd

the first argument of map_ordered_lists_2d expected function, passing tail, of type cell.

the following type-check , should starting point:

transition_world world (cell, (x, y)) = case (cell, (x, y)) of     (head, (x, y))-> map_ordered_lists_2d (const tail) world     (tail, (x, y)) -> map_ordered_lists_2d (const conductor) world     (empty, (x, y)) -> map_ordered_lists_2d (const empty) world     (conductor, (x, y))  -> map_ordered_lists_2d (const head) world 

(the function const takes value , turns function returns same value, regardless of argument.)


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -