let write =
  let console = ref None in
    fun msg ->
      let console =
        match !console with
          | None ->
              let div = eval "document" >>> call_method "createElement" [| string "div" |] in
                div >>> get "style" >>> set "position" (string "fixed") ;
                div >>> get "style" >>> set "right" (string "10px") ;
                div >>> get "style" >>> set "bottom" (string "10px") ;
                div >>> get "style" >>> set "width" (string "40em") ;
                div >>> get "style" >>> set "height" (string "12em") ;
                div >>> get "style" >>> set "white-space" (string "pre") ;
                div >>> get "style" >>> set "background-color" (string "black") ;
                div >>> get "style" >>> set "color" (string "green") ;
                eval "document" >>> get "body" >>> call_method "appendChild" [| div |] >>> ignore ;
                console := Some div ;
                div
          | Some c -> c
      in
      let line =  eval "document" >>> call_method "createTextNode" [| string msg |] in
        console >>> call_method "appendChild" [| line |] >>> ignore