On Tue, Jun 7, 2011 at 4:57 PM, John Clements <cleme...@brinckerhoff.org> wrote: > > On Jun 7, 2011, at 4:26 PM, Carl Eastlund wrote: > >> John, >> >> You had an easy time with + because it is monomorphic. You are having >> trouble applying one polymorphic function (map) to another (list or >> list2). Instantiate one or both functions explicitly, and Typed >> Racket won't get confused by the guesswork. >> >> Also, T ... i in a type does not mean T ... followed by i. It means T >> ... *indexed* by i. It's clarifying what the ... ranges over. > > Awesome! Many thanks. Next question. I'm reading sexps from a file, so > typed/racket insists that I check their shape before using them. That's > fine, but I find myself unable to define the "(Pairof Any (Pairof Any Null)) > predicate the way I'd expect it to be defined:
What you actually want to use here is `define-predicate', which will automatically define the predicate you want given the type. > > (: listoflength2? (Any -> Boolean : (Pairof Any (Pairof Any Null)))) > (define (listoflength2? a) > (and (pair? a) (pair? (cdr a)) (null? (cddr a)))) This definition will eventually typecheck, but not yet. :) -- sam th sa...@ccs.neu.edu _________________________________________________ For list-related administrative tasks: http://lists.racket-lang.org/listinfo/dev