[Haskell-cafe] distinguish functions from non-functions in a class/instances

Ryan Ingram ryani.spam at gmail.com
Wed Dec 5 17:21:07 EST 2007


No, that doesn't work; it's close, but not quite.  liftM doesn't have the
right type signature.

liftM :: Monad m => (a -> r) -> (m a1 -> m r)

What would work is if you could define a function
liftLast :: Monad m => (a0 -> a1 -> ... -> aN -> r) -> (a0 -> a1 -> ... ->
aN -> m r)

then

nary' f = runIdentity . nary (liftLast f)

  -- ryan


On 12/5/07, Dan Weston <westondan at imageworks.com> wrote:
>
> Wouldn't any isomorphism do (like the Identity monad)? How about
>
> nary' f = runIdentity . nary (liftM f) . return
>
>
> Brandon S. Allbery KF8NH wrote:
> >
> > On Dec 5, 2007, at 16:00 , Philipp N. wrote:
> >
> >> the odd thing is. you can get this to work, if you have a terminating
> >> type
> >> as result type (for example (IO x)). then you can work with all types
> (IO
> >> x), (a -> IO x), (a -> b -> IO x), ...
> >>
> >> but i don't want this delimiter IO! any ideas?
> >
> > Use ST instead?  (just tossing ideas in the wind...)
> >
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20071205/87197a9b/attachment.htm


More information about the Haskell-Cafe mailing list