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

Narrow down a type of record with explicit field declarations

$
0
0

I'm facing a problem that I need to narrow down the type

type 'a poly = {field1: 'a; field2: int}

I want to declare a new type

type mono = string poly = {field1: string; field2: int}

But when I try to do this I get an error

This variant or record definition does not match that of type
Base.string poly They have different arities.

However, the following definition does not cause errors:

type mono = string poly

I feel like I'm missing something, but the goal is to explicitly state the equality of these types.I understand that my approach is too naive, but I hope it will give you an understanding of the problem.Is there any way to do this?


Viewing all articles
Browse latest Browse all 531

Trending Articles