Re: [Haskell-cafe] Exception for NaN

2011-05-14 Thread Daniel Fischer
On Friday 13 May 2011 23:41:34, Casey McCann wrote:
 On Fri, May 13, 2011 at 4:48 PM, Luke Palmer lrpal...@gmail.com wrote:
  On Thu, May 12, 2011 at 5:50 PM, Daniel Fischer
  
  daniel.is.fisc...@googlemail.com wrote:
  Prelude Data.List maximum [0,-1,0/0,-5,-6,-3,0/0,-2]
  0.0
  Prelude Data.List minimum [0,-1,0/0,-5,-6,-3,0/0,-2]
  -2.0
  Prelude Data.List sort [0,-1,0/0,-5,-6,-3,0/0,-2]
  [-6.0,-5.0,-2.0,NaN,-3.0,NaN,-1.0,0.0]
  
  Wow, that's the best example of NaN poison I've seen.
 
 Somewhat less impressive, but would everyone expect these functions to
 be equivalent up to performance characteristics?
 
 f :: (Eq a) = [a] - [a]
 f = nub . concatMap (replicate 5)
 
 g :: (Eq a) = [a] - [a]
 g = nub
 
 If the answer that springs to mind is yes, for any well-behaved
 instance of Eq, well...

My answer is Yes, for any well-behaved instance of Eq or for lists of 
Float/Double not containing any NaN (and similar caveats for types using 
these) - other types with special cases may exist, none springs to mind.

It's (hopefully) well-known that the Eq and Ord instances of Double and 
Float aren't well-behaved in the presence of NaNs, but you can't have 
consistent instances which do what you expect on non-NaN values.

Not having Eq and Ord instances for Double and Float would be extremely 
inconvenient (too inconvenient to seriously consider, I think), so one can
a) do what's done now
b) make NaNs an error
c) come up with a brilliant solution.

While c) has not been achieved, I consider a) the least evil option.

 
 Bonus question: Should this function ever return False?
 
 h :: (Ord a) = a - a - Bool
 h x y = case compare x y of
 GT - x  y
 EQ - x == y
 LT - x  y

Not for well-behaved Ord instances, nor for Double and Float, provided 
neither argument is NaN (and derived cases).

 
 - C.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Sending messages up-and-down the iteratee-enumerator chain [Was: iterIO-0.1]

2011-05-14 Thread oleg


Sorry, this is just a simple answer to one question:

 However, I still have two questions.  First, the Iter type in your
 message seems more like your first iteratee implementation, which is
 the approach iterIO and enumerator now take.  I wonder if it's
 possible to implement something like Tell your current, CPS-based
 iteratee.  Part of the reason I didn't take a CPS-based approach for
 Iter was that I couldn't get the upward control requests to work.
 (Also I wanted pure iteratees, which reduced the gain from CPS.)

Here are the differences from the file UpDown.hs (along the lines of
IterateeMCPS.hs)

newtype IterCPS ee ie a =   -- non-monadic answer-type
  IterCPS{runIter :: forall r. 
(a - r) - 
((Stream ie - IterCPS ee ie a) - r) -
(ee (IterCPS ee ie) a - r) -
r}

instance Bindable ee = Monad (IterCPS ee ie) where
return x = IterCPS $ \ kd _ _ - kd x
IterCPS m = f = IterCPS $ \kd kc ke - 
  let m_done x = runIter (f x) kd kc ke
  m_cont g = kc (\s - g s = f)
  m_iexc e = ke (comp e f)
  in m m_done m_cont m_iexc

-- The simplest iteratee, which doesn't do anything but asks for trouble
ierr :: Sum2 Err c = IterCPS c ie a
ierr = IterCPS $ \_ _ ke - ke . inj2 $ Err (\_ - ierr)


-- A small iteratee: asks for little and accepts little
-- Return the current element
iehead :: (Sum2 Err c, Bindable c) = IterCPS c EOF Char
iehead = IterCPS $ \_ kc _ - kc step
 where
 step (Chunk a)  = return a
 step (SExc EOF) = ierr


-- Ask for the current position
itell :: (Sum2 Tell c, Bindable c) = IterCPS c ie Int
itell = IterCPS $ \_ _ ke - ke . inj2 $ Tell return


-- check to see if the current character is 'a' and it occurs at pos 2 (1-based)
ietell :: (Sum2 Err c, Sum2 Tell c, Bindable c) = IterCPS c EOF Bool
ietell = IterCPS $ \_ kc _ - kc step
 where
 step (Chunk 'a') = itell = return . (== 2)
 step (Chunk _)   = return False
 step (SExc EOF)  = ierr


-- Like iehead, but accept the Flush message
ieflush :: (Sum2 Err c, Bindable c) = IterCPS c (Either EOF Flush) Char
ieflush = IterCPS $ \_ kc _ - kc step
 where
 step (Chunk a)  = return a
 step (SExc x) | Just EOF   - prj x = ierr
 step (SExc x) | Just Flush - prj x = ieflush


-- Enumerators and enumeratees
-- Enumerators, in contrast, are explicit in what requests they may
-- satisfy, but implicit in what they may send on the stream.

-- Simple typical enumerator
-- The iteratee must at least accept EOF
-- The iteratee may return Err, but no other requests

en_str :: Sum EOF ie = String - IterCPS Err ie x - IterCPS Err ie x
en_str str i = runIter i kd kc ke
 where
 kd = return
 kc k = case str of
 - k eof
(h:t) - en_str t $ k (Chunk h)
 ke x | Just (Err _) - prj2 x = ierr


-- A typical enumeratee
-- It keeps the track of positions
-- It is explicit in requests it accepts: only Tell and Err.
-- It is polymorphic in the in-stream messages

en_pos :: Int - IterCPS (E2 Err Tell) ie x - IterCPS Err ie x
en_pos n i = runIter i kd kc ke
 where
 kd = return
 kc k = IterCPS $ \_ kc _ - kc (\s - en_pos (n+1) (k s))
 ke x | Just (Err _)  - prj2 x = ierr
 ke x | Just (Tell k) - prj2 x = en_pos n (k n)


irun :: Sum EOF ie = IterCPS Err ie x - x
irun i = runIter i kd kc ke
 where
 kd x = x
 kc k = irun $ k eof
 ke _ = error Iter error


The rest of the code, including the tests, are the same.


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Exception for NaN

2011-05-14 Thread Ketil Malde
Daniel Fischer daniel.is.fisc...@googlemail.com writes:

 Not having Eq and Ord instances for Double and Float would be extremely 
 inconvenient (too inconvenient to seriously consider, I think), so one can
 a) do what's done now
 b) make NaNs an error
 c) come up with a brilliant solution.

Maybe not terribly brilliant, but wouldn't it improve things slightly if
NaN was considered less or greater than any other value (possibly
excluding infinities)?

-k
-- 
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


Re: [Haskell-cafe] Division: Is there a way to simultaneously find the quotient and remainder?

2011-05-14 Thread Henning Thielemann
Chris Smith schrieb:

 Sure... see quotRem in the prelude.

http://www.haskell.org/haskellwiki/Haskell_programming_tips#Forget_about_quot_and_rem

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Division: Is there a way to simultaneously find the quotient and remainder?

2011-05-14 Thread KC
Thank you all.

I remember Hoogle'ing for rem and then quot but not finding qoutRem. :)


On Sat, May 14, 2011 at 6:55 AM, Henning Thielemann
schlepp...@henning-thielemann.de wrote:
 Chris Smith schrieb:

 Sure... see quotRem in the prelude.

 http://www.haskell.org/haskellwiki/Haskell_programming_tips#Forget_about_quot_and_rem

 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe




-- 
--
Regards,
KC

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Exception for NaN

2011-05-14 Thread Casey McCann
On Sat, May 14, 2011 at 9:14 AM, Ketil Malde ke...@malde.org wrote:
 Maybe not terribly brilliant, but wouldn't it improve things slightly if
 NaN was considered less or greater than any other value (possibly
 excluding infinities)?

