Re: [Haskell-cafe] Examples of MVars usage

2013-06-12 Thread lucas di cioccio
Hi Francisco,

You can try GitHub's code search
https://github.com/search?l=Haskellq=mvarref=cmdformtype=Code

Cheers,
--Lucas


2013/6/12 Francisco M. Soares Nt. xfrancisco.soa...@gmail.com

 Hello, everyone.

 I am looking for packages on hackage which use MVars extensively. Those
 which create plenty of MVars -- not just one or two for conditional
 synchronization or to keep track of a value throughout the program. My
 purpose is to analyze usage patterns of MVars. Does anybody have any
 suggestions?

 So far I have analyzed a few packages:

 * conjure (0.1)
 * distributed-process (0.4.2)
 * distributed-process-p2p (0.1.1.0)
 * leksah (0.12.1.3)
 * manatee-core (0.1.1)
 * urlcheck (0.1.1)

 Nonetheless, I feel like I still haven't covered a good enough range of
 usage, since some examples are small, and some use MVars just for a small
 number of cases, while the heavy lifting is done with STM. And surely
 because there are only 6 of them.

 Any suggestion will be very much appreciated.

 []'s
 --
 Francisco Soares Nt.


 ___
 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] Examples of MVars usage

2013-06-12 Thread Bas van Dijk
On 12 June 2013 21:29, Francisco M. Soares Nt.
xfrancisco.soa...@gmail.com wrote:
 I am looking for packages on hackage which use MVars extensively. Those
 which create plenty of MVars

Hi Francisco,

Also take a look at Control.Concurrent.Chan in the base library:

http://hackage.haskell.org/packages/archive/base/latest/doc/html/Control-Concurrent-Chan.html

A big Chan has a lot of MVars inside.

Bas

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


Re: [Haskell-cafe] Examples of MVars usage

2013-06-12 Thread Francisco M. Soares Nt.
First of all, thank you for your suggestions.

You can try GitHub's code search


For the moment I am ignoring Github because it's harder to separate stable
development from unstable. Even so, it might be worth the trouble to check
out github soon. Thank you, Lucas.

Also take a look at Control.Concurrent.Chan in the base library:


Yes, the base package seems like a good one for inclusion. Thank you, Bas.

[]'s
--
Francisco


2013/6/12 Bas van Dijk v.dijk@gmail.com

 On 12 June 2013 21:29, Francisco M. Soares Nt.
 xfrancisco.soa...@gmail.com wrote:
  I am looking for packages on hackage which use MVars extensively. Those
  which create plenty of MVars

 Hi Francisco,

 Also take a look at Control.Concurrent.Chan in the base library:


 http://hackage.haskell.org/packages/archive/base/latest/doc/html/Control-Concurrent-Chan.html

 A big Chan has a lot of MVars inside.

 Bas

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


Re: [Haskell-cafe] Examples for the problem

2011-03-02 Thread Tillmann Rendel

Hi,

Robert Clausecker wrote:

