Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module SI : sig
- type 'a t
- type meter
- type kilogram
- type second
- type ('a, 'b) mul
- type ('a, 'b) div
- val meters : float -> meter t
- val kilograms : float -> kilogram t
- val seconds : float -> second t
- val (+!) : 'a t -> 'a t -> 'a t
- val (-!) : 'a t -> 'a t -> 'a t
- val ( *! ) : 'a t -> 'a t -> ('a, 'b) mul t
- val (/!) : 'a t -> 'a t -> ('a, 'b) div t
- val to_float : 'a t -> float
- end = struct
- type 'a t = SiUnit of float
- type meter
- type kilogram
- type second
- type ('a, 'b) mul
- type ('a, 'b) div
- let meters x = SiUnit x
- let kilograms x = SiUnit x
- let seconds x = SiUnit x
- let (+!) (SiUnit x) (SiUnit y) = SiUnit (x +. y)
- let (-!) (SiUnit x) (SiUnit y) = SiUnit (x -. y)
- let ( *! ) (SiUnit x) (SiUnit y) = SiUnit (x *. y)
- let (/!) (SiUnit x) (SiUnit y) = SiUnit (x /. y)
- let to_float (SiUnit x) = x
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement