[Haskell-cafe] liftN
Arjun Comar
nrujac at gmail.com
Thu Oct 17 18:05:30 UTC 2013
This is slightly off-topic, but you might be interested in the
monad-layers<http://hackage.haskell.org/package/layers-0.1/docs/Documentation-Layers-Overview.html>package
that obviates the need for a function like liftN.
Thanks,
Arjun
On Thu, Oct 17, 2013 at 1:44 PM, Wvv <vitea3v at rambler.ru> wrote:
> Thank you!
>
> Unfortunately, liftN always take same number of arguments.
> So, polyvariadic "magic" don't work here.
>
>
> wren ng thornton wrote
> > On 10/16/13 5:06 PM, Wvv wrote:
> >> I try to write a function "liftN", but I'm not satisfied with result.
> >>
> >> lift :: (MonadTrans t) => Monad m => m a -> t m a
> >>
> >> liftN n
> >> | n < 1 = error "liftN: n<1"
> >> | n == 1 = lift
> >> | otherwise = lift . (liftN (n-1))
> >>
> >> 1) I know(?), that it is impossible to write liftN now: typechecker
> can't
> >> decide which signature it is.
> >
> > You should check out the solutions for encoding polyvariadic functions,
> > e.g.
> >
> > *
> > <
> http://community.haskell.org/~wren/wren-extras/dist/doc/html/wren-extras/Data-List-ZipWithN.html>
> ;
> > * <http://okmij.org/ftp/Haskell/polyvariadic.html#polyvartype-fn>
> > * <
> http://paczesiowa.blogspot.com/2010/03/generalized-zipwithn.html>
> > *
> > <
> http://hackage.haskell.org/package/TypeCompose-0.9.9/docs/Data-Zip.html>
> ;
> >
> > --
> > Live well,
> > ~wren
> > _______________________________________________
> > Haskell-Cafe mailing list
>
> > Haskell-Cafe@
>
> > http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>
>
>
>
> --
> View this message in context:
> http://haskell.1045720.n5.nabble.com/liftN-tp5738612p5738648.html
> Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.
> _______________________________________________
> 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/20131017/8ed5b709/attachment.html>
More information about the Haskell-Cafe
mailing list