You need a parser for the printed representation of your type. There are many sources of information on parsing in OCaml, for example: https://realworldocaml.org/v1/en/html/parsing-with-ocamllex-and-menhir.html, https://caml.inria.fr/pub/docs/oreilly-book/html/book-ora103.html; if you have a copy of "The Functional Approach To Programming" parsing is covered there also.  As a shortcut, you _may_ be able to use sexp-lib to automagically create a parser for you; sexp-lib is covered in https://realworldocaml.org/v1/en/html/data-serialization-with-s-expressions.html.

--
Best,
Zhenya

On Thu, Jun 29, 2017 at 11:24 AM, Umair Siddique <umair.hvg@gmail.com> wrote:
Hi all, 

Can someone indicate me the best way to read custom type from a file or from command line.

for example, type abc = Awsome | Great ;; 

I want to read it from a file or command line  


Thanks 

Uma