From bed1ed24f3f388d3ba0ea7eb515772c73bf25597 Mon Sep 17 00:00:00 2001 From: Sergiu Ivanov Date: Fri, 29 Apr 2022 16:32:22 +0200 Subject: [PATCH] Add and use deftype and defpolytype. --- scribblings/functions.scrbl | 5 ++++- scribblings/networks.scrbl | 16 +++++++++++----- scribblings/utils.scrbl | 10 ++++++++-- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/scribblings/functions.scrbl b/scribblings/functions.scrbl index 31d105c..f726981 100644 --- a/scribblings/functions.scrbl +++ b/scribblings/functions.scrbl @@ -13,6 +13,9 @@ @(define-syntax-rule (ex . args) (examples #:eval functions-evaluator . args)) +@(define-syntax-rule (deftype . args) + (defidform #:kind "type" . args)) + @title[#:tag "functions"]{dds/functions: Formal Functions} @defmodule[dds/functions] @@ -457,7 +460,7 @@ Instances of @racket[tbf] have the type @racket[TBF]. } -@defidform[#:kind "type" TBF]{ +@deftype[TBF]{ The type of the instances of @racket[tbf]: diff --git a/scribblings/networks.scrbl b/scribblings/networks.scrbl index 582e7ef..3b13eb0 100644 --- a/scribblings/networks.scrbl +++ b/scribblings/networks.scrbl @@ -16,6 +16,12 @@ @(define-syntax-rule (ex . args) (examples #:eval networks-evaluator . args)) +@(define-syntax-rule (defpolytype . args) + (defform #:kind "polymorphic type" . args)) + +@(define-syntax-rule (deftype . args) + (defidform #:kind "type" . args)) + @title[#:tag "networks"]{dds/networks: Formal Dynamical Networks} @defmodule[(submod dds/networks typed)] @@ -27,21 +33,21 @@ This model can generalise Boolean networks, TBANs, multivalued networks, etc. @section[#:tag "networks-basics"]{Basic types} -@defform[#:kind "type" (State a)]{ +@defpolytype[(State a)]{ An immutable mapping (a hash table) assigning elements of type @racket[a] to the variables. A synonym of @racket[VariableMapping]. } -@defform[#:kind "type" (UpdateFunction a)]{ +@defpolytype[(UpdateFunction a)]{ An update function is a function computing a value from the given state. This is a synonym of the type @racket[(-> (State a) a)]. } -@defform[#:kind "type" (Domain a)]{ +@defpolytype[(Domain a)]{ A domain which is a subset of the type @racket[a]. @@ -49,7 +55,7 @@ A domain which is a subset of the type @racket[a]. } -@defform[#:kind "type" (DomainMapping a)]{ +@defpolytype[(DomainMapping a)]{ A domain mapping is a hash table mapping variables to the lists of values in their domains. @@ -66,7 +72,7 @@ Instances of @racket[network] have the type @racket[Network]. } -@defidform[#:kind "type" Network]{ +@deftype[Network]{ The type of the instances of @racket[Network]. diff --git a/scribblings/utils.scrbl b/scribblings/utils.scrbl index 9d917b3..47732b6 100644 --- a/scribblings/utils.scrbl +++ b/scribblings/utils.scrbl @@ -15,6 +15,12 @@ @(define-syntax-rule (ex . args) (examples #:eval utils-evaluator . args)) +@(define-syntax-rule (defpolytype . args) + (defform #:kind "type" . args)) + +@(define-syntax-rule (deftype . args) + (defidform #:kind "polymorphic type" . args)) + @title[#:tag "utils"]{dds/utils: Various Utilities} @defmodule[dds/utils] @@ -25,13 +31,13 @@ the package: evaluating sexps, manipulating lists, @section{Base types} -@defidform[#:kind "type" Variable]{ +@deftype[Variable]{ Any Racket symbol. Designates a variable in a discrete dynamical network. } -@defform[#:kind "type" (VariableMapping A)]{ +@defpolytype[(VariableMapping A)]{ An immutable mapping (a hash table) assigning elements of type @racket[A] to the variables.