Hash in Haskell
Garner, Robin
Robin.Garner@crsrehab.gov.au
Tue, 17 Jun 2003 13:13:59 +1000
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
------_=_NextPart_001_01C3347E.7EEC60D0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Stable names/references may be what you need.
http://research.microsoft.com/~simonpj/Papers/weak.htm
Cheers
-----Original Message-----
From: Sergio Sebasti=E1n Giro [mailto:sergio@fceia.unr.edu.ar]
Sent: Tuesday, 17 June, 2003 12:08 PM
To: gilesb@cpsc.ucalgary.ca
Cc: haskell@haskell.org
Subject: Re: Hash in Haskell
On Mon, 16 Jun 2003 gilesb@cpsc.ucalgary.ca wrote:
Thanks anyway, but I want to maintain a set of elements of some (fixed)
unknown type. In a hash table, I can see in O(1) aprox. if the element
belongs or not to set.
> Typically, such functions are often used to implement mappings from
> something (such as a String) to something else.
>
> If that is what you want take a look at the type FiniteMap under the
> Data area of GHC and HUGS. It implements all the needed functionality
> without having to worry about creating a Hash for the keys.
>
> If you want if for some other reason, you would typically need to =
define
> a class such as:
>
> Class Hash where
> hash::a->Int
>
> and then implement it on your desired types. Strings are ususally
> somewhat easy to create a unique has value, other types will, =
naturally,
> depend on what is in them.
>
>
>
> On 16 Jun, Sergio Sebasti=E1n Giro wrote:
> > Hi, I need some function in Haskell to hash any value from any type =
to
> > Int. I guess that such a function needs to be a primitive, but I =
don't
> > found it in Hugs. Do you know how I can implement it or found it?
> > Thanks
> > Sergio
> > _______________________________________________
> > Haskell mailing list
> > Haskell@haskell.org
> > http://www.haskell.org/mailman/listinfo/haskell
>
> --
> Brett G. Giles
> Grad Student, University of Calgary
> Formal Methods, Category Theory, Semantics of Programming
> http://www.cpsc.ucalgary.ca/~gilesb =
mailto:gilesb@cpsc.ucalgary.ca
>
>
_______________________________________________
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell
------_=_NextPart_001_01C3347E.7EEC60D0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Diso-8859-1">
<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version =
5.5.2654.89">
<TITLE>RE: Hash in Haskell</TITLE>
</HEAD>
<BODY>
<P><FONT SIZE=3D2>Stable names/references may be what you need.</FONT>
</P>
<P><FONT SIZE=3D2><A =
HREF=3D"http://research.microsoft.com/~simonpj/Papers/weak.htm" =
TARGET=3D"_blank">http://research.microsoft.com/~simonpj/Papers/weak.htm=
</A></FONT>
</P>
<P><FONT SIZE=3D2>Cheers</FONT>
</P>
<P><FONT SIZE=3D2>-----Original Message-----</FONT>
<BR><FONT SIZE=3D2>From: Sergio Sebasti=E1n Giro [<A =
HREF=3D"mailto:sergio@fceia.unr.edu.ar">mailto:sergio@fceia.unr.edu.ar</=
A>]</FONT>
<BR><FONT SIZE=3D2>Sent: Tuesday, 17 June, 2003 12:08 PM</FONT>
<BR><FONT SIZE=3D2>To: gilesb@cpsc.ucalgary.ca</FONT>
<BR><FONT SIZE=3D2>Cc: haskell@haskell.org</FONT>
<BR><FONT SIZE=3D2>Subject: Re: Hash in Haskell</FONT>
</P>
<BR>
<P><FONT SIZE=3D2>On Mon, 16 Jun 2003 gilesb@cpsc.ucalgary.ca =
wrote:</FONT>
<BR><FONT SIZE=3D2>Thanks anyway, but I want to maintain a set of =
elements of some (fixed)</FONT>
<BR><FONT SIZE=3D2>unknown type. In a hash table, I can see in O(1) =
aprox. if the element</FONT>
<BR><FONT SIZE=3D2>belongs or not to set.</FONT>
</P>
<P><FONT SIZE=3D2>> Typically, such functions are often used to =
implement mappings from</FONT>
<BR><FONT SIZE=3D2>> something (such as a String) to something =
else.</FONT>
<BR><FONT SIZE=3D2>></FONT>
<BR><FONT SIZE=3D2>> If that is what you want take a look at =
the type FiniteMap under the</FONT>
<BR><FONT SIZE=3D2>> Data area of GHC and HUGS. It implements all =
the needed functionality</FONT>
<BR><FONT SIZE=3D2>> without having to worry about creating a Hash =
for the keys.</FONT>
<BR><FONT SIZE=3D2>></FONT>
<BR><FONT SIZE=3D2>> If you want if for some other reason, you would =
typically need to define</FONT>
<BR><FONT SIZE=3D2>> a class such as:</FONT>
<BR><FONT SIZE=3D2>></FONT>
<BR><FONT SIZE=3D2>> Class Hash where</FONT>
<BR><FONT SIZE=3D2>> hash::a->Int</FONT>
<BR><FONT SIZE=3D2>></FONT>
<BR><FONT SIZE=3D2>> and then implement it on your desired types. =
Strings are ususally</FONT>
<BR><FONT SIZE=3D2>> somewhat easy to create a unique has value, =
other types will, naturally,</FONT>
<BR><FONT SIZE=3D2>> depend on what is in them.</FONT>
<BR><FONT SIZE=3D2>></FONT>
<BR><FONT SIZE=3D2>></FONT>
<BR><FONT SIZE=3D2>></FONT>
<BR><FONT SIZE=3D2>> On 16 Jun, Sergio Sebasti=E1n Giro =
wrote:</FONT>
<BR><FONT SIZE=3D2>> > Hi, I need some function in Haskell to =
hash any value from any type to</FONT>
<BR><FONT SIZE=3D2>> > Int. I guess that such a function needs to =
be a primitive, but I don't</FONT>
<BR><FONT SIZE=3D2>> > found it in Hugs. Do you know how I can =
implement it or found it?</FONT>
<BR><FONT SIZE=3D2>> > Thanks</FONT>
<BR><FONT SIZE=3D2>> > Sergio</FONT>
<BR><FONT SIZE=3D2>> > =
_______________________________________________</FONT>
<BR><FONT SIZE=3D2>> > Haskell mailing list</FONT>
<BR><FONT SIZE=3D2>> > Haskell@haskell.org</FONT>
<BR><FONT SIZE=3D2>> > <A =
HREF=3D"http://www.haskell.org/mailman/listinfo/haskell" =
TARGET=3D"_blank">http://www.haskell.org/mailman/listinfo/haskell</A></F=
ONT>
<BR><FONT SIZE=3D2>></FONT>
<BR><FONT SIZE=3D2>> --</FONT>
<BR><FONT SIZE=3D2>> Brett G. Giles</FONT>
<BR><FONT SIZE=3D2>> Grad Student, University of Calgary</FONT>
<BR><FONT SIZE=3D2>> Formal Methods, Category Theory, Semantics of =
Programming</FONT>
<BR><FONT SIZE=3D2>> <A HREF=3D"http://www.cpsc.ucalgary.ca/~gilesb" =
TARGET=3D"_blank">http://www.cpsc.ucalgary.ca/~gilesb</A> &nb=
sp; <A =
HREF=3D"mailto:gilesb@cpsc.ucalgary.ca">mailto:gilesb@cpsc.ucalgary.ca</=
A></FONT>
<BR><FONT SIZE=3D2>></FONT>
<BR><FONT SIZE=3D2>></FONT>
<BR><FONT =
SIZE=3D2>_______________________________________________</FONT>
<BR><FONT SIZE=3D2>Haskell mailing list</FONT>
<BR><FONT SIZE=3D2>Haskell@haskell.org</FONT>
<BR><FONT SIZE=3D2><A =
HREF=3D"http://www.haskell.org/mailman/listinfo/haskell" =
TARGET=3D"_blank">http://www.haskell.org/mailman/listinfo/haskell</A></F=
ONT>
</P>
</BODY>
</HTML>
------_=_NextPart_001_01C3347E.7EEC60D0--