Commit 0bd01a58 authored by Sandra Dylus's avatar Sandra Dylus

Adapt usage of predefined types in Exercise3

parent 4803187f
......@@ -106,7 +106,8 @@ We implemented functions `replaceTokenInRow` and `replaceTokenInField`. Reimplem
5) Now that we know about polymorphic structures, let us redefine the `Field` type as follows.
> type Field token = [[token]]
> -- type Field token = [[token]]
> type Field token = [] ([] token)
Here, instead of reusing the `Token`s defined in the last exercise, we use a type parameter in order to use the type synonym `Field` with abritrary values.
Reimplement the function `replaceTokenInField` once more using the predefined higher-order function `map` that works an arbitrary lists; note that for this concrete example, we reuse `Ex.Token`.
......@@ -116,12 +117,15 @@ Reimplement the function `replaceTokenInField` once more using the predefined hi
6) We also redefined `CoordMap` using polymorphic lists and pairs.
> type Coord = (Int,Int)
> type Coords = [Coord]
> -- type Coord = (Int,Int)
> type Coord = (,) Int Int
> -- type Coords = [Coord]
> type Coords = [] Coord
Based on this type synonym we define a type to represent `Coordinate`s as keys and arbitrary tokens as values in order to describe the positions of such tokens. A list of such pairs describes a figure.
> type Figure token = [(Coord, token)]
> -- type Figure token = [(Coord, token)]
> type Figure token = [] ((,) Coord token)
Here, we again use a type parameter `token` to use `Figure` with an abitrary type.
Using this type, we can visualise, for example, the following figure.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment