[clean-list] unique record fields.

Ilya Shpitser ilyas@CSUA.Berkeley.EDU
Mon, 4 Jun 2001 21:31:14 -0700


Hello,

  This is probably a very basic question (for which I apologize).  I am trying
  to write hashtables in Clean.  The way I want to go about it is to define
  a Map type (parameterized by key and value types) corresponding to a record
  containing a (unique) array (and some other useful state):

:: *Map *a b =
	{ state :: {[(a, b)]}
	, size  :: Int
	, put   :: (Map a b) -> a -> b -> (Map a b)
	... etc.
	}

  Then the function to construct an object of this type would look like:

Map hash equal size = 
	{ state = createArray size []		  // <- error 2
	, put = put
	... etc.
	}
where
	put :: (*Map *a b) *a b -> (*Map *a b)    // <- error 1
	put map key val =
	...
	map

  However when I try to compile this program I get the following type errors:

Type error [Map.icl,34,put]: "map" attribute at the indicated position cannot be coerced: Map ^ a b | == b
Type error [Map.icl,22,Map]: "createArray ({})" cannot create a non-unique variant of this type at the indicated position: ^ [(a,b)]

  I am doing nothing in the program except defining the constructor, I am not
  even calling it.  Does anyone have any insight into this?
  If this list is not the right place for these sorts of questions I would be
  happy to direct them to the right place.

  Thanks in advance,

  Ilya