More type design questions

Konrad Hinsen
Tue, 19 Aug 2003 12:31:08 +0200

On Monday 18 August 2003 22:24, Remi Turk wrote:

> Would this suffice?

I guess so - it looks like what Brandon proposed, up to cosmetic differen=

Still, those cosmetic differences give me the chance to ask another quest=

> instance Functor Vector where
>     fmap f (Vector x y z)
>                     =3D Vector (f x) (f y) (f z)

Under what conditions would Haskell programmers make some type an instanc=
e of=20
Functor? Whenever it could possibly be done (i.e. whenever fmap makes sen=
Or just when fmap would be used frequently for some type?

In this case, I can't think of any other use for fmap than defining scala=
multiplication. There is no other vector operation that applies some=20
operation to each element and returns another vector. Would it be conside=
"better" to define fmap nevertheless, and then use it in scalar=20
multiplication, or would one prefer to define the mapping operation into =
only application?