Note that there are some explanatory texts on larger screens.

plurals
  1. POTrying to make the wireworld move by fmap (transition) but it shows me an error somehow (Haskell)
    primarykey
    data
    text
    <p>The same as my last question, im asked to make a wireworld by ordered lists, So i have written the following codes,(all of the function in the code is somehow defined in other modules, so, dont worry about that XD, feel free to ask me if u want to have a look at those "predefined funcs") however when i run it on terminal, it shows a error, here is the code:</p> <pre><code>module Transitions.For_Ordered_Lists_2D ( transition_world -- :: Ordered_Lists_2D Cell -&gt; Sparse_Line Cell ) where import Data.Cell (Cell (Head, Tail, Conductor, Empty)) import Data.Coordinates import Data.Ordered_Lists_2D -- Replace this function with something more meaningful: xandy :: Element_w_Coord Cell -&gt; Coord xandy (e, (x, y)) = (x, y) transition_sc :: Ordered_Lists_2D Cell -&gt; Placed_Elements Cell -&gt; Sparse_Line Cell transition_sc world pec = case world of Sparse_Line{y_pos = y, entries = xline}: rest_of_sparse_lines -&gt; case pec of Placed_Element{x_pos = x, entry = Head} : rest_of_placed_elements -&gt; (Sparse_Line{y_pos = y, entries = Placed_Element{x_pos = x, entry = Tail} : rest_of_placed_elements}) Placed_Element{x_pos = x, entry = Tail} : rest_of_placed_elements -&gt; (Sparse_Line{y_pos = y, entries = Placed_Element{x_pos = x, entry = Conductor} : rest_of_placed_elements}) Placed_Element{x_pos = x, entry = Empty} : rest_of_placed_elements -&gt; (Sparse_Line{y_pos = y, entries = Placed_Element{x_pos = x, entry = Empty} : rest_of_placed_elements}) Placed_Element{x_pos = x, entry = Conductor} : rest_of_placed_elements |element_occurrence Head neighbours == 1 || element_occurrence Head neighbours == 2 -&gt; (Sparse_Line{y_pos = y, entries = Placed_Element{x_pos = x, entry = Head} : rest_of_placed_elements}) |otherwise -&gt; (Sparse_Line{y_pos = y, entries = Placed_Element{x_pos = x, entry = Conductor} : rest_of_placed_elements}) where neighbours = local_elements (xandy (Conductor, (x, y))) world transition_world :: Ordered_Lists_2D Cell -&gt; Ordered_Lists_2D Cell transition_world world = fmap (transition_sc world) world --the end --the end --the end </code></pre> <p>however it shows me the following error:</p> <pre><code>u5363876@n114lt20:~/Desktop/lalal$ ./make_Wireworld [10 of 20] Compiling Transitions.For_Ordered_Lists_2D ( Sources/Transitions/For_Ordered_Lists_2D.hs, x86_64/Transitions/For_Ordered_Lists_2D.o ) Sources/Transitions/For_Ordered_Lists_2D.hs:35:53: Couldn't match expected type `Placed_Elements Cell' with actual type `Sparse_Line Cell' Expected type: [Placed_Elements Cell] Actual type: Ordered_Lists_2D Cell In the second argument of `fmap', namely `world' In the expression: fmap (transition_sc world) world </code></pre> <p>Im totally confused by this error Thank you in advance for anyone who can help me.</p> <p>@dave4420 here is the definition for Placed_Elements and Sparse_Lines</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] </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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