Quantcast
Channel: Active questions tagged ocaml - Stack Overflow
Viewing all articles
Browse latest Browse all 518

Using infix operator in the module in OCaml

$
0
0

I am trying to define a SCALAR signature with its own infix operator in

module type SCALAR =sig  type t                               (* type of scalar element *)  val zero : t   val one : t  val (++) : t -> t -> t               (* infix addition: t ++ t *)end

with using SCALAR signature, I defined a INT module:

module INT : SCALAR with type t = int=struct  type t = int  let zero = 0  let one = 1  let (++) x y = x + yend

I expected adding two INT modules with defined infix operator like INT.zero ++ INT.one is valid operation and expected its returning value int = 1 but it raises error of "Unbounded value ++".

However, INT.(++) INT.zero INT.one worked correctly (with the return value I expected).

How can I use specific module's infix operator, without explicitly specifying module's name?


Viewing all articles
Browse latest Browse all 518

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>