Re: [Haskell-cafe] hdbc-mysql fails to compile

2010-02-25 Thread Thomas Girod
replying to myself. there is only one line to fix in Setup.lhs


  (mysqlConfigProg, _) <- requireProgram verbosity
  mysqlConfigProgram AnyVersion (withPrograms lbi)


becomes :


  (mysqlConfigProg, _) <- requireProgram verbosity
  mysqlConfigProgram (withPrograms lbi)


obviously the new cabal version makes a difference between
"requireProgram" and "requireProgramVersion"


On Thu, Feb 25, 2010 at 08:01:34PM +0100, Thomas Girod wrote:
> Hi there. Looks like hdbc-mysql cannot compile against GHC-6.12 --
> confirmed by the hackage build logs. [1]
> 
> anyone know a way to dodge the problem ?
> 
> cheers,
> 
> Tom
> 
> [1]
> http://hackage.haskell.org/packages/archive/HDBC-mysql/0.6/logs/failure/ghc-6.12
> 
> ___
> 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] hdbc-mysql fails to compile

2010-02-25 Thread Thomas Girod
Hi there. Looks like hdbc-mysql cannot compile against GHC-6.12 --
confirmed by the hackage build logs. [1]

anyone know a way to dodge the problem ?

cheers,

Tom

[1]
http://hackage.haskell.org/packages/archive/HDBC-mysql/0.6/logs/failure/ghc-6.12

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


Re: [Haskell-cafe] Seen on reddit: or, foldl and foldr considered slightly harmful

2010-02-11 Thread Thomas Girod
Isn't it the kind of things Data Parallel Haskell is achieving ? I'm in
no way an expert of the field, but from what I've read on the subject it
looked like :

I have a list of N elements and I want to map the function F on it.
technically, I could spawn N processes and build the result from that,
but it would be highly inefficient. So the really hard part is to guess
how I should split my data to get the best performances.

Well, I guess it's pretty easy for a flat structure if you have access
to it's length, but for a recursive one it is complicated as you don't
know if a branch of the tree will lead to a leaf or a huge subtree ...
the "evil detail" !

Tom


On Thu, Feb 11, 2010 at 11:00:51AM +0100, Ketil Malde wrote:
> Johann Höchtl  writes:
> 
> > In a presentation of Guy Steele for ICFP 2009 in Edinburgh:
> > http://www.vimeo.com/6624203
> > he "considers foldl and foldr" harmful as they hinder parallelism
> > because of "Process first element, then the rest" Instead he proposes
> > a divide and merge aproach, especially in the light of going parallel.
> 
> In Haskell foldl/foldr apply to linked lists (or lazy streams, if you
> prefer) which are already inherently sequential, and gets a rather harsh
> treatment.  I notice he points to finger trees, which I though was
> implemented in Data.Sequence.
> 
> > are somewhat  geared towards Fortress, but I wonder what Haskellers
> > have to say about his position.
> 
> Can we (easily) parallelize operations on Data.Sequence?  Often, the
> devil is in the details, and there's a lot of ground to cover between
> 'trees are easier to parallelize' to an efficient and effective high
> level interface.  (E.g. non-strict semantics allowing speculative
> evalutaion - you still need to insert manual `par`s, right?)
> 
> -k
> -- 
> If I haven't seen further, it is by standing in the footprints of giants
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] various dependencies breakages

2010-02-09 Thread Thomas Girod
thanks Lars and Max. It did the trick, except for one small detail : 

MissingH needs the "testpack -any" dependency, but cabal does not
install it automatically.

tom

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


[Haskell-cafe] various dependencies breakages

2010-02-09 Thread Thomas Girod
Hi there.

I'm trying to reinstall gitit after updating to ghc 6.12 and it's
driving me crazy. I hope you will be able to help me troubleshoot this
mess ...  I'm starting from scratch again, using cabal. I will
post more problems as they appears.

$ cabal install gitit
Resolving dependencies...
cabal: cannot configure datetime-0.2. It requires QuickCheck ==2.*
For the dependency on QuickCheck ==2.* there are these packages:
QuickCheck-2.1, QuickCheck-2.1.0.1, QuickCheck-2.1.0.2 and
QuickCheck-2.1.0.3.
However none of them are available.
QuickCheck-2.1 was excluded because happstack-util-0.4.1 requires
QuickCheck
<2
QuickCheck-2.1.0.1 was excluded because happstack-util-0.4.1 requires
QuickCheck <2
QuickCheck-2.1.0.2 was excluded because happstack-util-0.4.1 requires
QuickCheck <2
QuickCheck-2.1.0.3 was excluded because happstack-util-0.4.1 requires
QuickCheck <2

Can't cabal handle several versions of the same library in parallel ? If
not, how can I solve this problem ?

cheers

tom

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


[Haskell-cafe] sound synthesis

