Re: [Haskell-cafe] Projects using Shake

2013-05-31 Thread Stefan Kersten
hi frerich,

On May 31, 2013, at 2:17 AM, Frerich Raabe wrote:
 Is anybody aware of open source projects which I could look at, or is there 
 maybe a conventional file extension for… what do you call them, Shakefiles? 
 other than .hs which I could google for?

we are using a shake-based build system for our mobile sound engine [1]; see 
the shakefile here [2] and associated modules [3]. the focus is on 
cross-compilation of static/shared libraries for mobile platforms (currently 
ios, android in the works) so it might not be what you're looking for. however, 
most of it is quite generic (if you're working with c, c++, objc, asm) and 
we're going to release it as a library as soon the features and the API have 
settled a bit.

cheers,
sk

[1] http://methc.la
[2] https://github.com/samplecount/methcla/blob/develop/engine/shakefile.hs
[3] https://github.com/samplecount/methcla/tree/develop/engine/Shakefile


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


[Haskell] [ANN] hsndfile 0.7

2013-03-25 Thread Stefan Kersten
I am happy to announce version 0.7 of hsndfile [1], a set of Haskell bindings 
to the venerable libsndfile library.

This release is a bugfix and maintenance release, thanks to Roman Cheplyaka for 
his contributions!

Changes since 0.6 [3]:

* Read and write signed instead of unsigned integer samples and rename 
`sf_readf_wordXX` and `sf_writef_wordXX` to `sf_readf_intXX` and 
`sf_writef_intXX`, respectively
* Add new supported header and sample formats

Have fun,
sk

[1] http://hackage.haskell.org/package/hsndfile
[2] http://www.mega-nerd.com/libsndfile/
[3] https://github.com/kaoskorobase/hsndfile/blob/master/ChangeLog.md


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


Re: [Haskell-cafe] Mobile app development?

2013-01-22 Thread Stefan Kersten

On Jan 19, 2013, at 10:29 PM, Nathan Hüsken wrote:
 Recently I managed to get ghc to target android working (this still
 needs some work): [4].

this is great news, thanks!

 Of couse, ffi bindings for all these platforms would be needed to get
 serious.


i think that you can get quite serious already if the main model is 
implemented in haskell and you only need bindings for communicating with a 
native user interface.

sk


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


Re: any successfull ghc registerised builds on arm?

2013-01-14 Thread Stefan Kersten
hi nathan,

On Jan 14, 2013, at 6:15 PM, Nathan Hüsken nathan.hues...@posteo.de wrote:
 Did anyone succesfully build ghc on an arm system which produces non
 crashing executables?
 
 I am asking, because I build a arm-linux-androideabi cross compiler, but
 the executables crash.
 Only in an unregisterised build, they work.
 
 So I wonder if it is a general arm problem or has to do with android.

stephen blackheath's ghc port to iOS cross compiles to armv7 [1] (using llvm, 
registerised, i assume?). see [2] for a list of libraries i've built and run on 
iOS. here [3] is some info on cross compiling for blackberry arm (QNX). maybe 
it would be worthwhile asking on the iphone mailing list [4], too?

sk

[1] https://github.com/ghc-ios/ghc/wiki
[2] https://github.com/kaoskorobase/ghc-ios-cabal-scripts
[3] http://www.haskell.org/pipermail/iphone/2012-November/000142.html
[4] http://www.haskell.org/mailman/listinfo/iphone


___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


[Haskell] ANN: hsc3-process-0.8 and hsc3-server 0.5

2012-12-20 Thread Stefan Kersten
I am happy to announce the release of version 0.8 of hsc3-process [1] and 
version 0.5 of hsc3-server [2], both providing additional features and 
abstractions for the excellent hsc3 interface [3] to the SuperCollider 
synthesis server [4].

hsc3-process allows to start external scsynth processes and run actions that 
communicate through the associated OpenSoundControl transport.

hsc3-server builds on hsc3 and hsc3-process and adds the following features:

* A `Server' monad for accessing synthesis server state from concurrent threads,
* Resource ID allocators for nodes, buffers and buses,
* A composable `Request' abstraction that allows to assemble synchronous and 
asynchronous server commands into OpenSoundControl bundles for efficient 
scheduling,
* A type-safe interface to the SuperCollider synthesis server command set.

hsc3-server has been in use internally for some time but this is the first 
release that is ready for consumption by the general public. Have a look at 
some examples here [5]. Any feedback welcome!

Happy synthesis!

[1] http://hackage.haskell.org/package/hsc3-process
[2] http://hackage.haskell.org/package/hsc3-server
[3] http://hackage.haskell.org/package/hsc3
[4] http://supercollider.sourceforge.net/
[5] https://github.com/kaoskorobase/hsc3-server/tree/master/examples


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


Re: [Haskell-cafe] Profiling with QtHaskell

2012-04-20 Thread Stefan Kersten
On 20.04.12 10:07, Øystein Kolsrud wrote:
 Hi! Does anyone know if it is possible to use QtHaskell with profiling turned 
 on?

afair i've used it when profiling an application (not qtHaskell itself). what's
the problem you're running into?

you need to compile the library with profiling support enabled, i have

library-profiling: True

in ~/.cabal/config

sk

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


Re: [Haskell-cafe] Open-source projects for beginning Haskell students?

2012-03-25 Thread Stefan Kersten
On 25.03.12 09:38, Heinrich Apfelmus wrote:
 John Lato wrote:
 From: Heinrich Apfelmus

 Also, as far as I am aware, you can't do low-level audio programming in
 SuperCollider, i.e. play a list of samples that you've calculated
 yourself. That's cool if you're only interested in sound design, but bad
 for learning how audio programming works.

 I think this charge is a bit unfair.  If you really want to do
 low-level stuff, it's possible within SC.  You just have to work in
 SuperCollider, not Haskell (AFAIK).
 
 Ah, right, I meant from within Haskell, i.e. by communicating with the SC3
 server component. Even in SC you have to write unit generators in C, I think,
 but I may well be mistaken.

there's a more functional option, too: faust [1] ;)

sk

[1] http://faust.grame.fr/index.php/documentation/what-faust

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


Re: [Haskell-cafe] matrix manipulations and calculations

2011-09-09 Thread Stefan Kersten

On 9/9/11 1:44 PM, Aleksey Khudyakov wrote:

If you install hmatrix with -fVector key it will use storable vectors
from vector package.


that flag defaults to True, so the representations are actually the same 
by default:


http://hackage.haskell.org/packages/archive/hmatrix/0.12.0.0/hmatrix.cabal

sk

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


[Haskell-cafe] how to generate source code from TH Exp?

2011-05-12 Thread Stefan Kersten

hi,

i was wondering if it's possible to directly generate Haskell source 
code from a Template Haskell `Q Exp', i.e. use TH as a kind of 
preprocessor? i am asking because currently the iOS port of ghc doesn't 
support TH and i need to generate some instances for the persistent 
package [1,2].


i've been toying with

fmap ppr . runQ $ q

but the result needs to be edited by hand quite a bit. any ideas where 
to start?


thanks,
sk

[1] http://hackage.haskell.org/package/persistent
[2] http://hackage.haskell.org/package/persistent-template

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


Re: [Haskell-cafe] how to generate source code from TH Exp?

2011-05-12 Thread Stefan Kersten

On 5/12/11 4:03 PM, Serguey Zefirov wrote:

Just pretty-print a Exp.

It seems that show $ ppr exp will produce exactly what you need.

The same goes for Dec (declarations), etc.


ah ok, thanks!

fwiw, here's a way to extract a list of module names that need to be 
imported, adapted from an example by Neil Mitchell using generics:


extractModules :: Data a = a - [String]
extractModules = sort . nub . everything (++) ([] `mkQ` f)
 where f (NameQ x) = [modString x]
   f (NameG _ _ x) = [modString x]
   f _ = []

which can be used to output a source code module:

mkModule :: (Data a, Ppr a) = [String] - String - a - String
mkModule exts name e =
unlines ([ {-# LANGUAGE  ++ intercalate ,  exts ++  #-}
 , module  ++ name ++  where ]
 ++ map (import qualified  ++) (extractModules e))
 ++ show (ppr e)

good enough for now ;)

sk

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


Re: [Haskell-cafe] [Cabal-devel] Cabal license combinations

2011-02-10 Thread Stefan Kersten
On 10.02.11 12:12, Duncan Coutts wrote:
 We are already working on a feature that will show the full set of
 licenses that the end user must comply with (a patch has been submitted
 and it's been through one round of review so far). In your example that
 would mean you expect the set to be {BSD} but the tool will show you
 that it is in fact {BSD, GPL}. You can then use that as your warning
 that the set of licenses is not what you expected.

that would be quite useful for those who want to distribute executables!

may i also suggest the following feature: collect all the copyright notices and
license files from each dependency (many licenses require those to be displayed
and distributed along with the executable) and optionally bundle them with the
applicaton's data-files? i briefly looked into this, but couldn't find a way to
retrieve the installed License-File from ~/.cabal using Cabal. doing this by
hand turns out to be quite tedious when there are many dependencies ...

sk

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


Re: [Haskell-cafe] Haskell for Gingerbread

2011-01-13 Thread Stefan Kersten
On 28.12.10 21:25, John Meacham wrote:
 jhc generated C works on the android/ARM just fine. Android specific
 libraries arn't available, so you would have to bind to what you want
 with the FFI.

is there a recommended procedure for porting code from GHC to JHC? i'd like to
port an application of mine to ios/android, but my naive approach of specifying
the jhc compiler in ~/.cabal/config fails with the first dependency (binary),
because the base library does not have the required version. any hints?

thanks,
sk

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


Re: [Haskell-cafe] GHC Out of memory

2010-11-23 Thread Stefan Kersten
On 23.11.10 09:36, Christopher Done wrote:
 What version of GHC/qtHaskell?

i've also noticed this on linux and osx with ghc 6.12.1/6.12.3 and qtHaskell
1.1.3.5/1.1.4. possibly a memory leak in ghc --make?

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


Re: [Haskell-cafe] GUI Designer

2010-11-22 Thread Stefan Kersten
On 18.11.10 21:28, c8h10n4o2 wrote:
 There's a tutorial on how to use qtDesigner with qtHaskell ?

sorry, i don't know of any tutorial, but there are some examples in the
`examples' directory of the source distribution (e.g. tetrix.hs). basically you
load the ui file, retrieve named widgets and attach signal handlers in haskell.
signals and slots of compatible types can also be connected directly in 
Designer.

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


