[racket] fingertree / nested datatype

From: Anthony Carrico (acarrico at memebeam.org)
Date: Wed Apr 10 21:27:25 EDT 2013

I've been reading about fingertrees, and I figure the best way to
understand is to implement. This is my first experience with typed
racket. Are nested datatypes supported?

This is my first try:

typed-fingertree.rkt:19:48: Type Checker: Structure type constructor
Deep applied to non-regular arguments ((U (Node2 a) (Node3 a)))

#lang typed/racket

(struct: (a) Digit1 ((v0 : a)))
(struct: (a) Digit2 ((v0 : a) (v1 : a)))
(struct: (a) Digit3 ((v0 : a) (v1 : a) (v2 : a)))
(struct: (a) Digit4 ((v0 : a) (v1 : a) (v2 : a) (v3 : a)))
(define-type (Digit a) (U (Digit1 a) (Digit2 a) (Digit3 a) (Digit4 a)))

(struct: (a) Node2 ((v0 : a) (v1 : a)))
(struct: (a) Node3 ((v0 : a) (v1 : a) (v2 : a)))
(define-type (Node a) (U (Node2 a) (Node3 a)))

(struct: Empty ())
(struct: (a) Single ((v : a)))
(struct: (a) Deep ((left : (Digit a))
		   (spine : (Fingertree (Node a)))
		   (right : (Digit a))))

(define-type (Fingertree a) (U Empty (Single a) (Deep a)))

Thank you!

-- 
Anthony Carrico

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 262 bytes
Desc: OpenPGP digital signature
URL: <http://lists.racket-lang.org/users/archive/attachments/20130410/3fa942e3/attachment.sig>

Posted on the users mailing list.