[Haskell-cafe] Restricted type classes

Daniel Fischer daniel.is.fischer at web.de
Tue Sep 7 04:21:04 EDT 2010


On Tuesday 07 September 2010 05:22:55, David Menendez wrote:
> On Mon, Sep 6, 2010 at 10:22 PM, wren ng thornton <wren at freegeek.org> 
wrote:
> > On 9/6/10 1:33 PM, David Menendez wrote:
> >> For that matter, can you even describe what pure is intended to do
> >> without reference to<*>  or join?
> >
> > As already stated: fmap f . pure = pure . f
>
> That's pretty general. For lists, the functions having that property
> include const [], \x -> [x,x], and repeat.
>
> In fact, I think *every* appropriately-typed function satisfies that
> law. Does anyone know of a counter-example?

class Functor f => Pointed f where
    point :: a -> f a
     -- satisfying fmap f . point = point . f

notQuitePure :: Pointed f => a -> f a
notQuitePure _ = point undefined

fmap (const True) . notQuitePure = point . const True

But I don't see how to violate that law without introducing undefined on 
the RHS.


More information about the Haskell-Cafe mailing list