pb5.ml 782 Bytes
Newer Older
SimonHalfon's avatar
SimonHalfon committed
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
(* ============ Tentative 5 (Cette fois ci, c'est la bonne)  ============ *)

module type Group =
  sig
    type t
	   
    module Sig: sig module type S end
    module Aux: Sig.S

    val neutral: t
    val op: t -> t -> t
    val inv: t -> t
  end ;;    


module Permutations_3 =
  struct
    type elt = A | B | C    
    type t = elt -> elt

    module Sig =
      struct
	module type S =
	  sig
	    val dcd: t -> elt list list
	  end
      end
	
    module Aux =
      struct
	let dcd s =
	  if s(A) = A then [ [A]; [B]; [C] ] else [ [A;B;C] ]
      end					   

    let neutral x = x
    let op s t = fun x -> s(t(x))
    let inv s = if Aux.dcd s = [] then s else s
  end ;;


module Perm: Group with module Sig = Permutations_3.Sig = Permutations_3 ;;

  
  Perm.Aux.dcd ;;