ADT.js

141 views
Skip to first unread message

Rehno Lindeque

unread,
Mar 30, 2012, 4:46:48 PM3/30/12
to roy...@googlegroups.com
Hi, I'm working on a algebraic data types library for javascript right now, because I desperately need it for a couple projects I'm working on. It's probably a bit unconventional but it will work directly with Haskell ADT's serialized with the standard Show and Read derivations.

I don't know if it will be relevant to Roy but I thought I should mention it. I'd be very pleased if it turned out that the two "just works" together. 

Cheers,
Rehno

PS it's not nearly ready yet, I reckon I probably need another week or two to get it done https://github.com/rehno-lindeque/adt.js. I'll post here again once I've got a working implementation.

Brian McKenna

unread,
May 6, 2012, 8:24:23 PM5/6/12
to roy...@googlegroups.com
Hi Rehno,

Very late reply :)

I'm a fan of ADT.js. I've taken a look at it previously to see if it
was suitable for Roy.

There's a few problems I can see with using it. Firstly, one of Roy's
goals is to compile to code with no dependencies. It wouldn't be
lightweight to inline any of ADT.js, right?

Secondly, I couldn't see a way to give static types to ADT.js due to
the dynamic way that it creates tags. I guess that's logic that Roy's
compiler would have to do.

Anyway, it's an awesome library that seems to be very powerful. I'll
definitely keep watching the project.

Thanks

Rehno Lindeque

unread,
May 9, 2012, 5:26:08 AM5/9/12
to roy...@googlegroups.com
Thanks Brian, and no worries :)

What I had in mind originally was that adt.js and Roy could simply share the same internal representation for data boxed/tagged with a constructor. Actually I still haven't quite settled on a finalized internal representation for data yet because I'd still like to do some benchmarks first. At the moment data tagged by a constructor looks just like an ordinary array with the zero'th element set to the constructor tag and an extra property called `_ADTData` to identify it as being derived from a data type but I'm not yet convinced about this since it feels a bit ugly to drag along that extra property. I have one alternate idea that I'm trying out at the moment.

It's possible that perhaps I'll try to imitate what Roy does with its boxed representation in the future if that makes sense. I think that Roy's goal for its data types might be a bit different from adt.js though which has a more loose interpretation right now. Anyway, let's see how things turn out!

Thanks for taking a look at ADT.js, I appreciate it!

P.S. I recently noticed another adt.js on the web (http://w3future.com/weblog/stories/2008/06/16/adtinjs.xml), I'm afraid that that one isn't actually me...

On Sunday, May 6, 2012 5:24:23 PM UTC-7, Brian McKenna wrote:
Hi Rehno,

Very late reply :)

I'm a fan of ADT.js. I've taken a look at it previously to see if it
was suitable for Roy.

There's a few problems I can see with using it. Firstly, one of Roy's
goals is to compile to code with no dependencies. It wouldn't be
lightweight to inline any of ADT.js, right?

Secondly, I couldn't see a way to give static types to ADT.js due to
the dynamic way that it creates tags. I guess that's logic that Roy's
compiler would have to do.

Anyway, it's an awesome library that seems to be very powerful. I'll
definitely keep watching the project.

Thanks

Reply all
Reply to author
Forward
0 new messages