private rows question

Keiko Nakata

Jacques Garrigue
 Keiko Nakata

Jacques Garrigue
[
Home
]
[ Index:
by date

by threads
]
[ Message by date: previous  next ] [ Message in thread: previous  next ] [ Thread: previous  next ]
[ Message by date: previous  next ] [ Message in thread: previous  next ] [ Thread: previous  next ]
Date:   (:) 
From:  Keiko Nakata <keiko@k...> 
Subject:  Re: [Camllist] private rows question 
From: Jacques Garrigue <garrigue@math.nagoyau.ac.jp> > From: Keiko Nakata <keiko@kurims.kyotou.ac.jp> > > > Why the following functor G is not typable? > > I thought that g could have a type something like int > [< `A  `B ]. > > > > module G(X:sig type t = private [< `A ] val f : int > t end) = struct > > let g x = if x = 0 then `B else X.f x > > end > > Since g may return `B, and probably `A (the probably concerns your > intention), the expected type would be > g : int > [> `A  `B ] > Next, if you want f to have a private row type, then you should > disconnect its type from the type of g (otherwise the type of g must > be the same as f.) So I would expect something like: > let g x = if x = 0 then `B else (X.f x : [< `A] :> [> `A]) Thank you for the correction. Obviously, the type checker is much more brilliant than me :) Private rows seem to give me more opportunities to reuse my program codes than I expected. Keiko NAKATA