[Haskell-cafe] ANNOUNCE: TCache 0.8

2011-04-12 Thread Alberto G. Corona
Tired of your persistence layer?

Take persistence the haskelll way. Besides the backward compatible stuff,
TCache now defines persistent STM variables (DBRef's) that  leverages the
traditional haskell reference syntax to perform fast in-memory database
transactions and inter-object references. It includes indexing, triggers and
an straightforward pure-haskell query language based on record field
relations.

http://hackage.haskell.org/package/TCache-0.8.0.2

This version includes a lot of changes and must be considered beta. Please
submit any bugs, comments and so on.

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


Re: [Haskell-cafe] Request for library recommendations

2011-04-12 Thread Michael Snoyman
On Wed, Apr 13, 2011 at 7:02 AM, Kazu Yamamoto  wrote:

> Erik,
>
> > I have done stuff like this before in C++ and Ocaml, so the mechanics
> > are not a mystery. However I would like as much as possible to make
> > use of existing Haskell libraries to cut down the development time.
>
> I recommend wai and warp which are available on Hackage. I asked
> Michael, the author of the libraries, to handle absolute URLs in
> warp. So, you can use it as a platform for HTTP proxies even for
> HTTP/1.0.
>
> And I would throw http-enumerator into that mix: its interface was actually
designed to work together with WAI, so it should be fairly easy to pair them
up together.

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


Re: [Haskell-cafe] Request for library recommendations

2011-04-12 Thread 山本和彦
Erik,

> I have done stuff like this before in C++ and Ocaml, so the mechanics
> are not a mystery. However I would like as much as possible to make
> use of existing Haskell libraries to cut down the development time.

I recommend wai and warp which are available on Hackage. I asked
Michael, the author of the libraries, to handle absolute URLs in
warp. So, you can use it as a platform for HTTP proxies even for
HTTP/1.0.

--Kazu

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


Re: [Haskell-cafe] Using DPH

2011-04-12 Thread Ben Lippmeier

On 12/04/2011, at 11:50 PM, Wilfried Kirschenmann wrote:

> surprisingly, when removing the R.force from the code you attached,
> performances are better (speed-up=2). I suppose but I am not sure that
> this allow for loop fusions beetween the R.map ant the R.sum.
> 
> I use ghc 7.0.3, Repa 2.0.0.3 and LLVM 2.9.
> 
> By the end, the performances with this new version (0.48s) is 15x
> better than my original version (6.9s)
> However, the equivalent sequential C code is still 15x better (0.034s).
> 
> This may indeed be explained by the fact that all computations are
> performed inside the R.sum.

Yeah, the Repa fold and sum functions just use the equivalent Data.Vector ones. 
They're not parallelised and I haven't looked at the generated code. I'll add a 
ticket to the trac to fix these, but won't have time to work on it myself  in 
the near future.

Ben.


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


[Haskell-cafe] Request for library recommendations

2011-04-12 Thread Erik de Castro Lopo
Hi all,

I'm currently scoping out a project for work that I'd like to do
in Haskell. Basically its a HTTP proxy (ie like the Squid proxy)
but with a few wrinkles:

 - Since the connecting clients are untrusted, the incoming
   connection is HTTP, the header is modified by the proxy to
   add BasicAuth (credentials known only to the proxy, not the
   client) and then forwared upstream with responses pass back
   to the client.

 - Needs to work via upstream Squid proxy (so this proxy needs to
   be able to requirest a CONNECT from the upstream Squid proxy).

 - In some cases, the client will POST via the proxy and 
   immediately exit and the proxy will be required to re-try the
   POST if it fails.

 - Other manipulation of headers and data.

I am aware that Squid can satisfy the first two requirements above
but not all the others (without actually hacking the Squid code base).

I have done stuff like this before in C++ and Ocaml, so the mechanics
are not a mystery. However I would like as much as possible to make
use of existing Haskell libraries to cut down the development time.

Performance is also not critical, so as long as the Haskell version
can beat a hypothetical Python implementation I'd be happy.

Thanks in advance.

Cheers,
Erik
-- 
--
Erik de Castro Lopo
http://www.mega-nerd.com/

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


Re: [Haskell-cafe] Problem building qtHaskell

2011-04-12 Thread Mark Wright
On Tue, 12 Apr 2011 12:14:50 +0200, Øystein Kolsrud  wrote:
> Hi! I am trying to install qtHaskell on a Windows 7 machine, but I am
> running into some problems while running the build script. I believe I
> have followed all the steps stated in the installation instructions,
> but get errors of this type:
> 
> Creating library file: ..\bin\libqtc_core.a
> c:\Prog\Qt\2010.05\qt\lib/libQtUiTools.a(quiloader.o):quiloader.cpp:(.text+0x3c3):
> undefined reference to `_Unwind_Resume'

Hi Øystein,

Maybe this might give some hints:

http://www.qtcentre.org/threads/33394-Link-errors-undefined-reference-to-_Unwind_Resume-and-__gxx_personality_v0
 
It suggests checking if c:\Prog\Qt\2010.05\qt\lib/libQtUiTools.a was
built with the same g++ version.

Regards, Mark

> Can anyone help me figure out what is missing? I have the following
> versions installed which should meet the requirements:
> 
> C:\Prog\QTHASK~1.4>g++ --version
> g++ (GCC) 4.4.3
> 
> C:\Prog\QTHASK~1.4>gmake --version
> GNU Make 3.81
> This program built for Windows32
> 
> C:\Prog\QTHASK~1.4>ghc --version
> The Glorious Glasgow Haskell Compilation System, version 7.0.2
> 
> Thanks!
> 
> Best regards, Øystein Kolsrud
> 
> ___
> 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] FFI for a beginner

2011-04-12 Thread Andrew Pennebaker
hsc2hs and c2hs are good suggestions, and some of the tutorials I'm
following use them.

But 1) Many Haskell FFI tutorials don't require them, so they only seem to
help, or only help in older versions of GHC.

And 2) When I did compile using c2hs, it just produced the same file, but
with filler comments like {#- LINE 13 #-}. And they still refused to compile
for the same reason:

ld: duplicate symbol _Charm_getWidth_info in charm.o and charm.o

Cheers,

Andrew Pennebaker
www.yellosoft.us

On Sat, Apr 9, 2011 at 9:50 PM, Jason Dagit  wrote:

> I don't know how to make ghc load them without using either hsc2hs or c2hs.
> I've had better experiences with hsc, but your mileage may vary.
>
> On Apr 8, 2011 3:34 AM, "Andrew Pennebaker" 
> wrote:
>
> ncurses is proving too difficult to setup, so I'm working on a new library
> called charm. The C code works by itself, but I can't compile a Haskell
> wrapper for it. While the tutorials at 
> HaskellWikiare 
> helpful, they're outdated. Argh! The
> docssay
>  that -#include pragmas no longer work, but fail to explain how to load
> code without them. Suffice to say I have no recourse but trial and error.
>
> GitHub: charm  and 
> hscharm
>
> $ make
> cp /usr/include/charm.c .
> ghc --make -fforce-recomp -o hellocharm hellocharm.hs charm.hs charm.c
> -I/usr/include -dylib-install-name /usr/lib/libcharm.dynlib
> [1 of 2] Compiling Charm( charm.hs, charm.o )
> [2 of 2] Compiling Main ( hellocharm.hs, hellocharm.o )
> Linking hellocharm ...
> ld: duplicate symbol _Charm_getWidth_info in charm.o and charm.o
> collect2: ld returned 1 exit status
> make: *** [hellocharm] Error 1
>
> Cheers,
>
> Andrew Pennebaker
> www.yellosoft.us
>
> ___
> 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: Extendable and Easy-To-Use Logger (HLogger)

2011-04-12 Thread Henk-Jan van Tuyl
On Tue, 12 Apr 2011 19:10:09 +0200, Gregory Collins  
 wrote:



On Tue, Apr 12, 2011 at 6:40 PM, Jon Kristensen
 wrote:

Hello Haskellers!

As I have now implemented everything that I could think of, I would  
like to

ask the Haskell community to give some feedback on HLogger so that I can
continuing improving it. Some questions:

Do you have any general/architectural thoughts on things I might be  
doing

wrong?


1) Use "Text" as the string type, not "String"

2) Re: SimpleLogger: writing to and flushing the log file upon
receiving each message is absolutely the wrong thing to do in
high-performance code. Each write() is a context switch into the
kernel, and doing it this way will kill your throughput (in messages
per second). What we do in our webserver (which relies on
high-throughput access logging) is to buffer messages to the log
channel in memory, and perform the actual writes in a separate worker
thread no more often than once every N seconds.


If you want to know what the last thing was that your application was  
doing, before it crashed (e.g. at the customers site), you better write  
every message immediately to disk.


Regards,
Henk-Jan van Tuyl


--
http://Van.Tuyl.eu/
http://members.chello.nl/hjgtuyl/tourdemonad.html
--

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


Re: [Haskell-cafe] syntactic sugar for heterogeneous lists

2011-04-12 Thread Alberto G. Corona
Yep, this is nice and flexible, but it is not standard. With quasiquotes
each one will create its own recipe, its own flavour and this is not good. I
would prefer something standard. The fact is that heterogeneous list are
powerful and flexible for doing unique things that are not possible with
other kind of structures, and the lack of standardization  (i.e sugaring to
begin with) makes them not being widely adopted.

That´s my opinion...

Albert.

2011/4/12 Antoine Latter 

> On Tue, Apr 12, 2011 at 12:57 PM, Alberto G. Corona 
> wrote:
> > Hi Cafe:
> > http://hackage.haskell.org/trac/ghc/ticket/1245
> >
> > I also want some kind of syntactic sugar for H. Lists.
> > The absence of syntactic sugar makes heterogeneous list to look scary.
> > People in haskell is accostumed to syntactic sugaring, so people think of
> > not sugared expressions as second class.
> > I´ don't know the details, but it seems that tuples are in the language
> to
> > cover the heterogeneous flexibility thing that homogeneous lists may not
> > provide, but they introduce its own inflexibilities; These repeating
> > instances for two, three, four and so on tuples makes them artificial and
> > repetitive. In its comparison, a complex but unique H. List instance look
> > elegant. specially if it is sugarized.
> > An alternative to sugarize H.Lists preserving tuples could be to use {}
> to
> > sugarize H. lists as
> >{x,y,z}
> > and desugarize it into:
> > x :*: y :*: z :*: {}
> > Just like [] means empty list, {} would mean HNil, the empty
> heterogeneous
> > list.
> >
> > But this alternative , if implemented, would soon render tuples
>  obsolete.
> > These (,,) (,,,) constructors may create marginally faster and compact
> > structures, but they are much less manageable.
> >
>
> You could use quasi-quotes as an way to do this while you explore
> building it in to a compiler:
>
> > [hlist|5, "hello", True]
>
> You should be able to steal most of the implementation from
> haskell-src-exts-qq. It would work for expressions and patterns. You
> could even make a type quasi-quoter if you get ambitious.
>
> Antoine
>
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] syntactic sugar for heterogeneous lists

2011-04-12 Thread Antoine Latter
On Tue, Apr 12, 2011 at 12:57 PM, Alberto G. Corona  wrote:
> Hi Cafe:
> http://hackage.haskell.org/trac/ghc/ticket/1245
>
> I also want some kind of syntactic sugar for H. Lists.
> The absence of syntactic sugar makes heterogeneous list to look scary.
> People in haskell is accostumed to syntactic sugaring, so people think of
> not sugared expressions as second class.
> I´ don't know the details, but it seems that tuples are in the language to
> cover the heterogeneous flexibility thing that homogeneous lists may not
> provide, but they introduce its own inflexibilities; These repeating
> instances for two, three, four and so on tuples makes them artificial and
> repetitive. In its comparison, a complex but unique H. List instance look
> elegant. specially if it is sugarized.
> An alternative to sugarize H.Lists preserving tuples could be to use {} to
> sugarize H. lists as
>    {x,y,z}
> and desugarize it into:
> x :*: y :*: z :*: {}
> Just like [] means empty list, {} would mean HNil, the empty heterogeneous
> list.
>
> But this alternative , if implemented, would soon render tuples  obsolete.
> These (,,) (,,,) constructors may create marginally faster and compact
> structures, but they are much less manageable.
>

You could use quasi-quotes as an way to do this while you explore
building it in to a compiler:

> [hlist|5, "hello", True]

You should be able to steal most of the implementation from
haskell-src-exts-qq. It would work for expressions and patterns. You
could even make a type quasi-quoter if you get ambitious.

Antoine

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


Re: [Haskell-cafe] Higher-kinded Quantification

2011-04-12 Thread Dan Doel
On Tuesday 12 April 2011 11:27:31 AM Leon Smith wrote:
> I think impredicative polymorphism is actually needed here;  if I write
> ...
> Then I get a type error
> ...

I'm not going to worry about the type error, because that wasn't what I had in 
mind for the types. The type for loop I had in mind was:

  [i] -> Iterator i o m a -> Iterator i o m a

Then, feedPure cracks open the first (forall m. ...), instantiates it to the m 
for the result, and runs loop on it. If we had explicit type application, it'd 
look like:

  feedPure l it = /\m -> loop l (it@m)

but as it is it's just:

  feedPure l it = loop l it

Which cannot be eta reduced.

> But what I find rather befuddling is the kind error:
> > feedPure' :: [i] -> Iterator i o (forall (m :: * -> *) . m) a -> Iterator
> > i o (forall (m :: * -> *) . m) a feedPure' = undefined
> 
> Iterator.hs:193:58:
> `m' is not applied to enough type arguments
> Expected kind `*', but `m' has kind `* -> *'
> In the type signature for `feedPure'':
>   feedPure' :: [i]
>-> Iterator i o (forall m :: (* -> *). m) a
>   -> Iterator i o (forall m :: (* -> *). m) a
> 
> Is impredicative polymorphism restricted to the kind *?

The problem is that (forall (m :: * -> *). m) is not a valid type, and forall 
is not a valid way to construct things with kind * -> *. You have:

  m :: * -> * |- T[m] :: * ==> |- (forall (m :: * -> *). T[m]) :: *

but that is the only way forall works.

-- Dan

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


Re: [Haskell-cafe] redefining a type class for one instance?

2011-04-12 Thread Edward Amsden
On Tue, Apr 12, 2011 at 3:13 PM, Henning Thielemann
 wrote:
>
> On Tue, 12 Apr 2011, Edward Amsden wrote:
>
>> I am trying as an experiment to write something as follows:
>>
>> data Wrapper a b where
>>  Pure :: (a -> b) -> Wrapper a b
>>  Nullable :: (Maybe a -> b) -> Wrapper a b
>>
>> class Liftable a b where
>>  liftTo :: (b -> c) -> a b c
>>
>> instance Liftable Wrapper a where
>>  liftTo = Pure
>
> Would it be ok, to erm wrap 'a', say
>
> newtype Generic a = Generic a
>
> instance Liftable Wrapper (Generic a) where
>  liftTo = ...
That rather defeats the purpose, as the point is to have a type level
dispatch on whether or not we can use a certain constructor or just a
general "all-purpose" constructor. This requires the user to decide to
wrap 'a' in Generic and not do the same for Maybe a.

>
>
>> instance Liftable Wrapper (Maybe a) where
>>  liftTo = Nullable
>



-- 
Edward Amsden
Student
Computer Science
Rochester Institute of Technology
www.edwardamsden.com

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


Re: [Haskell-cafe] redefining a type class for one instance?

2011-04-12 Thread Henning Thielemann


On Tue, 12 Apr 2011, Edward Amsden wrote:


I am trying as an experiment to write something as follows:

data Wrapper a b where
 Pure :: (a -> b) -> Wrapper a b
 Nullable :: (Maybe a -> b) -> Wrapper a b

class Liftable a b where
 liftTo :: (b -> c) -> a b c

instance Liftable Wrapper a where
 liftTo = Pure


Would it be ok, to erm wrap 'a', say

newtype Generic a = Generic a

instance Liftable Wrapper (Generic a) where
 liftTo = ...



instance Liftable Wrapper (Maybe a) where
 liftTo = Nullable


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


[Haskell-cafe] redefining a type class for one instance?

2011-04-12 Thread Edward Amsden
I am trying as an experiment to write something as follows:

data Wrapper a b where
  Pure :: (a -> b) -> Wrapper a b
  Nullable :: (Maybe a -> b) -> Wrapper a b

class Liftable a b where
  liftTo :: (b -> c) -> a b c

instance Liftable Wrapper a where
  liftTo = Pure

instance Liftable Wrapper (Maybe a) where
  liftTo = Nullable

Obviously this code (with suitable extensions enabled) complains of
overlapping type instances, but is there a way to accomplish
redefining a class instance for one particular group of types while
having it defined for all others? (Maybe a vs. a in this instance)




-- 
Edward Amsden
Student
Computer Science
Rochester Institute of Technology
www.edwardamsden.com

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


Re: [Haskell-cafe] Current heap size and other runtime statistics -- API for accessing in GHC?

2011-04-12 Thread Andrew Coppin

On 11/04/2011 12:52 AM, Don Stewart wrote:

I'd like a proper FFI binding for getting at Stats.c dynamically. So I
can write programs that determine their own stats about the GC and so
on.


I have often wished that there was a much bigger API for interacting 
with the RTS. Currently, you can query how many capabilities there are, 
and you can request a (magor?) GC cycle. And that's *it*.


One can imagine a far richer API, with the ability to do things like set 
and query RTS flags, query the GHC version number and RTS "way", ask how 
much RAM is allocated to what, request a minor or magor GC, try to 
release RAM to the OS, pre-allocate RAM from the OS because you're about 
to use it, find out how many threads are running or how many sparks are 
queued, and so on.


Of course, I doubt anyone is going to implement it anytime soon...

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


[Haskell-cafe] syntactic sugar for heterogeneous lists

2011-04-12 Thread Alberto G. Corona
Hi Cafe:

http://hackage.haskell.org/trac/ghc/ticket/1245


I also want some kind of syntactic sugar for H. Lists.

The absence of syntactic sugar makes heterogeneous list to look scary.
People in haskell is accostumed to syntactic sugaring, so people think of
not sugared expressions as second class.

I´ don't know the details, but it seems that tuples are in the language to
cover the heterogeneous flexibility thing that homogeneous lists may not
provide, but they introduce its own inflexibilities; These repeating
instances for two, three, four and so on tuples makes them artificial and
repetitive. In its comparison, a complex but unique H. List instance look
elegant. specially if it is sugarized.

An alternative to sugarize H.Lists preserving tuples could be to use {} to
sugarize H. lists as

   {x,y,z}

and desugarize it into:

x :*: y :*: z :*: {}

Just like [] means empty list, {} would mean HNil, the empty heterogeneous
list.


But this alternative , if implemented, would soon render tuples  obsolete.
These (,,) (,,,) constructors may create marginally faster and compact
structures, but they are much less manageable.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] RFC: Extendable and Easy-To-Use Logger (HLogger)

2011-04-12 Thread Antoine Latter
On Tue, Apr 12, 2011 at 11:40 AM, Jon Kristensen
 wrote:
> Hello Haskellers!
>
> I have developed a very simple logging library to be extendable and
> easy-to-use. You can see the current release at
> http://hackage.haskell.org/package/hlogger/. The SimpleHLogger module is an
> example of what a HLogger implementation could look like. It could be used
> like this:
>
> import System.Log.SimpleHLogger
>
> main = do
>
>   logger <- simpleLogger "test"
>
>   loggerLog logger (Just ("LoggerTest", "main")) Debug "Test"
>
>   loggerStop logger
>
> As I have now implemented everything that I could think of, I would like to
> ask the Haskell community to give some feedback on HLogger so that I can
> continuing improving it. Some questions:
>

It looks very simple, which is nice.

Just about the only things I would add:

* A standard-out/standard-error logger
* A monoid instance for the Logger type
* Convinience functions for logging without context and logging at a
specific error level:

> logError myLogger "Oh no!"
> logDebug myLogger "a thing happened"

These might be in a separate module, so I can define them for myslef
based on some logContext function, so that in my module I can define:

> logError msg = logContext "Module.Name" LogLevelError msg

You might even be able to offer a separate package with
TemplateHaskell splices to build these helpers. Maybe I'm going off
the deep-end it terms of complexity.


Have you looked into HsLogger at all? This project has a confusingly
similar name - so much so I thought that your email was about
HsLogger!


Take care,
Antoine

> Do you have any general/architectural thoughts on things I might be doing
> wrong?
> Is the ease-of-use goal contradicting making this library useful in more
> complex applications?
> Do I want to redesign HLogger to allow loggers to have a mutable state, and
> if so, how can I do that?
> Is there a nice way to provide the module and the function than using (Just
> ("LoggerTest, "main)) (shortening it somehow, I guess)?
>
> Thanks!
>
> Warm regards,
> Jon Kristensen
>
> ___
> 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: Extendable and Easy-To-Use Logger (HLogger)

2011-04-12 Thread Gregory Collins
On Tue, Apr 12, 2011 at 6:40 PM, Jon Kristensen
 wrote:
> Hello Haskellers!
>
> As I have now implemented everything that I could think of, I would like to
> ask the Haskell community to give some feedback on HLogger so that I can
> continuing improving it. Some questions:
>
> Do you have any general/architectural thoughts on things I might be doing
> wrong?

1) Use "Text" as the string type, not "String"

2) Re: SimpleLogger: writing to and flushing the log file upon
receiving each message is absolutely the wrong thing to do in
high-performance code. Each write() is a context switch into the
kernel, and doing it this way will kill your throughput (in messages
per second). What we do in our webserver (which relies on
high-throughput access logging) is to buffer messages to the log
channel in memory, and perform the actual writes in a separate worker
thread no more often than once every N seconds.


> Is the ease-of-use goal contradicting making this library useful in more
> complex applications?

"Easy to use" and "high performance" don't have to be contradictory,
but you shouldn't neglect the latter.

G
-- 
Gregory Collins 

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


[Haskell-cafe] RFC: Extendable and Easy-To-Use Logger (HLogger)

2011-04-12 Thread Jon Kristensen

Hello Haskellers!

I have developed a very simple logging library to be extendable and 
easy-to-use. You can see the current release at 
http://hackage.haskell.org/package/hlogger/. The SimpleHLogger module is 
an example of what a HLogger implementation could look like. It could be 
used like this:


   import System.Log.SimpleHLogger

   main = do

  logger<- simpleLogger "test"

  loggerLog logger (Just ("LoggerTest", "main")) Debug "Test"

  loggerStop logger


As I have now implemented everything that I could think of, I would like 
to ask the Haskell community to give some feedback on HLogger so that I 
can continuing improving it. Some questions:


  1. Do you have any general/architectural thoughts on things I might
 be doing wrong?
  2. Is the ease-of-use goal contradicting making this library useful
 in more complex applications?
  3. Do I want to redesign HLogger to allow loggers to have a mutable
 state, and if so, how can I do that?
  4. Is there a nice way to provide the module and the function than
 using (Just ("LoggerTest, "main)) (shortening it somehow, I guess)?


Thanks!

Warm regards,
Jon Kristensen
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ghc6: Re: Update: ... compiling ghc6

2011-04-12 Thread Svante Signell
On Mon, 2011-04-11 at 00:42 +0200, Svante Signell wrote:
> Addressing both Haskell and Hurd people here. Any hints by anyone?
> 
> On Wed, 2011-04-06 at 09:30 +0200, Svante Signell wrote:
> ...
> > #5  0x011d3ce0 in __libc_read (fd=DWARF-2 expression error: DW_OP_reg
> > operations must be used either alone or in conjuction with DW_OP_piece
> > or DW_OP_bit_piece.
> > ) at ../sysdeps/mach/hurd/read.c:27
> > #6  0x084919c8 in s9qJ_ret ()
> > #7  0x0861f842 in StgRun ()
> > #8  0x087c44e0 in ?? ()
> 
> Looking into this further, this looks like an error. What does it mean?
> from eglibc-2.11.2/sysdeps/mach/hurd/read.c
> 
> /* Read NBYTES into BUF from FD.  Return the number read or -1.  */
> ssize_t
> __libc_read (int fd, void *buf, size_t nbytes)
> {
>   error_t err = HURD_FD_USE (fd, _hurd_fd_read (descriptor, buf,
> &nbytes, -1));
>   return err ? __hurd_dfail (fd, err) : nbytes;
> }

Could not find any reference to __libc_read in either gnumach or hurd
code. The only place was in the binary file
hurd-20110319/ext2fs/ext2fs.static, but I assume this comes from a
linkage with libc. Is the calling function in the Haskell cabal-bin
binary linked with libc0.3 (and other libs)? How to enable debugging for
Haskell binaries with gdb?


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


Re: [Haskell-cafe] Higher-kinded Quantification

2011-04-12 Thread Leon Smith
I think impredicative polymorphism is actually needed here;  if I write

> {-# LANGUAGE ScopedTypeVariables #-}
> {-# LANGUAGE RankNTypes #-}

> feedPure :: forall i o a. [i] -> (forall m. Iterator i o m a) -> (forall m. 
> Iterator i o m a)
> feedPure = loop
>   where
> loop :: [i] -> (forall m. Iterator i o m a) -> (forall m. Iterator i o m 
> a)
> loop [] iter = iter
> loop (i:is) (NeedInput k)= loop is (k i)

Then I get a type error:

Iterator.hs:185:36:
Couldn't match type `m0' with `m1'
  because type variable `m1' would escape its scope
This (rigid, skolem) type variable is bound by
  a type expected by the context: Iterator i o m1 a
The following variables have types that mention m0
  k :: i -> Iterator i o m0 a (bound at Iterator.hs:185:28)

Which I think I vaguely understand,  as the type of NeedInput is (i ->
Iterator i o m a) -> Iterator i o m a,  meaning the type of m is
equal.   So it seems the polymorphism must be carried on m.

But what I find rather befuddling is the kind error:

> feedPure' :: [i] -> Iterator i o (forall (m :: * -> *) . m) a -> Iterator i o 
> (forall (m :: * -> *) . m) a
> feedPure' = undefined

Iterator.hs:193:58:
`m' is not applied to enough type arguments
Expected kind `*', but `m' has kind `* -> *'
In the type signature for `feedPure'':
  feedPure' :: [i]
   -> Iterator i o (forall m :: (* -> *). m) a
  -> Iterator i o (forall m :: (* -> *). m) a

Is impredicative polymorphism restricted to the kind *?

Best,
Leon




Then I get a tp



On Tue, Apr 12, 2011 at 5:37 AM, Dan Doel  wrote:
> On Monday 11 April 2011 8:31:54 PM Leon Smith wrote:
>> I have a type constructor (Iterator i o m a) of kind (* -> * -> (* ->
>> *) -> *),  which is a monad transformer,  and I'd like to use the type
>> system to express the fact that some computations must be "pure",  by
>> writing the impredicative type (Iterator i o (forall m. m) a).
>> However I've run into a bit of difficulty expressing this,  due to the
>> kind of m.   I've attached a minimal-ish example.   Is there a way to
>> express this in GHC?
>
> I think the simplest way is 'Iterator i o Id a'. Then there's a function:
>
>  embed :: Iterator i o Id a -> Iterator i o m a
>
> with the obvious implementation. This means your NeedAction case is no longer
> undefined, too. You can either peel off NeedActions (since they're just
> delays) or leave them in place.
>
> However, another option is probably:
>
>    [i] -> (forall m. Iterator i o m a) -> (forall m. Iterator i o m a)
>
> which will still have the 'this is impossible' case. You know that the
> incoming iterator can't take advantage of what m is, though, so it will be
> impossible.
>
> -- Dan
>
> ___
> 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] Assimp FFI Library

2011-04-12 Thread Joel Burget
John and Stephen,

Thanks for the suggestions! I'm going to evaluate them more fully to see if
they're what I'm looking for. Even though I tried looking through the vector
packages I managed to miss those (there are a lot of packages with "vec" in
their name).

Jason,

Wow, great suggestions! To address a few questions you raised, instead of
{-# UNPACK #-} pragmas, I used {-# OPTIONS_GHC -funbox-strict-fields #-}. I
believe this is equivalent to using the pragma on all of the strict fields.
It seems my operators aren't quite as intuitive as I hoped they would be,
The three examples I provided would be: (|*|) :: Vec n a t1 -> Vec n a t2 ->
Vec n a t3, (|*||) :: Vec n a t -> Mat n a -> Vec n a t, (||*) :: Mat n a ->
a -> Mat n a. These represent componentwise vector multiplication, plain
vector-matrix multiplication, and matrix-scalar multiplication. The idea is
that "||" represents a matrix, "|" represents a vector, and "" represents a
scalar. Also, I currently have a macro for the three sizes of vector and the
three sizes of matrix. I'm not going to mess around with it for now.

-Joel

On Tue, Apr 12, 2011 at 9:14 AM, John Lato  wrote:

> From: Joel Burget 
>> Subject: [Haskell-cafe] Assimp FFI Library
>> To: haskell-cafe@haskell.org
>> Message-ID: 
>> Content-Type: text/plain; charset="iso-8859-1"
>
>
>> 5. I've reduced a lot of boilerplate in Vec.hs by using the CPP
>> preprocessor
>> extension. I could reduce the boilerplate by another factor of 3 if I
>> could
>> recursively call templates but that's not allowed. I would like to have
>> one
>> template to generate both of these lines:
>>
>> > data Vec N2 Double t = Vec2D !Double !Double deriving (Show, Eq)
>> > data Vec N3 Double t = Vec3D !Double !Double !Double deriving (Show, Eq)
>>
>> Notice there is an extra !Double in the second. Is there an easy way to do
>> this? I don't know much about Template Haskell, would that work? Would it
>> be
>> easy?
>>
>
> Yes, it works, and it's pretty easy.  My adaptive-tuple package,
> http://hackage.haskell.org/package/adaptive-tuple, provides this (as well
> as strict vectors up to 20 elements).  Tuple is a bit of a misnomer.  You'll
> need to download the source to get the Template Haskell splices because they
> aren't exported (tarball from hackage, or via
> http://www.tiresiaspress.us/haskell/adaptive-tuple/)
>
> John L.
>
>
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Using DPH

2011-04-12 Thread Wilfried Kirschenmann
> Repa and DPH are different projects. The compilation mechanism and approach 
> to parallelism is quite different between them. You only need -fvectorise to 
> turn on the vectoriser for DPH code. You don't need (or want) -fvectorise for 
> Repa programs. DPH is also still at the "research prototype" stage, and not 
> yet at a point where you'd try to use it for anything real.
>
OK.


> With your example code, you also need to use R.force at appropriate points, 
> and add matches against @(Array _ [Region RangeAll (GenManifest _)]). The 
> reasons for both of these are explained in [1]. Hopefully the second will be 
> fixed by a subsequent GHC release. You must also add {-# INLINE fun #-} 
> pragmas to polymorphic functions or you will pay the price of dictionary 
> passing for the type class overloading.
>
> This runs but doesn't scale with an increasing number of threads. I haven't 
> looked at why. If all the work is in R.sum then that might be the problem -- 
> I haven't put much time into optimising reductions, just maps and filters.
>
surprisingly, when removing the R.force from the code you attached,
performances are better (speed-up=2). I suppose but I am not sure that
this allow for loop fusions beetween the R.map ant the R.sum.

I use ghc 7.0.3, Repa 2.0.0.3 and LLVM 2.9.

By the end, the performances with this new version (0.48s) is 15x
better than my original version (6.9s)
However, the equivalent sequential C code is still 15x better (0.034s).

This may indeed be explained by the fact that all computations are
performed inside the R.sum.
Carrefully tuned, this function shouldn't scale well (x3 on a dual
processor, each with 4 core)  since the performances are limited by
the memory bandwidth. However, this implementation doesn't scale at
all.
Whthout R.force, parallel performances are exactly the same as
sequential performances. With R.force, using the 8 core achieves a 1.1
speed-up.

Thank you for your help.

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


Re: [Haskell-cafe] Assimp FFI Library

2011-04-12 Thread John Lato
>
> From: Joel Burget 
> Subject: [Haskell-cafe] Assimp FFI Library
> To: haskell-cafe@haskell.org
> Message-ID: 
> Content-Type: text/plain; charset="iso-8859-1"


> 5. I've reduced a lot of boilerplate in Vec.hs by using the CPP
> preprocessor
> extension. I could reduce the boilerplate by another factor of 3 if I could
> recursively call templates but that's not allowed. I would like to have one
> template to generate both of these lines:
>
> > data Vec N2 Double t = Vec2D !Double !Double deriving (Show, Eq)
> > data Vec N3 Double t = Vec3D !Double !Double !Double deriving (Show, Eq)
>
> Notice there is an extra !Double in the second. Is there an easy way to do
> this? I don't know much about Template Haskell, would that work? Would it
> be
> easy?
>

Yes, it works, and it's pretty easy.  My adaptive-tuple package,
http://hackage.haskell.org/package/adaptive-tuple, provides this (as well as
strict vectors up to 20 elements).  Tuple is a bit of a misnomer.  You'll
need to download the source to get the Template Haskell splices because they
aren't exported (tarball from hackage, or via
http://www.tiresiaspress.us/haskell/adaptive-tuple/)

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


Re: [Haskell-cafe] Using DPH

2011-04-12 Thread Ben Lippmeier

On 12/04/2011, at 7:32 PM, Wilfried Kirschenmann wrote:

> Hi,
> 
> In order to do a performance comparison beetween different approaches for our 
> application, I make different implementation of a simple example (computing 
> the norm of a vector expression.
> I rely on Repa to do this. 
> However, when I tried to build the parallel version (-threaded -fvectorise 
> -rtsopts), I got an error specifying that dph-par was not available. Indeed, 
> It wasn't.

Repa and DPH are different projects. The compilation mechanism and approach to 
parallelism is quite different between them. You only need -fvectorise to turn 
on the vectoriser for DPH code. You don't need (or want) -fvectorise for Repa 
programs. DPH is also still at the "research prototype" stage, and not yet at a 
point where you'd try to use it for anything real.

With your example code, you also need to use R.force at appropriate points, and 
add matches against @(Array _ [Region RangeAll (GenManifest _)]). The reasons 
for both of these are explained in [1]. Hopefully the second will be fixed by a 
subsequent GHC release. You must also add {-# INLINE fun #-} pragmas to 
polymorphic functions or you will pay the price of dictionary passing for the 
type class overloading.


With the attached code:

desire:tmp benl$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.0.3

desire:tmp benl$ ghc-pkg list |grep repa
repa-2.0.0.2
repa-algorithms-2.0.0.2
repa-bytestring-2.0.0.2
repa-io-2.0.0.2

desire:tmp benl$ ghc -rtsopts -threaded -O3 -fllvm -optlo-O3 -fno-liberate-case 
--make haskell.hs -XBangPatterns -fforce-recomp

desire:tmp benl$ /usr/bin/time ./haskell
[3.3645823e12]
72518800
6.62 real 6.39 user 0.22 sys


This runs but doesn't scale with an increasing number of threads. I haven't 
looked at why. If all the work is in R.sum then that might be the problem -- I 
haven't put much time into optimising reductions, just maps and filters.

Cheers,
Ben.

[1] http://www.cse.unsw.edu.au/~benl/papers/stencil/stencil-icfp2011-sub.pdf




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


[Haskell-cafe] Call for Contributions - Haskell Communities and Activities Report, May 2011 edition

2011-04-12 Thread Janis Voigtländer

Dear all,

I would like to collect contributions for the 20th edition of the


 Haskell Communities & Activities Report

http://www.haskell.org/haskellwiki/Haskell_Communities_and_Activities_Report

  Submission deadline: 1 May 2011

  (please send your contributions to hcar at haskell.org,
  in plain text or LaTeX format)


This is the short story:

* If you are working on any project that is in some way related
  to Haskell, please write a short entry and submit it. Even if
  the project is very small or unfinished or you think it is not
  important enough -- please reconsider and submit an entry anyway!

* If you are interested in an existing project related to Haskell that
  has not previously been mentioned in the HCAR, please tell me, so
  that I can contact the project leaders and ask them to submit an
  entry.

* Feel free to pass on this call for contributions to others that
  might be interested.

More detailed information:

The Haskell Communities & Activities Report is a bi-annual overview of
the state of Haskell as well as Haskell-related projects over the
last, and possibly the upcoming six months. If you have only recently
been exposed to Haskell, it might be a good idea to browse the
November 2010 edition -- you will find interesting topics described as
well as several starting points and links that may provide answers to
many questions.

Contributions will be collected until the submission deadline. They
will then be compiled into a coherent report that is published online
as soon as it is ready. As always, this is a great opportunity to
update your webpages, make new releases, announce or even start new
projects, or to talk about developments you want every Haskeller to
know about!

Looking forward to your contributions,

Janis (current editor)


FAQ:

Q: What format should I write in?

A: The required format is a LaTeX source file, adhering to the template
that is available at:

 http://haskell.org/communities/05-2011/template.tex

There is also a LaTeX style file at

 http://haskell.org/communities/05-2011/hcar.sty

that you can use to preview your entry. If you do not know LaTeX, then
use plain text. If you modify an old entry that you have written for an
earlier edition of the report, you should already have received your old
entry as a template (provided I have your valid email address). Please
modify that template, rather than using your own version of the old
entry as a template.

Q: Can I include Haskell code?

A: Yes. Please consider using lhs2tex syntax
(http://people.cs.uu.nl/andres/lhs2tex/). The report is compiled in mode
polycode.fmt.

Q: Can I include images?

A: Yes, you are even encouraged to do so. Please use .jpg format, then.

Q: Should I send files in .zip archives or similar?

A: No, plain file attachements are the way. If you have several entries
to submit, it helps if you send them in separate emails.

Q: How much should I write?

A: Authors are asked to limit entries to about one column of text. This
corresponds to approximately one page, or 40 lines of text, with the
above style and template.

A general introduction is helpful. Apart from that, you should focus on
recent or upcoming developments. Pointers to online content can be given
for more comprehensive or "historic" overviews of a project. Images do
not count towards the length limit, so you may want to use this
opportunity to pep up entries. There is no minimum length of an entry!
The report aims for being as complete as possible, so please consider
writing an entry, even if it is only a few lines long.

Q: Which topics are relevant?

A: All topics which are related to Haskell in some way are relevant. We
usually had reports from users of Haskell (private, academic, or
commercial), from authors or contributors to projects related to
Haskell, from people working on the Haskell language, libraries, on
language extensions or variants. We also like reports about
distributions of Haskell software, Haskell infrastructure, books and
tutorials on Haskell. Reports on past and upcoming events related to
Haskell are also relevant. Finally, there might be new topics we do not
even think about. As a rule of thumb: if in doubt, then it probably is
relevant and has a place in the HCAR. You can also ask the editor.

Q: Is unfinished work relevant? Are ideas for projects relevant?

A: Yes! You can use the HCAR to talk about projects you are currently
working on. You can use it to look for other developers that might help
you. You can use it to write "wishlist" items for libraries and
language features you would like to see implemented.

Q: If I do not update my entry, but want to keep it in the report, what
should I do?

A: Tell the editor that there are no changes. The old entry will
typically be reused in this case, but it might be dropped if 

Re: [Haskell-cafe] IO and Cont as monads

2011-04-12 Thread Miguel Mitrofanov
As for Cont, it can be proved easily, either by hand, or by observation that 
Cont is an obvious composition of two adjoint functors.

As for IO, it has to be taken for granted, since IO internals are hidden from 
the programmer.

Отправлено с iPhone

Apr 12, 2011, в 14:39, Burak Ekici  написал(а):

> Dear List,
> 
> I am quite new in Haskell's categorical manner of programming. However I have 
> enough knowledge in Category Theory.
> I want to ask a question, maybe very well-known one by some of you, about 
> monads of Haskell.
> 
> For the type constructors like Maybe and [], I managed to prove that together 
> with 2 natural transformations (bind + return), both of these triples 
> construct a monad. But when I try to prove that IO and Cont type constructors 
> with the same natural transformations (bind + return) are monads as well, it 
> was failed.
> 
> Here my question is: Is there anyone who knows how to prove that IO and Cont 
> are monads with satisfing following properties:
> 
> join . fmap join = join . join
> join . fmap return = join . return = id
> return . f = fmap f . return
> join . fmap (fmap f) = fmap f . join
> 
> Thanks already now,
> Burak Ekici.
> ___
> 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] IO and Cont as monads

2011-04-12 Thread Burak Ekici

Dear List,

I am quite new in Haskell's categorical manner of programming. However I have 
enough knowledge in Category Theory.
I want to ask a question, maybe very well-known one by some of you, about 
monads of Haskell.

For
 the type constructors like Maybe and [], I managed to prove that 
together with 2 natural transformations (bind + return), both of these 
triples construct a monad. But when I try to prove that IO and Cont type
 constructors with the same natural transformations (bind + return) are 
monads as well, it was failed.

Here my question is: Is there anyone who knows how to prove that IO and Cont 
are monads with satisfing following properties:

join . fmap join = join . joinjoin . fmap return = join . return = idreturn . f 
= fmap f . returnjoin . fmap (fmap f) = fmap f . join
Thanks already now,
Burak Ekici.  ___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Problem building qtHaskell

2011-04-12 Thread Øystein Kolsrud
Hi! I am trying to install qtHaskell on a Windows 7 machine, but I am
running into some problems while running the build script. I believe I
have followed all the steps stated in the installation instructions,
but get errors of this type:

Creating library file: ..\bin\libqtc_core.a
c:\Prog\Qt\2010.05\qt\lib/libQtUiTools.a(quiloader.o):quiloader.cpp:(.text+0x3c3):
undefined reference to `_Unwind_Resume'

Can anyone help me figure out what is missing? I have the following
versions installed which should meet the requirements:

C:\Prog\QTHASK~1.4>g++ --version
g++ (GCC) 4.4.3

C:\Prog\QTHASK~1.4>gmake --version
GNU Make 3.81
This program built for Windows32

C:\Prog\QTHASK~1.4>ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.0.2

Thanks!

Best regards, Øystein Kolsrud

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


Re: [Haskell-cafe] Assimp FFI Library

2011-04-12 Thread Henning Thielemann


On Mon, 11 Apr 2011, Joel Burget wrote:


I should mention that I'm going to convert all the Storable instances from 
something
like this:
>  peek p = do
>    w <- (#peek aiQuaternion, w) p
>    x <- (#peek aiQuaternion, x) p
>    y <- (#peek aiQuaternion, y) p
>    z <- (#peek aiQuaternion, z) p
>    return $ Quaternion w x y z

to something like this:

>  peek p = Quaternion <$> (#peek aiQuaternion, w) p 
>                      <*> (#peek aiQuaternion, w) p 
>                      <*> (#peek aiQuaternion, w) p
>                      <*> (#peek aiQuaternion, w) p



I think it must be (pure Quaternion). I have written storable-record 
package that assists with writing such instances.


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


Re: [Haskell-cafe] Higher-kinded Quantification

2011-04-12 Thread Dan Doel
On Monday 11 April 2011 8:31:54 PM Leon Smith wrote:
> I have a type constructor (Iterator i o m a) of kind (* -> * -> (* ->
> *) -> *),  which is a monad transformer,  and I'd like to use the type
> system to express the fact that some computations must be "pure",  by
> writing the impredicative type (Iterator i o (forall m. m) a).
> However I've run into a bit of difficulty expressing this,  due to the
> kind of m.   I've attached a minimal-ish example.   Is there a way to
> express this in GHC?

I think the simplest way is 'Iterator i o Id a'. Then there's a function:

  embed :: Iterator i o Id a -> Iterator i o m a

with the obvious implementation. This means your NeedAction case is no longer 
undefined, too. You can either peel off NeedActions (since they're just 
delays) or leave them in place.

However, another option is probably:

[i] -> (forall m. Iterator i o m a) -> (forall m. Iterator i o m a)

which will still have the 'this is impossible' case. You know that the 
incoming iterator can't take advantage of what m is, though, so it will be 
impossible.

-- Dan

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


[Haskell-cafe] Using DPH

2011-04-12 Thread Wilfried Kirschenmann
Hi,

In order to do a performance comparison beetween different approaches for
our application, I make different implementation of a simple example
(computing the norm of a vector expression.
I rely on Repa to do this.
However, when I tried to build the parallel version (-threaded -fvectorise
-rtsopts), I got an error specifying that dph-par was not available. Indeed,
It wasn't.

As explained on the dph webpage, I installed a developpment version of ghc
(ghc-7.1.20110331).
However, when I try to build my application, I get the folowing error:
user error (Pattern match failure in do expression at
compiler/vectorise/Vectorise/Monad.hs:57:10-20)

My source code is attached and compiled with the following line:
ghc haskell.hs -O3 -XBangPatterns -msse2 -fforce-recomp -rtsopts -threaded
-fvectorise


So my question is : is the problem concerning the pattern matching known ?
If yes, is there a workaround ?
is there an other version of dph that would work with Repa ?

Thank you !

-
Wilfried Kirschenmann

"An expert is a person who has made all the mistakes that can be made in a
very narrow field."*
*Niels Bohr - *Danish physicist (1885 - 1962)*


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


Re: [Haskell-cafe] Stateful iteratees

2011-04-12 Thread Ertugrul Soeylemez
Maciej Marcin Piechotka  wrote:

> > Does someone know a cleaner, more elegant solution?  Encapsulating the
> > state in the iteratee's input type is not an option.
>
> The first thing that come to my mind.
>
> runWithState :: Iteratee a (StateT s m) b -> s -> Iteratee a m (b, s)
> runWithState i s = do
> let onDone v st = return (Right (v, st))
> onCont c err = return (Left (c, err))
> (i', s') <- runStateT (runIter i onDone onCont) s
> case i' of
>   Left (c, err) -> icont (\str -> runWithState (c str) s') err
>   Right (v, st) -> idone (v, s') st
>
> I believe it is equivalent to:
>
> runWithState :: Iteratee a (StateT s m) b -> s -> Iteratee a m (b, s)
> runWithState i s = do
> let onDone v st = do
> s' <- get
> return (idone (v, s') st)
> onCont c err = do
> s' <- get
> return (icont (\str -> runWithState (c str) s') err)
> joinIM $ evalStateT (runIter i onDone onCont) s

Thanks for the code.  It might come in handy, but for the current
implementation I decided not to use this approach, but instead to
generalize over 'm', which gives me better composability, for example:

  MailMonad m => Iteratee SmtpResponse m ()

Library users can write their own monads and make them instances of
MailMonad, which is very easy, because there is only one function to
implement.  This seems to solve my original problem.


> I haven't tested but it compiles so it should work.

I loved that statement -- specifically because it's not far-fetched in
Haskell.  You wouldn't dare to write anything like that in any of the
more commonly used languages. =)


Greets,
Ertugrul


-- 
nightmare = unsafePerformIO (getWrongWife >>= sex)
http://ertes.de/



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


Re: [Haskell-cafe] Foreign function performance: monadic vs pure

2011-04-12 Thread John Lato
>
> From: Gregory Collins 
>
> On Mon, Apr 11, 2011 at 3:55 PM, Serguei Son 
> wrote:
> > So if I must use a safe function returning IO a,
> > there is no way to improve its performance? To give you
> > a benchmark, calling gsl_ran_ugaussian a million times
> > in pure C takes only a second or two on my system.
>
> In the C version, are you also producing a linked list containing all
> of the values? Because that's what mapM does. Your test is mostly
> measuring the cost of allocating and filling ~3 million machine words
> on the heap. Try mapM_ instead.
>

I've done some rough tests of a few versions, and I believe Gregory's
analysis is correct.  These are for calculating a sum of sines of 1..10^7
with ghc-7.0.3.

version  execution time
IO, safe  - 4.08s
Pure, safe - 3.07s
IO, unsafe  - 2.77s
Pure, unsafe  - 1.95s

For the IO versions, I used the following:

main = foldM (\ !acc n -> fmap (acc +) $ c_sin_io n) [1..10^7] >>= print

(this can possibly be improved; it was the first thing I thought of)

The most important factor (as often the case with Haskell) is to pay
attention to the space properties of your algorithm.  Instead of using mapM,
which forces the spine of the list, it's much better to interleave the fold
step with the other IO.

Note that the "acc" parameter is strict, this is necessary to avoid building
a thunk.

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


Re: [Haskell-cafe] Assimp FFI Library

2011-04-12 Thread Stephen Tetley
You might want to depend on Conal Elliott's vector-space library
rather than implement your own vector space class. Then you don't need
the associated datatype which might allow simpler datatypes for
colours and vectors.

Also Conal's library is quite well used, so it does mean the operator
names will be familiar to other programmers.

Best wishes

Stephen

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