Returning to this after a long delay...

On Sat, Nov 11, 2017 at 01:34:05PM -0500, Matthias Felleisen wrote:

> > (Context: I only actually intend to use `store' with a single type, but I
> > want to define that type in a separate module.  Since the type's definition
> > refers to `addr', I made `store' polymorphic to break the cyclical
> > dependency.)
> This of course calls for Typed Units, which are now available in Typed Racket 
> thanks to Daniel Feltey.
> It might be worth trying it out — Matthias

I started to take a look at this, and I'm having trouble seeing how this
would work.  In particular, I'm not seeing how to include a type in a
signature.  The following isn't syntactically correct:

    (define-signature store^
      [empty-store : Store]
      [alloc : (Store Integer -> (Values Store Addr))]
      [alloc* : (Store (Listof Integer) -> (Values Store (Listof Addr)))]
      [deref : (Store Addr -> Integer)]
      [update : (Store Addr Integer -> Store)])

The presence of the bare `Addr' on the second line causes a syntax error,
as one would expect from the docs.  Purely at random, I tried the

    (define-signature store^
      [Addr : Type]
      [Store : Type]
      [empty-store : Store]
      [alloc : (Store Integer -> (Values Store Addr))]
      [alloc* : (Store (Listof Integer) -> (Values Store (Listof Addr)))]
      [deref : (Store Addr -> Integer)]
      [update : (Store Addr Integer -> Store)])

This doesn't compile either (no surprise there), but it yields an
interesting error message:

    define-signature: expected sig-var-form or expected sig-type-form
      at: Addr
      in: ...

The mention of `sig-type-form' in the error message suggests that it is
possible to do this, but I'm not seeing the concrete syntax for this
described anywhere.  Am I overlooking something?


Next: the signatures above only allow storing Integers in a Store.  I'd
assumed that I'd eventually want to import the value type into the store@
unit -- but then how do I include specify that type in store^ ?  In ML, I'd
use a signature plus a 'with', but I don't see an equivalent to that here.

I'm starting to think that my base assumption (that Typed Units are more or
less equivalent to ML signatures, structures, and functors) is way off.


You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
For more options, visit

Reply via email to