It would improve things in the sense of giving well-behaved instances
for Eq and Ord, yes. It would not improve things in the sense that it
would violate the IEEE floating point spec.

The real issue here, I think, is that we're expecting Ord to serve two
different purposes: Sometimes a logical ordering on the type according
to its semantics, sometimes an essentially arbitrary ordering for the
purpose of structuring data (e.g., for use as a key in Data.Map). For
most types, either there is no meaningful semantic ordering or the
obvious ordering serves both purposes.

In the case of floating point values, the semantics of the type are
that it is not fully ordered and thus arguably shouldn't be an
instance of Ord at all--in particular, there's nothing compare can
correctly return when given NaN. An arbitrary ordering, on the other
hand, could be established easily so that things like Data.Map would
work correctly, but only by breaking the semantics of the type (even
more than is already the case due to things like compare, that is).

The current situation is an awkward compromise that mostly works and
does what you want in most cases except when you get weird silent bugs
due to, say, minimum returning a non-minimal value, or Data.Map.lookup
returning Nothing for a key that actually exists, or whatever else.
Alternative approaches are generally going to be either horribly
inconvenient, cause as many problems as they solve, or require
massively disruptive changes to the standard library.

In short, file this one on the shelf next to why is Num designed the
way it is?

- C.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Exception for NaN

2011-05-14 Thread Daniel Fischer
On Saturday 14 May 2011 15:14:31, Ketil Malde wrote:
 Daniel Fischer daniel.is.fisc...@googlemail.com writes:
  Not having Eq and Ord instances for Double and Float would be
  extremely inconvenient (too inconvenient to seriously consider, I
  think), so one can a) do what's done now
  b) make NaNs an error
  c) come up with a brilliant solution.
 
 Maybe not terribly brilliant, but wouldn't it improve things slightly if
 NaN was considered less or greater than any other value (possibly
 excluding infinities)?

On the one hand yes, although it would be arbitrary and still produce 
undesirable results.

On the other hand, the behaviour of (==), () etc. with NaNs that we have 
is what is specified in the Java Language Specification (section 4.2.3) and 
in the C99 standard (fn. 206, §17.12.14.2 and Appendix F.8.3), if I read 
that footnote correctly, that behaviour is required by IEC 60559 (by which 
comparisons involving a NaN must raise an 'invalid' exception). I expect 
that other languages specify the same behaviour, I think it's what the 
hardware does.

So, is it worth changing? I'm not sure, but I tend towards thinking it's 
not, we'd need a better solution to make it worth the deviation.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Division: Is there a way to simultaneously find the quotient and remainder?

2011-05-14 Thread Daniel Fischer
On Saturday 14 May 2011 15:55:15, Henning Thielemann wrote:
 Chris Smith schrieb:
  Sure... see quotRem in the prelude.
 
 http://www.haskell.org/haskellwiki/Haskell_programming_tips#Forget_about
 _quot_and_rem

No, don't, just know when you want which.
quot and rem are what you get from the hardware (perhaps not all, but 
most), thus they are faster. If speed is important and the semantics 
coincide (e.g. when all operands are positive), use quot and rem.

If the semantics of quot or rem are better for your goal than those of div 
or mod (example from GHC.Float.floatToDigits:

-- Using quot instead of div is a little faster and requires
-- fewer fixup steps for negative lx.
let lx = p - 1 + e0
k1 = (lx * 8651) `quot` 28738

), use quot or rem.

div and mod have the better semantics for most use-cases, so they should be 
what one normally uses, but there are cases where you want quot and rem. 
For those cases, knowing them causes happiness.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Exception for NaN

2011-05-14 Thread KQ

On Sat, 14 May 2011 06:14:31 -0700, Ketil Malde ke...@malde.org wrote:


Daniel Fischer daniel.is.fisc...@googlemail.com writes:


Not having Eq and Ord instances for Double and Float would be extremely
inconvenient (too inconvenient to seriously consider, I think), so one can
a) do what's done now
b) make NaNs an error
c) come up with a brilliant solution.