[Haskell-cafe] deploying applications that use plugins

2010-10-15 Thread Stefan Kersten
hi all,

i am working on an application that evaluates haskell code entered by the user
using the plugins package [1]; now i want to deploy the application as a
self-contained .app bundle on OSX, i.e. the end user should not have to install
anything in addition.

what do i need to bundle in order for plugins to work on a vanilla machine? i
suppose i need ghc in PATH and have to ship modified versions of the
package.conf files that point to the corresponding libraries within the
application bundle? is there a parser for package.conf files? any pointers would
be greatly appreciated!

thanks,
sk

[1] http://hackage.haskell.org/package/plugins
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: [Haskell] analogous functions in Sound.File.Sndfile

2010-07-07 Thread stefan kersten
following up on haskell-cafe ...

On 07.07.10 04:07, Maria Gabriela Valdes wrote:
 Does anybody know what are the analogous functions and data types in the
 haskell library Sound.File.Sndfile of  the libsndfile library in C  ?

the decision may be debatable, but where it seemed appropriate the C identifiers
map to identifiers commonly used in haskell.

 data type : SNDFILE

Sound.File.Sndfile.Handle

 function: sf_open

Sound.File.Sndfile.openFile

 function : sf_read_short

the most lowlevel interface is the hGetBuf method of Sample; you have to
allocate buffer memory yourself. hGetBuffer returns a newly allocated instance
of Buffer; see the packages hsndfile-vector [1] and hsndfile-storablevector [2]
for instances and examples [3]. hGetContents returns the contents of the whole
file at once while hGetContentChunks returns a lazy list of buffers. readFile
and readFileChunks are just wrappers around openFile and hGetContents.

i just noticed though that the lazy versions don't work correctly because they
don't take closing the file handle into account properly. i think they should be
removed from the API, for incremental processing an iteratee interface would
probably be more appropriate.

sk

[1] http://hackage.haskell.org/package/hsndfile-vector
[2] http://hackage.haskell.org/package/hsndfile-storablevector
[3]
http://hackage.haskell.org/packages/archive/hsndfile-vector/0.4.0/doc/html/src/Sound-File-Sndfile-Buffer-Vector-Examples.html#normalizeSoundFile
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Can't install Criterion package on ghc ..

2010-04-15 Thread stefan kersten
On 13.04.10 14:46, Mozhgan kabiri wrote:
 I am trying to install Criterion package, but I keep getting an error
 and I can't figure it out why it is like this !!
[...]
 [8 of 9] Compiling Data.Vector.Algorithms.Intro (
 Data/Vector/Algorithms/Intro.hs, dist/build/Data/Vector/Algorithms/Intro.o )
 ghc: panic! (the 'impossible' happened)
   (GHC version 6.10.4 for i386-unknown-linux):
 idInfo co{v a9WB} [tv]

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

fwiw, the latest version of vector-algorithms (0.3.1) seems to build with ghc
6.10.4.

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


[Haskell] ANN: hsndfile 0.4

2010-03-09 Thread stefan kersten
i'm pleased to announce version 0.4 of hsndfile [1], a haskell interface to
libsndfile [2].

in version 0.4 the buffer i/o interface has been simplified and instances for
i/o based on the vector package [3] is provided by hsndfile-vector [4].

enjoy!

sk

[1] http://haskell.org/haskellwiki/Hsndfile
[2] http://www.mega-nerd.com/libsndfile/
[3] http://hackage.haskell.org/package/vector
[4] http://hackage.haskell.org/package/hsndfile-vector
___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell-cafe] vector stream fusion, inlining and compilation time

2010-03-05 Thread stefan kersten
 This is a general problem when working with RULES-based
 optimisations. Here is an example of what happens: suppose we have
 
 foo :: Vector Int - Vector Int
 foo xs = map (+1) xs
 
 Now, GHC will generate a nice tight loop for this but if in a
 different module, we have something like this:
 
 bar xs = foo (foo xs)
 
 then this won't fuse because (a) foo won't be inlined and (b) even if
 GHC did inline here, it would inline the nice tight loop which can't
 possibly fuse instead of the original map which can. By slapping an
 INLINE pragma on foo, you're telling GHC to (almost) always inline the
 function and to use the original definition for inlining, thus giving
 it a chance to fuse.

