[Haskell-cafe] Pointless functors
Matthew Brecknell
haskell at brecknell.org
Fri Mar 13 12:12:45 EDT 2009
Ross Paterson wrote:
> No. Choose an arbitrary element shape :: f () and define
> point x = fmap (const x) shape
Interesting. Is the arbitrariness of the shape some sort of evidence
that Pointed is not really a very useful class in its own right?
Certainly, the shape does matter if you plan to progress to non-trivial
Applicative or Monad instances. For example, the non-determinism monad
requires shape = [()], while the ZipList applicative functor requires
shape = repeat ().
Eugene Kirpichov wrote:
> 'An arbitrary element' means 'undefined will suffice'
> point x = fmap (const x) undefined
Well, that would rather limit the possible Applicative instances. :-)
(Consider the Applicative law: fmap g x = pure g <*> x)
Brent Yorgey wrote:
> Prelude> fmap (const 1) [()]
> [1]
> Prelude> fmap (const 1) undefined
> *** Exception: Prelude.undefined
True, but as far as I can tell, that doesn't violate any laws of the
Pointed class. To put it crudely, if [] is as good as [()], then how is
undefined any worse?
More information about the Haskell-Cafe
mailing list