From ndmitchell at gmail.com Tue Dec 9 11:37:58 2008 From: ndmitchell at gmail.com (Neil Mitchell) Date: Tue Dec 9 11:31:02 2008 Subject: Repair to floating point enumerations? In-Reply-To: <48FEFC6A.5040004@gmail.com> References: <20081015104125.3c260127.Malcolm.Wallace@cs.york.ac.uk> <48FEFC6A.5040004@gmail.com> Message-ID: <404396ef0812090837x2f5872eay9659c875d4600b9f@mail.gmail.com> Hi Bringing up an old thread, but this issue just bit me in real life: [0, 2.5 .. 3.75 ] = [0, 2.5, 5.0] I was comparative testing some C++ and some Haskell, and its a shame when its the Haskell that is clearly wrong! I don't think any end decision was reached in this thread, but I think this is sufficiently incorrect to call the Haskell 98 behaviour a bug. Thanks Neil On Wed, Oct 22, 2008 at 10:11 AM, Simon Marlow wrote: > Malcolm Wallace wrote: > >> Phil proposes that, although retaining the instances of Enum for Float >> and Double, we simplify the definitions of the numericEnumFrom family: >> >> numericEnumFromThenTo :: (Fractional a, Ord a) => a -> a -> a -> [a] >> numericEnumFrom = iterate (+1) >> numericEnumFromThen n m = iterate (+(m-n)) n >> numericEnumFromTo n m = takeWhile (<= m) (numericEnumFrom n) >> numericEnumFromThenTo n m p = takeWhile (<= p) (numericEnumFromThen n m) > > I'll leave it to the floating-point experts to decide exactly what to do > here for Haskell' (but I note that David Roundy's version looks better than > the iterate version above, because the errors won't accumulate). > >> But as maintainer and bug-fixer of the Haskell'98 Report, I have also >> been asked whether we should make this change retrospectively to the >> Haskell'98 language (as a "typo"). Since it involves not merely an >> ordinary library function, but a Prelude function, and moreover a >> function that is used in the desugaring of syntax, it is less clear to >> me whether to alter Haskell'98. > > We definitely can't make breaking changes to Haskell 98; this would be much > more than a "typo". > > However, this does give us a problem if we decide to make a change here for > H', as Neil points out, because there would be two mutually-incompatible > instances for Enum Float. We'd need to have a clear distinction between > programs that are Haskell 98 and those that are not, with only the former > allowed to use the haskell98 package. > > Cheers, > Simon > > _______________________________________________ > Haskell-prime mailing list > Haskell-prime@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-prime > From alson at alsonkemp.com Sat Dec 13 18:49:43 2008 From: alson at alsonkemp.com (Alson Kemp) Date: Sat Dec 13 18:42:33 2008 Subject: Suggestion: Syntactic sugar for Maps! Message-ID: <2629c41e0812131549mcac143cj6cf86129e16ffa1c@mail.gmail.com> >>> circularfunc: >>> > I suggest Haskell introduce some syntactic sugar for Maps. >>> > >>> > Python uses {"this": 2, "is": 1, "a": 1, "Map": 1} >>> > >>> > Clojure also use braces: {:k1 1 :k2 3} where whitespace is comma but >>> > commas are also allowed. >>> > >>> > I find the import Data.Map and then fromList [("hello",1), ("there", >>> > 2)] or the other form that I forgot(because it is to long!) to be to >>> > long... >>> > >>> > So why not {"hello": 1, "there": 2} ? A comment from the peanut gallery: I took circ's comment to be a suggestion that we adopt an _idiom_. That you can non-idiomatically accomplish the same thing in Haskell by defining some datatypes and functions doesn't seem to address the core suggestion. I'd rewrite circ's suggestion as follows: A bunch of modern and popular languages use the idiom of braces for maps (e.g. { 'a' => 1, 'b' => 2} ). Its simplicity has made maps vital parts of most programs. Much of the world has adopted this idiom and if Haskell adopts this syntactic sugar it will make it easier for others to adopt Haskell. Haskell is really interesting for a number of reasons. Map syntax isn't one of them but map syntax sugar would make adoption of Haskell that much easier. As I think Don S said, it's hard enough to adopt Haskell, so let's make it easier when possible... - Alson From ndmitchell at gmail.com Sun Dec 14 09:35:35 2008 From: ndmitchell at gmail.com (Neil Mitchell) Date: Sun Dec 14 09:28:22 2008 Subject: Suggestion: Syntactic sugar for Maps! In-Reply-To: <2629c41e0812131549mcac143cj6cf86129e16ffa1c@mail.gmail.com> References: <2629c41e0812131549mcac143cj6cf86129e16ffa1c@mail.gmail.com> Message-ID: <404396ef0812140635t1f2e8e4es3231b2185f56c65@mail.gmail.com> Hi Alson, >>>> > So why not {"hello": 1, "there": 2} ? > > A comment from the peanut gallery: > I took circ's comment to be a suggestion that we adopt an _idiom_. > That you can non-idiomatically accomplish the same thing in Haskell by > defining some datatypes and functions doesn't seem to address the core > suggestion. > > I'd rewrite circ's suggestion as follows: > A bunch of modern and popular languages use the idiom of braces for > maps (e.g. { 'a' => 1, 'b' => 2} ). Its simplicity has made maps > vital parts of most programs. Much of the world has adopted this > idiom and if Haskell adopts this syntactic sugar it will make it > easier for others to adopt Haskell. I am fairly certain someone could write the necessary magic so: do {'a' ~> 1; 'b' ~> 2} becomes a map without any changes to the language at all. It seems like throwing syntax at a problem should be a last resort. I often do: let (*) = (,) in ['a' * 1, 'b' * 2] I find that quite elegant as an associative list, which you can then convert to a map, a hash table, use as an associative list etc. I also think that those who are looking for Haskell will have their mind so blown by lazy evaluation that keeping their maps similar isn't so necessary :-) Thanks Neil From g9ks157k at acme.softbase.org Sun Dec 21 20:28:43 2008 From: g9ks157k at acme.softbase.org (Wolfgang Jeltsch) Date: Sun Dec 21 20:21:11 2008 Subject: Suggestion: Syntactic sugar for Maps! In-Reply-To: <404396ef0812140635t1f2e8e4es3231b2185f56c65@mail.gmail.com> References: <2629c41e0812131549mcac143cj6cf86129e16ffa1c@mail.gmail.com> <404396ef0812140635t1f2e8e4es3231b2185f56c65@mail.gmail.com> Message-ID: <200812220228.43930.g9ks157k@acme.softbase.org> Am Sonntag, 14. Dezember 2008 15:35 schrieb Neil Mitchell: > I am fairly certain someone could write the necessary magic so: > > do {'a' ~> 1; 'b' ~> 2} > > becomes a map without any changes to the language at all. It seems > like throwing syntax at a problem should be a last resort. I often do: > > let (*) = (,) in ['a' * 1, 'b' * 2] > > I find that quite elegant as an associative list, which you can then > convert to a map, a hash table, use as an associative list etc. > > I also think that those who are looking for Haskell will have their > mind so blown by lazy evaluation that keeping their maps similar isn't > so necessary :-) > > Thanks > > Neil +1