thanks for the insight, roman!

 the downside after adding the INLINE pragmas is that now some of my modules 
 take
 _really_ long to compile (up to a couple of minutes); any ideas where i can
 start looking to bring the compilation times down again?
 
 Alas, stream fusion (and fusion in general, I guess) requires what I
 would call whole loop compilation - you need to inline everything into
 loops. That tends to be slow. I don't know what your code looks like
 but you could try to control inlining a bit more. For instance, if you
 have something like this:
 
 foo ... = ... map f xs ...
   where
 f x = ...
 
 you could tell GHC not to inline f until fairly late in the game by adding
 
   {-# INLINE [0] f #-}
 
 to the where clause. This helps sometimes.

thanks, i'll check it out.

 I'm surprised -Odph doesn't produce faster code than -O2. In any
 case, you could try turning these flags on individually (esp.
 -fno-method-sharing and the spec-constr flags) to see how they affect
 performance and compilation times.

in the end it turned out that i had forgotten another INLINE pragma and in my
crude benchmarks -O2 and -Odph give basically the same results, -O2 being a
little faster. i hope i'll have time next week to do proper benchmarks, and i
also want to try ghc HEAD with the llvm patches.

conv_1  conv_2  conv_3
-Odph   1.004   2.715   1.096
-O2 1.000   2.710   1.097

i'm still curious, though, why my three versions of direct convolution perform
so differently (see attached file). in particular, i somehow expected conv_3 to
be the slowest and conv_2 to perform similar to conv_1. any ideas? i haven't had
a look at the core yet, mainly because i'm lacking the expertise ...

sk
import   Data.Vector.Generic (Vector, (!))
import qualified Data.Vector.Generic as V

conv_1, conv_2, conv_3 :: (Num a, Vector v a) = v a - v a - v a
{-# INLINE conv_1 #-}
conv_1 h x = V.generate (l+m) f
where
m = V.length h - 1
l = V.length x
{-# INLINE f #-}
f n = g 0 n (max 0 (n-l+1)) (min n m)
g y n m k = if m = k
then let y' = y + (h ! m) * (x ! (n-m))
 in y' `seq` g y' n (m+1) k
else y
{-# INLINE conv_2 #-}
conv_2 h x = V.generate (l+m) f
where
l = V.length x
m = V.length h - 1
{-# INLINE f #-}
f n = let j = max 0 (n-l+1)
  k = (min n m) - j + 1
  in V.sum (V.zipWith (*) (V.slice j k h) (V.reverse (V.slice (n - 
j - k + 1) k x)))
{-# INLINE conv_3 #-}
conv_3 h x = V.generate (l+m-1) f
where
m   = V.length h
l   = V.length x
p   = V.replicate (m-1) 0
x'  = p ++ x ++ p
{-# INLINE f #-}
f i = V.sum (V.zipWith (*) (V.reverse h) (V.slice i m x'))
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: How many Haskell Engineer I/II/IIIs are there?

2010-02-12 Thread stefan kersten
On 12.02.10 16:29, Simon Marlow wrote:
 I'm aware that some people need a GC with shorter pause times.  We'll
 probably put that on the roadmap at some point.

for some applications (like realtime audio processing) it would be interesting
to even have short pause times with a guaranteed upper bound, but i realize this
is a very specialized need that could be better served by making the GC
implementation swappable (which otoh doesn't seem to be trivial).

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


Re: [Haskell-cafe] vector to uvector and back again

2010-02-11 Thread stefan kersten
On 10.02.10 19:03, Bryan O'Sullivan wrote:
 I'm thinking of switching the statistics library over to using vector.

that would be even better of course! an O(0) solution, at least for me ;) let me
know if i can be of any help (e.g. in testing). i suppose uvector-algorithms
would also need to be ported to vector, then.

 uvector is pretty bit-rotted in comparison to vector at this point, and
 it's really seeing no development, while vector is The Shiny Future.
 Roman, would you call the vector library good enough to use in
 production at the moment?

i've been using the library for wavelet transforms, matching pursuits and the
like, and while my implementations are not heavily optimized, they perform
reasonably well (no benchmarking done yet, though). the key arguments for using
vector instead of uvector were the cleaner interface and Data.Vector.Storable
for interfacing with foreign libraries (such as fftw, through the fft package).

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


Re: [Haskell-cafe] vector to uvector and back again

2010-02-11 Thread stefan kersten
On 11.02.10 18:55, Henning Thielemann wrote:
 i've been using the library for wavelet transforms, matching pursuits
 and the like,

 Nice I have also worked on this topics, even with Haskell. However, at
 that time I used plain lists.

interesting! was performance acceptable for practical work? at the moment i'm
not too concerned about performance -- the base line maybe could be to be
competitive with matlab. in the long run i hope i'll be able to scale my stuff
to larger amounts of data, however ...

 and while my implementations are not heavily optimized, they perform
 reasonably well (no benchmarking done yet, though). the key arguments
 for using vector instead of uvector were the cleaner interface and
 Data.Vector.Storable for interfacing with foreign libraries (such as
 fftw, through the fft package).

 Btw. Data.StorableVector can also be used for this interfacing, and
 I would be very interested in an interface to FFTW. Actually, I have
 already used FFTW on StorableVector

i'm simply using the fft package and adapted some of it's internals to work on
Data.Vector.Storable; nothing fancy though, and only for RC and CR transforms.
let me know if you're interested in the code ...

 There is also Data.StorableVector.Lazy which is nice for processing
 stream data.

yes, i know about storablevector, but i already had some code using uvector,
so in the end vector was the easier upgrade. to me the relative merits of
storablevector vs. vector are still unclear; the lazy interface could be
implemented on top of vector as well, i suppose?

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


[Haskell-cafe] vector to uvector and back again

2010-02-10 Thread stefan kersten
hi,

i've been using the vector [1] library for implementing some signal processing
algorithms, but now i'd like to use the statistics [2] package on my data, which
is based on the uvector [3] library. is there a (straightforward) way of
converting between vectors and uvectors, preferrably O(1)?

thanks,
sk

[1] http://hackage.haskell.org/package/vector
[2] http://hackage.haskell.org/package/statistics
[3] http://hackage.haskell.org/package/uvector
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] OpenAL and Hsndfile

2009-12-09 Thread stefan kersten
hi matthew,

On 09.12.09 14:37, Matthew wrote:
 Yesterday, I set out to accomplish the challenge of loading and playing
 a sound from a file.
 So far, my attempts have resulted only in silence... rather
 disheartening after all the effort
 it took to get everything to build and run cleanly.
 
 I currently take the following steps:
 - Load samples from file into an IOCArray using hsndfile
 - Create an OpenAL buffer which points to the IOCArray
 - Play sound using OpenAL
 code is at: http://hpaste.org/fastcgi/hpaste.fcgi/view?id=13836

could you isolate the problem by checking if the array returned by hsndfile
actually contains non-zero sample frames? e.g. by computing the maximum 
amplitude:

(Data.List.foldl' (max) 0 . fmap abs) `fmap` Data.Array.MArray.getElems buffer

you could also try to test OpenAL  with a synthesized sound, e.g.
sin(2*pi*f/fs*k); i'm not familiar with OpenAL, though.

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


Re: [Haskell-cafe] ANNOUNCE: usb-0.3

2009-12-09 Thread stefan kersten
On 09.12.09 14:35, Bas van Dijk wrote:
 I made a new release of my usb library for high-level communication
 with usb devices from Haskell.

looks great, thanks! do you happen to have some example code for working with
HID devices (mice, keyboards, etc.)?

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


Re: [Haskell-cafe] ANNOUNCE: usb-0.3

2009-12-09 Thread stefan kersten
hi roel,

On 09.12.09 16:50, Roel van Dijk wrote:
 On Wed, Dec 9, 2009 at 4:20 PM, stefan kersten s...@k-hornz.de wrote:
 looks great, thanks! do you happen to have some example code for working with
 HID devices (mice, keyboards, etc.)?
 
 The usb package does not support the various device classes directly.
 You won't find a function like isKeyPressed ∷ Device → KeyCode → IO
 Bool. But you could write it based solely on functions from the usb
 package. Enumerate the devices connected to your system, find your HID
 device, open a handle (or enter a safe region), choose an interface
 and an alternative and finally send some sort of control request
 encoded in a ByteString. The actual bytes you need to send in order to
 discover if some key on your USB keyboard is pressed is defined
 somewhere in the USB HID device class specification.

ok, thanks. i just thought you might have something ready to use ;)

 If you really need that kind of functionality then you could create a
 package usb-hid that offers an abstraction over the HID device
 class. But if you just want to know if some key is pressed then a much
 simpler solution would be to use a library like SDL or GLUT.

i'm interested in headless appliances, where no window system is actually
running. on linux i could use the input device layer, but it would be nice to
have something more portable ...

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


Re: [Haskell-cafe] ANN: Yi 0.4.1

2008-07-27 Thread stefan kersten
On Sun, Jul 27, 2008 at 03:08:04PM +, Jean-Philippe Bernardy wrote:
 I'm very pleased to announce the 0.4.1 release of the Yi editor.

great, i can't wait to check it out ...

i get the following error when installing via hackage/cabal (ghc 6.8.1, cabal
1.4.0.1):

Yi/Buffer.hs:253:0:
No instance for (Typeable4 RWS)
  arising from the 'deriving' clause of a data type declaration
   at Yi/Buffer.hs:(253,0)-(254,101)
Possible fix: add an instance declaration for (Typeable4 RWS)
When deriving the instance for (Typeable1 BufferM)

Yi/Buffer.hs:256:0:
Can't make a derived instance of `Typeable4 RWS'
  (even with cunning newtype deriving:
   the representation type has wrong kind)
In the stand-alone deriving instance for `Typeable4 RWS'

any ideas what's going wrong? is it finally time to upgrade my ghc
installation?

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


Re: [Haskell-cafe] Data.Complex.magnitude slow?

2008-07-18 Thread stefan kersten

On 17.07.2008, at 21:46, Lennart Augustsson wrote:

If scaleFloat and exponent are implemented with bit twiddling they can
be quite fast.


is there a way in ghc to 'cast' between float/int32 and double/int64  
(without going through memory)?


sk

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


Re: [Haskell-cafe] Data.Complex.magnitude slow?

2008-07-18 Thread stefan kersten

On 18.07.2008, at 13:05, Henning Thielemann wrote:

On Fri, 18 Jul 2008, stefan kersten wrote:


On 17.07.2008, at 21:46, Lennart Augustsson wrote:
If scaleFloat and exponent are implemented with bit twiddling  
they can

be quite fast.


is there a way in ghc to 'cast' between float/int32 and double/ 
int64 (without going through memory)?


What speaks against going through memory? If you want to write a  
large chunk of Doubles to disk, you may write it to a  
StorableVector and write that to disk. However shipping internal  
bit patterns to disk may violate portability, because on different  
machines there can be different floating point formats. What other  
situations might be there, where you want to cast Float to Int32  
and so on?


for implementing scaleFloat and exponent on the bitlevel as lennart  
suggested, it would be preferable if the cast would be compiled to a  
register move/reinterpretation, rather than a store/load through  
several layers of abstraction (such as Data.Binary). i'm just curious ;)


sk

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


Re: [Haskell-cafe] Data.Complex.magnitude slow?

2008-07-18 Thread stefan kersten

On 18.07.2008, at 19:47, Don Stewart wrote:

sk:

On 17.07.2008, at 21:46, Lennart Augustsson wrote:
If scaleFloat and exponent are implemented with bit twiddling  
they can

be quite fast.


is there a way in ghc to 'cast' between float/int32 and double/int64
(without going through memory)?


Yeah,

fromIntegral/Int-Float   fromIntegral = int2Float
truncate/Float-Int   truncate = float2Int


truncate/Double-Int  truncate = double2Int

with appropriate no-op fromIntegrals for the 32 and 64 variants.


i actually meant something like *(uint32_t*)fptr, but thanks anyway ;)

sk

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


[Haskell-cafe] Data.Complex.magnitude slow?

2008-07-17 Thread stefan kersten

hi,

i've attached an example program which seems to indicate that the  
magnitude function from Data.Complex is very slow compared to a more  
naive implementation (for Complex Float). on my machine (intel core2  
duo, osx 10.4) the CPU time using the library function is about 6-7  
times as much as when using the other function. any ideas what might  
be going on? any flaws in my measurement code?


thanks,
sk



magnitude.hs
Description: Binary data



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


Re: [Haskell-cafe] Data.Complex.magnitude slow?

2008-07-17 Thread stefan kersten

On 17.07.2008, at 17:42, Ian Lynagh wrote:

On Thu, Jul 17, 2008 at 05:18:01PM +0200, Henning Thielemann wrote:

Complex.magnitude must prevent overflows, that is, if you just square
1e200::Double you get an overflow, although the end result may be  
also
around 1e200. I guess, that to this end Complex.magnitude will  
separate

mantissa and exponent, but this is done via Integers, I'm afraid.


Here's the code:

{-# SPECIALISE magnitude :: Complex Double - Double #-}
magnitude :: (RealFloat a) = Complex a - a
magnitude (x:+y) =  scaleFloat k
 (sqrt ((scaleFloat mk x)^(2::Int) +  
(scaleFloat mk y)^(2::Int)))

where k  = max (exponent x) (exponent y)
  mk = - k

So the slowdown may be due to the scaling, presumably to prevent
overflow as you say. However, the e^(2 :: Int) may also be causing a
slowdown, as (^) is lazy in its first argument; I'm not sure if  
there is
a rule that will rewrite that to e*e. Stefan, perhaps you can try  
timing

with the above code, and also with:

{-# SPECIALISE magnitude :: Complex Double - Double #-}
magnitude :: (RealFloat a) = Complex a - a
magnitude (x:+y) =  scaleFloat k
 (sqrt (sqr (scaleFloat mk x) + sqr (scaleFloat  
mk y)))

where k  = max (exponent x) (exponent y)
  mk = - k
  sqr x = x * x

and let us know what the results are?


thanks ian, here are the absolute runtimes (non-instrumented code)  
and the corresponding entries in the profile:


c_magnitude0 (Complex.Data.magnitude)   0m7.249s
c_magnitude1 (non-scaling version)  0m1.176s
c_magnitude2 (scaling version, strict square)   0m3.278s

 %time  %alloc
 (inherited)

c_magnitude0 91.6   90.2
c_magnitude1 41.7   49.6
c_magnitude2 81.5   71.1

interestingly, just pasting the original ghc library implementation  
seems to

slow things down considerably (0m12.264s) when compiling with

-O2
-funbox-strict-fields
-fvia-C
-optc-O2
-fdicts-cheap
-fno-method-sharing
-fglasgow-exts

when leaving away -fdicts-cheap and -fno-method-sharing the execution  
time for
the pasted library code reduces to 0m6.873s. seems like some options  
that are
useful (or even necessary?) for stream fusion rule reduction, may  
produce

non-optimal code in other cases?

sk

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


Re: [Haskell-cafe] Data.Complex.magnitude slow?

2008-07-17 Thread stefan kersten

On 17.07.2008, at 17:18, Henning Thielemann wrote:
i've attached an example program which seems to indicate that the  
magnitude function from Data.Complex is very slow compared to a  
more naive implementation (for Complex Float). on my machine  
(intel core2 duo, osx 10.4) the CPU time using the library  
function is about 6-7 times as much as when using the other  
function. any ideas what might be going on? any flaws in my  
measurement code?


Complex.magnitude must prevent overflows, that is, if you just  
square 1e200::Double you get an overflow, although the end result  
may be also around 1e200. I guess, that to this end  
Complex.magnitude will separate mantissa and exponent, but this is  
done via Integers, I'm afraid.


very enlightening, thanks! it might be possible to (almost) get the  
best of two worlds (ported from dejagnu's libm):


c_magnitude4 :: Complex Float - Float
c_magnitude4 (x:+y) = if x'  y'
then mag y' x'
else mag x' y'
where
x'  = abs x
y'  = abs y
sqr x   = x * x
mag a 0 = a
mag a b = a * sqrt (1 + sqr (b/a))

is fast and doesn't overflow intermediate results but accuracy isn't  
so great ...


sk

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


Re: [Haskell-cafe] uvector and the stream interface

2008-07-16 Thread stefan kersten

On 14.07.2008, at 20:48, Don Stewart wrote:

Yes, we have long been discussing a generic Stream library to which
the various sequence structures can be translated to and from. Already
it is useful to say, stream bytestrings into uvectors and out to  
lists.


could the Stream interface be made public in uvector for writing  
custom adapters?



If people are using uvector or stream-fusion (the list version) and
are interested in interop please let Roman, Duncan and I know, so we
can think more about how best to make it all play together.


i'd be interested, just have to gather a little more infrastructure  
before i start working on real algorithms.


sk

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


[Haskell-cafe] vector vs uvector

2008-07-14 Thread stefan kersten

hi,

what's the difference between the vector [1] and uvector [2]  
packages? should one of those preferred over the other?


thanks,
sk

[1] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/ 
vector-0.1
[2] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/ 
uvector-0.1.0.1


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


[Haskell-cafe] uvector and the stream interface

2008-07-14 Thread stefan kersten

currently i'm working on stuff that looks something like this:

1 read soundfile from disk in blocks of N samples (IOCArray, hsndfile  
package)

2 convert to CArray with unsafeFreeze (simple O(1) cast, carray package)
3 perform FFT (CArray, fftw package)
4 convert to UArr (uvector package)
5 do some stuff with vectors

i'd like to minimize copying, and since the FFT returns a new array  
anyway, the only copying conversion is the one between CArray and  
UArr in step 4. the approach i've been following is defining a  
`stream' conversion for CArray, hoping that subsequent carray  
accesses will be fused with uvector operations without the need for  
allocating a vector in between. does that make sense? could this be a  
general strategy for avoiding copying at the boundary between the  
various array libraries?


thanks,
sk

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


Re: [Haskell-cafe] uvector and the stream interface

2008-07-14 Thread stefan kersten

On 14.07.2008, at 18:42, Jules Bean wrote:
It would be helpful to see the programs people are writing with  
uvector,

so I can polish up the API some more :)


It would also be helpful to have someone explain why we have:

Ptr a
ByteString
IOUArray
IOCArray
Data.Storable.StorableArray
UArr

Of course, I know the answers to some of those questions,  
ByteString is obviously less polymorphic than all the others there,  
and Ptr a doesn't contain size information. But it seems we have a  
rapidly bifurcating profusion of 'typed interfaces to chunks of  
memory' with no obvious consistency to their naming scheme and I  
think it's starting to get confusing...


maybe it would be useful to look at (1) what's expected in terms of  
the underlying array implementation and (2) in terms of array access.


(1) some things that come to mind:

* ghc heap or system heap (can the garbage collector move memory  
during calls to C?)
* access to a Ptr for interfacing to external libraries (possible  
with UArr?)

* alignment (most SIMD instruction sets require 16 byte aligned data)
* mutability
* strict vs (partially) lazy

(2) personally i much prefer the list-like interface provided by the  
stream-fusion powered libraries (ndp, uvector, vector). can't the  
stream-fusion framework and correspondingly the vector interface be  
separated from the memory representation, provided a particular  
concrete representation comes up with a stream/unstream pair? then it  
would be easy to swap out the underlying representation according to  
the required characteristics.


sk

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


Re: [Haskell-cafe] vector vs uvector

2008-07-14 Thread stefan kersten

On 14.07.2008, at 18:10, Lyle Kopnicky wrote:
You should use the most mature and stable package, which is of  
course, uvector, being a whole 0.0.0.1 versions past vector.


oops, didn't notice the thread announcing vector. i'll stick with  
uvector then for the time being :)


sk

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


[Haskell-cafe] reactive and loop

2008-06-19 Thread stefan kersten

hi,

i'm having problems with a very simple example using conal elliott's  
'reactive' library:


module Main where

import Control.Applicative
import Control.Concurrent
import Control.Monad
import Data.Reactive
import System.Random

main :: IO ()
main = do
(e, snk) - mkEvent
forkIO $ forever ((getStdRandom random :: IO Double) = snk   
threadDelay 1)

runE (print `fmap` withPrevE e)
return ()

which starts to output this after a while:

reactive_loop.hs: loop

this is with ghc 6.8.1 on osx 10.4. any ideas what might be going wrong?

many thanks,
sk

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


[Haskell] ANNOUNCE: hsndfile 0.1.1

2008-06-04 Thread stefan kersten

Haskell bindings for libsndfile.

Libsndfile is a comprehensive C library for reading and writing a  
large number

of soundfile formats: http://www.mega-nerd.com/libsndfile/.

Hackage:

http://hackage.haskell.org/cgi-bin/hackage-scripts/package/hsndfile

Darcs:

http://darcs.k-hornz.de/cgi-bin/darcsweb.cgi?r=hsndfile;a=summary

Enjoy!

sk

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


[Haskell] ANNOUNCE: sonic-visualiser 0.1.1

2008-06-04 Thread stefan kersten

Library for reading and parsing Sonic Visualiser project files.

Sonic Visualiser is available at http://sonicvisualiser.org.

Hackage:

http://hackage.haskell.org/cgi-bin/hackage-scripts/package/sonic- 
visualiser


Darcs:

http://darcs.k-hornz.de/cgi-bin/darcsweb.cgi?r=sonic- 
visualiser;a=summary


Enjoy!

sk

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


[Haskell-cafe] realtime garbage collector for ghc (was: Why functional programming matters)

2008-01-25 Thread Stefan Kersten

On 25.01.2008, at 00:04, Evan Laforge wrote:

Well... ghc still has a single-threaded garbage collector, so all the
par threads must stop for garbage collection.  So scaling to the
level of a cluster would be significantly sub-linear.


A real time incremental gc would be really cool.  Some people claim
they exist, but which languages have one?


james mccartney's supercollider [1] has a non-copying incremental  
collector based on [2], though not a parallel one.


btw, is an implementation of the incremental collector described in  
[3] available somewhere? are there any plans to incorporate it into  
future ghc versions?


sk

[1] http://supercollider.sourceforge.net
[2] P. R. Wilson and M. S. Johnstone. Real-time non-copying garbage  
collection. In ACM OOPSLA Wsorkshop on Memory Management and Garbage  
Collection, 1993.
[3] A. M. Cheadle, A. J. Field, S. Marlow, S. L. P. Jones, and R. L.  
While. Exploring the barrier to entry: incremental generational  
garbage collection for haskell. In ISMM ’04: Proceedings of the 4th  
international symposium on Memory management, pages 163–174, New  
York, NY, USA, 2004. ACM.


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


Re: [Haskell-cafe] library to read/write audio files

2007-12-11 Thread Stefan Kersten

hi john,

On 11.12.2007, at 18:14, John Lato wrote:

I've been working on a library to encode/decode audio files (wave,
aiff, etc.) to and from lazy bytestrings, and it's finally in a form
where I'm willing to share.  It's available at
http://mml.music.utexas.edu/jwlato/HSoundFile/, lightly cabalized and
haddock-ified.  The basic item is a Data.SoundFile datatype and a
SndFileCls class.  Each file format (wave, etc.) has a datatype with
instances of SndFileCls and Data.Binary (thanks to Don S. for
suggesting Data.Binary).  At least that's the idea, I've only
implemented the Wave format so far, but I wanted to make it easy to
add new formats.


sounds good!


I originally intended to use Erik de Castro Lopo's excellent
libsndfile (and there are some remnants of that in darcs), but after
realizing I wanted a more functional interface I decided to roll my
own.  It's likely possible to wrap libsndfile in a functional
interface, but that is beyond my current abilities.


incidentally, i've been working on libsndfile bindings the last few  
days; here's the darcs repository:


http://darcs.k-hornz.de/cgi-bin/darcsweb.cgi?r=hsndfile;a=summary

it's not quite finished yet, but if you're interested you could have  
a look at the interface and make suggestions. maybe both projects  
could benefit from each other? i personally don't see much advantages  
in _not_ using libsndfile underneath ...


sk

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


Re: [Haskell-cafe] c2hs and cabal

2007-12-11 Thread Stefan Kersten

On 02.12.2007, at 22:34, Eric Sessoms wrote:

Just add

Build-Tools: c2hs

And cabal will take it from there.


thanks eric, that's really pleasingly simple (it appears that the  
Build-Tools: line isn't even needed).


sk

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


[Haskell-cafe] c2hs and cabal

2007-12-02 Thread Stefan Kersten

hi,

i'm looking for a way to integrate c2hs (single .chs file) in a cabal  
build setup; can anybody give me some hints?


thanks,
sk

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


Re: [Haskell-cafe] The Yampa Arcade: source code available?

2007-11-19 Thread Stefan Kersten

On 19.11.2007, at 19:54, Peter Verswyvelen wrote:
I can find the paper, but is the source code for that Space  
Invaders alike game also available somewhere?


it's included here: http://haskell.org/yampa/afrp-0.4-src.tgz

btw, does anybody know what's the current state of affairs with yampa/ 
afrp? is the framework still developed further?


sk

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


Re: [Haskell-cafe] HTTP actions proxy server

2007-11-19 Thread Stefan Kersten

On 16.11.2007, at 13:55, Jim Burton wrote:
The docs say Should be of the form http://host:port, host,  
host:port, or
http://host; but none of the variations work. Any ideas where I  
might find

an example of code that does this?


this works for me (modulo error handling):

simpleHTTP' :: Request - IO (Result Response)
simpleHTTP' req = do
proxy - catch
(getEnv HTTP_PROXY = return . (flip Proxy Nothing))
(\_ - return NoProxy)
(_, resp) - browse (setProxy proxy  request req)
return (Right resp)

i.e. run the request in the browser monad.

sk

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