Note that there are some explanatory texts on larger screens.

plurals
  1. PO"Couldn't match expected type" error
    text
    copied!<p>Here is my code:</p> <pre><code>xandy :: Element_w_Coord Cell -&gt; Coord xandy (e, (x, y)) = (x, y) transition_world :: Ordered_Lists_2D Cell -&gt; Element_w_Coord Cell -&gt; Ordered_Lists_2D Cell transition_world world (cell, (x, y)) = case (cell, (x, y)) of (Head, (x, y))-&gt; map_Ordered_Lists_2D Tail world (Tail, (x, y)) -&gt; map_Ordered_Lists_2D Conductor world (Empty, (x, y)) -&gt; map_Ordered_Lists_2D Empty world (Conductor, (x, y)) -&gt; map_Ordered_Lists_2D Head world </code></pre> <p>And here is the error message:</p> <pre><code>Sources/Transitions/For_Ordered_Lists_2D.hs:33:43: Couldn't match expected type `Element_w_Coord e0 -&gt; Cell' with actual type `Cell' In the first argument of `map_Ordered_Lists_2D', namely `Tail' In the expression: map_Ordered_Lists_2D Tail world In a case alternative: (Head, (x, y)) -&gt; map_Ordered_Lists_2D Tail world </code></pre> <p>Anyone likes to tell me what's wrong with my code pls?</p> <p>Btw, here is the definition for </p> <pre><code>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 -&gt; b) -&gt; Ordered_Lists_2D e -&gt; Ordered_Lists_2D b map_Ordered_Lists_2D f world = case world of l: ls -&gt; map_line f l: map_Ordered_Lists_2D f ls [] -&gt; [] where map_line :: (Element_w_Coord e -&gt; b) -&gt; Sparse_Line e -&gt; Sparse_Line b map_line f line = Sparse_Line {y_pos = (y_pos line), entries = map_elements f (y_pos line) (entries line)} where map_elements :: (Element_w_Coord e -&gt; b) -&gt; Y_Coord -&gt; Placed_Elements e -&gt; Placed_Elements b map_elements f y elements = case elements of c: cs -&gt; Placed_Element {x_pos = (x_pos c), entry = f ((entry c), ((x_pos c), y))}: map_elements f y cs [] -&gt; [] </code></pre> <p>Thanks for anyone who can good me some advice XD</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload