title: Higher-order type constructors and functors in Ocaml
body: <p>Can the following polymorphic functions</p>
  
  <pre><code>let id x = x;;
  let compose f g x = f (g x);;
  let rec fix f = f (fix f);;     (*laziness aside*)
  </code></pre>
  
  <p>be written for types/type constructors or modules/functors? I tried</p>
  
  <pre><code>type 'x id = Id of 'x;;
  type 'f 'g 'x compose = Compose of ('f ('g 'x));;
  type 'f fix = Fix of ('f (Fix 'f));;
  </code></pre>
  
  <p>for types but it doesn't work.</p>
  
  <p>Here's a Haskell version for types:</p>
  
  <pre><code>data Id x = Id x
  data Compose f g x = Compose (f (g x))
  data Fix f = Fix (f (Fix f))
  
  -- examples:
  l = Compose [Just 'a'] :: Compose [] Maybe Char
  
  type Natural = Fix Maybe   -- natural numbers are fixpoint of Maybe
  n = Fix (Just (Fix (Just (Fix Nothing)))) :: Natural   -- n is 2
  
  -- up to isomorphism composition of identity and f is f:
  iso :: Compose Id f x -&gt; f x
  iso (Compose (Id a)) = a
  </code></pre>