In the routing section, the article says:
We can see that the RenderRoute class defines an associated data type providing the routes for our application.
What does associated data type mean? It means type families?
In the routing section, the article says:
We can see that the RenderRoute class defines an associated data type providing the routes for our application.
What does associated data type mean? It means type families?
Quoting code from the article:
instance RenderRoute HelloWorld where
data Route HelloWorld = HomeR
deriving (Show, Eq, Read)
renderRoute HomeR = ([], [])
As you can see Route
is an associated data type and yes, it means data families. Take a look at wiki example:
We define a type class whose instances are the types that we can use as keys in our generic maps:
class GMapKey k where data GMap k :: * -> * empty :: GMap k v lookup :: k -> GMap k v -> Maybe v insert :: k -> v -> GMap k v -> GMap k v
The interesting part is the associated data family declaration of the class. It gives a kind signature (here
* -> *
) for the associated data typeGMap k
- analogous to how methods receive a type signature in a class declaration.
type Content a
and what is it? –
Lentigo type families
and data families
? –
Lentigo © 2022 - 2024 — McMap. All rights reserved.
type
instead ofdata
like show in ocharles.org.uk/posts/2014-12-12-type-families.html – Lentigo