Each instruction has up to three operands, looking like this:

 @+4 (Jump for bytes forward)
  foo (the string foo
  '0'(1+2)

etc. A string literal may contain anything but a newline, (there are
no escape codes or similar). But when I  add a check for a newline,
the parser just fails and the next one is tried. This is undesired, as
I want to return an error like unexpected newline instead. How is
this handled in other parsers?


I would expect that the other parsers are tried, but fail, because they 
do not accept an initial quotation mark. You get two errors messages then:


  1. Unexpected newline after quotation mark
  2. Unexpected quotation mark

These two error messages reflect the two ways to solve the problem: 
Either delete the first quotation mark, or add a second one.


  Tillmann

PS. Please use Reply to answer posts, so that they can be put into the 
same thread.


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


Re: [Haskell-cafe] Examples for the problem

2011-03-02 Thread Steve Schafer
On Wed, 2 Mar 2011 14:14:02 +0100, you wrote:

Thank you all for the responses. Here's an example:

As I alrerady said, I tried to parse the MMIXAL assembly language.
Each instruction has up to three operands, looking like this:

@+4 (Jump for bytes forward)
 foo (the string foo
 '0'(1+2)

etc. A string literal may contain anything but a newline, (there are
no escape codes or similar). But when I  add a check for a newline,
the parser just fails and the next one is tried. This is undesired, as
I want to return an error like unexpected newline instead. How is
this handled in other parsers?

Tillman's reply is absolutely correct. If a particular sequence of
characters is invalid according to your grammar, then _all_ of the
alternatives in scope at that point should fail to parse that sequence.
If that's not happening, then there's something wrong with the way
you've expressed your grammar.

I don't know how much experience you have with language grammars, but it
might be helpful to try to write down MMIXAL's grammar using EBNF
notation, as a starting point.

-Steve Schafer

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


Re: [Haskell-cafe] Examples for the problem

2011-03-02 Thread Stephen Tetley
Apologies if this has been answered already (I've got a bit lost with
this thread), but the *try* here seems to be giving you precisely the
behaviour you don't want.

*try* means backtrack on failure, and try the next parser. So if you
want ill formed strings to throw an error if they aren't properly
enclosed in double quotes don't use try.

| try $ (char '' * (StringLit . B.pack $
   manyTill (notChar '\n') (char '')))

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


Re: [Haskell-cafe] Examples for the problem

2011-03-02 Thread Stephen Tetley
Actually this is stranger than I thought - from testing it seems like
Attoparsec's (|) is different to Parsec's. From what I'm seeing
Attoparsec appears to do a full back track for (|) regardless of
whether the string lexer is wrapped in try, whereas Parsec needs try
to backtrack.

On 2 March 2011 16:24, Stephen Tetley stephen.tet...@gmail.com wrote:


 *try* means backtrack on failure, and try the next parser. So if you
 want ill formed strings to throw an error if they aren't properly
 enclosed in double quotes don't use try.

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


Re: [Haskell-cafe] Examples for the problem

2011-03-02 Thread Carl Howells
Actually, It's not | that's different, it's the string combinator.
In Parsec, string matches each character one at a time.  If the match
fails, any partial input it matched is consumed.  In attoparsec,
string matches either the entire thing or not, as a single step.  If
it fails to match, no input is consumed.

Carl

On Wed, Mar 2, 2011 at 9:51 AM, Stephen Tetley stephen.tet...@gmail.com wrote:
 Actually this is stranger than I thought - from testing it seems like
 Attoparsec's (|) is different to Parsec's. From what I'm seeing
 Attoparsec appears to do a full back track for (|) regardless of
 whether the string lexer is wrapped in try, whereas Parsec needs try
 to backtrack.

 On 2 March 2011 16:24, Stephen Tetley stephen.tet...@gmail.com wrote:


 *try* means backtrack on failure, and try the next parser. So if you
 want ill formed strings to throw an error if they aren't properly
 enclosed in double quotes don't use try.

 ___
 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] Examples/docs for simulated annealing bindings

2010-02-11 Thread John Meacham
On Thu, Oct 15, 2009 at 02:41:42PM +0100, Dougal Stanton wrote:
 I found the HsASA library [1] on Hackage, but there's no documentation
 and it's not particularly intuitive. I can't see any obvious way of
 choosing initial config or generating new configurations. Google
 reveals no one using it. Does anyone have ideas?

Hi, performing ASA efficiently relies on a very efficient implementation
of the algorithm, the actual parameters of the ASA are hard coded as C
#defines, see the original C distribution for documentation on them. For
using HsASA in projects, it is recommended you directly include the
modules into your program and modify them with the specific parameters
appropriate to your task.

John

-- 
John Meacham - ⑆repetae.net⑆john⑈ - http://notanumber.net/
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Examples/docs for simulated annealing bindings

2009-10-15 Thread minh thu
2009/10/15 Dougal Stanton dou...@dougalstanton.net:
 I found the HsASA library [1] on Hackage, but there's no documentation
 and it's not particularly intuitive. I can't see any obvious way of
 choosing initial config or generating new configurations. Google
 reveals no one using it. Does anyone have ideas?

 [1]: http://hackage.haskell.org/package/HsASA-0.1

If the wrapping is not too involved, the original documentation [*]
should help...

Cheers,
Thu

[*] http://www.ingber.com/ASA-README.html
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Examples

2009-08-12 Thread Andrew Coppin

John D. Ramsdell wrote:

Usually I include the example program in the package, but make its compilation 
conditional using a Cabal flag like buildExamples.



But then the binaries generated from the example program get
installed.  I think the poster wants to share the source code, not
install a demo.
  


Indeed yes. Example programs that don't really do anything exciting, 
but show you what kind of program structure you need to use and which 
functions to read up on to get your bearings.


Since nobody else seems to have mentioned it yet: Another possibility is 
to embed [short!] examples into the Haddock documentation. For example, 
Control.Monad.Reader has several pages of example code at the bottom of 
the Haddock page. I am ambivilent as to whether this is a good or bad 
idea...



I haven't figure out a way to specify test programs that don't get
installed, but are only intended to be built and run within the
context of a source distribution.
  


Yes, I was going to ask about that too - but that's a seperate question. ;-)

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


Re: [Haskell-cafe] Examples

2009-08-10 Thread Wolfgang Jeltsch
Am Samstag, 8. August 2009 13:29 schrieb Andrew Coppin:
 As some of you may remember, I recently released a couple of packages on
 Hackage. I'd like to also release some example programs using these
 packages, but I'm not sure of the best way to do this.

 Do I make the example programs part of the package itself? Do I release
 a seperate package which just contains the example code? Something else
 entirely? What's the recommendation here?

I had to make this decision for Grapefruit, and I decided to put the examples 
into a separate package named grapefruit-examples. Note that the rest of 
Grapefruit was already split into several packages with names of the form 
grapefruit-*.

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


Re: [Haskell-cafe] Examples

2009-08-10 Thread Keith Sheppard
This seems to me like the kind of thing hackage maintainers should be
giving guidance on (maybe they do already?) so that there is
consistency.

Sorry if this seems too off base, but here I go anyway... I have used
apache IVY for packaging/dependency management in java and I really
like the way it works. They have spent a lot of effort figuring out
how to deal with complex project dependencies. For example they have
organization (eg. com.sun) and project (eg javaSDK) concepts that
help to keep the namespace clean. They also have different profiles
like test or dist that you can depend on. Maybe it would be
worthwhile to poke around ivy's docs and see if we want to pull any of
these concepts into cabal/hackage

On Mon, Aug 10, 2009 at 10:04 AM, Wolfgang
Jeltschg9ks1...@acme.softbase.org wrote:
 Am Samstag, 8. August 2009 13:29 schrieb Andrew Coppin:
 As some of you may remember, I recently released a couple of packages on
 Hackage. I'd like to also release some example programs using these
 packages, but I'm not sure of the best way to do this.

 Do I make the example programs part of the package itself? Do I release
 a seperate package which just contains the example code? Something else
 entirely? What's the recommendation here?

 I had to make this decision for Grapefruit, and I decided to put the examples
 into a separate package named grapefruit-examples. Note that the rest of
 Grapefruit was already split into several packages with names of the form
 grapefruit-*.

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




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


Re: [Haskell-cafe] Examples

2009-08-09 Thread John D. Ramsdell
 Usually I include the example program in the package, but make its 
 compilation conditional using a Cabal flag like buildExamples.

But then the binaries generated from the example program get
installed.  I think the poster wants to share the source code, not
install a demo.

I haven't figure out a way to specify test programs that don't get
installed, but are only intended to be built and run within the
context of a source distribution.

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


Re: [Haskell-cafe] Examples

2009-08-09 Thread Thomas DuBuisson
John D. Ramsdell wrote:
 Usually I include the example program in the package, but make its 
 compilation conditional using a Cabal flag like buildExamples.

 But then the binaries generated from the example program get
 installed.  I think the poster wants to share the source code, not
 install a demo.

But only if the flag is set.  The user can simply look at the source
code example without installing the program.  Another option: test
code (or any other source) can easily be included in the source dist
by adding them to the extra-source-files: line in the .cabal file.
I include tests in the pureMD5 package in this manner.

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


Re: [Haskell-cafe] Examples

2009-08-09 Thread John D. Ramsdell
On Sun, Aug 9, 2009 at 8:15 PM, Thomas
DuBuissonthomas.dubuis...@gmail.com wrote:

... Another option: test
 code (or any other source) can easily be included in the source dist
 by adding them to the extra-source-files: line in the .cabal file.

But then cabal doesn't know how to build binaries from the source
files with that option.

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


Re: [Haskell-cafe] Examples

2009-08-09 Thread John D. Ramsdell
Maybe in addition to having a buildable boolean in a library or
executable section, there should be an installable boolean.  It would
default to true, but when false, the library or executable section is
ignored during package installation.

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


Re: [Haskell-cafe] Examples

2009-08-09 Thread Mark Wotton


On 10/08/2009, at 9:29 AM, John D. Ramsdell wrote:

Usually I include the example program in the package, but make its  
compilation conditional using a Cabal flag like buildExamples.


But then the binaries generated from the example program get
installed.  I think the poster wants to share the source code, not
install a demo.

I haven't figure out a way to specify test programs that don't get
installed, but are only intended to be built and run within the
context of a source distribution.


Couldn't resist a chance to spruik TBC (Testing By Convention) http://hackage.haskell.org/package/TBC 
 - it's a framework Pete Gammie and I are developing to run tests in  
Haskell.


In addition to a few other neat features like not having to write  
boilerplate main functions by way of some conventions about how to run  
tests, it knows enough about Cabal to use the package information etc  
to link your tests together, and provides a command line tool (tbc) to  
run your tests and provide a report.


If you use it and it's helpful to you, or you have any suggestions for  
how it could be improved, please let me or Pete know.


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


Re: [Haskell-cafe] Examples

2009-08-08 Thread Henning Thielemann


On Sat, 8 Aug 2009, Andrew Coppin wrote:

As some of you may remember, I recently released a couple of packages on 
Hackage. I'd like to also release some example programs using these packages, 
but I'm not sure of the best way to do this.


Do I make the example programs part of the package itself? Do I release a 
seperate package which just contains the example code? Something else 
entirely? What's the recommendation here?


Usually I include the example program in the package, but make its 
compilation conditional using a Cabal flag like buildExamples. This way, 
you can build the examples explicitly by

  cabal install package -fbuildExamples
 but they won't be build when the package is build as dependent package.

See for instance:
  http://code.haskell.org/gnuplot/gnuplot.cabal
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] examples for error handling in takusen?

2009-03-16 Thread Alistair Bayley
2009/3/14 Gü?nther Schmidt gue.schm...@web.de:
 Hi,

 can someone please point me to error handling examples with takusen?

 I try to run a piece of code with takusen but just get the very sparse
 Database.InternalEnumerator.DBException

Hello Günther,

We use dynamic exceptions in Takusen, which is why you don't get much
useful information when an exception is thrown. We will include the
new extensible-exceptions code in the next release, so once that it
done perhaps we can change the way we do exceptions so that you get
better messages by default.

There are some basic exception handling functions in
Database.Enumerator which should help. Firstly, you need to add an
exception handler with catchDB. Then you can choose to ignore the
error, report it, or re-raise it (see basicDBExceptionReporter and
reportRethrow). Also, the DBException constructors are exported, so
you can pattern match on it to extract more information, like
SqlState, error number, and error message.

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


Re: [Haskell-cafe] Examples of Mutually Recursive Types

2008-10-26 Thread wren ng thornton

Hugo Pacheco wrote:

Hi all,
I have been searching for examples of Haskell real scenarios that employ
mutually recursive datatype definitions.
Does anyone know some interesting libraries or structures that I could play
with?


Tim Sheard presents a realistic use case in [1]. We're using it in a 
logic language compiler, though your definitions of realism may vary. 
There's an expanded version of the two-level types idea in [2].


