package preface
Source file divisible.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77open Preface_core.Fun module Core_via_divide_and_conquer (Req : Preface_specs.Divisible.WITH_DIVIDE_AND_CONQUER) = struct include Req let contramap f x = (divide ((fun x -> ((), x)) % f) conquer) x end module Core_via_contramap_and_divide_and_conquer (Req : Preface_specs.Divisible.WITH_CONTRAMAP_AND_DIVIDE_AND_CONQUER) = Req module Operation (Core : Preface_specs.Divisible.CORE) = struct include Contravariant.Operation (Core) let divided x = Core.divide id x let conquered = Core.conquer end module Infix (Core : Preface_specs.Divisible.CORE) (Operation : Preface_specs.Divisible.OPERATION with type 'a t = 'a Core.t) = struct include Contravariant.Infix (Core) (Operation) let ( >*< ) = Operation.divided let ( ^*^ ) = Operation.divided let ( >* ) x = Core.divide (fun x -> (x, ())) x let ( ^* ) = ( >* ) let ( *< ) x y = Core.divide (fun x -> ((), x)) x y let ( &* ) = ( *< ) end module Via (Core : Preface_specs.Divisible.CORE) (Operation : Preface_specs.Divisible.OPERATION) (Infix : Preface_specs.Divisible.INFIX) = struct include Core include Operation include Infix module Infix = Infix end module Via_divide_and_conquer (Req : Preface_specs.Divisible.WITH_DIVIDE_AND_CONQUER) = struct module Core = Core_via_divide_and_conquer (Req) include Core module Operation = Operation (Core) include Operation module Infix = Infix (Core) (Operation) include Infix end module Via_contramap_and_divide_and_conquer (Req : Preface_specs.Divisible.WITH_CONTRAMAP_AND_DIVIDE_AND_CONQUER) = struct module Core = Core_via_contramap_and_divide_and_conquer (Req) include Core module Operation = Operation (Core) include Operation module Infix = Infix (Core) (Operation) include Infix end module Over_contravariant (Contravariant : Preface_specs.Contravariant.CORE) (Req : Preface_specs.Divisible.WITH_DIVIDE_AND_CONQUER with type 'a t = 'a Contravariant.t) = Via_contramap_and_divide_and_conquer (struct include Req let contramap = Contravariant.contramap end)