The Mixture project provides a comprehensive mixins library for the OCaml module system.
The Mixture_Compare module defines a mixin which derives all classical comparison operators (in prefix and infox form) from a compare function. For instance
module PlayingCard =
struct
type card =
| Card of regular
| Joker
and regular = { suit : card_suit; name : card_name; }
and card_suit = Heart | Club | Spade | Diamond
and card_name = Ace | King | Queen | Jack | Simple of int
module Basis =
struct
type t = card
let compare = Pervasives.compare
end
module CompareMethods =
Mixture_Compare.Make(Basis)
include Basis
include CompareMethods
endThe module PlayingCard has prefix and infix comparison operators
derived from compare so, if a and b are cards, one can write
PlayingCard.lt a b or equivalently PlayingCard.Infix.(a < b).
The growing list of mixins defined in the library is:
- Mixture_Applicative
- Mixture_Compare
- Mixture_Format
- Mixture_Parse
- Mixture_Monad
- Mixture_FoldRight
- Mixture_FoldAssoc
It is written by Michael Grünewald and is distributed as a free software: copying it and redistributing it is very much welcome under conditions of the CeCILL-B licence agreement, found in the COPYING and COPYING-FR files of the distribution.
It is easy to install Mixture using opam and its pinning feature. In a shell visiting the repository, say
% autoconf
% opam pin add mixture .It is also possible to install Mixture manually. The installation procedure is based on the portable build system BSD Owl Scripts written for BSD Make.
-
Verify that prerequisites are installed:
-
Get the source, either by cloning the repository or by exploding a distribution tarball.
-
Optionally run
autoconfto produce a configuration script. This is only required if the script is not already present. -
Run
./configure, you can choose the installation prefix with--prefix. -
Run
make build. -
Optionally run
make testto test your build. -
Finally run
make install.
Depending on how BSD Make is called on your system, you may need to
replace make by bsdmake or bmake in steps 5, 6, and 7.
The GNU Make program usually give up the ghost, croaking
*** missing separator. Stop. when you mistakingly use it instead of
BSD Make.
Step 7 requires that you can su - if you are not already root.
Michael Grünewald in Bonn, on August 11, 2015