utils: Remove type annotations.

I am very early in my project, and I have already spent literal days
trying to make the types fit together.

I'm trying contracts next.
This commit is contained in:
Sergiu Ivanov 2020-02-19 22:49:50 +01:00
parent 9cbfcfca4b
commit 404362a91c
3 changed files with 7 additions and 14 deletions

4
bn.rkt
View file

@ -1,4 +1,4 @@
#lang typed/racket #lang racket
;;; dds/bn ;;; dds/bn
@ -10,8 +10,6 @@
(require "utils.rkt") (require "utils.rkt")
(provide (provide
;; Types
Variable State UpdateFunc Network
;; Functions ;; Functions
update make-state make-bn-funcs update-func-form->update-func update make-state make-bn-funcs update-func-form->update-func
bn-form->bn make-bn-forms bn-form->bn make-bn-forms

View file

@ -1,8 +1,8 @@
#lang typed/racket #lang racket
;;; Tests for dds/utils. ;;; Tests for dds/utils.
(require typed/rackunit "utils.rkt") (require rackunit "utils.rkt")
(test-case "HashTable Injection" (test-case "HashTable Injection"
(test-case "auto-hash-ref/explicit" (test-case "auto-hash-ref/explicit"

View file

@ -1,4 +1,4 @@
#lang typed/racket #lang racket
;;; dds/utils ;;; dds/utils
@ -96,16 +96,14 @@
;;; [z 1]) ;;; [z 1])
;;; (eval-with ht '(+ b z a 1))) ;;; (eval-with ht '(+ b z a 1)))
;;; ;;;
(: eval-with (-> (HashTable Symbol Any) Any AnyValues))
(define (eval-with ht expr) (define (eval-with ht expr)
(parameterize ([current-namespace (current-namespace)]) (parameterize ([current-namespace (make-base-namespace)])
(hash-for-each ht (lambda (x val) (hash-for-each ht (lambda (x val)
(namespace-set-variable-value! x val))) (namespace-set-variable-value! x val)))
(eval expr))) (eval expr)))
;;; Same as eval-with, but returns only the first value produced by ;;; Same as eval-with, but returns only the first value produced by
;;; the evaluated expression. ;;; the evaluated expression.
(: eval-with1 (-> (HashTable Symbol Any) Any Any))
(define (eval-with1 ht expr) (define (eval-with1 ht expr)
(let ([vals (call-with-values (λ () (eval-with ht expr)) (let ([vals (call-with-values (λ () (eval-with ht expr))
(λ vals vals))]) (λ vals vals))])
@ -118,13 +116,10 @@
;;; Produces a list of symbols appearing in the quoted expression ;;; Produces a list of symbols appearing in the quoted expression
;;; passed in the first argument. ;;; passed in the first argument.
(: extract-symbols (-> Any (Listof Symbol)))
(define (extract-symbols form) (define (extract-symbols form)
(cond (cond
[(symbol? form) [(symbol? form)
(list (cast form Symbol))] (list form)]
[(list? form) [(list? form)
(cast (flatten (for/list : (Listof (Listof Symbol)) (flatten (for/list ([x form]) (extract-symbols x)))]
([x (cast form (Listof Any))])
(extract-symbols x))) (Listof Symbol))]
[else '()])) [else '()]))