Re: [Haskell-cafe] Calling Haskell from .Net Environment
On Friday 29 October 2004 03:48, David Lo wrote: Dear all, I'm new in Haskell. I need to port a haskell application written by someone else to be called by a .Net C# application. Please kindly advise on which option to pursue. Any helps will really be appreciated. The easiest path I know would be to use xmlrpc, (or perhaps soap if you know it - but I am unsure of availability of the latter for haskell, you might check the www.haskell.org website). Bye Vincenzo -- I was dressed for success, but success it never comes [Pavement - Here] ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Set of reals...?
I forgot to mention: With regard to the dangerous practice of using == (as in your `elem` example) on Double, every computer scientist or programmer should read the following paper at some point in their training: David Goldberg, What every computer scientist should know about floating-point arithmetic. ACM Computing Survey Volume 23 , Issue 1 (March 1991) Pages: 5 - 48. http://portal.acm.org/citation.cfm?id=103163 --KW 8-) -- Keith Wansbrough [EMAIL PROTECTED] http://www.cl.cam.ac.uk/users/kw217/ University of Cambridge Computer Laboratory. ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] hugs segmentation fault
On 2004-10-29 at 00:50BST Ben Rudiak-Gould wrote: Jon Fairbairn wrote: On 2004-10-29 at 00:03BST Ben Rudiak-Gould wrote: Not much better, though: in my experience this particular exception leaves ghci in a very peculiar state, and it's usually necessary to quit and restart it before it will work again. I don't think I've seen such a problem (maybe I so rarely make that type of mistake?;-). What version? What are the symptoms of this not working of which you speak? It seems OK in ghci 6.2.1 Well, here's a sample session I recorded just now: C:\\ghc\ghc-6.2.1\bin\ghci ___ ___ _ / _ \ /\ /\/ __(_) / /_\// /_/ / / | | GHC Interactive, version 6.2.1, for Haskell 98. / /_\\/ __ / /___| | http://www.haskell.org/ghc/ \/\/ /_/\/|_| Type :? for help. Loading package base ... linking ... done. Prelude let p = 1 : [2 * x | x - p, x 1] in p [1*** Exception: loop Prelude 123 Fail: thread blocked indefinitely C:\ Does this only happen to me? I'm using Linux, you Windows. I suspect there's a hint there. Has this been reported to Glasgow Haskell bugs? (cc'd) -- Jón Fairbairn [EMAIL PROTECTED] ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Set of reals...?
MR K P SCHUPKE wrote: | otherwise = contractSet (contract x0 y0:xs) ys I think you'll find the original is correct. The first two cases deal with non-overlapping ranges. The only remaining case is overlapping ranges, (partial and full overlap) both these cases are dealt with by contract, and as a result use up both the ranges at the head of both lists, sdo the merged range is prepended to the output list and the tail is calculated by passing the unused tails of both lists to contactSet... Consider the case of merging [(1,2),(3,4)] and [(1,4)]. I think your function will produce an answer of [(1,4),(3,4)]. -- Ben ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Set of reals...?
Keith Wansbrough wrote: Which brings me to a question: is there a better way to write -inf and +inf in Haskell than -1/0 and 1/0? Shouldn't (minBound :: Double) and (maxBound :: Double) work? They don't, but shouldn't they? -- Ben ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Set of reals...?
Keith Wansbrough wrote: Which brings me to a question: is there a better way to write -inf and +inf in Haskell than -1/0 and 1/0? Why not do it with types: data InfDbl = Dbl Double | PositiveInfinity | NegativeInfinity Keean. ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] hugs segmentation fault
Jon Fairbairn [EMAIL PROTECTED] writes: On 2004-10-29 at 00:50BST Ben Rudiak-Gould wrote: Jon Fairbairn wrote: Well, here's a sample session I recorded just now: C:\\ghc\ghc-6.2.1\bin\ghci Prelude let p = 1 : [2 * x | x - p, x 1] in p [1*** Exception: loop Prelude 123 Fail: thread blocked indefinitely C:\ Does this only happen to me? I'm using Linux, you Windows. I suspect there's a hint there. Has this been reported to Glasgow Haskell bugs? (cc'd) Plenty of times, but maybe not that particular manifestation of the problem. Fixed in 6.2.2 --sigbjorn ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Newbie Question on type constructors
On Fri, 29 Oct 2004, Brian Beckman wrote: This is a tiny question on the data syntax. snip There's a significant difference between data constructors and ordinary functions - you can't use pattern-matching to match an ordinary function. In effect, data constructors are used not just to build values but also to take them apart. Syntactically speaking, data constructors must begin with a capital letter, variables and function definitions with a lower case letter. -- [EMAIL PROTECTED] ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: [Haskell-cafe] Set of reals...?
Very pretty, Keean, though to get it to work in Hugs Nov 2002 I had to type the following uglier but equivalent syntax myInterval = Interval { isin = (\r - if r == 0.6 then True else if r 0.7 r 1.0 then True else False ) } -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Keean Schupke Sent: Wednesday, October 27, 2004 3:53 AM To: Stijn De Saeger Cc: [EMAIL PROTECTED] Subject: Re: [Haskell-cafe] Set of reals...? I think someone else mentioned using functions earlier, rather than a datatype why not define: data Interval = Interval { isin :: Float - Bool } Then each range becomes a function definition, for example: myInterval = Interval { isin r | r == 0.6 = True | r 0.7 r 1.0 = True | otherwise = False } Then you can test with: (isin myInterval 0.6) Keean ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Set of reals...?
Keith Wansbrough wrote: [...] Your data structure should be something like: data Interval = Interval { left :: Double, leftopen :: Bool, right :: Double, rightopen :: Bool } data Set = Set [Interval] If you want more efficiency, you probably want a bintree datastructure (search Google for quadtree and octree, and make the obvious dimension shift). An easy-ish special case, if you're only dealing with intervals in one dimension, is (untested): import Data.FiniteMap type IntervalSet k = FiniteMap k (k, Bool, Bool) isin :: (Ord k) = k - IntervalSet k - Bool k `isin` s = case fmToList_GE k s of [] - False ((k2, (k1, open1, open2)):_) - (if open1 then k k1 else k = k1) (if open2 then k k2 else k = k2) where each key in the finite map is the upper end of a range, and each element of the finite map contains the lower end of the range and the open/closed flags. This sort of thing seems to be the intended use of the _GE functions in Data.FiniteMap. Regards, Tom ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Set of reals...?
MR K P SCHUPKE wrote: Double already has +Inf and -Inf; it's just that Haskell doesn't have (AFAIK) syntax to write them as constants. In the source for the GHC libraries it uses 1/0 for +Infinity and -1/0 for -Infinity, so I assume these are the official way to do it. Personally I would define nicer names: positiveInfinity :: Double positiveInfinity = 1/0 negativeInfinity :: Double negativeInfinity = -1/0 Or just: infinity = 1/0 and use -infinity for the negative. One other nit: isn't the read/show syntax for Haskell98 types supposed to valid Haskell syntax? From http://www.haskell.org/onlinereport/derived.html#derived-text The result of show is a syntactically correct Haskell expression containing only constants, given the fixity declarations in force at the point where the type is declared. [Note: the above sentecne refers specifically to derived instances, but induction would require that it also holds for base types.] However: Prelude let infinity = 1/0 :: Double Prelude show infinity Infinity Prelude read (show infinity) :: Double Infinity Prelude Infinity interactive:1: Data constructor not in scope: `Infinity' -- Glynn Clements [EMAIL PROTECTED] ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe