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 differences.

Still, those cosmetic differences give me the chance to ask another question.

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

Under what conditions would Haskell programmers make some type an instance of 
Functor? Whenever it could possibly be done (i.e. whenever fmap makes sense)? 
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 scalar 
multiplication. There is no other vector operation that applies some 
operation to each element and returns another vector. Would it be considered 
"better" to define fmap nevertheless, and then use it in scalar 
multiplication, or would one prefer to define the mapping operation into its 
only application?

Konrad.

_______________________________________________
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to