Created
January 5, 2015 18:11
-
-
Save gsg/b176f985399e8446c6f0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module type Witness = sig type 'a key type 'a value end | |
module type Witnessed = sig | |
type 'a key | |
type 'a value | |
type t | |
type ('a, 'b) conv = { | |
key : 'c . 'c key -> 'a; | |
value : 'c . 'c value -> 'b; | |
} | |
val box : 'a key -> 'a value -> t | |
val conv : ('a, 'b) conv -> t -> ('a * 'b) | |
end | |
module MAKE(W : Witness) : Witnessed | |
with type 'a key = 'a W.key | |
and type 'a value = 'a W.value = | |
struct | |
include W | |
type t = Box : 'a key * 'a value -> t | |
let box k v = Box (k, v) | |
type ('a, 'b) conv = { | |
key : 'c . 'c key -> 'a; | |
value : 'c . 'c value -> 'b; | |
} | |
let conv conv (Box (k, v)) = (conv.key k, conv.value v) | |
end | |
type _ token | |
type _ attrib | |
module W = struct | |
type 'a key = 'a token | |
type 'a value = 'a attrib | |
end | |
module Boxed = struct | |
include MAKE(W) | |
type lexeme = t | |
type ('a, 'b) lexeme_conv = ('a, 'b) conv | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment