Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Octachron <octa@polychoron.fr>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Dimensional Analysis question
Date: Fri, 17 Oct 2014 07:58:21 +0200	[thread overview]
Message-ID: <5440AFFD.4010203@polychoron.fr> (raw)
In-Reply-To: <CANgVXKZ=3Fxe2KPcFPD1D9fQsT0TYpfXKOtwvnfTL-Q1Z=1uaQ@mail.gmail.com>

Le 10/16/14 19:35, Mario Alvarez Picallo wrote:
> Hello Shayne,
>
> I was at first convinced that this could not be done, but you can in 
> fact encode it (in a verbose way) with phantom types,
> using a smart typelevel representation of integers 
> (http://www.kb.ecei.tohoku.ac.jp/ml2008/slides/lindley.pdf).
>
> I've written a small proof of concept that seems to work just fine 
> (but, of course, there may be errors), that you can find
> here: https://gist.github.com/m-alvarez/b1e42b7b42cbeed7d1f0
>
> It seems to be solid enough to pass the tests that Octachron tried, 
> but there probably are some other corner cases for which
> it breaks down. Otherwise, it would be interesting to coalesce both 
> representations, using Octachron's idea of row types instead
> of tuples to have extensible dimensional analysis, where each part of 
> the program can introduce its own dimensions.
>
> Regards,
> Mario A.
>

I forget to add variance annotation in my test so my examples broke down 
due to the presence of monomorphic types. With the right implementation 
(i.e. Mario's),
problems appear within functions. For instance,

let f x = x* x

works only for adimensional variable (i.e f : ('a*'a) t -> ('a*'a) t ) 
which is maybe not surprising.
However, the same thing  also happens to

let f x y = (x+y)*x*y .

because the type of x and y are unified during the addition "x+y".

Regards,
Octachron.

  reply	other threads:[~2014-10-17  5:58 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-16 16:37 Shayne Fletcher
2014-10-16 17:21 ` Octachron
2014-10-16 17:35 ` Mario Alvarez Picallo
2014-10-17  5:58   ` Octachron [this message]
2014-11-10 18:14   ` Shayne Fletcher
2014-10-16 18:10 ` Thomas Gazagnaire
2014-10-17 10:22   ` David MENTRE
2014-10-16 19:36 ` Shayne Fletcher
2014-10-17  6:50 ` Roberto Di Cosmo

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=5440AFFD.4010203@polychoron.fr \
    --to=octa@polychoron.fr \
    --cc=caml-list@inria.fr \
    /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