Maybe not terribly brilliant, but wouldn't it improve things slightly if
NaN was considered less or greater than any other value (possibly
excluding infinities)?

-k


It has a certain aesthetic appeal, but another concern of this approach would 
be non-termination.  This is perhaps less of a concern for functional 
methodologies, but still a danger for algorithms that assume total ordering.

--
-KQ

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Is there an efficient way to generate Euler's totient function for [2, 3..n]?

2011-05-14 Thread KC
Is there an efficient way to generate Euler's totient function for [2,3..n]?

Or an arithmetical sequence?

Or a geometric sequence?

Or some generalized sequence?

-- 
--
Regards,
KC

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Is there an efficient way to generate Euler's totient function for [2, 3..n]?

2011-05-14 Thread Warren Henning
On Sat, May 14, 2011 at 10:22 AM, KC kc1...@gmail.com wrote:
 Is there an efficient way to generate Euler's totient function for [2,3..n]?

 Or an arithmetical sequence?

 Or a geometric sequence?

 Or some generalized sequence?

Does computing the totient function require obtaining the prime
factorization of an integer, which can't be done in polynomial time?

Maybe I misunderstood what you were saying.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Is there an efficient way to generate Euler's totient function for [2, 3..n]?

2011-05-14 Thread KC
Instead of finding the totient of one number, is there a quicker way
when processing a sequence?


-- From: http://www.haskell.org/haskellwiki/99_questions/Solutions/34
totient :: Int - Int
totient n = length [x | x - [1..n], coprime x n]
   where
   coprime a b = gcd a b == 1



On Sat, May 14, 2011 at 10:29 AM, Warren Henning
warren.henn...@gmail.com wrote:
 On Sat, May 14, 2011 at 10:22 AM, KC kc1...@gmail.com wrote:
 Is there an efficient way to generate Euler's totient function for [2,3..n]?

 Or an arithmetical sequence?

 Or a geometric sequence?

 Or some generalized sequence?

 Does computing the totient function require obtaining the prime
 factorization of an integer, which can't be done in polynomial time?

 Maybe I misunderstood what you were saying.

 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe




-- 
--
Regards,
KC

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Experimental GHC with GHCJS built in and Cabal support for JavaScript files

2011-05-14 Thread Hamish Mackenzie
Blackh and I have been trying out some ideas on how to make it easier use GHCJS 
in your Cabal projects.  We took Victor's GHCJS code and added it back into GHC 
(we could not easily accomplish what we wanted using the current GHC API).  We 
set it up so that GHC outputs a .js file whenever it outputs an object file.  
We added code to Cabal to install the .js files (in the same place as the .hi 
files).  At link time GHC copies all the .js files from the packages used into 
a .jsexe directory (with the same name and in the same location as the 
executable).  Finally when the executable is installed we copy the .jsexe 
directory along with it.  Only files with differing modified dates are copied 
to avoid slowing things down too much.

I have updated my yesod-slides example to show how all this can be used.

https://github.com/hamishmack/yesod-slides

