package gobba

  1. Overview
  2. Docs

Source file typep.ml

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
open Types
open Errors
open Typecheck
(* open Util *)

(** String Primitives *)

let typeofp args =
  if Array.length args != 1 then iraise WrongPrimitiveArgs else
  EvtString (show_typeinfo (typeof args.(0)))

let myfailwith args =
  if Array.length args != 1 then iraise WrongPrimitiveArgs else
  let msg = unpack_string args.(0) in
  let _ = iraise (InternalFailure msg) in EvtUnit

let show args =
  match args with
  | [|EvtString x|] -> (EvtString x)
  | [|x|] -> EvtString (Values.show_evt_fancy x)
  | _ -> iraise WrongPrimitiveArgs

let table = [
  ("show",              Primitive (show, ("show", [|"anything"|], Pure)));
  ("typeof", Primitive (typeofp, ("typeof", [|"anything"|], Pure)));
  ("failwith", Primitive (myfailwith, ("failwith", [|"message"|], Pure)));
]

OCaml

Innovation. Community. Security.