caml-list - the Caml user's mailing list
 help / Atom feed
* [Caml-list] An awkwardness with type parameters
@ 2019-02-26  6:24 Hendrik Boom
  2019-02-26  6:39 ` Jacques Garrigue
  0 siblings, 1 reply; 5+ messages in thread
From: Hendrik Boom @ 2019-02-26  6:24 UTC (permalink / raw)
  To: Ocaml Mailing List

I have a (broken) function definition starting:

let mixfix : 'token1 'phrase1.
  ('token1, 'phrase1, ('token1, 'phrase1) Phrasestream.phrasestream) grammar
        -> ('token1, 'phrase1) parser
   =  fun gram -> (
  ...

It goes o for a hundred-odd lines.
The type-parameterized types Phrasestream.phrasestream, grammar, and parser   
have been previously defined, and there are also operations defined on these
types.

The problem I'm having is that the OCaml type-checker ends up identifying
the type parameters 'token1 an 'phrase1 because of type errors I've made in
the body of the mixfix function.  Somewhere I ended up using an
operator that's supposed to work on values of type 'token1
on a value of type 'phrase1 instead, and identification of 'token1 and 
'phrase1 is the natural result.

Is there some way of forcing the type checker to treat 'token1 and 
'phrase1 as different types so that I can get meaningful type errors
at the point were they occur?

With the present setup I only get type violation messages much later, 
when I try to use the mixfix function.  It's far too late to trace the 
problem back to the actual error by that time.

-- hendrik



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, back to index

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-26  6:24 [Caml-list] An awkwardness with type parameters Hendrik Boom
2019-02-26  6:39 ` Jacques Garrigue
2019-02-27  2:00   ` Hendrik Boom
2019-02-27  3:46     ` Jacques Garrigue
2019-02-27 18:21   ` Hendrik Boom

caml-list - the Caml user's mailing list

Archives are clonable: git clone --mirror https://inbox.ocaml.org/caml-list

AGPL code for this site: git clone https://public-inbox.org/ public-inbox