The README.mardown there has instructions for building GHC and Cabal with the 
GHCJS stuff in it.  It is a bit painful to build, but the changes to 
yesod-slides were quite minor...
 * Added ghcjs-rts to the build depends
 * Published the yesod-slides.jsexe folder (using Yesod's staticFiles)
 * Added script tags to head for rts-common.js and rts-plain.js
 * Added Julius script to init the rts

Currently GHC is hard coded to use the GHCJS Trampoline calling convention (in 
GHC's HscMain.hs).

Hamish
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Is there an efficient way to generate Euler's totient function for [2, 3..n]?

2011-05-14 Thread Daniel Fischer
On Saturday 14 May 2011 19:38:03, KC wrote:
 Instead of finding the totient of one number, is there a quicker way
 when processing a sequence?

For some sequences.

For [1 .. n] (you asked about [2 .. n], but it may be better to include 1), 
it can efficiently be done, O(n*log log n), iirc.

Variant 1 (doesn't need to include 1):

for i = 1 to n:
  sieve[i] := i

for i = 2 to n:
  if sieve[i] == i -- i is prime
for j = 1 to (n `div` i):
  sieve[i*j] := sieve[i*j]/i

A more involved but faster variant is first building a smallest prime 
factor sieve, then calculating the totients from that (by the 
multiplicativity of the totient function; this is where it's nice to 
include 1); this allows a few optimisations the other one doesn't.

 
 
 -- From: http://www.haskell.org/haskellwiki/99_questions/Solutions/34
 totient :: Int - Int
 totient n = length [x | x - [1..n], coprime x n]
where
coprime a b = gcd a b == 1

NEVER do that! It's awfully slow.

 
 
 
 On Sat, May 14, 2011 at 10:29 AM, Warren Henning
 
 warren.henn...@gmail.com wrote:
  On Sat, May 14, 2011 at 10:22 AM, KC kc1...@gmail.com wrote:
  Is there an efficient way to generate Euler's totient function for
  [2,3..n]?
  
  Or an arithmetical sequence?

Totients of [a, a+d .. a+n*d] ?
For some values of a and d it can be done efficiently, in general not.

  
  Or a geometric sequence?

Totients of [a*q^k | k - [x .. y]] ?

Yes, find the factorisations of a and q; from those it's trivial to compute 
the factorisations of a*q^k, and from those the totients.

Of course, for large a and q finding the factorisation may be nontrivial.

  
  Or some generalized sequence?

No, without special structure, the only way is to find each totient 
individually.

  
  Does computing the totient function require obtaining the prime
  factorization of an integer,

For a single integer, an efficient calculation of the totient requires 
finding the prime factorisation, for a range [1 .. n], you can stop a 
little short of that.

  which can't be done in polynomial time?

I suppose you mean polynomial in the number of digits.
I don't think it's proven that there's no polynomial time algorithm, just 
none has been found (yet) [if there is one].

  
  Maybe I misunderstood what you were saying.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Experimental GHC with GHCJS built in and Cabal support for JavaScript files

2011-05-14 Thread Mathijs Kwik
Wow, this is great news.
(still compiling, so didn't even try it out yet)

Will it be possible to interface (from/to) with native javascript
functions in this release?
And are there any packages that provide the objects/functions provided
by the DOM?

Thanks for continuing ghcjs. I was beginning to fear people didn't
mind to code JS by hand :P



On Sat, May 14, 2011 at 7:44 PM, Hamish Mackenzie
hamish.k.macken...@googlemail.com wrote:
 Blackh and I have been trying out some ideas on how to make it easier use 
 GHCJS in your Cabal projects.  We took Victor's GHCJS code and added it back 
 into GHC (we could not easily accomplish what we wanted using the current GHC 
 API).  We set it up so that GHC outputs a .js file whenever it outputs an 
 object file.  We added code to Cabal to install the .js files (in the same 
 place as the .hi files).  At link time GHC copies all the .js files from the 
 packages used into a .jsexe directory (with the same name and in the same 
 location as the executable).  Finally when the executable is installed we 
 copy the .jsexe directory along with it.  Only files with differing modified 
 dates are copied to avoid slowing things down too much.

 I have updated my yesod-slides example to show how all this can be used.

 https://github.com/hamishmack/yesod-slides

 The README.mardown there has instructions for building GHC and Cabal with the 
 GHCJS stuff in it.  It is a bit painful to build, but the changes to 
 yesod-slides were quite minor...
  * Added ghcjs-rts to the build depends
  * Published the yesod-slides.jsexe folder (using Yesod's staticFiles)
  * Added script tags to head for rts-common.js and rts-plain.js
  * Added Julius script to init the rts

 Currently GHC is hard coded to use the GHCJS Trampoline calling convention 
 (in GHC's HscMain.hs).

 Hamish
 ___
 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


Re: [Haskell-cafe] Please add a method for optimized concat to the Semigroup class

2011-05-14 Thread Henning Thielemann
Yitzchak Gale schrieb:

 When using it in practice, it would be very useful
 to have an analogue to the mconcat method of
 Monoid. It has the obvious default implementation,
 but allows for an optimized implementation for
 specific instances. That turns out to be something
 that comes up all the time (at least for me) in
 real life.

Btw. has someone an idea how to design 'mconcat' for pair types?

I mean, it is certainly sensible to define:

instance (Monoid a, Monoid b) = Monoid (a,b) where
  mappend (a0,b0) (a1,b1) = (mappend a0 a1, mappend b0 b1)
  mconcat pairs = (mconcat (map fst pairs), mconcat (map snd pairs))

but the mconcat definition would be inefficient for the type (Sum a, Sum
b). E.g. if I evaluate the first sum in (mconcat pairs) first and the
second sum last, then 'pairs' must be stored until we evaluate the
second sum. Without the Monoid instance I would certainly compute both
sums simultaneously in one left fold. Since a left fold can be expressed
in terms of a right fold, it would certainly work to map left-fold-types
like Sum to an Endo type, but this leads us to functional dependent
types or type functions.


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] parMap doesn't work fine

2011-05-14 Thread Maciej Marcin Piechotka
On Thu, 2011-05-12 at 15:29 +0400, Grigory Sarnitskiy wrote:
 Hello!
 
 I've just started using parallel computations in Haskell. parMap works fine, 
 it is so easy to use. However, parMap fails with functions returning lazy 
 structures, e.g. tuples.
 
 This code works as expected:
 
 (parMap rpar) bm tvalues
 
 bm :: Double - Double is some heavy function. But if I want to return list 
 of pairs (t, bm t) it doesn't use cpu cores fine (only one is in use):
 
 (parMap rpar) (\t - (t, bm t)) tvalues
 
 The same is valid for functions returning lists. How do I use multiple cores 
 with functions returning tuples?

You probably want deepseq:

parMap rpar ((\x - deepseq x x) . bm) tvalues

where bm returns tuples. For examples

parMap rpar ((\x - deepseq x x) . (\t - (t, bm t)) tvalues

If you want to get only head:

parMap rpar (\t - let z = bm t in z  `seq` t `seq` (t, z)) tvalues

Regards



signature.asc
Description: This is a digitally signed message part
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Using cmake with haskell

2011-05-14 Thread Maciej Marcin Piechotka
On Wed, 2011-05-11 at 18:13 -0700, Gregory Crosswhite wrote:
 on top of it and have to start from scratch --- or worse, *autotools* 
 (SHUDDER!) 

While i don't have much experience autotools seems to be villainize.
Sure it's old and have it's quirks. It is hard to learn and many people
use it improperly. It have horrible libtool - but on the other hand it
have many features that others had not in any sane manner (to mention
one which is often neglected - parallel build).

Regards


signature.asc
Description: This is a digitally signed message part
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Fwd: Work on Collections Processing Arrows?

2011-05-14 Thread Adam Megacz

David Barbour dmbarb...@gmail.com writes:
 you likened asynchronous/distributed products used in 'synch' to
 'additive conjunction' in the earlier message (help for asynchronous
 arrows) and the same concept to multiplicative disjunction here.

I apologize; I transposed additive and multiplicative.  Instead of this:

Adam Megacz meg...@cs.berkeley.edu writes:
 If you look at the corresponding multi-level language, the type of
 synch's input (pair-of-streams) is additive conjunction [2] and its
 output type (stream-of-pairs) is multiplicative conjunction

I should have written: the type of synch's input (pair-of-streams)
is multiplicative conjunction ($\bindnasrepma$) and its output type
(stream-of-pairs) is additive conjunction ().

  -a


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Using cmake with haskell

2011-05-14 Thread Gregory Crosswhite

On 5/14/11 1:25 PM, Maciej Marcin Piechotka wrote:

(to mention
one which is often neglected - parallel build).


While I do appreciate you stepping in to defend autotools (if for no 
other reason then because someone has to so that the discussion is 
balanced :-) ), I think that you are wrong to say that autotools is 
unusual in getting the idea of parallel builds right, since in my 
experience the opposite is the case:  most systems support parallel 
builds --- such as SCons, CMake, I think waf, etc. --- with Cabal being 
an outlier here.


Cheers,
Greg

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Exception for NaN

2011-05-14 Thread wren ng thornton

On 5/12/11 3:22 PM, Andrew Coppin wrote:

There is an isNaN function somewhere.


N.B., on Hugs (September 2006), isNaN is flagrantly broken; so is 
isInfinite. I have a solution available[1], but alas, it seems unlikely 
to ever make its way back upstream.


Moral: double check your compiler before trusting things like that.


[1] 
http://hackage.haskell.org/packages/archive/logfloat/0.12.1/doc/html/Hugs-RealFloat.html


--
Live well,
~wren

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Using cmake with haskell

2011-05-14 Thread Nathan Howell
Waf supports parallel builds and works with GHC without too much trouble. I
use it in a mixed Haskell, C++, Scala and Python build. If there is interest
I could conceivably clean up the ghc waf tool and release it.

On Sat, May 14, 2011 at 5:32 PM, Gregory Crosswhite 
gcr...@phys.washington.edu wrote:

 On 5/14/11 1:25 PM, Maciej Marcin Piechotka wrote:

 (to mention
 one which is often neglected - parallel build).


 While I do appreciate you stepping in to defend autotools (if for no other
 reason then because someone has to so that the discussion is balanced :-) ),
 I think that you are wrong to say that autotools is unusual in getting the
 idea of parallel builds right, since in my experience the opposite is the
 case:  most systems support parallel builds --- such as SCons, CMake, I
 think waf, etc. --- with Cabal being an outlier here.


 Cheers,
 Greg

 ___
 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


Re: [Haskell-cafe] Using cmake with haskell

2011-05-14 Thread Gregory Crosswhite
What on earth are you doing that mixes Haskell, C++, Scala, and Python?  
I am very intrigued by the very idea of such a project.  :-)


I have to confess that don't care for waf myself because I had 
unpleasant experiences using it which stemmed in part from its design 
which I also didn't like.  For example, if you don't get the proper 
complex incantations correct then it will simply fail silently without 
giving you any hint as to what you might have gotten wrong, even for the 
most basic of tasks!  Also, the last time I looked into waf in depth a 
couple of years ago the basic task model was designed around a language 
like C++  where there is a build phase and then a link phase and 
everything within a phase can be built in any order, so to compile 
something like Haskell code you need to essentially put every file in 
its own phase, but the scheduler they used for phases was not optimized 
at all precisely because they were assuming a C++-like model where there 
were only a couple of phases;  they could have changed this since then, 
though.


But anyway, I am always willing to keep an open mind about tools if 
someone convinces me that my current negative impressions about them is 
wrong or outdated, so if you got waf to build a project with all four of 
those languages then that does definitely give it extra points in my 
book.  :-)


Cheers,
Greg

On 5/14/11 6:12 PM, Nathan Howell wrote:


Waf supports parallel builds and works with GHC without too much 
trouble. I use it in a mixed Haskell, C++, Scala and Python build. If 
there is interest I could conceivably clean up the ghc waf tool and 
release it.



On Sat, May 14, 2011 at 5:32 PM, Gregory Crosswhite 
gcr...@phys.washington.edu mailto:gcr...@phys.washington.edu wrote:


On 5/14/11 1:25 PM, Maciej Marcin Piechotka wrote:

(to mention
one which is often neglected - parallel build).


While I do appreciate you stepping in to defend autotools (if for
no other reason then because someone has to so that the discussion
is balanced :-) ), I think that you are wrong to say that
autotools is unusual in getting the idea of parallel builds right,
since in my experience the opposite is the case:  most systems
support parallel builds --- such as SCons, CMake, I think waf,
etc. --- with Cabal being an outlier here.


Cheers,
Greg

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org mailto: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