tel / purescript-intmaps

Big-endian Patricia tree IntMap implementation in Purescript.
7 stars 7 forks source link

Lazy IntMap #5

Open paf31 opened 8 years ago

paf31 commented 8 years ago

Would you be interested in adding a lazy IntMap implementation? It would really help to simplify some things in purescript-memoize related to memoizing functions of integers.

Thanks!

tel commented 8 years ago

I'd be interested in that, but I'm not sure I understand laziness well enough in Purescript at the moment. Is it best just to read the information on purescript-lazy?

paf31 commented 8 years ago

purescript-lists currently defines two different modules, one strict, and one lazy using purescript-lazy. It's difficult to share one implementation and keep things stack-safe, while keeping all lazy operations lazy. So perhaps that's the way to go here as well.

tel commented 8 years ago

Hm, I'll take a look. Thanks!

bagl commented 8 years ago

I'm looking into this one...

bagl commented 8 years ago

Help needed with testing

For map the Strict version throws and Lazy does not in the following code (not in psci however, don't know why):

import Control.Monad.Eff.Exception.Unsafe (unsafeThrow)
import Data.IntMap.Lazy (singleton)
import Prelude (($), map)

m = map (_ $ 1) $ singleton 1 (\_ -> unsafeThrow "ERR")

Is this sufficient?

How about testing insert?

bagl commented 8 years ago

ping

Is it even possible to test insert on it's own for laziness?