cartazio / strict-identity

strict identity monad, handy for writing high performance strict code sanely
BSD 3-Clause "New" or "Revised" License
7 stars 1 forks source link

Applicative may not be strict enough #4

Open kvanbere opened 10 years ago

kvanbere commented 10 years ago

Changing the Applicative instance to something like this may have been intended;

instance Applicative Identity where
    pure !x = return x
    {-# INLINE pure #-}
    (<*>) !a !b = do   !f <- a ; !v <- b ; return $! (f $! v)
    {-# INLINE (<*>) #-}

I'm not completely sure.

cartazio commented 10 years ago

its unclear, it may be that in some sense its impossible to write the right strict applicative and functor instances!

cartazio commented 10 years ago

i'll stare at this more this evening / later this week, may write error instead :)