Abstraction in SML 
Author Message
 Abstraction in SML


I've got some trouble to understand abstraction in SML/NJ 0.93.
To learn , I'm using " Introduction to SML" by Ropert Harper.
He said that if we define:

signature SIG =
    type t
    val x: t -> t


abstraction V:SIG =
    type t = int
    val x = fn x => x

First, he said that the given result of the previous definition is:

> abstraction V:SIG
or I obtain
> structure V:SIG

and that we should be enable to do:
but I've got the error:
std_in:18.1-18.6 Error: operator and operand don't agree (tycon
  operator domain: V.t
  operand:         int
  in expression:
    x (3)

What's wrong with it ?
Moreover, can somebody tell me more about abstraction ?

        Stephane Baudet

Tue, 03 Nov 1998 03:00:00 GMT  
 Abstraction in SML

Those notes are somewhat dated and should be revised.

The effect of an abstraction declaration (which is not official SML,but
is supported by SML/NJ) is to restrict type sharing information to
exactly that which is specified in the signature.  So if you make an
abstraction binding and the signature merely says "type t", then this
type is distinct from all other types.

As you can readily see, abstraction bindings are not always what you
would like.  eg, if we make an abstraction A of signature POSET, where

signature POSET = sig

        type t
        val le : t * t -> bool


then A is useless because A.le can never be applied!  The solution to
this problem is to provide a finer degree of control over visibility of
type information by allowing type definitions to occur in signatures.

A planned revision of SML (to be completed in about a month) will
provide a more flexible variant of abstraction bindings and admit type
definitions in signatures, leading to a significantly more flexible
module system.

Bob Harper

Fri, 06 Nov 1998 03:00:00 GMT  
 [ 2 post ] 

 Relevant Pages 

1. Subroutine, lambda abstraction, tacit form

2. ST stack abstraction: objects/boxing etc.

3. Data Abstraction

4. abstraction and encapsulation (Re: Will Java kill C++?)

5. Leaky Abstractions: what we knew

6. Re-writing abstractions, or Lambda: the ultimate pattern macro

7. Is abstraction needed for application?

8. Full Abstraction for PCF

9. Lambda abstractions in C++ vs. Scheme

10. Abstraction facilities and source-level optimizations

11. xTalk and Ada: Abstraction of Syntax and Semantics

12. complexity of the bracket abstraction?


Powered by phpBB® Forum Software