Re: Question about the use of an inner forall

"Scott J."
Hi,
I am going to stop this discussion . What counts for me at this moment is that I know how it works.
Alright.
I thank everybody who replied to my email.
You're welcome.
As for the discussion about Curry Howard isomorphism and more about type theory, I shall gladly discuss these things further but than in private email.
Do you mean ``but in private email''? Why? I think that, because of the strong mathematical basis underlying Haskell, these things are on-topic. So, why not let the list profit from the discussion?
Hey, I hope really that I know how it works but this seems to be confirmed in these emails.
I left Ocamel for Haskell for it's more functional approach.
I think documentation about the features extending Haskell 98 is very needed for those who want only to program with the language Haskell.
True; unfortunately, too many extensions are documented only in technical papers...
Thx for all replies
Scott
Jon Cast

Well.
I have a question. Why are sets not implemented in Haskell? . I have read a
bit how the compiler is made. Ok lists are easier to implement but sets
could have been implemented too.
So why didn't the implementors not do it?
Scott
----- Original Message -----
From: "Jon Cast"
"Scott J."
wrote: Hi,
I am going to stop this discussion . What counts for me at this moment is that I know how it works.
Alright.
I thank everybody who replied to my email.
You're welcome.
As for the discussion about Curry Howard isomorphism and more about type theory, I shall gladly discuss these things further but than in private email.
Do you mean ``but in private email''? Why? I think that, because of the strong mathematical basis underlying Haskell, these things are on-topic. So, why not let the list profit from the discussion?
Hey, I hope really that I know how it works but this seems to be confirmed in these emails.
I left Ocamel for Haskell for it's more functional approach.
I think documentation about the features extending Haskell 98 is very needed for those who want only to program with the language Haskell.
True; unfortunately, too many extensions are documented only in technical papers...
Thx for all replies
Scott
Jon Cast _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

G'day all. On Tue, Aug 20, 2002 at 05:39:41AM +0200, Scott J. wrote:
I have a question. Why are sets not implemented in Haskell? . I have read a bit how the compiler is made. Ok lists are easier to implement but sets could have been implemented too. So why didn't the implementors not do it?
Almost certainly because the most efficient implementation of sets depends on data type and usage. For many applications, binary trees may be the most appropriate method. For others, hash tables might be better. For others, dense bit vectors and for yet others, sorted lists. Of course Haskell could have defined signatures and some implementations and left any specialist implementations up to the developer, however, the "most correct" type signatures require fundeps, which are not in Haskell 98. Incidentally, if someone wants an interesting project, Edison hasn't been touched in a while. Getting it a) fundep-compliant, b) complete and c) playing with the Monad Template Library would be a pretty useful thing. Cheers, Andrew Bromage

"Scott J."
I have a question. Why are sets not implemented in Haskell?
What do you mean? Isn't http://www.haskell.org/ghc/docs/latest/html/hslibs/set.html sufficient? (Remember to tell GHC '-package data') -kzm -- If I haven't seen further, it is by standing in the footprints of giants

As far a I know sets can implemented by implementing a list of anything(a
list of all types) The sets Haskell does have are AFAIK sets of elements of
the same type: these are not general sets.
Scott
----- Original Message -----
From: "Ketil Z. Malde"
"Scott J."
writes: I have a question. Why are sets not implemented in Haskell?
What do you mean? Isn't
http://www.haskell.org/ghc/docs/latest/html/hslibs/set.html
sufficient? (Remember to tell GHC '-package data')
-kzm -- If I haven't seen further, it is by standing in the footprints of giants _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Sets of arbitrary elements are not possible, because, for instance, you need to be able to compare elements to ensure no duplicates in the set and you can't do this for any arbitrary pair of types. Lists with arbitrary elements are possible, but not very useful. After all, what could you do with them? You don't know what type they are so you couldn't apply any function to them, except for a function which doesn't depend in any way on the type of its argument and hence doesn't depend on its argument at all. Any example of such lists would be: data AnyList = AnyNil | forall a . AnyCons a AnyList But I don't think this is what you really want. If you need to be able to store any two types in a list/set, use a union datatype, like: data Either a b = Left a | Right b then you can have a set of, for example, Either Int String. You can generalize this on your own. On Tue, 20 Aug 2002, Scott J. wrote:
As far a I know sets can implemented by implementing a list of anything(a list of all types) The sets Haskell does have are AFAIK sets of elements of the same type: these are not general sets.
Scott
----- Original Message ----- From: "Ketil Z. Malde"
To: Sent: Tuesday, August 20, 2002 8:56 AM Subject: Re: Question about sets "Scott J."
writes: I have a question. Why are sets not implemented in Haskell?
What do you mean? Isn't
http://www.haskell.org/ghc/docs/latest/html/hslibs/set.html
sufficient? (Remember to tell GHC '-package data')
-kzm -- If I haven't seen further, it is by standing in the footprints of giants _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

G'day all. On Tue, Aug 20, 2002 at 10:57:36AM -0700, Hal Daume III wrote:
Lists with arbitrary elements are possible, but not very useful. After all, what could you do with them?
It's often useful to have containers of arbitrary _constrained_ types, because then you can do something with them. For example, given the class of partial mappings on orderable keys: class (Ord k) => Map m k v | m -> k v where lookupM :: m -> k -> Maybe v instance (Ord k) => Map (FiniteMap k v) k v where lookupM = lookupFM instance (Ord k) => Map [(k,v)] k v where lookupM m k = case [ v | (k',v) <- m, k == k' ] of [] -> Nothing (v:_) -> Just v instance (Ord k) => Map (k -> Maybe v) k v where lookupM = id You can make a list of elements, which can be any type so long as they are a member of that class: data MAP k v = forall m. (Map m k v) => MAP m type ListOfMap k v = [MAP k v] Then you can do things with it: lookupLom :: (Ord k) => ListOfMap k v -> k -> [ Maybe v ] lookupLom xs k = [ lookupM a k | MAP a <- xs ] test :: [Maybe Int] test = lookupLom maps 1 where maps = [ MAP finiteMap, MAP assocListMap, MAP functionMap ] finiteMap = listToFM [(1,2)] assocListMap = [(1,3)] functionMap = \k -> if k == 1 then Just 4 else Nothing It's a little unfortunate that you have to introduce the MAP type here. You can in fact construct a list of this type: type ListOfMap k v = [ forall m. (Map m k v) => m ] But then you can't use the elements in the list because the Haskell type checker can't find the (Map m k v) constraint. Cheers, Andrew Bromage
participants (5)
-
Andrew J Bromage
-
Hal Daume III
-
Jon Cast
-
ketil@ii.uib.no
-
Scott J.