[1] http://web.cecs.pdx.edu/~sheard/papers/generic.ps
[2] http://web.cecs.pdx.edu/~sheard/papers/JfpPearl.ps

--
Live well,
~wren
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Examples of Mutually Recursive Types

2008-10-26 Thread Henning Thielemann


On Sun, 26 Oct 2008, Hugo Pacheco wrote:


Hi all,
I have been searching for examples of Haskell real scenarios that employ
mutually recursive datatype definitions.
Does anyone know some interesting libraries or structures that I could play
with?


http://darcs.haskell.org/wraxml/src/Data/Tree/BranchLeafTag.hs

Here Elem uses Tree.T and Tree.T uses Elem. Is this what you are looking 
for?

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


Re: [Haskell-cafe] Examples of Mutually Recursive Types

2008-10-26 Thread Martijn van Steenbergen
Think of any real programming language out there. For example, in many 
languages statements may contain expressions, and expressions in turn 
may contain statements (in Java through anonymous inner classes, for 
example).


Boa noite,

Martijn.


Hugo Pacheco wrote:

Hi all,

I have been searching for examples of Haskell real scenarios that 
employ mutually recursive datatype definitions.
Does anyone know some interesting libraries or structures that I could 
play with?


Thanks,
hugo

--
www.di.uminho.pt/~hpacheco http://www.di.uminho.pt/~hpacheco




