sharing datatypes between Duck and Haskell

1 view
Skip to first unread message

Geoffrey Irving

unread,
Sep 6, 2009, 9:04:21 AM9/6/09
to Dylan Alex Simon, duck...@googlegroups.com
Since the memory layout involves closures, and therefore types,
expressions, overloads, variances, primitives, etc., there are going
to a lot of algebraic datatypes shared between Duck and Haskell.
These types are going to be in rapid flux, so having two copies of
them with hand-written marshaling back and forth would be extremely
painful. If we want to avoid duplicate definitions, I see three
options:

1. Don't expose these structures as native duck types. Instead, turn
them into StablePtr's and make them opaque in the Duck memory layout.
This is unpleasant, so I'm mentioning it only for completeness.
2. Declare the types in Haskell and use template Haskell to generate
the corresponding Duck datatypes and marshaling functions.
3. Declare the types in Duck and generate the corresponding Haskell
definitions and marshaling functions via pretty printing.

(3) is, of course, the coolest option. However, it requires a
bootstrapping step since the basic data types used by the compiler
would be generated by the compiler itself. These generated files
would be checked back into git so that the bootstrap is built into the
source code.

Geoffrey

Reply all
Reply to author
Forward
0 new messages