-1

I'm new to OCaml. I installed utop(version 2.6.0) with latest homebrew on MacOS, installed libraries with opam install core base.

Here's my .ocamlinit:

#use "topfind";;
#thread;;
#require "core.top";;

open Base;;
open Core;;

I met an error of type FI:

utop # FI;;
Line 1, characters 0-2:
Error: The constructor FI expects 3 argument(s),
       but is applied here to 0 argument(s)

What's type FI in OCaml ?

Here's type info introduced in TAPL(https://www.cis.upenn.edu/~bcpierce/tapl/): type info = FI of string * int * int | UNKNOWN,

What's type UNKNOWN in OCaml ?

ghilesZ
  • 1,502
  • 1
  • 18
  • 30
linrongbin
  • 2,967
  • 6
  • 31
  • 59
  • `info` is a variant type with two possible values - `FI` or `UNKNOWN`. Consult an ocaml tutorial or the manual for more. – Shawn Dec 21 '20 at 11:14

1 Answers1

0

As all the commenters are telling you, StackOverflow is not a good place to learn a new language by asking questions. It will be much, much more productive for you to start by reading through a tutorial on OCaml, say at the OCaml Learning page.

To answer your questions here, neither of these identifiers (FI or UNKNOWN) means anything in particular "in OCaml". They're just upper-case identifiers that can be defined to be many possible things. In your case they are defined by the type definition you cite:

type info = FI of string * int * int | UNKNOWN

This defines the names info, FI, and UNKNOWN. The latter two are the "constants" of a new type named info. The first constant (called a value constructor actually), FI, is a way of collecting up a string and two ints into a unit with the tag FI. The second one is just a simple value that doesn't collect up any data. It's similar in a way to NULL in some other language, in that it says there is no interesting data.

Jeffrey Scofield
  • 65,646
  • 2
  • 72
  • 108