source: Deliverables/D4.1/Byte.ml @ 63

Last change on this file since 63 was 63, checked in by mulligan, 10 years ago

More work on bits, bytes, nibbles, and added modules for byte7s and
words.

File size: 1.9 KB
Line 
1(*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*)
2(* FILENAME:    Byte.ml                                                      *)
3(* DESCRIPTION: An ADT implementing standard 8 bit bytes, and common         *)
4(*              operations on them.                                          *)
5(* CREATED:     10/09/2010, Dominic Mulligan                                 *)
6(* BUGS:                                                                     *)
7(*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*)
8
9open Bit;;
10open Nibble;;
11
12module type BYTE =
13sig
14  type bit
15  type nibble
16  type byte
17(*
18  val from_bits: bit -> bit -> bit -> bit -> bit -> bit -> bit -> bit -> byte
19  val from_bit: bit -> byte
20  val from_nibbles: nibble -> nibble -> byte
21  val from_nibble: nibble -> byte
22  val from_int: int -> byte
23
24  val to_bit: byte -> bit option
25  val to_nibble: byte -> nibble option
26  val to_int: byte -> int
27
28  val get_nibble_at: int -> byte -> nibble
29  val set_nibble_at: int -> nibble -> byte -> byte option
30  val get_bit_at: int -> byte -> bit
31  val set_bit_at: int -> bit -> byte -> byte option
32
33  val (-&-): byte -> byte -> byte
34  val (-|-): byte -> byte -> byte
35  val (-^-): byte -> byte -> byte
36  val not: byte -> byte
37
38  val map_nibble: (nibble -> nibble) -> byte -> byte
39  val map_bit: (bit -> bit) -> byte -> byte
40  val iter_nibble: (nibble -> string) -> byte -> string
41  val iter_bit: (bit -> string) -> byte -> string
42  val zip_nibble: (nibble -> nibble -> nibble) -> byte -> byte -> byte
43  val zip_bit: (bit -> bit -> bit) -> byte -> byte -> byte
44  val pretty: byte -> string
45*)
46end
47
48module Byte(Nibble: NIBBLE): BYTE
49  with type bit = Nibble.bit and type nibble = Nibble.nibble =
50struct
51  type bit = Nibble.bit
52  type nibble = Nibble.nibble
53  type byte = nibble * nibble
54
55  let from_bits b1 b2 b3 b4 b5 b6 b7 b8 =
56    let nibble
57end
Note: See TracBrowser for help on using the repository browser.