Re: [Haskell-cafe] What is the meaning of tilde ("~") symbol

2010-02-16 Thread Neil Mitchell
Hi Patrick,

>> The symbols that are not specified in a library can be found here:
>>  http://www.haskell.org/haskellwiki/Keywords
>
> I noticed that \ is not in that list, should it be?

Yes! Add it. If it would help a beginner understand what something
means, it should be on that list.

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


Re: [Haskell-cafe] Re: sendfile leaking descriptors on Linux?

2010-02-16 Thread Jeremy Shaw
On Tue, Feb 16, 2010 at 3:48 PM, Bardur Arantsson wrote:

> The problem is that the sendfile library *doesn't* wake
> up when the connection is terminated (because of threadWaitWrite)
> -- it doesn't matter what the timeout is.
>
>
Have we actually confirmed this? We know that with the default socket
configuration things are good. But have we actually tested testing the
timeout to something short and seeing what happens? It would be good to know
for sure..

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


Re: [Haskell-cafe] Re: Implementing "unionAll"

2010-02-16 Thread Leon Smith
> I see no obvious deficiencies. :) Personally, I'd probably structure it like
>
>   http://www.haskell.org/haskellwiki/Prime_numbers#Implicit_Heap

This variant,  based on the wiki article,  is cleaner,  slightly
simpler,  appears to be just as fast,  and allocates slightly less
memory:

> import GHC.Exts(inline)
> import Data.List.Ordered(unionBy)

