[m-users.] Typeclasses question
Volker Wysk
post at volker-wysk.de
Tue Oct 21 18:01:27 AEDT 2025
Am Dienstag, dem 21.10.2025 um 08:44 +0200 schrieb Volker Wysk:
> Hi!
>
> In Haskell, not only types can be members of a typeclass, but also type
> constructors. Here's an example:
>
> https://downloads.haskell.org/ghc/latest/docs/libraries/base-4.21.0.0-8bb5/Data-Functor.html
>
> I want to build this typeclass, following the Haskell typeclass "Functor":
>
> :- typeclass functor(A) where [
> func fmap(func(X) = Y, A(X)) = A(Y)
> ].
>
> "A" is a type constructor.
>
> With this, you could do, for instance:
>
> fmap(func(X) = X+1, maybe(2))
>
> and get maybe(3).
... no, I mean:
fmap(func(X) = X+1, yes(2))
and get yes(3).
V.
More information about the users
mailing list