___
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] Examples of Mutually Recursive Types

2008-10-26 Thread Niklas Broberg
 Think of any real programming language out there. For example, in many
 languages statements may contain expressions, and expressions in turn may
 contain statements (in Java through anonymous inner classes, for example).

... and as an example of this you could have a look at the
haskell-src(-exts) package that encodes the Haskell syntax as an AST.
For example there are expressions containing statements (e.g. the
do-expression) and statements containing expressions (obviously).

Cheers,

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


Re: [Haskell-cafe] Examples of Mutually Recursive Types

2008-10-26 Thread Hugo Pacheco
Probably I overdid the real part.I was thinking of examples such as ASTs
(such as the Haskell one), trees and imagining more fancy things, maybe
L-systems and fractal processing.
I will have a look at the Haskell sources and the previous papers from Tim
Sheard.

Cheers,
hugo

On Sun, Oct 26, 2008 at 6:07 PM, Niklas Broberg [EMAIL PROTECTED]wrote:

  Think of any real programming language out there. For example, in many
  languages statements may contain expressions, and expressions in turn may
  contain statements (in Java through anonymous inner classes, for
 example).

 ... and as an example of this you could have a look at the
 haskell-src(-exts) package that encodes the Haskell syntax as an AST.
 For example there are expressions containing statements (e.g. the
 do-expression) and statements containing expressions (obviously).

 Cheers,

 /Niklas




-- 
www.di.uminho.pt/~hpacheco
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Examples of using Haskell for mathematics

2008-05-27 Thread Conal Elliott
Along these lines, check out (and maybe quote) the July 2007 note from Doug
McIlroy to the Haskell list:
http://www.haskell.org/pipermail/haskell/2007-July/019632.html

I've particularly been enjoying Doug's paper The Music of Streams,
mentioned in that note.

   - Conal

On Mon, May 26, 2008 at 11:49 AM, Henning Thielemann 
[EMAIL PROTECTED] wrote:


 On Mon, 26 May 2008, Brent Yorgey wrote:

  Hi all!

 In a couple weeks I will be giving a short (15-min.) talk to an audience
 of
 mostly mathematicians, entitled Executable Mathematics: A Whirlwind
 Introduction to Haskell.  The idea will be to give a flavor of Haskell,
 its
 uniquenesses, and why it is a great language for playing around with
 mathematics, by way of some well-chosen examples.  There are definitely
 plenty of such examples out there, and I've already found quite a few that
 I
 might use, but I thought I would send an email to the cafe to ask whether
 anyone has any code which you think particularly exemplifies some aspect
 of
 why Haskell is a great language for mathematics.  I'm looking to include a
 wide range of examples, so any length (from a few to hundreds of lines of
 code) and any level (from simple number theory to things only a few people
 in the world understand) are fair game.


 The mathematical examples I like most are power series (including elegant
 solution of differential equations and series inversion) and computable real
 numbers.

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


 http://darcs.haskell.org/numericprelude/src/MathObj/PowerSeries/DifferentialEquation.hs

 http://darcs.haskell.org/numericprelude/docs/README


 ___
 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] Examples of OpenAL and ALUT?

2007-06-11 Thread Henning Thielemann

