module type DICTIONARY = sig
type ' a t
val empty : ' a t
val insert : key -> ' a -> ' a t -> ' a t
val lookup : key -> ' a t -> ' a option
val map : ( ' a -> ' b) -> ' a t -> ' b t
end
module type DICTIONARY_PLUS = sig
include DICTIONARY
end
module AssocList : DICTIONARY = struct
type ' a t
= ( key
* ' a
) list
let empty = [ ]
let insert k v dict =
( k, v) :: dict
let rec lookup k dict =
match dict with
| [ ] -> None
| ( k' ,v) :: dict' ->
if k = k' then Some v
else lookup k dict'
let rec map fn dict =
List . map
( fun ( k, v
) -> ( k, fn v
) ) dict
end
module AssocListPlus : DICTIONARY_PLUS = struct
include AssocList
end
bW9kdWxlIHR5cGUgRElDVElPTkFSWSA9IHNpZwogIHR5cGUga2V5ID0gc3RyaW5nCiAgdHlwZSAnYSB0CgogIHZhbCBlbXB0eSA6ICdhIHQKICB2YWwgaW5zZXJ0IDoga2V5IC0+ICdhIC0+ICdhIHQgLT4gJ2EgdAogIHZhbCBsb29rdXAgOiBrZXkgLT4gJ2EgdCAtPiAnYSBvcHRpb24KICB2YWwgbWFwIDogKCdhIC0+ICdiKSAtPiAnYSB0IC0+ICdiIHQKZW5kCgptb2R1bGUgdHlwZSBESUNUSU9OQVJZX1BMVVMgPSBzaWcKICBpbmNsdWRlIERJQ1RJT05BUlkKICB2YWwgc2l6ZSA6ICdhIHQgLT4gaW50CmVuZAoKbW9kdWxlIEFzc29jTGlzdCA6IERJQ1RJT05BUlkgPSBzdHJ1Y3QKICB0eXBlIGtleSA9IHN0cmluZwogIHR5cGUgJ2EgdCA9IChrZXkgKiAnYSkgbGlzdAoKICBsZXQgZW1wdHkgPSBbXQoKICBsZXQgaW5zZXJ0IGsgdiBkaWN0ID0KICAgIChrLCB2KSA6OiBkaWN0CgogIGxldCByZWMgbG9va3VwIGsgZGljdCA9CiAgICBtYXRjaCBkaWN0IHdpdGgKICAgICAgfCBbXSAtPiBOb25lCiAgICAgIHwgKGsnLHYpOjpkaWN0JyAtPgogICAgICAgICAgaWYgayA9IGsnIHRoZW4gU29tZSB2CiAgICAgICAgICBlbHNlIGxvb2t1cCBrIGRpY3QnCgogIGxldCByZWMgbWFwIGZuIGRpY3QgPQogICAgTGlzdC5tYXAgKGZ1biAoaywgdikgLT4gKGssIGZuIHYpKSBkaWN0CmVuZAoKbW9kdWxlIEFzc29jTGlzdFBsdXMgOiBESUNUSU9OQVJZX1BMVVMgPSBzdHJ1Y3QKICBpbmNsdWRlIEFzc29jTGlzdAogIGxldCBzaXplID0gTGlzdC5sZW5ndGgKZW5k
compilation info
File "prog.ml", line 36, characters 41-96:
Signature mismatch:
Modules do not match:
sig
type key = string
type 'a t = 'a AssocList.t
val empty : 'a t
val insert : key -> 'a -> 'a t -> 'a t
val lookup : key -> 'a t -> 'a option
val map : ('a -> 'b) -> 'a t -> 'b t
val size : 'a list -> int
end
is not included in
DICTIONARY_PLUS
Values do not match:
val size : 'a list -> int
is not included in
val size : 'a t -> int
stdout