Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file intf_lang.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276(** Module types useful for metaprogramming. *)(** Abstraction for standard boilerplate *)moduletypeStd=sigtype'amtypetvalcompare:tm->tm->intmvalequal:tm->tm->boolmvalpp:Format.formatterm->tm->unitmvalhash:tm->intmend(** Empty abstraction. *)moduletypeEmpty=sig(** ['a m] is the type of programs computing a value of type ['a] *)type'amend(** Abstraction for sequencing. Expected to be associative. *)moduletypeSequencing=sigtype'am(** Non-binding sequencing construct. *)valseq:unitm->(unit->'am)->'am(** Binding sequencing construct. *)val(let*):'am->('am->'bm)->'bmvalunit:unitmend(** Abstraction for loops. *)moduletypeLoop=sigtype'am(** The type of loop indices. *)typeindex(** [for_ ~start ~stop f] is a for loop, iterating [f] in
the interval [[start;stop]] in order. *)valfor_:start:indexm->stop:indexm->(indexm->unitm)->unitm(** While loop. *)valwhile_:cond:(unit->boolm)->(unit->unitm)->unitmend(** Abstraction for constants. *)moduletypeConst=sigtype'am(** The type of cosntants. *)typet(** Injects a constant from the meta to the object language. *)valconst:t->tmend(** Abstraction for abstraction :) *)moduletypeLambda=sigtype'am(** Lambda-abstraction. *)vallam:('am->'bm)->('a->'b)m(** Function application. *)valapp:('a->'b)m->'am->'bmend(** Abstraction for products. *)moduletypeProduct=sigtype'am(** Product-forming. *)valprod:'am->'bm->('a*'b)m(** First projection. *)valfst:('a*'b)m->'am(** Last projection. *)valsnd:('a*'b)m->'bmend(** Abstraction for monomorphic storage. *)moduletypeStorage=sigtype'am(** The type of mutable storage. *)typet(** The type of data stored in the storage. *)typeelt(** [create v] creates a mutable storage with initial content [v]. *)valcreate:eltm->tm(** Update a mutable storage. *)valset:tm->eltm->unitm(** Get the current value in a mutable storage. *)valget:tm->eltmend(** Abstraction for booleans. *)moduletypeBool=sigtype'amvaltrue_:boolmvalfalse_:boolmval(||):boolm->boolm->boolmval(&&):boolm->boolm->boolm(** [dispatch cond branches] constructs an if-then-else branching
expression. *)valdispatch:boolm->(bool->'am)->'amend(** Abstraction for enums. *)moduletypeEnum=sigtype'am(** The type of enumerations. *)typet(** All cases in the enumeration.*)valall:tarray(** [enum x] is the index of [x] in [all]. *)valenum:t->int(** Injects a case of the enumeration from the meta to the object language. *)valconst:t->tm(** Dispatch on a value of the enumeration. *)valdispatch:tm->(t->'am)->'amend(** Abstraction for arrays. *)moduletypeArray=sigtype'amtypettypeelttypeindexvalget:tm->indexm->eltmvalset:tm->indexm->eltm->unitmvalmake:indexm->eltm->tmvallength:tm->indexmvalunsafe_get:tm->indexm->eltmvalunsafe_set:tm->indexm->eltm->unitmvalcopy:tm->tmvalblit:tm->indexm->tm->indexm->indexm->unitmvalsub:tm->indexm->indexm->tmend(** Abstraction for rings. *)moduletypeRing=sigtype'amtypetincludeIntf_algebra.Ringwithtypet:=tmend(** Ring equipped with standard boilerplate. *)moduletypeRing_std=sigincludeRingincludeStdwithtypet:=tandtype'am:='amend(** Abstraction for Fields. *)moduletypeField=sigtype'amtypetincludeIntf_algebra.Fieldwithtypet:=tmend(** Field equipped with standard boilerplate. *)moduletypeField_std=sigincludeFieldincludeStdwithtypet:=tandtype'am:='amend(** Abstraction for raising exceptions. *)moduletypeExn=sigtype'amvalraise_:exn->'amend(** Infix ordering operators. *)moduletypeInfix_order=Intf_infix.Infix_order(* Doing a bit on introspection on where I got these "shapes" from, these probably
come from the work on containers by the Scottish PL gang (McBride, Ghani et al)
as well as from readings on the theory of combinatorial species (two related
pieces of work). *)(** Shapes: folding and iterating over abstract indexed structures. *)moduletypeShape=sigtype'am(** The type of (one-dimensional) positions in a shape. *)typepos(** The type of shapes, parametric in the type of positions. *)type'at(** [mem p s] is true iff [p] is a position in the shape [s]. *)valmem:'at->'am->boolm(** [pos_equal s p p'] is true iff [p] and [p'] are equal positions
in the shape [s]. *)valpos_equal:'at->'am->'am->boolm(** [equal s s'] is true iff [s] and [s'] describe equal shapes. *)valequal:'at->'at->boolm(** First-class mutable storage. *)moduletypeStorage=Storagewithtype'am='am(* We declare this here to avoid resorting to higher-kinded encodings. *)type'eltstorage=(moduleStoragewithtypeelt='elt)(** Iterate on a shape. *)valiter:('am->unitm)->'at->unitm(** Fold on a shape. *)valfold:'accstorage->('am->'accm->'accm)->'at->'accm->'accm(** Shape morphisms, described as a category. *)moduleMorphism:sigtype'aobj:='at(** The type of morphisms from a tensor indexed by ['a] to a tensor indexed by ['b]. *)type('a,'b)t(** Get the map on positions underlying the shape morphism. *)valunderlying:('a,'b)t->'am->'bm(** [domain m] is the domain of the morphism [m], ie a tensor indexed by ['a]. *)valdomain:('a,'b)t->'aobj(** [range m] is the range of the morphism [m], ie a tensor indexed by ['b]. *)valrange:('a,'b)t->'bobj(** [identity s] is the identity morphism at the shape [s]. *)validentity:'aobj->('a,'a)t(** [compose] is sequential morphism composition. *)valcompose:('a,'b)t->('b,'c)t->('a,'c)tendend