RE: Hash in Haskell
Title: RE: Hash in Haskell Stable names/references may be what you need. http://research.microsoft.com/~simonpj/Papers/weak.htm Cheers -Original Message- From: Sergio Sebastián Giro [mailto:[EMAIL PROTECTED]] Sent: Tuesday, 17 June, 2003 12:08 PM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: Hash in Haskell On Mon, 16 Jun 2003 [EMAIL PROTECTED] 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án 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 > > [EMAIL PROTECTED] > > 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:[EMAIL PROTECTED] > > ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Re: Hash in Haskell
On Mon, 16 Jun 2003 [EMAIL PROTECTED] 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án 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 > > [EMAIL PROTECTED] > > 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:[EMAIL PROTECTED] > > ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
C++ class structure mapping
I'd like to make a haskell binding for a C++ library. Most of the tools out there seem oriented towards c bindings, so it looks like I'll be writing the FFI code generator myself. While I'm at it I figure I might as well just make a general C++ binding tool. I've been thinking about this, and I'd like some feedback on the ideas I've had. First - it seems natural to use template haskell to do the code generation. That way, the library could either write the generated code to a file using the pretty-printers, or just be spliced in directly. Now comes the question of how to map a C++ class hierarchy into haskell. It seems natural to try to map C++ classes into haskell typeclasses; however, there are a few issues involved with that. A separate datatype would have to be made for each C++ class to allow it to actually be instantiated, which isn't too bad. However, to allow haskell instances of the typeclass to call the old behavior it seems that there'd have to be duplicate functions of the ones in the typeclass, i.e. class A a where foo :: a -> IO () foo_cpp :: (A a) => a -> IO () That seems to be needed to allow haskell instances to call the old implementation in their definition, but it rubs me the wrong way. Can anyone suggest an alternate method, or suggest a different direction entirely? Abe ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
FM 2003 Call for Participation
Title: FM 2003 Call for Participation Sorry if some of you receive multiple copies of this message. Stefania Gnesi (FM2003 General Chair) == Call for Participation -- The 12th International FME Symposium Pisa, Italy - September 8-14, 2003 http://fme03.isti.cnr.it - [EMAIL PROTECTED] -- FM 2003 is the twelfth in a series of symposia organized by Formal Methods Europe, an independent association whose aim is to stimulate the use of, and research on, formal methods for software development. These symposia have been notably successful in bringing together a community of users, researchers, and developers of precise mathematical methods for software development as well as industrial users. Formal methods have been controversial throughout their history, and the realization of their full potential remains, in the eyes of many practitioners, merely a promise. Have they been successful in industry? If so, under which conditions? Has any progress been made in dispelling the skepticism that surrounds them? Are they worth the effort? Which aspects of formal methods have become so well established in the industrial practices to loose the "formal method" label in the meanwhile? FM 2003 aims to answer these questions, by contributions not only from the Formal Methods community but also from outsiders and even from skeptical people who are most welcome to explain, document, and motivate the source of their reluctance. Satellite Events FM 2003, will host 7 Workshops, 8 Tutorials and 1 Day dedicated to the Industry besides the 3 days of the FME Symposium. Tool demonstrations will also take place during the symposium, with the opportunity of holding presentations for each tool. For full details on the Symposium organization and to register please see the web site http://fme03.isti.cnr.it, or send your query to [EMAIL PROTECTED].
Re: Hash in Haskell
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án 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 > [EMAIL PROTECTED] > 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:[EMAIL PROTECTED] ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Hash in Haskell
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 [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Re: Typesafe MRef's
> Keith Wansbrough wrote (snipped) > > > I think I'm missing something... why is this? Do you only allow one > > value of each type? It seems to me that updating k1's value should > > not affect k2's. > > Perhaps you could explain what "insert" is meant to do, since it doesn't > cite a key value. I'm thinking newSTRef - allocate a new cell. --KW 8-) -- Keith Wansbrough <[EMAIL PROTECTED]> http://www.cl.cam.ac.uk/users/kw217/ University of Cambridge Computer Laboratory. ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Re: Typesafe MRef's
Keith Wansbrough wrote (snipped) I think I'm missing something... why is this? Do you only allow one value of each type? It seems to me that updating k1's value should not affect k2's. Perhaps you could explain what "insert" is meant to do, since it doesn't cite a key value. ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Re: hiddencode
I have added my experiences with Haskell literate programming to the wiki: http://haskell.org/hawiki/LiterateProgramming Ciao, Steffen -- Steffen Mazanek - www.steffen-mazanek.de - GPG: 791F DCB3 Haskell, that's where I just curry until fail, unwords any error, drop all undefined, maybe break, otherwise in sequence span isControl and take max $, id: (d:[]) ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Re: Typesafe MRef's
George Russell writes: > So what does the function > insert2 val1 val2 = >let > (m1,k1) = insert empty (Just val1) > (m2,k2) = insert m1 (Just val2) > m3 = update m2 k1 Nothing >in > isJust (lookup m3 k2) > return? It looks to me as if it returns True if val1 and val2 have > different types, False if they have the same type. So you have now > got a way of comparing two types for equality, and so a rather > roundabout reimplementation of Dynamic. I think I'm missing something... why is this? Do you only allow one value of each type? It seems to me that updating k1's value should not affect k2's. --KW 8-) ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Re: Typesafe MRef with a regular monad
> Yes, that's a good point. So there are really three issues: > a) single-threaded-ness > b) making sure you look up in the right map > c) making sure the thing you find has the right type > > Even if you have typed keys, (Key a), then if you look them up in the > wrong map, any guarantee that it maps to a value of type 'a' is out of > the window. Not true, if you use the finite map implementation based on dynamics. Here, the story is: with single-threaded-ness you can omit the dynamic type checks (they are guaranteed to succeed); if you use finite maps in a persistent manner, this is no longer true. Cheers, Ralf ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
RE: Typesafe MRef with a regular monad
| If you use Simon PJ's type signatures, you can't really disallow using | a key from one map with another map. Yes, that's a good point. So there are really three issues: a) single-threaded-ness b) making sure you look up in the right map c) making sure the thing you find has the right type Even if you have typed keys, (Key a), then if you look them up in the wrong map, any guarantee that it maps to a value of type 'a' is out of the window. I can think of two solutions i) Guarantee that keys are unique across all maps, so that a key from one map is never in the domain of another. ii) Use the (ST s) and (STRef s) trick, to connect the key with the map. This seems cleaner, but demands more of the programmer. But my main point remains: that some form of typed finite map ought to exist that does no dynamic type checks, because none are necessary. This must be a terribly old problem; and unsafeCoerce seems like a rather brutal "solution". Simon ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell