Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 57 lines (43 sloc) 1.376 kb
fccc685 Initial open-source release
MLstate authored
1 (*
2 Copyright © 2011 MLstate
3
4 This file is part of OPA.
5
6 OPA is free software: you can redistribute it and/or modify it under the
7 terms of the GNU Affero General Public License, version 3, as published by
8 the Free Software Foundation.
9
10 OPA is distributed in the hope that it will be useful, but WITHOUT ANY
11 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
13 more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with OPA. If not, see <http://www.gnu.org/licenses/>.
17 *)
18 (* depends *)
19
20 (* shorthands *)
21
22 (* debug *)
23 #<Debugvar:DEBUG_DB>
24
25 (* -- *)
26
27 type data =
28 | Int of int
29 | Text of string
30 | Binary of string
31 | Float of float
32 | Unit
33
34 type t = data
35 type io = t
36
37 let empty = Unit
38
39 let to_string o =
40 match o with
41 | Int i -> string_of_int i
42 | Text s -> "\"" ^ String.escaped (BaseString.limit 60 s) ^"\""
43 | Binary s -> "BINARY (size " ^ string_of_int (String.length s) ^ ")"
44 | Float f -> string_of_float f
45 | Unit -> "()"
46
47 let get_string o =
48 match o with
49 | Int i -> string_of_int i
50 | Text s | Binary s -> s
51 | Float f -> string_of_float f
52 | Unit -> ""
53
54 let index_fun = function
55 | Text s -> Indexer.utf8_string StringMap.empty s
56 | _ -> StringMap.empty
Something went wrong with that request. Please try again.