(* Let's start with a small interactive-style script *)

(* Enf of block, indentation of application... *)
aaa
  bb
  cc dd ;

bla ;
bli blu
  blo ;

(* End of block with if/then stuff *)
if a
then
  b ;

if a
then hbjhbjhb
       jhbjhb ;;

(* Now, real-life OCaml style *)

(* Nested if/then *)
let _ =
  if if a then b ; cond
  then
    plop ;
  a

let _ =
  if a then
    let _ = foo in
      plop a ;
      plop b
  else
    wohooo ;
  back home ;;

(* The = trick *)

let () =
  a = b ;
  (* Allez un petit commentaire,
   * dans la foulée...
   *)
  foo
    (* Blah
     * Yo!
     * bloh *)

(* Funk with let and match *)
let a =
  let a = b in
  let a = b in
    begin
      ( a (0 + 0) ;
        b ; b
              a begin
                ( ( (* A bad begin <- there *) ) )
              end
              match (
                if a then b else c ) with
                  a -> ()
                | b -> begin (* Looking for a sig ? *) end
                         b ) ;
      "Hey! I'm the begin you need!"
    end

let (a,b) = c in if a then b else c ;;

(* let special *)
let a =
  a ;
  let b = d in
    b ;
    ok ;

    let here = ok

(* Nice comments
 * I like them
 * this way!
 *)

(* Tricking searchpair *)

let _ =
  if a then (if a then b
             else c)
  else shit ;

  let _ =
    if a then
      match a with
          _ -> if a then pouet else foo
        | x -> if a then foo
               else argh
    else
      match a with
        | _ -> match b with
                 | pat -> (match ()
                           with
                             | () -> hop)
                 | x ->
                     match n
                     with
                       | _ -> long

(* Sorry guys I must remain strict on match-like constructs... *)
let f = function
            bla -> bli
          | yes -> no
          | _ -> ending

let f =
  function
      a -> b
    | xl ->
        ( match x with
            | Cons ((bli::_),bli) x when
                truc () ;
                test ()
              ->
                exit 0
            | A _ x::[] when x>a ->
                exit 1
            | n -> n )
    | _ -> 0

let f = fun x ->
          0

(* Toplevel let, OK. Toplevel comment, KO. *)
let a = b
let c =
  let x = y
  and y = z
  and a = b
  in
    begin
      f x ;
      g ()
    end

(* Modules *)
module A (B:T) =
struct
  include B

  let a = 1
  type t = int list
  class plop = object end
  class plop =
  object

    inherit plop
    val mutable v = 1
    method foo =
      self#plop ;
      v <- 0 ;
      foo

    initializer v <- 1
  end

  type t2 =
    | A of int
    | A of int
    | B of char

  type t3 =
    {
      truc : int ;
      mutable machin : char
    }

  type t4 = {
    mmm : int ;
  }

end

module type B =
sig
  val x : int
  val f : int -> int
end