File: pytypes.ml

package info (click to toggle)
pyml 20231101-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 592 kB
  • sloc: ml: 7,043; ansic: 1,802; makefile: 317; sh: 13
file content (38 lines) | stat: -rw-r--r-- 666 bytes parent folder | download | duplicates (4)
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
29
30
31
32
33
34
35
36
37
38
type pyobject

type compare = LT | LE | EQ | NE | GT | GE

type input = Single | File | Eval

let int_of_compare c =
  match c with
    LT -> 0
  | LE -> 1
  | EQ -> 2
  | NE -> 3
  | GT -> 4
  | GE -> 5

let compare_of_int c =
  match c with
    0 -> LT
  | 1 -> LE
  | 2 -> EQ
  | 3 -> NE
  | 4 -> GT
  | 5 -> GE
  | _ -> failwith "Pytypes.compare_of_int"

let input_of_int input =
  match input with
    256 -> Single
  | 257 -> File
  | 258 -> Eval
  | _ -> failwith "Pytypes.input_of_int"

type 'a file = Filename of string | Channel of 'a

let file_map f x =
  match x with
    Filename filename -> Filename filename
  | Channel channel -> Channel (f channel)