Attempt to make it work without metafunctions, but I think it's going to be difficult to use
This commit is contained in:
parent
a103d48aaf
commit
4b9d7cba22
|
@ -1,6 +1,6 @@
|
||||||
#lang type-expander
|
#lang type-expander
|
||||||
|
|
||||||
(require "../traversal.hl.rkt"
|
(require "traversal-util.rkt" ;"../traversal.hl.rkt"
|
||||||
"ck.rkt")
|
"ck.rkt")
|
||||||
|
|
||||||
(define-type Foo (Listof String))
|
(define-type Foo (Listof String))
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#lang typed/racket
|
#lang typed/racket
|
||||||
|
|
||||||
(require "../traversal.hl.rkt"
|
(require "traversal-util.rkt" ;"../traversal.hl.rkt"
|
||||||
type-expander
|
type-expander
|
||||||
phc-adt
|
phc-adt
|
||||||
"ck.rkt"
|
"ck.rkt"
|
||||||
|
|
22
test/traversal-util.rkt
Normal file
22
test/traversal-util.rkt
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
#lang typed/racket
|
||||||
|
(require (for-syntax syntax/parse
|
||||||
|
syntax/parse/experimental/template
|
||||||
|
type-expander/expander)
|
||||||
|
"../traversal.hl.rkt")
|
||||||
|
|
||||||
|
(provide define-fold)
|
||||||
|
|
||||||
|
(define-syntax define-fold
|
||||||
|
(syntax-parser
|
||||||
|
[(_ _function-name:id
|
||||||
|
_type-name:id
|
||||||
|
whole-type:type
|
||||||
|
_type-to-replaceᵢ:type ...)
|
||||||
|
(with-folds
|
||||||
|
(λ ()
|
||||||
|
(template
|
||||||
|
(begin
|
||||||
|
(define-type _type-name
|
||||||
|
(∀-replace-in-type whole-type _type-to-replaceᵢ ...))
|
||||||
|
(define _function-name
|
||||||
|
(λ-replace-in-instance whole-type _type-to-replaceᵢ ...))))))]))
|
|
@ -389,7 +389,7 @@ where @racket[foldl-map] is defined as:
|
||||||
(for-meta 2 phc-toolkit/untyped)
|
(for-meta 2 phc-toolkit/untyped)
|
||||||
(for-meta 2 syntax/parse))
|
(for-meta 2 syntax/parse))
|
||||||
|
|
||||||
(provide define-fold
|
(provide with-folds
|
||||||
(for-syntax replace-in-instance)
|
(for-syntax replace-in-instance)
|
||||||
(for-syntax replace-in-type))
|
(for-syntax replace-in-type))
|
||||||
<foldl-map>
|
<foldl-map>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user