On Thu, 7 Jun 2007, Dan Piponi wrote:

 Does anyone have any sample Haskell code they'd like to share for
 doing things like creating a waveform from a list of samples or a
 mathematical function and playing them using these libraries (or
 indeed any easy to install on MacOS X Haskell library)?

I use to listen to real functions by Sox' play command:
 http://darcs.haskell.org/synthesizer/src/Sox/Play.hs
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Examples of using STUArray + help with converting code

2005-10-14 Thread Joel Reymont

If I don't cast then how do I convert this code?

doubleToInts d = runST (
do arr - newDoubleArray (1,2)
   writeDoubleArray arr 1 d
   i1 - readIntArray arr 1
   i2 - readIntArray arr 2
   return (i1,i2))

Or can I just read an array of ints from the double array using the  
new polymorphic approach?


Thanks, Joel

On Oct 13, 2005, at 7:09 PM, Tomasz Zielonka wrote:


I also don't yet
understand how to cast that double array to read ints from it.



Don't.


--
http://wagerlabs.com/





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


Re: [Haskell-cafe] Examples of using STUArray + help with converting code

2005-10-14 Thread Ketil Malde
Joel Reymont [EMAIL PROTECTED] writes:

 If I don't cast then how do I convert this code?

Uh, what is wrong with divMod?  

  *Main Data.Word (100::Word64) `divMod` (2^32)
  (2,1410065408)

 doubleToInts d = runST ( [...]

This will only give you a headache. :-)

-k
-- 
If I haven't seen further, it is by standing in the footprints of giants

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


Re: [Haskell-cafe] Examples of using STUArray + help with converting code

2005-10-14 Thread Udo Stenzel
joel reymont wrote:
 I don't understand the syntax needed to create a new double or float
 array with newArray from Data.Array.MArray. I also don't yet
 understand how to cast that double array to read ints from it.
 
 doubleToInts d = runST (
 do arr - newDoubleArray (1,2)
writeDoubleArray arr 1 d
i1 - readIntArray arr 1
i2 - readIntArray arr 2
return (i1,i2))

Just use newArray, writeArray and readArray.  Something (writeArray is
probably the easiest) will need an explicit type signature to resolve
the overloading.  Also from the GHC docs:

castSTUArray :: STUArray s ix a - ST s (STUArray s ix b)
  Casts an STUArray with one element type into one with a different
  element type. All the elements of the resulting array are undefined
  (unless you know what you're doing...).

Note the part in parentheses.  This is Haskell, not C after all.  A
clean solution may not be that far away.


Udo.
-- 
I underthand that people theem to like it better now.  
That it ith written in thee pluth pluth inthtead of lithp.


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


Re: [Haskell-cafe] Examples of using STUArray + help with converting code

2005-10-14 Thread Ketil Malde
Joel Reymont [EMAIL PROTECTED] writes:

 I must be missing something because I don't think the code below
 converts a double.

Yes, sorry, my bad.  I was (and is) confused about what you wanted to
do. 

-k
-- 
If I haven't seen further, it is by standing in the footprints of giants

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


Re: [Haskell-cafe] Examples of using STUArray + help with converting code

2005-10-14 Thread Joel Reymont
I'm just trying to replicate the example using the fresh syntax  
that does not use readDoubleArray, readIntArray, etc.


On Oct 14, 2005, at 4:32 PM, Ketil Malde wrote:


Yes, sorry, my bad.  I was (and is) confused about what you wanted to
do.


--
http://wagerlabs.com/





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


Re: [Haskell-cafe] Examples of using STUArray + help with converting code

2005-10-13 Thread Tomasz Zielonka
On 10/13/05, joel reymont [EMAIL PROTECTED] wrote:
 Folks,

 Are there any examples on using STUArray and friends? I'm trying to
 convert the following bit of code which uses deprecated features.

 I don't understand the syntax needed to create a new double or float
 array with newArray from Data.Array.MArray.

do arr  - newArray_ (1,2) :: ST s (STUArray s Int Double)
   writeArray arr 1 d
   ...

The type signature is to remove the ambiguity in type-class
constraints.

 I also don't yet
 understand how to cast that double array to read ints from it.

Don't.

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