[Haskell-cafe] Inferred type less polymorphic than expected

Joel Reymont joelr1 at gmail.com
Tue Nov 8 13:40:48 EST 2005


The road to hell is paved with good intentions. I sold this to the  
client as a "simple scripting language" and I have to deliver now,  
lest I loose my credibility. This were working quite well ... except  
the program is spending 50% of the time collecting garbage and  is  
shuffling a few Gb of memory while at it. All in the span of, say, 5  
minutes.

I decided to rewrite the pickling and the way I manage properties. I  
need dynamic records since I don't want the customer to deal with  
Haskell constructors, etc. What I want is described quite nicely in  
the HList library under extensible records. Problem is that I don't  
have the time to learn the library and convert everything. I think I  
don't but I'll give it another look. I already reinvented the wheel  
quite badly with prior pickling.

My records are formerly property lists and now maps. This lets me  
supply default values and let the customer pass in "keyword arguments".

On Nov 8, 2005, at 5:56 PM, Udo Stenzel wrote:

> This doesn't give you a (PU Props), but a (PU [exists a . a]) or
> something, which is bogus syntax, since the idea is already  
> nonsensical.
> You have to dismantle and create 'Prop's if you want to put them  
> into a
> list, and you forgot a M.fromList somewhere, too.

I did forgot the fromList somewhere but the idea makes a lot of sense  
to me. I'm storing the pickler when making the attribute. Let me know  
if I missed something!

data Attr a = Attr String
     (a -> Dynamic, Dynamic -> Maybe a)
     (PU a)

and

playersFlop :: Attr Word8 = makeAttr "playersFlop" byte

So at the time of unpickling I'm using exactly the pickler that was  
stored when creating the attribute.

	Thanks, Joel

--
http://wagerlabs.com/







More information about the Haskell-Cafe mailing list