How to implement a list of pairs (i,v) such that v can be both of type int and of type bool?

Hi I am new to OCaml and I was asking myself if there is a way to implement a list of (identifiers / value) pairs, such that value is for some identifiers of type int and for some other identifiers of type bool?

type identifier = string;;
type value =
| int
| bool
;;
(* list of (identifier/value) pairs *)
type map = (identifier*value)list ;;

Sounds like you want

type value =
| Int of int 
| Bool of bool

cf OCaml - The core language

4 Likes