caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Nicolas Boulay <nicolas@boulay.name>
To: Roberto Di Cosmo <roberto@dicosmo.org>
Cc: caml users <caml-list@inria.fr>
Subject: Re: [Caml-list] Adding Dimensions to types
Date: Fri, 13 Jun 2014 14:10:10 +0200	[thread overview]
Message-ID: <CAH+PdrD3rQJQMfFxGcq1mGLnV+W2W7xyoxH+Y9ZYaLvQDx6DhA@mail.gmail.com> (raw)
In-Reply-To: <20140613095403.GB18282@traveler>

[-- Attachment #1: Type: text/plain, Size: 1547 bytes --]

2014-06-13 11:54 GMT+02:00 Roberto Di Cosmo <roberto@dicosmo.org>:

> On Fri, Jun 13, 2014 at 11:43:20AM +0200, Gabriel Scherer wrote:
> > Encoding integers with addition at the type level is easy enough (it
> > is possible to use a technique akin to difference list where you keep
> > unary numbers with a unification variable at their tail, to get the
> > unification engine to do the addition for you). Anything below that,
> > in particular substraction, cannot be done *conveniently* in the
> > type-system. It is possible to encode arbitrary operation on
> > type-level numbers (unary or not), expressed relationally
> > (Prolog-style: ('a, 'b, 'c) add is inhabited if 'a+'b='c) by a GADT
> > witnessing the relation, but actually building and using these
> > operations then requires the programmer to provide those witness terms
> > that are manipulated at runtime.
>
> Actually, we want to have dimension checking at compile time, with no
> trace of it at runtime.
>

Is it possible to think with dimension inference ? This avoid the need to
give dimension everywhere.

You can have rules like
if "a + b = c" => dim(a) == dim(b) == dim(c).
if(e*f=g) => dim(g) = dim(e) * dim(f)

You can even go further. https://en.wikipedia.org/wiki/Dimensional_analysis
gives some hint :  Position vs displacement.

if T1 and T2 are absolut point in time, (T1-T2) are time offset. But "T1 +
T2"  is a none sense.

You could also extend the check of dimension in space direction (x,y,z).

The idea is to add a check with minimum new user input.

Nicolas

[-- Attachment #2: Type: text/html, Size: 2448 bytes --]

  reply	other threads:[~2014-06-13 12:10 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-13  9:10 Roberto Di Cosmo
2014-06-13  9:42 ` David MENTRE
2014-06-13 10:09   ` Roberto Di Cosmo
2014-06-13  9:43 ` Gabriel Scherer
2014-06-13  9:54   ` Roberto Di Cosmo
2014-06-13 12:10     ` Nicolas Boulay [this message]
2014-06-13  9:52 ` Leo White
2014-06-13 10:12   ` Roberto Di Cosmo
2014-06-13 11:06     ` Leo White
2014-06-13 20:08   ` Török Edwin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAH+PdrD3rQJQMfFxGcq1mGLnV+W2W7xyoxH+Y9ZYaLvQDx6DhA@mail.gmail.com \
    --to=nicolas@boulay.name \
    --cc=caml-list@inria.fr \
    --cc=roberto@dicosmo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).