Add the type Domain.
This commit is contained in:
parent
be729f6ca8
commit
e867a86d4d
2 changed files with 13 additions and 4 deletions
|
@ -8,21 +8,22 @@
|
||||||
(require typed/rackunit))
|
(require typed/rackunit))
|
||||||
|
|
||||||
(provide
|
(provide
|
||||||
State UpdateFunction DomainMapping
|
State UpdateFunction Domain DomainMapping
|
||||||
(struct-out network) Network
|
(struct-out network) Network
|
||||||
|
|
||||||
make-same-domains make-boolean-domains make-boolean-network)
|
make-same-domains make-boolean-domains make-boolean-network)
|
||||||
|
|
||||||
(define-type (State a) (VariableMapping a))
|
(define-type (State a) (VariableMapping a))
|
||||||
(define-type (UpdateFunction a) (-> (State a) a))
|
(define-type (UpdateFunction a) (-> (State a) a))
|
||||||
(define-type (DomainMapping a) (VariableMapping (Listof a)))
|
(define-type (Domain a) (Listof a))
|
||||||
|
(define-type (DomainMapping a) (VariableMapping (Domain a)))
|
||||||
|
|
||||||
(struct (a) network ([functions : (VariableMapping (UpdateFunction a))]
|
(struct (a) network ([functions : (VariableMapping (UpdateFunction a))]
|
||||||
[domains : (DomainMapping a)])
|
[domains : (DomainMapping a)])
|
||||||
#:transparent
|
#:transparent
|
||||||
#:type-name Network)
|
#:type-name Network)
|
||||||
|
|
||||||
(: make-same-domains (All (a) (-> (Listof Variable) (Listof a)
|
(: make-same-domains (All (a) (-> (Listof Variable) (Domain a)
|
||||||
(DomainMapping a))))
|
(DomainMapping a))))
|
||||||
(define (make-same-domains vars domain)
|
(define (make-same-domains vars domain)
|
||||||
(for/hash ([var vars]) : (DomainMapping a)
|
(for/hash ([var vars]) : (DomainMapping a)
|
||||||
|
|
|
@ -41,6 +41,14 @@ state. This is a synonym of the type @racket[(-> (State a) a)].
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@defform[#:kind "type" (Domain a)]{
|
||||||
|
|
||||||
|
A domain which is a subset of the type @racket[a].
|
||||||
|
|
||||||
|
@racket[(Domain a)] is a synonym of @racket[(Listof a)].
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@defform[#:kind "type" (DomainMapping a)]{
|
@defform[#:kind "type" (DomainMapping a)]{
|
||||||
|
|
||||||
A domain mapping is a hash table mapping variables to the lists of values in
|
A domain mapping is a hash table mapping variables to the lists of values in
|
||||||
|
@ -80,7 +88,7 @@ The type of the instances of @racket[Network].
|
||||||
@section{Constructing networks}
|
@section{Constructing networks}
|
||||||
|
|
||||||
@defproc[(make-same-domains [vars (Listof Variable)]
|
@defproc[(make-same-domains [vars (Listof Variable)]
|
||||||
[domain (Listof a)])
|
[domain (Domain a)])
|
||||||
(DomainMapping a)]{
|
(DomainMapping a)]{
|
||||||
|
|
||||||
Makes a hash set mapping all variables to a single domain.
|
Makes a hash set mapping all variables to a single domain.
|
||||||
|
|
Loading…
Reference in a new issue