Proposal: Add a strict version of <$> for monads

Roman Cheplyaka roma at ro-che.info
Sat Nov 30 11:05:06 UTC 2013


No. Evaluation of your 'strictify' function will be delayed for the very
same reason that evaluation of 'f' is delayed in the first place.

It doesn't matter what 'strictify' *does* if it's not even evaluated.

* Nicolas Trangez <nicolas at incubaid.com> [2013-11-30 02:11:02+0100]
> I'm without a doubt overlooking something, but couldn't this be (otoh)
> 
>     fmap' :: Functor f => (a -> b) -> f a -> f b
>     fmap' f = fmap (strictify f)
>       where
>         strictify s = (($!) id) . s
> 
> Nicolas
> On Nov 30, 2013 12:11 AM, "Edward Kmett" <ekmett at gmail.com> wrote:
> 
> > Figure out how to write one using either of those APIs, and I'll be quite
> > impressed. =)
> >
> > I personally use this quite often when working in a monad, in lieu of
> > `return $!` games.
> >
> > The argument for implementing a version of it in terms of Monad and not
> > some new class off to the side of the class hierarchy that Monad doesn't
> > subclass is that, frankly, if such a thing existed, I'd still have to use
> > this combinator anyways when working with a transformer stack, etc. and
> > would derive little benefit.
> >
> > -Edward
> >
> >
> > On Fri, Nov 29, 2013 at 12:03 PM, Carter Schonwald <
> > carter.schonwald at gmail.com> wrote:
> >
> >> could someone explain to me why this <$!> would be for monads rather
> >> being more generally also for functors or applicatives?
> >>
> >>
> >> On Fri, Nov 29, 2013 at 10:35 AM, Johan Tibell <johan.tibell at gmail.com>wrote:
> >>
> >>> I'm trying to figure out whether this is a property of the functor
> >>> itself. I guess it is, but at the same time it seems somewhat orthogonal
> >>> whether to `seq` some value`.
> >>>
> >>>
> >>> On Fri, Nov 29, 2013 at 3:50 PM, Twan van Laarhoven <twanvl at gmail.com>wrote:
> >>>
> >>>> On 29/11/13 12:23, Johan Tibell wrote:
> >>>>
> >>>>> On Fri, Nov 29, 2013 at 1:19 PM, Twan van Laarhoven <twanvl at gmail.com
> >>>>> <mailto:twanvl at gmail.com>> wrote:
> >>>>>
> >>>>>     I don't like that this function is implemented for Monads, I think
> >>>>> that it
> >>>>>     makes sense for some other functors as well. Though to do this
> >>>>> 'properly' we
> >>>>>     would probably end up with another typeclass "StrictFunctor" or
> >>>>> something,
> >>>>>     and that is perhaps too much unnecessary complexity.
> >>>>>
> >>>>>
> >>>>> Do you have an example of such a functor?
> >>>>>
> >>>>> -- Johan
> >>>>>
> >>>>
> >>>> The first thing that came to mind was ZipList. Perhaps a more realistic
> >>>> example would be parsing combinator or FRP libraries that are applicative
> >>>> but not monadic.
> >>>>
> >>>>
> >>>> Twan
> >>>>
> >>>
> >>>
> >>> _______________________________________________
> >>> Libraries mailing list
> >>> Libraries at haskell.org
> >>> http://www.haskell.org/mailman/listinfo/libraries
> >>>
> >>>
> >>
> >> _______________________________________________
> >> Libraries mailing list
> >> Libraries at haskell.org
> >> http://www.haskell.org/mailman/listinfo/libraries
> >>
> >>
> >
> > _______________________________________________
> > Libraries mailing list
> > Libraries at haskell.org
> > http://www.haskell.org/mailman/listinfo/libraries
> >
> >

> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://www.haskell.org/mailman/listinfo/libraries

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://www.haskell.org/pipermail/libraries/attachments/20131130/f7a8159c/attachment.sig>


More information about the Libraries mailing list