2008-05-02 Thread Thomas Girod
Hi there. Following this advice 
(http://reddit.com/info/6hknz/comments/c03vdc7), I'm posting here.



Recently, I read a few articles about Haskell (and FP in general) and 
music/sound.


I remember an article ranting about how lazy evaluation would be great 
to do signal processing, but it was lacking real world example.


I tried to do a little something about it, even though I'm still an 
haskell apprentice. So, here I come with a small bit of code, waiting 
for your insights to improve it.


The task is to generate a sine wave and pipe it to /dev/dsp on my linux 
box. There is probably a nicer way to make some noise, like using SDL 
audio API bindings, but I didn't take the time to poke around this yet.


So here it is :


module Main where



import qualified Data.ByteString as B
import Data.Word
import IO (stdout)



rate = 44100



sinusFloat :: [Float]
sinusFloat = map (\t -> (1 + sin (t*880*2*pi/rate)) / 2) [0..44099]



sinusWord :: [Word8]
sinusWord = map (\s -> floor (s * max)) sinusFloat
where max = 255



byte = B.pack sinusWord



main = B.hPut stdout byte


It is supposed to generate a 880hz sine wav playing for one second, by 
typing ./bin > /dev/dsp, assuming your soundcard has a 44100hz samplingrate.


/dev/dsp is supposed to receive its audio flux as an unsigned byte 
stream, that's why I'm converting my sine from [-1;1] to [0;1] and then 
to [0;255] Word8.


However, I must miss something because the sound does not have the right
frequency and is played too long. I guess the default sound format is 
44100hz 16bits stereo, which would explain why it doesn't behave as 
expected.


I'm wondering how I could convert a [Word16] to ByteString, and how I 
could use lazy evaluation to generate an infinite sine that stops with 
the interupt.


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


[Haskell-cafe] representing differencial equations in haskell

2007-09-25 Thread Thomas Girod
Hi there.

Let's say I have mathematical model composed of several differential
equations, such as :

di/dt = cos(i)
dc/dt = alpha * (i(t) - c(t))

(sorry my maths are really bad, but I hope you get the point)

I would like to approximate the evolution of such a system iteratively. How
would you do that in haskell ?

cheers,

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


[Haskell-cafe] transparent parallelization

2007-09-18 Thread Thomas Girod
Hi there. Beeing rather new to the realm of Haskell and functional
programming, I've been reading about "how is easier it is to parallelize
code in a purely functional language" (am I right saying that ?).

My knowledge of parallelization is also very weak, but I've been thinking
about this and I have a question. Let's say we take a small piece of code,
like the quicksort algorithm.

> qsort [] = []
> qsort (x:xs) = qsort lesser ++ [x] ++ qsort greater
> where lesser = filter (=x) xs

(actually I didn't test this code, this is just for the example)

Here, computing "lesser" and "greater" are two disjoint actions - we don't
need the result from one to compute the other, and haskell does not allow
one to alter data so that would change the behaviour of the other. So I
guess those could be run in parallel.

Would it be fairly simple to automatically determine parts of code that can
be run in parallel, and parts that cannot (at least in non-monadic code) ?

So the final question is : if it is possible to automatically define
segments of code that can be run in parallel, is [insert compiler name here]
compiling this code as a one thread thing, or as a multithreaded version ?

I guess on single processor machines, it is more efficient to do it as a
single thread - but with those "many-cores" processors that are coming, it
probably won't be true anymore.

Sorry if this post is blowing off open doors (I guess this doesn't mean
anything in english but it sounds cool) ...

Regards

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


[Haskell-cafe] nested datatypes

2007-08-26 Thread Thomas Girod
Hi there.

recently I was trying to represent complex data by defining several
datatypes and nesting them, such as

data Foo = Foo { foo :: Bar }
deriving (Eq,Show)
data Bar = Bar { bar :: Int }
deriving (Eq,Show)

To change only a part of the data, syntactic sugar is quite convenient. But
it seems to be quite painful with nested datatypes.

b = Bar 10
f = Foo b

foobar :: Int -> Foo -> Foo
foobar i f =
let nb = (foo f){bar = i}
in f{foo = nb}

So, my question is : is there a nifty way to modify data within a nested
datatype, similar to the f{foo = bar} style ? If not, anyone is using some
kind of workaround for this ?
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] newbie : multi-parameter type classes

2007-08-24 Thread Thomas Girod
Hi there.

I'm trying to define a generic graph type here and don't understand on one
error I get. Here I come.

module Graph
 where

class (Eq n, Eq e) => Topo a n e where
empty:: a
nodes:: a -> [n]
edges:: a -> [e]

data Node n = Node n
deriving (Eq,Show)

data Edge n e = Edge e (Node n) (Node n)
deriving (Show)

instance (Eq e) => Eq (Edge n e) where
(Edge e1 _ _) == (Edge e2 _ _) = e1 == e2

data Graph n e = Graph [Node n] [Edge n e]
deriving (Eq,Show)

instance (Eq n, Eq e) => Topo (Graph n e) (Node n) (Edge n e) where
empty = Graph [] []
nodes (Graph ns _) = ns
edges (Graph _ es) = es


My class Topo (for topography) is supposed to give the basic interface any
graph should have.

My instance is Topo (Graph n e) (Node n) (Edge n e), so the infered types of
the functions should be :

empty :: Graph n e
nodes :: Graph n e -> [Nodes n]
edges :: Graph n e -> [Edge n e]

right ?


When I load the code in GHCi, no errors. But then :

*Graph> let g = Graph [Node 0, Node 1] []
*Graph> nodes g

:1:0:
No instance for (Topo (Graph Integer e1) n e)
  arising from use of `nodes' at :1:0-6
Possible fix:
  add an instance declaration for (Topo (Graph Integer e1) n e)
In the expression: nodes g
In the definition of `it': it = nodes g
*Graph>

And I don't understand this. How can he search for an instance of Topo
(Graph integer e1) n e) ?

regards,

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