> union' :: People Int -> People Int -> People Int
> union' (VIP x xt) ys= VIP x (union' xt ys)
> union' (Crowd xs) (Crowd ys)= Crowd (inline unionBy compare xs ys)
> union' xs@(Crowd (x:xt)) ys@(VIP y yt)  = case compare x y of
>LT -> VIP x (union' (Crowd xt) ys)
>EQ -> VIP x (union' (Crowd xt) yt)
>GT -> VIP y (union' xs yt)

> foldTree :: (a -> a -> a) -> [a] -> a
> foldTree f xs = case xs of
>   [] -> []
>   xs -> loop xs
>  where
>loop [x]= x
>loop (x:xs) = x `f` loop (pairs xs)
>
>pairs (x:y:ys) = f x y : pairs ys
>pairs xs = xs

>  unions xss = serve $ inline foldTree union' [ VIP x (Crowd xs) | (x:xs) <- 
> xss ]
> where
> serve (VIP x xs) = x:serve xs
> serve (Crowd xs) = xs

One of the differences is that I started with a slightly different
"foldTree",  one that was taken directly from Data.List.sort.

The only problem is that it has the same problem as I mentioned:

unionAll [[1,2],[1,2]]  == [1,1,2]

whereas unionAll is intended to be a generalization of "foldr union
[]" to an infinite number of lists,  and should thus return [1,2].
But I should be able to fix this without much difficulty.

> Your  loop  function is a strange melange of many different concerns
> (building a tree, union', adding and removing the VIP constructors).
>
>
> Note that it's currently unclear to me whether the lazy pattern match in
>
>   pairs ~(x: ~(y:ys)) = f x y : pairs ys
>
> is beneficial or not; you used a strict one
>
>   unionPairs (x:y:zs) = union' x y : unionPairs zs
>

Well,  as the library implementation must work on finite cases as
well,  the lazy pattern seems out of the question.

> If you're really concerned about time & space usage, it might even be
> worth to abandon the lazy tree altogether and use a heap to achieve the
> same effect, similar to Melissa O'Neils prime number code. It's not as
> "neat", but much more predictable. :)

Well, it is intended as a high quality, generally useful
implementation,  so of course I care about time and space usage.  :)
 Dave Bayer's original algorithm does slightly better,  but was much
larger in terms of both source code and object size.

Omar implemented something along these lines,  but it didn't perform
so well.   I did not dig into the reasons why, though;  it might not
have had anything to do with the fact an explicit heap was used.

Incidentally,  I tried implementing something like implicit heaps once
upon a time;   but it had a severe performance problem,  taking a few
minutes to produce 20-30 elements.I didn't have a pressing reason
to figure out why though,  and didn't pursue it further.

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


Re: [Haskell-cafe] Heterogeneous Data Structures - Nested Pairs and functional references

2010-02-16 Thread Alexander Solla


On Feb 16, 2010, at 2:11 PM, Stephen Tetley wrote:


Your monad looks equivalent to the Identity monad but over a much
bigger syntax. What advantages do you get from it being a monad,
rather than just a functor?



I replied to Stephen, but forgot to include the list.  I took the  
liberty of making some changes.


I mostly use this construct functorially.  Defining a monad instance  
can be done in O(n) lines, but an applicative functor instance needs  
O(n^2) lines, where n is the number of type constructors.  The monadic  
structure doesn't interfere with the semantics I want, so I went with  
that.


As you said, this is basically an identity monad, but it's not too  
hard to turn it into a sequencing monad.  For example, instead of  
defining (NestViews l m r) >>= f as (NestViews (l >>= f) (m >>= f) (r  
>>= f)), we can do it in terms of arbitrary constructors, as long as  
>>= induced a partial order.  This approach has some interesting  
potential.

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


Re: GUI (was: Re: [Haskell-cafe] DLL on Windows)

2010-02-16 Thread Thomas DuBuisson
On Tue, Feb 16, 2010 at 3:48 PM, Henk-Jan van Tuyl  wrote:
> On Tue, 16 Feb 2010 18:57:20 +0100, Neil Mitchell 
> wrote:
>
>> I used to recommend Gtk2hs over wxHaskell for GUI development as there
>> was always a version that worked on Windows with the latest GHC
>> release. I think I might have to switch back to recommending C# for
>> GUI development...
>
> The latest revision of wxHaskell can be compiled relatively easy, so that
> wxHaskell can be used immediately for the latest version of GHC.

Exciting allegation, but it doesn't quite check out with GHC 6.12.1 +
cabal 1.8.0.2 and cabal-install 0.8 (see below).  I would expect this
issue to be easily resolved by specifying "containers <= 0.3.*" in the
"wxdirect" package, but cabal is misbehaving (for me) and stating
wxdirect needs reinstalled with a supposedly newer version of
containers, 0.2.0.1.

Thomas

[to...@mavlo ~]$ cabal install wx
Resolving dependencies...
Downloading containers-0.2.0.1...
Configuring containers-0.2.0.1...
Preprocessing library containers-0.2.0.1...
Building containers-0.2.0.1...

Data/IntMap.hs:182:7:
Could not find module `Data.Data':
  It is a member of the hidden package `base'.
  Perhaps you need to add `base' to the build-depends in your .cabal file.
  Use -v to see a list of the files searched for.
cabal: Error: some packages failed to install:
containers-0.2.0.1 failed during the building phase. The exception was:
ExitFailure 1
wx-0.12.1.2 depends on containers-0.2.0.1 which failed to install.
wxcore-0.12.1.2 depends on containers-0.2.0.1 which failed to install.
wxdirect-0.12.1.1 depends on containers-0.2.0.1 which failed to install.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] What is the meaning of tilde ("~") symbol

2010-02-16 Thread Patrick LeBoutillier
Hi,

> The symbols that are not specified in a library can be found here:
>  http://www.haskell.org/haskellwiki/Keywords

I noticed that \ is not in that list, should it be?

Patrick

-- 
=
Patrick LeBoutillier
Rosemère, Québec, Canada
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Notes on migrating from uvector to vector

2010-02-16 Thread Richard O'Keefe


On Feb 17, 2010, at 2:26 AM, Ozgur Akgun wrote:

Wikipedia claims in short that "Year Zero is the year before 1 A.D.  
used in astronomical calculations.".

In full: http://en.wikipedia.org/wiki/Year_zero

Seems like no calendar, other than astronomical things include it


That's not what that page says.
Read on, where it says
"there is a year zero in ... ISO 8601:2004 (where it coincides with
 the Gregorian year 1 BC)"
and later
"ISO 8601:2004 (and previously ISO 8601:2000, but not ISO 8601:1988)
 explicitly uses astronomical year numbering in its date reference
 systems.".
Read that carefully; it doesn't mean that the 1988 edition of the
standard didn't use year zero, just that it was not explicit about it.

ISO 8601 is *the* international standard for representing
dates and times.

Sort of.  XML Schema adopts 8601 *formats* but in
section D.3.2 explicitly rejects year 0.  Why they felt it advisible
to override a core industry standard is not clear to me.

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


Re: [Haskell-cafe] Efficient M to N conversion on fusion?

2010-02-16 Thread iquiw
I'll try it, thanks!

iquiw

On Tue, Feb 16, 2010 at 11:12 PM, Felipe Lessa  wrote:
> On Tue, Feb 16, 2010 at 07:52:51PM +0900, iquiw wrote:
>> Is there any efficient way to convert M-length ByteString, Text or
>> Vector into N-length one?
>
> This is just a guess, but in vector at least it should be
> possible to use sized[1] to tell how much space should be
> allocated on the final vector.  For example, something like the
> following *untested* code:
>
> import qualified Data.Vector.Stream.Monadic as S
> import qualified Data.Vector.Generic as G
> import Control.Applicative
> import Data.Vector.Stream.Size
>
> -- | The size should be the size of each v b.
> concatMapSized :: (G.Vector v a, G.Vector v b) => Size -> (a -> v b) -> v a 
> -> v b
> concatMapSized size_each f v =
>  let stream = G.stream v
>      size   = mult size_each (S.size stream)
>  in G.unstream . flip S.sized size . S.concatMap (G.stream . f) $ stream
>
> mult :: Size -> Size -> Size
> mult (Exact n) (Exact m) = Exact (n*m)
> mult x y = maybe Max Unknown $ (*) <$> upperBound x <*> upperBound y
>
> I really don't know if this would improve or worsen performance,
> you should check the core and do benchmarks :).
>
> [1] 
> http://hackage.haskell.org/packages/archive/vector/0.5/doc/html/Data-Vector-Fusion-Stream.html#v%3Asized
>
> --
> Felipe.
> ___
> 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] Notes on migrating from uvector to vector

2010-02-16 Thread Ivan Miljenovic
On 17 February 2010 01:26, Martijn van Steenbergen
 wrote:
> Ivan Miljenovic wrote:
>>
>> On 16 February 2010 08:35, Don Stewart  wrote:
>>>
>>> Enjoy the new decade of flexible, fusible, fast arrays for Haskell!
>>
>> /me points out that 2010 is actually the last year of the decade, and
>> not the first year of a new decade...
>
> There certainly is /a/ decade that starts today. :-)

Well, yes.  By the way, I'm celebrating New Year's Eve in 12 days
time; anyone want to join me? :p

-- 
Ivan Lazar Miljenovic
ivan.miljeno...@gmail.com
IvanMiljenovic.wordpress.com
Stephen Leacock  - "I detest life-insurance agents: they always argue
that I shall some day die, which is not so." -
http://www.brainyquote.com/quotes/authors/s/stephen_leacock.html
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


GUI (was: Re: [Haskell-cafe] DLL on Windows)

2010-02-16 Thread Henk-Jan van Tuyl
On Tue, 16 Feb 2010 18:57:20 +0100, Neil Mitchell   
wrote:



I used to recommend Gtk2hs over wxHaskell for GUI development as there
was always a version that worked on Windows with the latest GHC
release. I think I might have to switch back to recommending C# for
GUI development...


The latest revision of wxHaskell can be compiled relatively easy, so that  
wxHaskell can be used immediately for the latest version of GHC.


Regards,
Henk-Jan

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


Re: [Haskell-cafe] Heterogeneous Data Structures - Nested Pairs and functional references

2010-02-16 Thread Stephen Tetley
Hi Alexander

Your monad looks equivalent to the Identity monad but over a much
bigger syntax. What advantages do you get from it being a monad,
rather than just a functor?

Best wishes

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


[Haskell-cafe] Re: pandoc code bocks not working

2010-02-16 Thread John MacFarlane
Why don't you direct your pandoc-related questions to the pandoc-discuss
mailing list?  http://groups.google.com/group/pandoc-discuss

In this case, it would also be helpful to have more information -- such
as a sample input file and instructions on how to reproduce the
problem you're seeing.  (I've been using pandoc compiled with GHC 6.12
without problems.)

John

+++ Anatoly Yakovenko [Feb 16 10 12:17 ]:
> Thanks, that solved it.
> 
> I am also seening that pandoc compiled with 6.12 seems to barf on the
> .css file that is used in the examples.
> 
> 
> commitAndReleaseBuffer: invalid argument (Invalid or incomplete
> multibyte or wide character)
> 
> 
> On Sun, Feb 14, 2010 at 5:48 PM, Walter De Jonge  wrote:
> > http://johnmacfarlane.net/pandoc/README.html#delimited-code-blocks
> >
> > "Like regular code blocks, delimited code blocks must be separated from
> > surrounding text by blank lines."
> >
> > goodluck
> >
> > walter
> > ___
> > 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
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: sendfile leaking descriptors on Linux?

2010-02-16 Thread Bardur Arantsson

Taru Karttunen wrote:

Excerpts from Bardur Arantsson's message of Tue Feb 16 22:57:23 +0200 2010:
As far as I can tell, all nonblocking networking code is vulnerable to 
this issue (unless it actually does use threadWaitRead, obviously :)).


There are a few easy fixes:

1) socket timeouts with Network.Socket.setSocketOption


The whole point of this thread is that this isn't sufficent.


2) just make your server code have timeouts in Haskell

This cannot be fixed in the sendfile library, it is a 
feature of TCP that connections may linger for a long

time unless explicit timeouts are used.


The problem is that the sendfile library *doesn't* wake
up when the connection is terminated (because of threadWaitWrite)
-- it doesn't matter what the timeout is.

Client code of the sendfile library shouldn't have to try
to work around this -- it's absurd to expect it to.

Please read the entire thread.

Cheers,

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


Re: [Haskell-cafe] Heterogeneous Data Structures - Nested Pairs and functional references

2010-02-16 Thread Alexander Solla


On Feb 16, 2010, at 12:48 PM, Alexander Solla wrote:

(Accumulator String)s are (Accumulator value)s for any value.  So  
you can build things like:




Sorry, I made a typo.  I meant "StringAccumulator String"s are  
"Accumulator value"s for any value.

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


Re: [Haskell-cafe] Re: sendfile leaking descriptors on Linux?

2010-02-16 Thread Taru Karttunen
Excerpts from Bardur Arantsson's message of Tue Feb 16 22:57:23 +0200 2010:
> As far as I can tell, all nonblocking networking code is vulnerable to 
> this issue (unless it actually does use threadWaitRead, obviously :)).

There are a few easy fixes:

1) socket timeouts with Network.Socket.setSocketOption
2) just make your server code have timeouts in Haskell

This cannot be fixed in the sendfile library, it is a 
feature of TCP that connections may linger for a long
time unless explicit timeouts are used.

So just document it and in your code using sendfile
wrap it in an application specific timeout.

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


[Haskell-cafe] Re: sendfile leaking descriptors on Linux?

2010-02-16 Thread Bardur Arantsson

Bardur Arantsson wrote:

Jeremy Shaw wrote:

[--snip--]
Re: a test case, you'll probably need to run the test case code on a 
client whose OS allows (from userspace) the sudden dropping of 
connections without sending a proper connection shutdown sequence. I'm 
not sure that that OS would be.


Actually, scratch that. Maybe it's just a question having a high enough 
connection rate to hit the case where threadWaitWrite "hangs". Although 
I did try a few times using wget, I didn't really try hammering the 
server properly. It probably needs the right timing to trigger the 
problem (i.e. the disconnect needs to happen exactly when sendfile is 
done with its block and we're going around to threadWaitWrite again.)


I'll see if I get the time try a test client which can really hammer my 
server -- that ought to be able to trigger the problem. If that works, 
I'll try to produce a minimal server program which still exhibits the issue.


Cheers,

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


[Haskell-cafe] Re: sendfile leaking descriptors on Linux?

2010-02-16 Thread Bardur Arantsson

Jeremy Shaw wrote:

On Sun, Feb 14, 2010 at 2:04 PM, Bardur Arantsson wrote:



Not sure what the best solution for this would be, API-wise... Maybe
actually have sendfile read the data and supply it to a user-defined
function which could react to the data in some way? (Could supply two
standard functions: "disconnect immediately" and "accumulate all received
data into a bytestring".)



I think this goes beyond just a sendfile issue -- anyone trying to write
non-blocking network code should run into this issue, right ? For now, maybe
we should patch sendfile with what we have. But I think we really need to
summarize our findings, see if we can generate a test case, and then see
what Simon Marlow and company have to say...


As far as I can tell, all nonblocking networking code is vulnerable to 
this issue (unless it actually does use threadWaitRead, obviously :)).


In particular, I would imagine most of the Haskell HTTP servers are 
vulnerable to this since they do use the same pattern of:


  1) read all the input from the client connection,
  2) send all the output to the client connection

where there is no reading from the socket in step 2.

I'm just not sure whether the GHC "built-in" I/O code *somehow*
avoids this problem. I think my tests indicate that it does, so it would 
seem that it's only when you "go C" that you need to worry.


Re: a test case, you'll probably need to run the test case code on a 
client whose OS allows (from userspace) the sudden dropping of 
connections without sending a proper connection shutdown sequence. I'm 
not sure that that OS would be.


Cheers,

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


Re: [Haskell-cafe] Linear programming in Haskell

2010-02-16 Thread Daniel Peebles
As far as I can see, you'd use that for systems of linear *equalities*, but
for systems of linear *inequalities* with a linear objective function, it's
not suitable. I may be wrong though :)

On Tue, Feb 16, 2010 at 3:37 PM, Felipe Lessa wrote:

> On Tue, Feb 16, 2010 at 03:12:53PM -0500, Daniel Peebles wrote:
> > How would you use hmatrix? By linear programming I assume he means
> systems
> > of linear inequalities, as typically solved by the simplex algorithm. I
> too
> > am interested in this question (and the more general one of nonlinear
> > optimization)!
>
> I have never used this part of hmatrix, but does
> Numeric.LinearAlgebra satisfy your needs?  In particular, see
> linearSolve[1] and linearSolveR[2].
>
> [1]
> http://hackage.haskell.org/packages/archive/hmatrix/0.8.3.1/doc/html/Numeric-LinearAlgebra-Algorithms.html#v%3AlinearSolve
> [2]
> http://hackage.haskell.org/packages/archive/hmatrix/0.8.3.1/doc/html/Numeric-LinearAlgebra-LAPACK.html#v%3AlinearSolveR
>
> HTH,
>
> --
> Felipe.
> ___
> 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] Re: sendfile leaking descriptors on Linux?

2010-02-16 Thread Bryan O'Sullivan
On Tue, Feb 16, 2010 at 12:37 PM, Jeremy Shaw  wrote:


> I think this goes beyond just a sendfile issue -- anyone trying to write
> non-blocking network code should run into this issue, right ?
>

What's a fairly concise description of the issue at hand? I haven't been
paying much attention to this thread, and the descriptions I have seen have
been somewhat confused.

One admittedly unhelpful observation is that when something goes wrong in
this area, it's usually due to pilot error (either on the part of whoever
wrote the Haskell library, or its user), and not so often caused by a bug in
the underlying platform.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Heterogeneous Data Structures - Nested Pairs and functional references

2010-02-16 Thread Alexander Solla


On Feb 16, 2010, at 12:14 PM, Günther Schmidt wrote:


Let's say there was some clever monad ...

someMonad = do
h1 <- add "twenty"
h2 <- add False
h3 <- add 16
.   
modify h2 True

and get a ("twenty",(True, 16)) back. And while *in* the monad some  
accessors available.


Your return value will be wrapped a bit more strongly if you use  
monads and try to combine types.  Basically, build a monad with lots  
of values with no free monadic variables.  For example, in Maybe, Just  
has a free variable, whereas Nothing doesn't.  You can create values  
free in the monadic variable to carry any SPECIFIC type you want.  (Or  
even type class instances, if you use existential types)


> data Accumulator value = AtomicAccumulator value |  
StringAccumulator String | IntAccumulator Int | ConcatAccumulators  
(Accumulator value) (Accumulator value)


(Accumulator String)s are (Accumulator value)s for any value.  So you  
can build things like:


> ConcatAccumulators (IntAccumulator 10) (StringAccumulator "Hi")

I would build up accessors to these values using record syntax.   
Here's a meaty example I've been working on:


data View view = (Left view) `ConcatViews` (Right view)
   | NestViews (Left view) (Middle view) (Right view)

   | EmptyView
   | AtomicView view
   | ReturnView view

  -- View Nodes:
   | DocumentView { document_title_view  :: View view
  , document_toc :: View view
  , document_footer  :: View view
  , document_header  :: View view
  , document_contents:: View view
  }
   | PageView { page_title   :: View view
  , page_contents:: View view
  }
   | TableView { table_title_view:: View view
   , table_heading_view  :: View view
   , table_row_view  :: View view
   , table_subtotal_row_view :: View view
   , table_total_row_view:: View view
   }
   | SectionView { section_title :: View view
 , section_heading_view  :: View view
 , section_contents  :: View view
 }
   | SidebarView { sidebar_title :: View view
 , sidebar_heading   :: View view
 , sidebar_contents  :: View view
 }
   | FieldView
   | HeadingViewString
   | ListView [ View view ] -- View of list, not list of  
views.

   | PageFooterView
   | PageHeaderView
   | PageHeadingViewString
   | ParagraphView  String
   | RowView
   | TableTitleView String
   | TextView   String
   deriving Show

instance Monoid (View view) where
mempty = EmptyView
EmptyView `mappend` right   = right
left  `mappend` EmptyView   = left
left  `mappend` right   = ConcatViews left right


data Field = Field { field_name :: String
   , field_description  :: String
   }

data Row = HeadingRow [Field]

instance Monad View where
return = ReturnView
(AtomicView view)   >>= f = f view
(ConcatViews left right)>>= f = ( ConcatViews (left >>= f)  
(right >>=f)  )

(DocumentView title toc footer header content) >>= f =
( DocumentView (title   >>= f)
   (toc >>= f)
   (footer  >>= f)
   (header  >>= f)
   (content >>= f) )
(NestViews l m r)   >>= f = ( NestViews (l >>= f) (m >>=  
f) (r >>= f) )


(EmptyView) >>= f = EmptyView
(HeadingView string)>>= f = HeadingView string
(ReturnView view)   >>= f = f view
(PageView t c)  >>= f = ( PageView (t >>= f) (c >>=  
f) )

(TableView title heading row subtotal total) >>= f =
( TableView (title  >>= f)
(heading>>= f)
(row>>= f)
(subtotal   >>= f)
(total  >>= f) )

(SectionView title heading contents) >>= f =
( SectionView (title>>= f)
  (heading  >>= f)
  (contents >>= f) )

(ListView views) >>= f = ListView (fmap (>>= f) views)
(SidebarView title heading contents) >>= f =
( SidebarView (title>>= f)
  (heading  >>= f)
  (contents >>= f) )

(TextView   

Re: [Haskell-cafe] Linear programming in Haskell

2010-02-16 Thread Felipe Lessa
On Tue, Feb 16, 2010 at 03:12:53PM -0500, Daniel Peebles wrote:
> How would you use hmatrix? By linear programming I assume he means systems
> of linear inequalities, as typically solved by the simplex algorithm. I too
> am interested in this question (and the more general one of nonlinear
> optimization)!

I have never used this part of hmatrix, but does
Numeric.LinearAlgebra satisfy your needs?  In particular, see
linearSolve[1] and linearSolveR[2].

[1] 
http://hackage.haskell.org/packages/archive/hmatrix/0.8.3.1/doc/html/Numeric-LinearAlgebra-Algorithms.html#v%3AlinearSolve
[2] 
http://hackage.haskell.org/packages/archive/hmatrix/0.8.3.1/doc/html/Numeric-LinearAlgebra-LAPACK.html#v%3AlinearSolveR

HTH,

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


Re: [Haskell-cafe] Re: sendfile leaking descriptors on Linux?

2010-02-16 Thread Jeremy Shaw
On Sun, Feb 14, 2010 at 2:04 PM, Bardur Arantsson wrote:

>
> I've tested this extensively during this weekend and not a single "leaked"
> FD so far.
>
> I think we can safely say that polling an FD for read readiness is
> sufficient to properly detect a disconnected client regardless of why/how
> the client disconnected.
>
> The only issue I can see with just dropping the above code directly into
> the sendfile library is that it may lead to busy-waiting on EAGAIN *if* the
> client is actually trying to send data to the server while it's receiving
> the file via sendfile(). If the client sends even a single byte and the
> server isn't reading it from the socket, then threadWaitRead will keep
> returning immediately since it's level-triggered rather than edge triggered.
>

Yeah. That could be trouble.


> Not sure what the best solution for this would be, API-wise... Maybe
> actually have sendfile read the data and supply it to a user-defined
> function which could react to the data in some way? (Could supply two
> standard functions: "disconnect immediately" and "accumulate all received
> data into a bytestring".)
>
>
I think this goes beyond just a sendfile issue -- anyone trying to write
non-blocking network code should run into this issue, right ? For now, maybe
we should patch sendfile with what we have. But I think we really need to
summarize our findings, see if we can generate a test case, and then see
what Simon Marlow and company have to say...

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


Re: [Haskell-cafe] pandoc code bocks not working

2010-02-16 Thread Anatoly Yakovenko
Thanks, that solved it.

I am also seening that pandoc compiled with 6.12 seems to barf on the
.css file that is used in the examples.


commitAndReleaseBuffer: invalid argument (Invalid or incomplete
multibyte or wide character)


On Sun, Feb 14, 2010 at 5:48 PM, Walter De Jonge  wrote:
> http://johnmacfarlane.net/pandoc/README.html#delimited-code-blocks
>
> "Like regular code blocks, delimited code blocks must be separated from
> surrounding text by blank lines."
>
> goodluck
>
> walter
> ___
> 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


[Haskell-cafe] Heterogeneous Data Structures - Nested Pairs and functional references

2010-02-16 Thread Günther Schmidt

Hi,

I've been thinking a lot lately about heterogeneous and extensible data 
structures for which HList certainly offers a solution.


While HList is implemented through type-level programming I wonder if I 
can achieve similar results through value-level programming alone.


This is where I was thinking of functional references.

I wonder if or rather how one could do this:

Let's say there was some clever monad ...

someMonad = do
h1 <- add "twenty"
h2 <- add False
h3 <- add 16
.   
modify h2 True

and get a ("twenty",(True, 16)) back. And while *in* the monad some 
accessors available.


Now come to think of it I think I actually read about this somewhere so 
I doubt this is truly my idea.


Anybody got some thoughts on this?

Günther


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


Re: [Haskell-cafe] Linear programming in Haskell

2010-02-16 Thread Daniel Peebles
How would you use hmatrix? By linear programming I assume he means systems
of linear inequalities, as typically solved by the simplex algorithm. I too
am interested in this question (and the more general one of nonlinear
optimization)!

Thanks,
Dan

On Tue, Feb 16, 2010 at 2:54 PM, Felipe Lessa wrote:

> On Tue, Feb 16, 2010 at 01:37:54PM -0600, Louis Wasserman wrote:
> > Is there a nice package out there somewhere with a linear programming
> > implementation?  Preferably with a nicely functional interface?
>
> hmatrix?
>
> Cheers,
>
> --
> Felipe.
> ___
> 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] Linear programming in Haskell

2010-02-16 Thread Felipe Lessa
On Tue, Feb 16, 2010 at 01:37:54PM -0600, Louis Wasserman wrote:
> Is there a nice package out there somewhere with a linear programming
> implementation?  Preferably with a nicely functional interface?

hmatrix?

Cheers,

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


[Haskell-cafe] Linear programming in Haskell

2010-02-16 Thread Louis Wasserman
Is there a nice package out there somewhere with a linear programming
implementation?  Preferably with a nicely functional interface?

Kthxbai,

Louis Wasserman
wasserman.lo...@gmail.com
http://profiles.google.com/wasserman.louis
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Category Theory woes

2010-02-16 Thread Alexander Solla

On Feb 16, 2010, at 9:43 AM, Gregg Reynolds wrote:

I've looked through at least a dozen.  For neophytes, the best of  
the bunch BY FAR is Goldblatt, Topoi: the categorial analysis of  
logic .  Don't be put off by the title.  He not only explains the  
stuff, but he explains the problems that motivated the invention of  
the stuff.  He doesn't cover monads, but he covers all the basics  
very clearly, so once you've got that down you can move to another  
author for monads.


He does cover monads, briefly.  They're called "triples" in this  
context, and the chapter on interpretations of the intuitionistic  
logic depend on functorial/monadic techniques.  If I remember  
correctly, he uses the techniques and abstracts from them.___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Threading and FFI

2010-02-16 Thread Yves Parès

There is a minimal code which produces this issue: 
http://old.nabble.com/file/p27613138/func.c func.c 
http://old.nabble.com/file/p27613138/main.hs main.hs 


Yves Parès wrote:
> 
> Well I tried both 'unsafe' and 'safe', and actually I saw no difference...
> Even with 'safe', I see a huge difference between calling a C function
> which sleeps and another which doesn't. When there is a sleep, the other
> thread is really slower (it just prints numbers, and I look at which pace
> they're displayed).

-
Yves Parès

Live long and prosper
-- 
View this message in context: 
http://old.nabble.com/Threading-and-FFI-tp27611528p27613138.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

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


Re: [Haskell-cafe] Threading and FFI

2010-02-16 Thread Yves Parès

Well I tried both 'unsafe' and 'safe', and actually I saw no difference...
Even with 'safe', I see a huge difference between calling a C function which
sleeps and another which doesn't. When there is a sleep, the other thread is
really slower (it just prints numbers, and I look at which pace they're
displayed).


Felipe Lessa wrote:
> 
> On Tue, Feb 16, 2010 at 09:00:08AM -0800, Yves Parès wrote:
>> I was wondering: is the Haskell default runtime (that which uses only one
>> processor) scheduler able to interrupt a thread which is currently
>> calling
>> to a C function in order to enable another haskell thread to progress?
>> I think it can't, because I have starvation problems when I have a thread
>> which calls inside its loop to a C function which makes a little "sleep".
> 
> Did you try marking the call as safe?
> 
> Cheers,
> 
> --
> Felipe.
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
> 
> 


-
Yves Parès

Live long and prosper
-- 
View this message in context: 
http://old.nabble.com/Threading-and-FFI-tp27611528p27612884.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

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


Re: [Haskell-cafe] DLL on Windows

2010-02-16 Thread Neil Mitchell
Oh no, I just give up on Haskell and use C# entirely - I'd much rather
program in Haskell, but if all you are doing is a simple Windows app
then a nice GUI is easy in C# with the form designer.

Thanks, Neil

On Tue, Feb 16, 2010 at 6:01 PM, Serguey Zefirov  wrote:
> Thank you very much.
>
> How do you use C# for GUI development? Do you use hs-dotnet?
>
> 2010/2/16 Neil Mitchell :
>> Hi Serguey,
>>
>> A GHC 6.10.4 version of Gtk2hs:
>>
>> http://www.mail-archive.com/gtk2hs-de...@lists.sourceforge.net/msg00340.html
>>
>> I used to recommend Gtk2hs over wxHaskell for GUI development as there
>> was always a version that worked on Windows with the latest GHC
>> release. I think I might have to switch back to recommending C# for
>> GUI development...
>>
>> Thanks, Neil
>>
>> On Tue, Feb 16, 2010 at 5:19 PM, Serguey Zefirov  wrote:
>>> I'd like to, but I cannot. My code is tied to gtk2hs, which supports
>>> either 6.10.1 or 6.10.3.
>>>
>>> I put it another way: could I build DLL using ghc 6.12.*?
>>>
>>> If I can, I'll use 6.10.3 for gtk2hs code and 6.12 for all new stuff.
>>>
>>> 2010/2/16 Neil Mitchell :
 Hi Serguey,

 I notice you are using GHC 6.10.3, I suggest you try 6.10.4 which I
 know does work.

 I rewrote that section of the manual recently. I haven't had time to
 merge it back in, but it might give you more help:

 http://neilmitchell.blogspot.com/2009/11/haskell-dlls-on-windows.html

 Thanks, Neil

 On Tue, Feb 16, 2010 at 2:33 PM, Serguey Zefirov  
 wrote:
> I tried the way described in
> http://www.haskell.org/ghc/docs/latest/html/users_guide/win32-dlls.html
> and i got this error message:
>
> 
> ghc -shared -o test.dll --make test.hs
> [1 of 1] Compiling Test             ( test.hs, test.o )
> ghc.exe: panic! (the 'impossible' happened)
>  (GHC version 6.10.3 for i386-unknown-mingw32):
>        link: GHC not built to link this way: LinkDynLib
>
> Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug
> 
> How can I fix it?
> ___
> 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] DLL on Windows

2010-02-16 Thread Serguey Zefirov
Thank you very much.

How do you use C# for GUI development? Do you use hs-dotnet?

2010/2/16 Neil Mitchell :
> Hi Serguey,
>
> A GHC 6.10.4 version of Gtk2hs:
>
> http://www.mail-archive.com/gtk2hs-de...@lists.sourceforge.net/msg00340.html
>
> I used to recommend Gtk2hs over wxHaskell for GUI development as there
> was always a version that worked on Windows with the latest GHC
> release. I think I might have to switch back to recommending C# for
> GUI development...
>
> Thanks, Neil
>
> On Tue, Feb 16, 2010 at 5:19 PM, Serguey Zefirov  wrote:
>> I'd like to, but I cannot. My code is tied to gtk2hs, which supports
>> either 6.10.1 or 6.10.3.
>>
>> I put it another way: could I build DLL using ghc 6.12.*?
>>
>> If I can, I'll use 6.10.3 for gtk2hs code and 6.12 for all new stuff.
>>
>> 2010/2/16 Neil Mitchell :
>>> Hi Serguey,
>>>
>>> I notice you are using GHC 6.10.3, I suggest you try 6.10.4 which I
>>> know does work.
>>>
>>> I rewrote that section of the manual recently. I haven't had time to
>>> merge it back in, but it might give you more help:
>>>
>>> http://neilmitchell.blogspot.com/2009/11/haskell-dlls-on-windows.html
>>>
>>> Thanks, Neil
>>>
>>> On Tue, Feb 16, 2010 at 2:33 PM, Serguey Zefirov  wrote:
 I tried the way described in
 http://www.haskell.org/ghc/docs/latest/html/users_guide/win32-dlls.html
 and i got this error message:

 
 ghc -shared -o test.dll --make test.hs
 [1 of 1] Compiling Test             ( test.hs, test.o )
 ghc.exe: panic! (the 'impossible' happened)
  (GHC version 6.10.3 for i386-unknown-mingw32):
        link: GHC not built to link this way: LinkDynLib

 Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug
 
 How can I fix it?
 ___
 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] DLL on Windows

2010-02-16 Thread Neil Mitchell
Hi Serguey,

A GHC 6.10.4 version of Gtk2hs:

http://www.mail-archive.com/gtk2hs-de...@lists.sourceforge.net/msg00340.html

I used to recommend Gtk2hs over wxHaskell for GUI development as there
was always a version that worked on Windows with the latest GHC
release. I think I might have to switch back to recommending C# for
GUI development...

Thanks, Neil

On Tue, Feb 16, 2010 at 5:19 PM, Serguey Zefirov  wrote:
> I'd like to, but I cannot. My code is tied to gtk2hs, which supports
> either 6.10.1 or 6.10.3.
>
> I put it another way: could I build DLL using ghc 6.12.*?
>
> If I can, I'll use 6.10.3 for gtk2hs code and 6.12 for all new stuff.
>
> 2010/2/16 Neil Mitchell :
>> Hi Serguey,
>>
>> I notice you are using GHC 6.10.3, I suggest you try 6.10.4 which I
>> know does work.
>>
>> I rewrote that section of the manual recently. I haven't had time to
>> merge it back in, but it might give you more help:
>>
>> http://neilmitchell.blogspot.com/2009/11/haskell-dlls-on-windows.html
>>
>> Thanks, Neil
>>
>> On Tue, Feb 16, 2010 at 2:33 PM, Serguey Zefirov  wrote:
>>> I tried the way described in
>>> http://www.haskell.org/ghc/docs/latest/html/users_guide/win32-dlls.html
>>> and i got this error message:
>>>
>>> 
>>> ghc -shared -o test.dll --make test.hs
>>> [1 of 1] Compiling Test             ( test.hs, test.o )
>>> ghc.exe: panic! (the 'impossible' happened)
>>>  (GHC version 6.10.3 for i386-unknown-mingw32):
>>>        link: GHC not built to link this way: LinkDynLib
>>>
>>> Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug
>>> 
>>> How can I fix it?
>>> ___
>>> 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] Category Theory woes

2010-02-16 Thread Gregg Reynolds
On Tue, Feb 2, 2010 at 5:26 AM, Mark Spezzano
wrote:

> Hi all,
>
> Has anyone else found it frustratingly difficult to find details on
> easy-to-diget material on Category theory. The Chapter that I'm stuck on is
> actually labeled Preliminaries and so I reason that if I can't
>

I've looked through at least a dozen.  For neophytes, the best of the bunch
BY FAR is Goldblatt, Topoi: the categorial analysis of
logic.
 Don't be put off by the title.  He not only explains the stuff, but
he
explains the problems that motivated the invention of the stuff.  He doesn't
cover monads, but he covers all the basics very clearly, so once you've got
that down you can move to another author for monads.

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


Re: [Haskell-cafe] Linguistic hair-splitting

2010-02-16 Thread Gregg Reynolds
On Sat, Jan 30, 2010 at 1:24 AM, Conal Elliott  wrote:

> I call it "an m" or (more specifically) "an Int m" or "a list of Int".  For
> instance, "a list" or "an Int list" or "a list of Int".  - Conal
>
>
> On Wed, Jan 27, 2010 at 12:14 PM, Luke Palmer  wrote:
>
>> On Wed, Jan 27, 2010 at 11:39 AM, Jochem Berndsen 
>> wrote:
>> >> Now, here's the question: Is is correct to say that [3, 5, 8] is a
>> >> monad?
>> >
>> > In what sense would this be a monad? I don't quite get your question.
>>
>> I think the question is this:  if m is a monad, then what do you call
>> a thing of type m Int, or m Whatever.
>>
>> Luke
>>
>
Conal's is the most sensible approach - "what do you call it" amounts to
"what sort of a thing is it", and the best we can say in that respect is
"er, its a thing of type m Whatever".  (My preference, if maximal
explicitness is needed, is to say "it's a token of its type"; some say "term
of type m Whatever".)  Trying to classify such a thing as "value", "object",
"computation", "reduction" etc. inevitably (and necessarily) leads to
tail-chasing since those notions are all essentially equivalent.  Plus they
miss the essential point, which is the typing.

Original poster would probably find Martin-Lof's philosophically-tinged
writings very good on this - clear, reasonably simple, and revelatory, if
you've never closely looked at intuitionistic logic before.  Truth of a
proposition, evidence of a judgment, validity of a
proofis especially readable, as is
On
the meanings of the Logical Constants and the Justifications of the Logical
Laws .
Presents a completely new (to me) way of thinking about "what is it,
really?" questions about computation, monads, etc., i.e. ask not "what is
it?" but "how do you know?" or even "how do you make it?"  The Stanford
article on types and
tokensis also very
enlightening in this respect.

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


Re: [Haskell-cafe] Threading and FFI

2010-02-16 Thread Felipe Lessa
On Tue, Feb 16, 2010 at 09:00:08AM -0800, Yves Parès wrote:
> I was wondering: is the Haskell default runtime (that which uses only one
> processor) scheduler able to interrupt a thread which is currently calling
> to a C function in order to enable another haskell thread to progress?
> I think it can't, because I have starvation problems when I have a thread
> which calls inside its loop to a C function which makes a little "sleep".

Did you try marking the call as safe?

Cheers,

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


Re: [Haskell-cafe] What is the meaning of tilde ("~") symbol

2010-02-16 Thread Neil Mitchell
Hi

> The symbols that are not specified in a library can be found here:
>  http://www.haskell.org/haskellwiki/Keywords
> Hoogle used to show links to this page, when a keyword was searched, but not
> anymore.

And that's a bug:
http://code.google.com/p/ndmitchell/issues/detail?id=280 (that I only
just became aware of).

I'll fix this up shortly.

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


[Haskell-cafe] Re: Implementing "unionAll"

2010-02-16 Thread Heinrich Apfelmus
Leon Smith wrote:
> With the urging and assistance of Omar Antolín Camarena,  I will be
> adding two functions to data-ordlist:  mergeAll and unionAll,  which
> merge (or union)  a potentially infinite list of potentially infinite
> ordered lists,   under the assumption that the heads of the non-empty
> lists appear in a non-decreasing sequence.
> 
> However,  as Omar pointed out to me,  the following implementation of
> unionAll has a flaw:
> 
>> unionAll :: Ord a => [[a]] -> [a]
>> unionAll = foldr (\(x:xs) ys -> x : union xs ys) []
> 
> Namely unionAll [[1,2],[1,2]] should return [1,2],  whereas it
> actually returns [1,1,2].   After some work,  I believe I have
> generalized H. Apfelmus's algorithm to handle this;  however it seems
> a bit complicated.   I would love feedback,  especially with regard to
> simplifications,  bugs,  testing strategies,  and optimizations:
> 
>> unionAll' :: Ord a => [[a]] -> [a]
>> unionAll' = unionAllBy compare
> 
>> data People a = VIP a (People a) | Crowd [a]
> 
>> unionAllBy :: (a -> a -> Ordering) -> [[a]] -> [a]
>> unionAllBy cmp xss = loop [ (VIP x (Crowd xs)) | (x:xs) <- xss ]
>>   where
>> loop [] = []
>> loop (  VIP x xs  :  VIP y ys  :  xss  )
>>   = case cmp x y of
>>   LT -> x : loop (  xs  :  VIP y ys  :  xss  )
>>   EQ -> loop (  VIP x (union' xs ys)  :  unionPairs xss  )
>>   GT -> error "Data.List.Ordered.unionAll:  assumption violated!"
>> loop (  VIP x xs  :  xss  )
>>   =  x : loop (xs:xss)
>> loop [Crowd xs] = xs
>> loop (xs:xss) = loop (unionPairs (xs:xss))
>>
>> unionPairs [] = []
>> unionPairs [x] = [x]
>> unionPairs (x:y:zs) = union' x y : unionPairs zs
>>
>> union' (VIP x xs) (VIP y ys)
>>= case cmp x y of
>>LT -> VIP x (union' xs (VIP y ys))
>>EQ -> VIP x (union' xs ys)
>>GT -> error "Data.List.Ordered.unionAll:  assumption violated!"
>> union' (VIP x xs) (Crowd ys) = VIP x (union' xs (Crowd ys))
>> union' (Crowd []) ys = ys
>> union' (Crowd xs) (Crowd ys) = Crowd (unionBy cmp xs ys)
>> union' xs@(Crowd (x:xt)) ys@(VIP y yt)
>>= case cmp x y of
>>LT -> VIP x (union' (Crowd xt) ys)
>>EQ -> VIP x (union' (Crowd xt) yt)
>>GT -> VIP y (union' xs yt)

I see no obvious deficiencies. :) Personally, I'd probably structure it like

   http://www.haskell.org/haskellwiki/Prime_numbers#Implicit_Heap

so that your code becomes

   unionAll = serve . foldTree union' . map vip

Your  loop  function is a strange melange of many different concerns
(building a tree, union', adding and removing the VIP constructors).


Note that it's currently unclear to me whether the lazy pattern match in

   pairs ~(x: ~(y:ys)) = f x y : pairs ys

is beneficial or not; you used a strict one

   unionPairs (x:y:zs) = union' x y : unionPairs zs

Daniel Fischer's experiments suggest that the strict one is better

   http://www.mail-archive.com/haskell-cafe@haskell.org/msg69807.html

If you're really concerned about time & space usage, it might even be
worth to abandon the lazy tree altogether and use a heap to achieve the
same effect, similar to Melissa O'Neils prime number code. It's not as
"neat", but much more predictable. :)


Regards,
Heinrich Apfelmus

--
http://apfelmus.nfshost.com

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


[Haskell-cafe] Microsoft Research PhD Scholarship, University of Leeds

2010-02-16 Thread David Duke


I'm pleased to announce a PhD Scholarship within the Visualization and  
VR group at Leeds, generously funded by Microsoft Research.  We are  
seeking a student to investigate how visualization techniques can be  
further developed to understand and improve the performance of
parallel Haskell programs running on multi-core CPUs.  Closing date  
for applications is 22 March 2010.


Could you please pass on this call to anyone who might be interested  
in applying.


Further details are included below, and are also available on the web,
at http://www.engineering.leeds.ac.uk/pg/studentships/duke.shtml

thanks,
David Duke



PROJECT TITLE: "Visualizing Performance for Multicore Haskell"

SUPERVISION:
Dr. David Duke, School of Computing, University of Leeds, UK

MRL CO-SUPERVISION:
Dr. Satnam Singh
Prof. Simon Peyton Jones
Dr. Simon Marlow
Microsoft Research Laboratory, Cambridge, UK


OUTLINE:

The GHC Haskell compiler now provides high-level abstractions that  
allow the programmer to benefit from multi-core CPUs.  These  
abstractions support implicit parallelism - the programmer can  
indicate expressions that could usefully be evaluated in parallel, but  
is freed from concerns about when parallel evaluation takes place.   
However, it now becomes more difficult to isolate and resolve  
performance issues.


Visualization of run-time behaviour can help. The Haskell community  
already have the benefit of a tool, ThreadScope, developed at  
Microsoft Research Cambridge (research.microsoft.com/en-us/labs/
Cambridge/) that provides insight into resource utilisation. However  
ThreadScope, like other performance visualization tools, presents the  
programmer with a view of low-level resources that differs from the  
level of abstraction at which Haskell programmers are encouraged to  
work. This studentship will investigate visualization techniques for  
linking high-level program abstractions with low-level runtime  
performance data. It should allow Haskell programmers to exploit  
parallelism more effectively.


The student will join the Visualization and VR group at Leeds (www.comp.leeds.ac.uk/vvr) 
. Work on the PhD will involve: understanding how information about  
run-time resources can be extracted and visualized, and how  
programmers use these representations to reason about design and  
implementation choices; building or extending visualization tools;  
conducting user evaluations; modify components of the GHC compiler and  
runtime system.  Work will be undertaken with support from the GHC/ 
ThreadScope team at Microsoft Research (Satnam Singh, Simon Peyton  
Jones, and Simon Marlow).  At the discretion of Microsoft Research,  
the student may also be offered an internship at MRL Cambridge.



FUNDING:

The Scholarship provides a bursary of £20,000 per year for three  
years, covering fees and maintenance. A further £3000 per annum has  
been reserved for travel expenses to attend conferences and visits to  
Microsoft Research in Cambridge.  Applicants from outside of the EU
should note that higher student fees (currently £13,300) will  
necessarily reduce the amount available for maintenance. Home/EU fees  
stand at £3,390 currently. Microsoft Research will provide the  
successful candidate with a laptop equipped with a suite of software.



ENTRY REQUIREMENTS:

Applicants must hold a First-Class BSc (Hon) degree in Computer  
Science or equivalent. It is essential that applicants have excellent  
knowledge of functional programming and significant practical  
experience writing software in Haskell, Clean, or ML. Experience with  
GUI programming and/or information visualization is highly desirable.   
Knowledge of programming technologies, in particular compilers and  
implementation techniques for functional languages is also desirable.  
The position is open to students of all nationalities.



SCHOOL OF COMPUTING, LEEDS:

The School of Computing (www.comp.leeds.ac.uk) is among the 10 best  
Computing departments in the UK according to the 2008 Research  
Assessment Exercise (RAE).  An impressive 80% of staff is rated
internationally excellent or world leading. This clearly confirms the  
School’s position as one of the leading computing departments in the  
UK and a leader in the field internationally.



APPLICATION PROCEDURE:

Formal applications for research degree study must be made either  
online through the University website, or on the University’s  
application form. Detailed information of how to apply on line can be  
found at: www.leeds.ac.uk/students/apply_research.htm


The paper application form is available at: 
www.leeds.ac.uk/rds/Admissions/Admis_home.htm
Please return the completed application form to: Research Degrees &  
Scholarships Office, University of Leeds, LS2 9JT.


Please provide all the documents required as soon as possible, either  
included with your paper application or sent directly to the School of  
Computing secretary (rsad...@comp

Re: [Haskell-cafe] DLL on Windows

2010-02-16 Thread Serguey Zefirov
I'd like to, but I cannot. My code is tied to gtk2hs, which supports
either 6.10.1 or 6.10.3.

I put it another way: could I build DLL using ghc 6.12.*?

If I can, I'll use 6.10.3 for gtk2hs code and 6.12 for all new stuff.

2010/2/16 Neil Mitchell :
> Hi Serguey,
>
> I notice you are using GHC 6.10.3, I suggest you try 6.10.4 which I
> know does work.
>
> I rewrote that section of the manual recently. I haven't had time to
> merge it back in, but it might give you more help:
>
> http://neilmitchell.blogspot.com/2009/11/haskell-dlls-on-windows.html
>
> Thanks, Neil
>
> On Tue, Feb 16, 2010 at 2:33 PM, Serguey Zefirov  wrote:
>> I tried the way described in
>> http://www.haskell.org/ghc/docs/latest/html/users_guide/win32-dlls.html
>> and i got this error message:
>>
>> 
>> ghc -shared -o test.dll --make test.hs
>> [1 of 1] Compiling Test             ( test.hs, test.o )
>> ghc.exe: panic! (the 'impossible' happened)
>>  (GHC version 6.10.3 for i386-unknown-mingw32):
>>        link: GHC not built to link this way: LinkDynLib
>>
>> Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug
>> 
>> How can I fix it?
>> ___
>> 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


[Haskell-cafe] Threading and FFI

2010-02-16 Thread Yves Parès

Hello!

I was wondering: is the Haskell default runtime (that which uses only one
processor) scheduler able to interrupt a thread which is currently calling
to a C function in order to enable another haskell thread to progress?
I think it can't, because I have starvation problems when I have a thread
which calls inside its loop to a C function which makes a little "sleep".

BTW, what is the portable way to sleep a thread in Haskell ?
Control.Concurrent.threadDelay is "GHC only".

-
Yves Parès

Live long and prosper
-- 
View this message in context: 
http://old.nabble.com/Threading-and-FFI-tp27611528p27611528.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

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


[Haskell-cafe] Re: on finding abstractions ...

2010-02-16 Thread Heinrich Apfelmus
Günther Schmidt wrote:
> I've got a problem, in short my haskell code sucks. While it does work
> and I do manage to use higher-orderish aspects quite extensively to make
> my code more concise it still is nowhere abstract, always concrete and
> thus always with lots of boilerplate.
> 
> Oh I have gotten better compared to when I started but on the
> abstraction slope I'm still stuck.
> 
> So fellows, what is the next stop on my road to enlightenment? I really
> think I need best to start from scratch. I think I'm sufficiently
> familiar now with most of Haskell's technicalities but how do I climb
> the ladder of abstraction?

As others said, there are already a few existing abstractions that you
can take advantage of, like applicative functors, functional references
(aka data-accessor) or monads; it pays to know them well.


Other than that, many abstractions will probably be some kind of domain
specific language. Since those are by definition specific to the problem
domain, it's hard to give general advice. I'd suggest to learn from
examples like

  Paul Hudak. The Design of a Pretty-printing Library.
  http://citeseer.ist.psu.edu/hughes95design.html

  Philip Wadler. A prettier printer.
  http://decenturl.com/homepages.inf.ed/wadler-98-prettier-printer

  Simon Peyton Jones, Jean-Marc Eber, Julian Seward.
  Composing contracts: an adventure in financial engineering.
  http://decenturl.com/research.microsoft/spj-financial-contracts



Regards,
Heinrich Apfelmus

--
http://apfelmus.nfshost.com

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


[Haskell-cafe] Re: RFC: concurrent-extra

2010-02-16 Thread Simon Marlow

On 16/02/2010 15:51, Roel van Dijk wrote:

Hello,

We wrote a small library (1) which offers a few extra synchronization
primitives. These primitives are found in the standard libraries of
languages like Java and Python, but not in Haskell.

Before releasing concurrent-extra on hackage, we would like some
comments on its name, design, implementation, documentation (2) and
general usefulness.

All primitives are implemented with MVars and IORefs, except for
Control.Concurrent.STM.Event.

There is a small test suite which tests some properties:

   cabal configure -ftest
   cabal build
   cabal test

The test suite still needs to be expanded a great deal. We found that
testing concurrent algorithms is really hard. Now we test things like
"this shouldn't deadlock" by checking if it doesn't take too long. But
that doesn't feel very formal. Is there a more principled approach to
testing concurrent algorithms in Haskell?


You might want to take a look at the concurrency part of the GHC test suite:

http://darcs.haskell.org/testsuite/tests/ghc-regress/concurrent/should_run/

Not that we've really solved the problem you're talking about, but you 
might get some ideas.


Often deadlocks are caught by the RTS and result in an exception which 
you can catch, though with the threaded RTS this relies on detecting 
idle time and running the GC, which by default happens after 0.3s of 
idle time.  Some people find this annoying and turn off the idle-time GC 
(+RTS -I0) but then you lose deadlock detection.  Swings and roundabouts.


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


Re: [Haskell-cafe] Interpreting profiling results

2010-02-16 Thread Malcolm Wallace
So for me the question remains open, is "entries" a precisely  
counted value or a statistically determined one?


The entry count is precise.  It is only the time (and allocation)  
counts that are determined statistically.


(If the entry count _were_ statistically sampled, it would give  
exactly the same information as the time counts, no more and no less.)


Regards,
Malcolm




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


Re: [Haskell-cafe] DLL on Windows

2010-02-16 Thread Neil Mitchell
Hi Serguey,

I notice you are using GHC 6.10.3, I suggest you try 6.10.4 which I
know does work.

I rewrote that section of the manual recently. I haven't had time to
merge it back in, but it might give you more help:

http://neilmitchell.blogspot.com/2009/11/haskell-dlls-on-windows.html

Thanks, Neil

On Tue, Feb 16, 2010 at 2:33 PM, Serguey Zefirov  wrote:
> I tried the way described in
> http://www.haskell.org/ghc/docs/latest/html/users_guide/win32-dlls.html
> and i got this error message:
>
> 
> ghc -shared -o test.dll --make test.hs
> [1 of 1] Compiling Test             ( test.hs, test.o )
> ghc.exe: panic! (the 'impossible' happened)
>  (GHC version 6.10.3 for i386-unknown-mingw32):
>        link: GHC not built to link this way: LinkDynLib
>
> Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug
> 
> How can I fix it?
> ___
> 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] RFC: concurrent-extra

2010-02-16 Thread Neil Brown

Hi,

I had a look at the code for Event (both versions) and Lock (but not the 
others just yet) and it seemed fine.  If you do lots of calls to 
waitTimeout before a set you will accumulate old locks in the list, but 
that won't cause any error that I can see, so it would only be a problem 
in pathological cases.


I'm not sure there is a good way to test MVar algorithms.  One way to do 
it (which the Concurrent Haskell Debugger did online, IIRC: 
http://www.informatik.uni-kiel.de/~fhu/chd/) is to reimplement IO to 
explore different interleavings of the various MVar calls to look for 
deadlocks.  If you're testing STM, generally you can look to capture 
invariants of your transactions and check that they hold after each 
transaction (e.g. that if the state is Set, there shouldn't be any locks 
waiting with an event).


Thanks,

Neil.

Roel van Dijk wrote:

Hello,

We wrote a small library (1) which offers a few extra synchronization
primitives. These primitives are found in the standard libraries of
languages like Java and Python, but not in Haskell.

Before releasing concurrent-extra on hackage, we would like some
comments on its name, design, implementation, documentation (2) and
general usefulness.

All primitives are implemented with MVars and IORefs, except for
Control.Concurrent.STM.Event.

There is a small test suite which tests some properties:

  cabal configure -ftest
  cabal build
  cabal test

The test suite still needs to be expanded a great deal. We found that
testing concurrent algorithms is really hard. Now we test things like
"this shouldn't deadlock" by checking if it doesn't take too long. But
that doesn't feel very formal. Is there a more principled approach to
testing concurrent algorithms in Haskell?

After writing our version of a read-write lock we noticed the package
rwlock (3) on hackage. But there is a difference: rwlock is
implemented with STM while our version is implemented entirely with
MVars.


Regards,
Roel & Bas van Dijk


1 - http://code.haskell.org/~roelvandijk/code/concurrent-extra/
2 - 
http://code.haskell.org/~roelvandijk/code/concurrent-extra/doc/html/concurrent-extra/index.html
3 - http://hackage.haskell.org/package/rwlock
___
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] Interpreting profiling results

2010-02-16 Thread Johan Tibell
On Tue, Feb 16, 2010 at 3:45 PM, Jean-Marie Gaillourdet  wrote:

> Hi,
>
> Daniel Fischer wrote:
> >>total alloc = 165,728 bytes  (excludes profiling overheads)
> >>
> >> COST CENTREMODULE   %time %alloc
> >>
> >> CAFGHC.Handle 0.0   10.7
> >> CAFText.Read.Lex  0.02.1
> >> CAFGHC.Read   0.01.2
> >> square Main   0.02.8
> >> solve  Main   0.01.3
> >> show_aVx   Main   0.03.7
> >> readsPrec_aYF  Main   0.0   60.6
> >> main   Main   0.09.6
> >> genNumsMain   0.05.0
> >> cell   Main   0.01.2
> >>
> >>
> >>
> >>individualinherited
> >> COST CENTRE  MODULE
> >>   no.entries  %time %alloc   %time %alloc
> >>
> >> MAIN MAIN
> >> 1   0   0.00.3 0.0  100.0
> >>  mainMain
> >>   186   1   0.09.6 0.0   85.6
> >>  show_aVx   Main
> >>   196   2   0.03.7 0.03.7
> >>   cell  Main
> >>   197  16   0.00.0 0.00.0
> >>  solve  Main
> >>   188   5   0.01.3 0.0   11.8
> >>   genNums   Main
> >>   189   8   0.05.0 0.0   10.4
> >>square   Main
> >>   194  88   0.02.8 0.03.2
> >> cellMain
> >>   195  16   0.00.4 0.00.4
> >>col  Main
> >>   192   4   0.00.7 0.01.1
> >> cellMain
> >>   193  16   0.00.4 0.00.4
> >>row  Main
> >>   190   4   0.00.7 0.01.1
> >> cellMain
> >>   191  16   0.00.4 0.00.4
> >>  readsPrec_aYF  Main
> >>   187   3   0.0   60.6 0.0   60.6
> >>  CAF GHC.Read
> >>   151   1   0.01.2 0.01.2
> >>  CAF Text.Read.Lex
> >>   144   8   0.02.1 0.02.1
> >>  CAF GHC.Handle
> >>   128   4   0.0   10.7 0.0   10.7
> >>  CAF GHC.Conc
> >>   127   1   0.00.0 0.00.0
> >>
> >> Does the column 'entries' represent the number of times the function
> >> was called?
> >
> > Number of times it was 'entered', not quite the same as the number of
> times it was called.
> > I think (Warning: speculation ahead, I don't *know* how the profiles are
> generated) it's
> > thus:
> > Say you call a function returning a list. One call, first entry. It finds
> the beginning of
> > the list, the first k elements and hands them to the caller. Caller
> processes these, asks
> > "can I have more, or was that it?". Same call, second entry: f looks for
> more, finds the
> > next m elements, hands them to caller. Caller processes. Repeat until
> whatever happens
> > first, caller doesn't ask whether there's more or callee finds there's
> nothing more (or
> > hits bottom).
> >
>
> Warning: speculation ahead, but is based on my knowledge on other
> profilers.
>
> Many profilers work statistically, they interrupt a program at more less
> random (or equal) intervals and inspect the stack, whick is of course
> quite difficult in Haskell as far as I understand it. I have interpreted
> the entries column as an indication for the amount of "profile
> interrupts" which happened when a function f was on top of the stack,
> whatever that means in Haskell.
>
> The manual of GHC 6.10.4, chapter 5 states:
>
> >The actual meaning of the various columns in the output is:
> >
> >entries
> >
> >The number of times this particular point in the call graph was
> >entered.
>
>
> So for me the question remains open, is "entries" a precisely counted
> value or a statistically determined one?


I believe it's the latter. I think the RTS uses a periodic SIGALRM to figure
out which function is currently executing and to record that in the profile.
Simon Marlow would know.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] RFC: concurrent-extra

2010-02-16 Thread Roel van Dijk
Hello,

We wrote a small library (1) which offers a few extra synchronization
primitives. These primitives are found in the standard libraries of
languages like Java and Python, but not in Haskell.

Before releasing concurrent-extra on hackage, we would like some
comments on its name, design, implementation, documentation (2) and
general usefulness.

All primitives are implemented with MVars and IORefs, except for
Control.Concurrent.STM.Event.

There is a small test suite which tests some properties:

  cabal configure -ftest
  cabal build
  cabal test

The test suite still needs to be expanded a great deal. We found that
testing concurrent algorithms is really hard. Now we test things like
"this shouldn't deadlock" by checking if it doesn't take too long. But
that doesn't feel very formal. Is there a more principled approach to
testing concurrent algorithms in Haskell?

After writing our version of a read-write lock we noticed the package
rwlock (3) on hackage. But there is a difference: rwlock is
implemented with STM while our version is implemented entirely with
MVars.


Regards,
Roel & Bas van Dijk


1 - http://code.haskell.org/~roelvandijk/code/concurrent-extra/
2 - 
http://code.haskell.org/~roelvandijk/code/concurrent-extra/doc/html/concurrent-extra/index.html
3 - http://hackage.haskell.org/package/rwlock
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Interpreting profiling results

2010-02-16 Thread Daniel Fischer
Am Dienstag 16 Februar 2010 15:45:38 schrieb Jean-Marie Gaillourdet:
> Warning: speculation ahead, but is based on my knowledge on other
> profilers.
>
> Many profilers work statistically, they interrupt a program at more less
> random (or equal) intervals and inspect the stack, whick is of course
> quite difficult in Haskell as far as I understand it. I have interpreted
> the entries column as an indication for the amount of "profile
> interrupts" which happened when a function f was on top of the stack,
> whatever that means in Haskell.
>
> The manual of GHC 6.10.4, chapter 5 states:
> >The actual meaning of the various columns in the output is:
> >
> >entries
> >
> >    The number of times this particular point in the call graph was
> >    entered.
>
> So for me the question remains open, is "entries" a precisely counted
> value or a statistically determined one?

I have one observation that supports "precisely counted", namely, while the 
time spent in each cost centre (number of ticks) varies between profiling 
runs of the same code, the number of bytes allocated and the number of 
entries remain the same.

It's far from conclusive, though. Anybody willing to dig into the profiler 
code? 8-)

>
>
> Best regards,
> Jean

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


Re: [Haskell-cafe] Interpreting profiling results

2010-02-16 Thread Jean-Marie Gaillourdet
Hi,

Daniel Fischer wrote:
>>total alloc = 165,728 bytes  (excludes profiling overheads)
>>
>> COST CENTREMODULE   %time %alloc
>>
>> CAFGHC.Handle 0.0   10.7
>> CAFText.Read.Lex  0.02.1
>> CAFGHC.Read   0.01.2
>> square Main   0.02.8
>> solve  Main   0.01.3
>> show_aVx   Main   0.03.7
>> readsPrec_aYF  Main   0.0   60.6
>> main   Main   0.09.6
>> genNumsMain   0.05.0
>> cell   Main   0.01.2
>>
>>
>>
>>individualinherited
>> COST CENTRE  MODULE
>>   no.entries  %time %alloc   %time %alloc
>>
>> MAIN MAIN
>> 1   0   0.00.3 0.0  100.0
>>  mainMain
>>   186   1   0.09.6 0.0   85.6
>>  show_aVx   Main
>>   196   2   0.03.7 0.03.7
>>   cell  Main
>>   197  16   0.00.0 0.00.0
>>  solve  Main
>>   188   5   0.01.3 0.0   11.8
>>   genNums   Main
>>   189   8   0.05.0 0.0   10.4
>>square   Main
>>   194  88   0.02.8 0.03.2
>> cellMain
>>   195  16   0.00.4 0.00.4
>>col  Main
>>   192   4   0.00.7 0.01.1
>> cellMain
>>   193  16   0.00.4 0.00.4
>>row  Main
>>   190   4   0.00.7 0.01.1
>> cellMain
>>   191  16   0.00.4 0.00.4
>>  readsPrec_aYF  Main
>>   187   3   0.0   60.6 0.0   60.6
>>  CAF GHC.Read
>>   151   1   0.01.2 0.01.2
>>  CAF Text.Read.Lex
>>   144   8   0.02.1 0.02.1
>>  CAF GHC.Handle
>>   128   4   0.0   10.7 0.0   10.7
>>  CAF GHC.Conc
>>   127   1   0.00.0 0.00.0
>>
>> Does the column 'entries' represent the number of times the function
>> was called?
> 
> Number of times it was 'entered', not quite the same as the number of times 
> it was called.
> I think (Warning: speculation ahead, I don't *know* how the profiles are 
> generated) it's 
> thus:
> Say you call a function returning a list. One call, first entry. It finds the 
> beginning of 
> the list, the first k elements and hands them to the caller. Caller processes 
> these, asks 
> "can I have more, or was that it?". Same call, second entry: f looks for 
> more, finds the 
> next m elements, hands them to caller. Caller processes. Repeat until 
> whatever happens 
> first, caller doesn't ask whether there's more or callee finds there's 
> nothing more (or 
> hits bottom).
> 

Warning: speculation ahead, but is based on my knowledge on other profilers.

Many profilers work statistically, they interrupt a program at more less
random (or equal) intervals and inspect the stack, whick is of course
quite difficult in Haskell as far as I understand it. I have interpreted
the entries column as an indication for the amount of "profile
interrupts" which happened when a function f was on top of the stack,
whatever that means in Haskell.

The manual of GHC 6.10.4, chapter 5 states:

>The actual meaning of the various columns in the output is:
>
>entries
>
>The number of times this particular point in the call graph was
>entered.


So for me the question remains open, is "entries" a precisely counted
value or a statistically determined one?


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


[Haskell-cafe] DLL on Windows

2010-02-16 Thread Serguey Zefirov
I tried the way described in
http://www.haskell.org/ghc/docs/latest/html/users_guide/win32-dlls.html
and i got this error message:


ghc -shared -o test.dll --make test.hs
[1 of 1] Compiling Test ( test.hs, test.o )
ghc.exe: panic! (the 'impossible' happened)
  (GHC version 6.10.3 for i386-unknown-mingw32):
link: GHC not built to link this way: LinkDynLib

Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug

How can I fix it?
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Notes on migrating from uvector to vector

2010-02-16 Thread Martijn van Steenbergen

Ivan Miljenovic wrote:

On 16 February 2010 08:35, Don Stewart  wrote:

Enjoy the new decade of flexible, fusible, fast arrays for Haskell!


/me points out that 2010 is actually the last year of the decade, and
not the first year of a new decade...


There certainly is /a/ decade that starts today. :-)

Martijn.

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


Re: [Haskell-cafe] Efficient M to N conversion on fusion?

2010-02-16 Thread Felipe Lessa
On Tue, Feb 16, 2010 at 07:52:51PM +0900, iquiw wrote:
> Is there any efficient way to convert M-length ByteString, Text or
> Vector into N-length one?

This is just a guess, but in vector at least it should be
possible to use sized[1] to tell how much space should be
allocated on the final vector.  For example, something like the
following *untested* code:

import qualified Data.Vector.Stream.Monadic as S
import qualified Data.Vector.Generic as G
import Control.Applicative
import Data.Vector.Stream.Size

-- | The size should be the size of each v b.
concatMapSized :: (G.Vector v a, G.Vector v b) => Size -> (a -> v b) -> v a -> 
v b
concatMapSized size_each f v =
  let stream = G.stream v
  size   = mult size_each (S.size stream)
  in G.unstream . flip S.sized size . S.concatMap (G.stream . f) $ stream

mult :: Size -> Size -> Size
mult (Exact n) (Exact m) = Exact (n*m)
mult x y = maybe Max Unknown $ (*) <$> upperBound x <*> upperBound y

I really don't know if this would improve or worsen performance,
you should check the core and do benchmarks :).

[1] 
http://hackage.haskell.org/packages/archive/vector/0.5/doc/html/Data-Vector-Fusion-Stream.html#v%3Asized

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


Re: [Haskell-cafe] Notes on migrating from uvector to vector

2010-02-16 Thread Ozgur Akgun
Wikipedia claims in short that "Year Zero is the year before 1 A.D. used in
astronomical calculations.".
In full: http://en.wikipedia.org/wiki/Year_zero

Seems like no calendar, other than astronomical things include it.


On 16 February 2010 04:32, Richard O'Keefe  wrote:

>
> On Feb 16, 2010, at 4:53 PM, Ivan Miljenovic wrote:
>
>  On 16 February 2010 14:45, Don Stewart  wrote:
>>
>>> ivan.miljenovic:
>>>
 On 16 February 2010 08:35, Don Stewart  wrote:

> Enjoy the new decade of flexible, fusible, fast arrays for Haskell!
>

 /me points out that 2010 is actually the last year of the decade, and
 not the first year of a new decade...

>>>
>>> Computer scientists count from zero. :-)
>>>
>>
>> Except that the current numbering system to record the number of
>> revolutions that our planet has revolved around the nearest solar body
>> was not devised by computer scientists...
>>
>
> I'm not sure what kind of people are responsible for ISO 8601,
> but the ISO calendar, mandated by several programming language
> standards including ANSI Smalltalk, uses something called the
> "proleptic Gregorian calendar" (ISO 8601) or the "retrospective
> Gregorian calendar" (ANSI Smalltalk), which includes a year zero.
> Although 1AD was preceded by 1BC, 1CE is preceded by 0CE.
>
> Given that Europe got the concept of zero from the Muslims,
> I wonder whether the Muslim calendar(s) has(have) a year 0?
>
>
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>



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


Re: [Haskell-cafe] Efficient M to N conversion on fusion?

2010-02-16 Thread Ivan Miljenovic
On 16 February 2010 21:52, iquiw  wrote:
> Is there any efficient way to convert M-length ByteString, Text or
> Vector into N-length one?

I don't believe so, no.  Maybe the lazy variants would have better
efficiency than the strict ones though...

-- 
Ivan Lazar Miljenovic
ivan.miljeno...@gmail.com
IvanMiljenovic.wordpress.com
Stephen Leacock  - "I detest life-insurance agents: they always argue
that I shall some day die, which is not so." -
http://www.brainyquote.com/quotes/authors/s/stephen_leacock.html
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Efficient M to N conversion on fusion?

2010-02-16 Thread iquiw
Hi,

Is there any efficient way to convert M-length ByteString, Text or
Vector into N-length one?

For example,
 (a) converting byte array into array of their hex representations.
("abc" => "616263")
 (b) escaping some specific characters in string. ("a\bc" => "a\\bc")

The only way I found is to use concatMap...

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


Re: [Haskell-cafe] Undecidable instances with functional dependencies

2010-02-16 Thread Yves Parès

However, TypeFamilies seems too be non portable as according to this
http://www.haskell.org/haskellwiki/GHC/Type_families, it works only as from
GHC 6.10.1.


Henning Thielemann-4 wrote:
> 
> Miguel Mitrofanov schrieb:
>> -- {-# LANGUAGE FunctionalDependencies#-}
>> -- {-# LANGUAGE MultiParamTypeClasses #-}
>> {-# LANGUAGE TypeFamilies #-}
>> module Register where
>> -- class Register a r | a -> r
>> class Register a where
>> type R a
>> -- instance Register Int Int
>> instance Register Int where
>> type R Int = Int
>> -- instance Register Float Float
>> instance Register Float where
>> type R Float = Float
>> -- instance (Register a1 r1, Register a2 r2) => Register (a1, a2) (r1, 
>> r2)
>> instance (Register a, Register b) => Register (a, b) where
>> type R (a, b) = (R a, R b)
>>
> So type functions are undecidable by default?
> 
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
> 
> 


-
Yves Parès

Live long and prosper
-- 
View this message in context: 
http://old.nabble.com/Undecidable-instances-with-functional-dependencies-tp27555079p27605436.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

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


Re: [Haskell-cafe] How can i run darcs in ghci?

2010-02-16 Thread Marc Weber

> Any help on how to load the .h is greatly appreciated. I tried -i
> with
> path to the src directory but it didn't work (should it?).
Try -I -i is used for .hs files only (?).

> I am also very curious how others approach a new code base.  What do
> the you
> do to figure out an implementation?
ghci offers a debugger. I haven't used that much yet.
If things are a little bit more complex I don't use ghci. I use ghc to
call the code I'm interested in. This way my memory :-) doesn't vanish.
If you stop ghci things are gone. Yeah, you can copy paste code into an
editor.. Sometimes the only way for me to understand code is spending
hours reading it.

However I'm not sure whether you can get to know code that much faster.
Afterall it depends on your goals.  What do you want to do with darcs?
There are some papers as well.

You should also know that there is a darcs (devel/users) mailinglist if
you're stuck that's the appropriate place to ask questions (or try irc)

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