Thread View: comp.lang.functional
3 messages
3 total messages
Started by Richard A. O'Keefe
Mon, 28 Sep 1992 08:08
Type checking with physical dimensions
Author: Richard A. O'Keefe
Date: Mon, 28 Sep 1992 08:08
Date: Mon, 28 Sep 1992 08:08
14 lines
1216 bytes
1216 bytes
Has anyone extended a Hindley/Milner-style type checker to check physical dimensions (mass,length,time,current,&c)? I have my own ideas about how to do it, but before I start coding and writing, I'd like to know what has already been done. (I already know that it is possible to combine polymorphism with dimension checking; I _think_ I can see a way to combine them with integer/float overloading; I believe that automatic scaling can be done in a functional language but not in a logic programming language, but don't ask me to prove it yet.) -- RMIT policy requires the use of Gender Inclusive Language in all publications and in all information conveyed to students, staff, and potential job applicants. Lapses into English are the sole responsibility of the author. The Constitution of Australia does _not_ guarantee Freedom of Speech.
Re: Type checking with physical dimensions
Author: David Barton
Date: Mon, 28 Sep 1992 15:04
Date: Mon, 28 Sep 1992 15:04
41 lines
2278 bytes
2278 bytes
I was going to respond to this by Email; however, since it might be of general interest, I am responding to the list. In article <14724@goanna.cs.rmit.oz.au> ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) writes: Has anyone extended a Hindley/Milner-style type checker to check physical dimensions (mass,length,time,current,&c)? I have my own ideas about how to do it, but before I start coding and writing, I'd like to know what has already been done. (I already know that it is possible to combine polymorphism with dimension checking; I _think_ I can see a way to combine them with integer/float overloading; I believe that automatic scaling can be done in a functional language but not in a logic programming language, but don't ask me to prove it yet.) We are desigining a microwave hardware description language based upon Haskell. We have written a Physical type which is simply another data type under the Haskell class system; thus, overloading with standard operators simply involves a new data instance for each appropriate class that defined the operators for type Physical. Our physical datatype includes (not bothering with the Haskell syntax): 1) A 10-tuple that corresponds to the appropriate "exponent", or dimension, of each of the standard ISO "basic" units (we added dollars). 2) A rational multiplier (for factors of the same dimenstion: feet and meters, for example). A multiplier of one refers to the ISO standard units. 3) The numeric part (the "10" in "10 miles"). The definition of arithemetic operations on these quantities is fairly trivial. Please Email me if there are questions. Dave Barton dlb@hudson.wash.inmet.com
Re: Type checking with physical dimensions
Author: Deryk Barker
Date: Mon, 28 Sep 1992 19:22
Date: Mon, 28 Sep 1992 19:22
22 lines
1599 bytes
1599 bytes
In article <DLB.92Sep28100432@fanny.wash.inmet.com> dlb@fanny.wash.inmet.com (David Barton) writes: >I was going to respond to this by Email; however, since it might be of >general interest, I am responding to the list. > >In article <14724@goanna.cs.rmit.oz.au> ok@goanna.cs.rmit.oz.au >(Richard A. O'Keefe) writes: > > Has anyone extended a Hindley/Milner-style type checker to check > physical dimensions (mass,length,time,current,&c)? I have my own ideas > about how to do it, but before I start coding and writing, I'd like to > know what has already been done. (I already know that it is possible to > combine polymorphism with dimension checking; I _think_ I can see a way > to combine them with integer/float overloading; I believe that automatic > scaling can be done in a functional language but not in a logic programming > language, but don't ask me to prove it yet.) > >We are desigining a microwave hardware description language based upon >Haskell. All this just to cook food? (Sorry, I couldn't resist it!) Deryk Barker, Computer Science Dept., Camosun College, Victoria B.C.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads