val example1:string
val example1:string
let example1 : string =
  string_of_dirs [Arg Int; Arg String] (fun s -> s) 42 " answer"
(*
   Copyright 2008-2018 Microsoft Research

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*)
module SimplePrintf

open FStar.Char
open FStar.String

// arguments to printf
type arg =
  | Bool
  | Int
  | Char
  | String

// directives to printf
type dir =
  | Lit of char
  | Arg of arg

let arg_type (a:arg) : Tot Type0 =
  match a with
  | Bool   -> bool
  | Int    -> int
  | Char   -> char
  | String -> string

let rec dir_type (ds:list dir) : Tot Type0 =
  match ds with
  | [] -> string
  | Lit c :: ds' -> dir_type ds'
  | Arg a :: ds' -> arg_type a -> Tot (dir_type ds')


let rec string_of_dirs ds (k:string -> Tot string)
  : dir_type ds
  = match ds with
    | [] -> k ""
    | Lit c :: ds' ->
      string_of_dirs ds' (fun res -> k (string_of_char c ^ res))
      <: normalize_term (dir_type ds')
    | Arg a :: ds' ->
      fun (x : arg_type a) ->
        string_of_dirs ds' (fun res -> k (match a with
                                        | Bool -> string_of_bool x
                                        | Int -> string_of_int x
                                        | Char -> string_of_char x
                                        | String -> x) ^ res)
/
prims.fst.checked FStar.String.fsti.checked FStar.Pervasives.fsti.checked FStar.Char.fsti.checked
SimplePrintf.fst
Prims.string
SimplePrintf.string_of_dirs Prims.Cons SimplePrintf.dir SimplePrintf.Arg SimplePrintf.Int SimplePrintf.String Prims.Nil Prims.string
let example1:string =
  
string_of_dirs [Arg Int; Arg String] (fun s -> s) 42 " answer"