Re: [Haskell-cafe] Help me understand general recursion from cata- and anamorphism

2013-06-23 Thread Takayuki Muranushi
Dear all, https://github.com/nushio3/practice/blob/master/recursion-schemes/FibTest.hs After learning fix-point operators, I found an answer by myself. ``` fibBase :: (Integer - Integer) - Integer - Integer fibBase fib n | n = 1= 1 | otherwise = fib (n-1) + fib (n-2) fibWithFix ::

Re: [Haskell-cafe] help understanding zlib space leak

2013-05-05 Thread diego souza
Sorry, I should've removed the pid number from the output. The following should be correct: $ sudo dd if=/dev/sda bs=4K count=2048K | ./test +RTS -M1M -s /dev/null ... 8589934592 bytes (8.6 GB) copied, 243.525 s, 35.3 MB/s 41,942,119,192

Re: [Haskell-cafe] Help to write type-level function

2013-02-27 Thread Raphael Gaschignard
I think it might be impossible with type families. I don't think it's possible to differentiate with type families something like T a a, and T a b, with b different from a. I think that you would need overlap to write this.

Re: [Haskell-cafe] Help to write type-level function

2013-02-27 Thread Aleksey Khudyakov
On 27 February 2013 12:01, Raphael Gaschignard dasur...@gmail.com wrote: I think it might be impossible with type families. I don't think it's possible to differentiate with type families something like T a a, and T a b, with b different from a. It's indeed impossible to write such type

Re: [Haskell-cafe] Help to write type-level function

2013-02-27 Thread Dmitry Kulagin
That seems to be very relevant to my problem (especially HList.Record). Am I right that UndecidableInstances is required mostly because of eq on types, like in this instances: class HRLabelSet (ps :: [*]) instance HRLabelSet '[] instance HRLabelSet '[x] instance ( HEq l1 l2 leq ,

Re: [Haskell-cafe] Help to write type-level function

2013-02-27 Thread Dmitry Kulagin
Very clear solution, I will try to adopt it. Thank you! On Wed, Feb 27, 2013 at 12:17 PM, Aleksey Khudyakov alexey.sklad...@gmail.com wrote: On 27 February 2013 12:01, Raphael Gaschignard dasur...@gmail.com wrote: I think it might be impossible with type families. I don't think it's

Re: [Haskell-cafe] Help to write type-level function

2013-02-27 Thread Dmitry Kulagin
Hi Aleksey, Unfortunately, your solution does not work for me (ghc 7.6.2). I reduced the problem to: -- | Type class for type equality. class TypeEq (a :: α) (b :: α) (eq :: Bool) | a b - eq instance TypeEq a a True -- instance TypeEq a b False instance eq ~ False = TypeEq a b eq

Re: [Haskell-cafe] Help to write type-level function

2013-02-27 Thread Aleksey Khudyakov
On 27.02.2013 17:35, Dmitry Kulagin wrote: Hi Aleksey, Unfortunately, your solution does not work for me (ghc 7.6.2). I reduced the problem to: -- | Type class for type equality. class TypeEq (a :: α) (b :: α) (eq :: Bool) | a b - eq instance TypeEq a a True -- instance TypeEq a

Re: [Haskell-cafe] Help to write type-level function

2013-02-27 Thread Dmitry Kulagin
Oh, that is my fault - I was sure that I specified the extension and it didn't help. It really works with OverlappingUndecidable. Thank you! On Wed, Feb 27, 2013 at 10:36 PM, Aleksey Khudyakov alexey.sklad...@gmail.com wrote: On 27.02.2013 17:35, Dmitry Kulagin wrote: Hi Aleksey,

Re: [Haskell-cafe] help diagnosing space leak with IORef/STRef, just incrementing a million times.

2013-01-06 Thread Albert Y. C. Lai
On 13-01-07 12:12 AM, Thomas Hartman wrote: I have a space leak in a function that increments a number inside IORef or STRef (either lazy or strict). IORef and STRef operations do not automatically evaluate contents. writeIORef r (x + 1) simply stores a pointer to the expression (thunk) x +

Re: [Haskell-cafe] help diagnosing space leak with IORef/STRef, just incrementing a million times.

2013-01-06 Thread Christopher Done
A similar use-case and same solution with IORefs: http://hpaste.org/diff/80055/80058 Guess which one threw a stackoverflow and which one ran indefinitely when given a few hundred million lines of input. On 7 January 2013 07:35, Albert Y. C. Lai tre...@vex.net wrote: On 13-01-07 12:12 AM, Thomas

Re: [Haskell-cafe] Help optimize fannkuch program

2012-12-08 Thread Branimir Maksimovic
Here it is :http://shootout.alioth.debian.org/u64/program.php?test=fannkuchreduxlang=ghcid=4 Date: Mon, 3 Dec 2012 15:32:20 -0800 Subject: Re: [Haskell-cafe] Help optimize fannkuch program From: b...@serpentine.com To: bm...@hotmail.com CC: haskell-cafe@haskell.org On Mon, Dec 3, 2012 at 11:18

Re: [Haskell-cafe] Help optimize fannkuch program

2012-12-03 Thread Bryan O'Sullivan
On Sun, Dec 2, 2012 at 3:12 PM, Branimir Maksimovic bm...@hotmail.comwrote: Well, playing with Haskell I have literally trasnlated my c++ program http://shootout.alioth.debian.org/u64q/program.php?test=fannkuchreduxlang=gppid=3 and got decent performance but not that good in comparison with

Re: [Haskell-cafe] Help optimize fannkuch program

2012-12-03 Thread Branimir Maksimovic
mine version.Thanks ! Should I contribute your version on shootout site? Date: Mon, 3 Dec 2012 00:01:32 -0800 Subject: Re: [Haskell-cafe] Help optimize fannkuch program From: b...@serpentine.com To: bm...@hotmail.com CC: haskell-cafe@haskell.org On Sun, Dec 2, 2012 at 3:12 PM, Branimir Maksimovic bm

Re: [Haskell-cafe] Help optimize fannkuch program

2012-12-03 Thread Bryan O'Sullivan
On Mon, Dec 3, 2012 at 11:18 AM, Branimir Maksimovic bm...@hotmail.comwrote: Thanks ! Should I contribute your version on shootout site? Do whatever you like with it. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] Help: Main: thread blocked in MVar operation

2012-11-04 Thread José A. Lopes
Hey, So, I couldn't really get a small code sample. But I have a new example of the same problem. Anyway, let me just give you the overall picture. I am building an interpreter and I want to evaluate the definition of a recursive function. This entails registering the function symbol in the

Re: [Haskell-cafe] Help: Main: thread blocked in MVar operation

2012-10-23 Thread Joey Adams
On Tue, Oct 23, 2012 at 5:03 PM, José A. Lopes jose.lo...@ist.utl.pt wrote: Hey everyone, I changed my code I now I get the following error message Main: thread blocked indefinitely in an MVar operation Before the change, I was using the State monad with runState. Then, I changed the

Re: [Haskell-cafe] Help a young graduate haskeller to land its dream job

2012-09-12 Thread Eugene Kirpichov
Hi Alfredo, You might look at the various bigdata companies. I was surprised by how many of them are using Scala or Clojure - it's definitely over 50%. Looks like FP is really gaining traction in this area. On Wed, Sep 12, 2012 at 11:48 AM, Alfredo Di Napoli alfredo.dinap...@gmail.com wrote: Hi

Re: [Haskell-cafe] Help requested: naming things in conduit

2012-06-28 Thread Paolo Capriotti
On Thu, Jun 28, 2012 at 6:11 PM, Michael Snoyman mich...@snoyman.com wrote: Hi all, I'm just about ready to make the 0.5 release of conduit. And as usual, I'm running up against the hardest thing in programming: naming things. Here's the crux of the matter: in older versions of conduit,

Re: [Haskell-cafe] Help requested: naming things in conduit

2012-06-28 Thread Michael Snoyman
On Thu, Jun 28, 2012 at 8:36 PM, Paolo Capriotti p.caprio...@gmail.com wrote: On Thu, Jun 28, 2012 at 6:11 PM, Michael Snoyman mich...@snoyman.com wrote: Hi all, I'm just about ready to make the 0.5 release of conduit. And as usual, I'm running up against the hardest thing in programming:

Re: [Haskell-cafe] help with safecopy + acid-state

2012-01-31 Thread Johannes Waldmann
Can I really rename  old.T = new.T_orig ? It looks as if then tries to load the wrong acid-state snapshot. The name of your data type doesn't matter as acid-state doesn't store that on the disk. I think it does - because file names are state/T/*.log and so on? J.W.

Re: [Haskell-cafe] help with safecopy + acid-state

2012-01-31 Thread Antoine Latter
On Tue, Jan 31, 2012 at 8:27 AM, Johannes Waldmann waldm...@imn.htwk-leipzig.de wrote: Can I really rename  old.T = new.T_orig ? It looks as if then tries to load the wrong acid-state snapshot. The name of your data type doesn't matter as acid-state doesn't store that on the disk. I

Re: [Haskell-cafe] help with safecopy + acid-state

2012-01-30 Thread Johannes Waldmann
Felipe Almeida Lessa felipe.lessa at gmail.com writes: data T_orig = T_orig Foo $(deriveSafeCopy 0 'base ''T_orig) data T = T Foo Bar $(deriveSafeCopy 0 'extension ''T) instance Migrate T where type MigrateFrom T = T_Orig ... As you can read from deriveSafeCopy's documentation [1],

Re: [Haskell-cafe] help with safecopy + acid-state

2012-01-30 Thread Felipe Almeida Lessa
On Mon, Jan 30, 2012 at 4:46 PM, Johannes Waldmann waldm...@imn.htwk-leipzig.de wrote: Thanks - which zero? (there are two of them.) You should not change the deriveSafeCopy of your old data type. The only allowed change is renaming your data type (see below). You should increment the version

Re: [Haskell-cafe] help with safecopy + acid-state

2012-01-27 Thread Felipe Almeida Lessa
On Fri, Jan 27, 2012 at 3:04 PM, Johannes Waldmann waldm...@imn.htwk-leipzig.de wrote: data T_orig = T_orig Foo $(deriveSafeCopy 0 'base ''T_orig) data T = T Foo Bar $(deriveSafeCopy 0 'extension ''T) instance Migrate T where type MigrateFrom T = T_Orig ... As you can read from

Re: [Haskell-cafe] Help understanding Haskell runtime costs

2011-08-11 Thread Henning Thielemann
On 09.08.2011 01:43, Thiago Negri wrote: Hello all, I'm relatively new to Haskell and trying to solve some online judge's problems in it. One of the problems is to say if a given sentence is a tautogram or not. A tautogram is just a sentence with all the words starting with the same letter. My

Re: [Haskell-cafe] Help understanding Haskell runtime costs

2011-08-11 Thread Thiago Negri
So, thanks to Henning Thielemann I was able to make a code a little more functional. I did find ByteString module that really speed things up. I got 0.04 seconds with the following snippet: -- code start import qualified Data.ByteString.Char8 as BS import Data.Char (toLower) main :: IO () main

Re: [Haskell-cafe] Help

2011-06-27 Thread Stoyan Peev
Yes, how can i miss that... It's working now, but still it works only for the first element of the list. It prints the result only for the first string. Now when it's operational, i have just to modify it to be working for all of the elements of the list. If i run the program right now, the

Re: [Haskell-cafe] Help

2011-06-27 Thread Daniel Patterson
so think about the high level design for a second, and let that guide the types. then the types should guide the code. p, which I assume is the top level evaluation, is supposed to take a list of strings, and produce a list of integers (the result of evaluating the expression), right? So it

Re: [Haskell-cafe] Help

2011-06-27 Thread Stoyan Peev
Yeah, that really helped me :)) Finally i got the results i wanted : Main p [2*34/3,2+3,2*(6/2)] [22,5,6] There is only one more question i have about this. I have already written 2 error captures, but they don't really apply to the task i have. Here are my error captures:

Re: [Haskell-cafe] Help

2011-06-27 Thread Daniel Patterson
Well, if you are at all familiar with (or wanted to learn about) the Maybe type, I would suggest you use that. A brief synopsis: data Maybe a = Nothing | Just a Which means that a Maybe Int is either Nothing or or Just an int. If you were to got this path, then your p function should have

Re: [Haskell-cafe] Help

2011-06-25 Thread Stoyan Peev
First I am using WinHugs. that's the code i made so far but it's still not working: http://hpaste.org/48318 Error: ERROR file:.\kursovazadacha.hs:36 - Type error in explicitly typed binding *** Term : p *** Type : [String] - [a] *** Does not match : [String] - Int I'm

Re: [Haskell-cafe] Help

2011-06-25 Thread Jack Henahan
The error in ghci is Couldn't match expected type `Int' with actual type `[a0]' In the expression: [] In an equation for `p': p [] = [] You've defined p as [String] - Int, but then your base case is p [] = []. [] is not an Int. I changed it to 0 and it'll compile, at least, but I'm not

Re: [Haskell-cafe] Help

2011-06-24 Thread Daniel Patterson
What have you tried to do in order to make it work for the list, and what error results? What is confusing about the error message? More generally, how could you transform an operation on a single string into one that does the same thing to a list of strings? You've probably talked about higher

Re: [Haskell-cafe] Help

2011-06-24 Thread Stoyan Peev
I found the library myself, and i already put the code in that site: http://hpaste.org/48277 That's what i have tried to do for making the task by calling the one string function by another one: include kursovazadacha parse :: [a] - [a] parse [] = [] parse (x:xs) = eval (x:xs) The error

Re: [Haskell-cafe] Help

2011-06-24 Thread Daniel Patterson
what haskell compiler are you using? And what does the include line do? That does not look like a GHC error message (the only compiler I'm familiar with), but it seems like it is saying that you should not have the extra newlines between the function type signature and declaration. - that's

Re: [Haskell-cafe] help with dynamic load

2011-03-26 Thread Rob Nikander
On Fri, Mar 25, 2011 at 9:52 PM, Bernie Pope florbit...@gmail.com wrote: On 26 March 2011 05:57, Rob Nikander rob.nikan...@gmail.com wrote: \begin{comment} -- A work-around for Dynamics. The keys used to compare two TypeReps are -- somehow not equal for the same type in hs-plugin's loaded

Re: [Haskell-cafe] help with dynamic load

2011-03-25 Thread Bernie Pope
On 26 March 2011 05:57, Rob Nikander rob.nikan...@gmail.com wrote: I'm trying to use the 'plugins' package.  Since I already posted to stackoverflow I'll just link to that.  I posted a simple program that I thought would work, but mostly doesn't.   Any pointers, appreciated.

Re: [Haskell-cafe] Help optimising a Haskell program

2011-03-23 Thread David MacIver
On 22 March 2011 15:49, Jason Dagit dag...@gmail.com wrote: This seems to consistently give about a 0.4s improvement, which isn't nothing but isn't a particularly interesting chunck of 8s (actually it's 8.4s - 8s). Setting it to 256M doesn't make any difference. You should use criterion to

Re: [Haskell-cafe] Help optimising a Haskell program

2011-03-22 Thread David MacIver
On 22 March 2011 02:00, Jesper Louis Andersen jesper.louis.ander...@gmail.com wrote: On Tue, Mar 22, 2011 at 00:59, David MacIver da...@drmaciver.com wrote: It's for rank aggregation - taking a bunch of partial rankings of some items from users and turning them into an overall ranking (aka

Re: [Haskell-cafe] Help optimising a Haskell program

2011-03-22 Thread Jesper Louis Andersen
On Tue, Mar 22, 2011 at 09:11, David MacIver da...@drmaciver.com wrote:  Productivity  85.0% of total user, 85.0% of total elapsed That is somewhat ok. So much for hoping GC tuning would yield an improvement. -- J. ___ Haskell-Cafe mailing list

Re: [Haskell-cafe] Help optimising a Haskell program

2011-03-22 Thread Jason Dagit
On Tue, Mar 22, 2011 at 1:11 AM, David MacIver da...@drmaciver.com wrote: On 22 March 2011 02:00, Jesper Louis Andersen jesper.louis.ander...@gmail.com wrote: On Tue, Mar 22, 2011 at 00:59, David MacIver da...@drmaciver.com wrote: It's for rank aggregation - taking a bunch of partial

Re: [Haskell-cafe] Help optimising a Haskell program

2011-03-21 Thread Jesper Louis Andersen
On Tue, Mar 22, 2011 at 00:59, David MacIver da...@drmaciver.com wrote: It's for rank aggregation - taking a bunch of partial rankings of some items from users and turning them into an overall ranking (aka That thing that Hammer Principle does). Two questions immediately begs themselves: *

Re: [Haskell-cafe] Help optimising a Haskell program

2011-03-21 Thread Johan Tibell
You use a lot of (linked lists). Are they all used to represent streams or are they actually manifest during runtime? If it's the latter switch to a better data structure, like Vector. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] Help with how to concatenate with own datatypes

2011-03-11 Thread eldavido
Yeah, that works! Thanks! -- View this message in context: http://haskell.1045720.n5.nabble.com/Help-with-how-to-concatenate-with-own-datatypes-tp3424433p3425325.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. ___

Re: [Haskell-cafe] Help with how to concatenate with own datatypes

2011-03-10 Thread Antoine Latter
On Thu, Mar 10, 2011 at 7:41 PM, eldavido eldavi...@hotmail.com wrote: Hi, I´m doing a project in haskell and I need to define an operator that concatenate some own defined data types, just like the operator ++ does for lists. I don´t see how to define the operator recursively since this

Re: [Haskell-cafe] help for the usage on mfix

2011-02-23 Thread Ryan Ingram
Just write a loop: let loop gs gu | Just z - find_obj gu usyms = do ... (gs', gu') - handle_obj_ar ... loop gs' gu' | otherwise = return (gs,gu) (gs, gu) - loop def undef mfix is for when you have mutually recursive data but you want the IO operation

Re: [Haskell-cafe] Help needed for converting IOArray to ByteString

2011-02-17 Thread Henning Thielemann
On Tue, 8 Feb 2011, C K Kashyap wrote: I need to convert IOArray to bytestring as shown below -  import Data.Array.IO import Data.Binary.Put import qualified Data.ByteString.Lazy as BS import Data.Word main = do arr - newArray (0,9) 0 :: IO (IOArray Int Int) let bs=toByteString arr return ()

Re: [Haskell-cafe] Help needed for converting IOArray to ByteString

2011-02-08 Thread Michael Snoyman
Your array contains machine-sized Ints, which in practice are likely either 32-bit or 64-bit, while a ByteString is the equivalent of an array or 8-bit values. So you'll need to somehow convert the Ints to Word8s. Do you know if you need big or little endian? A basic approach would be: * Use

Re: [Haskell-cafe] Help needed for converting IOArray to ByteString

2011-02-08 Thread C K Kashyap
On Tue, Feb 8, 2011 at 2:26 PM, Michael Snoyman mich...@snoyman.com wrote: Your array contains machine-sized Ints, which in practice are likely either 32-bit or 64-bit, while a ByteString is the equivalent of an array or 8-bit values. So you'll need to somehow convert the Ints to Word8s. Do

Re: [Haskell-cafe] Help needed for converting IOArray to ByteString

2011-02-08 Thread Michael Snoyman
On Tue, Feb 8, 2011 at 11:13 AM, C K Kashyap ckkash...@gmail.com wrote: On Tue, Feb 8, 2011 at 2:26 PM, Michael Snoyman mich...@snoyman.com wrote: Your array contains machine-sized Ints, which in practice are likely either 32-bit or 64-bit, while a ByteString is the equivalent of an array

Re: [Haskell-cafe] Help needed for converting IOArray to ByteString

2011-02-08 Thread C K Kashyap
1) Just use Data.Word.Word8 instead of the second Int in your type sig for IOArray 2) Use getElems to get a [Word8] 3) Data.ByteString.pack converts a [Word8] into a ByteString Michael I am currently using a list of tuples - [(Int,Int,Int)] to represent an image buffer. You can see it in

Re: [Haskell-cafe] Help needed for converting IOArray to ByteString

2011-02-08 Thread Ketil Malde
C K Kashyap ckkash...@gmail.com writes: I am currently using a list of tuples - [(Int,Int,Int)] to represent an image buffer. [...] Looks like this is pretty slow, Unsurprisingly, as there's a huge space overhead, and (depending on usage, but probably even worse) linear access time. I

Re: [Haskell-cafe] Help needed for converting IOArray to ByteString

2011-02-08 Thread Gábor Lehel
On Tue, Feb 8, 2011 at 10:39 AM, C K Kashyap ckkash...@gmail.com wrote: 1) Just use Data.Word.Word8 instead of the second Int in your type sig for IOArray 2) Use getElems to get a [Word8] 3) Data.ByteString.pack converts a [Word8] into a ByteString Michael I am currently using a list of

Re: [Haskell-cafe] Help!! Cannot get RandT and liftIO to work together...

2010-12-23 Thread Daniel Fischer
On Thursday 23 December 2010 15:52:40, JP Moresmau wrote: Hello all, sorry I must have taken my stupid pills this morning, I cannot get the following code to compile, what am I missing? Works here. Which versions of the packages and GHC are you using?

Re: [Haskell-cafe] Help!! Cannot get RandT and liftIO to work together...

2010-12-23 Thread Daniel Fischer
On Thursday 23 December 2010 15:52:40, JP Moresmau wrote: what am I missing? Maybe I just spotted it: But the MonadRandom docs say: Instances: MonadIOhttp://hackage.haskell.org/packages/archive/transformers/0.2.2.0/doc/html/Control- Monad-IO-Class.html#t:MonadIO m links to the

Re: [Haskell-cafe] Help!! Cannot get RandT and liftIO to work together...

2010-12-23 Thread JP Moresmau
GHC 6.12.1, base 4.2.0.0, MonadRandom-0.1.6, transformers-0..2.2.0, on Windows.Could it be that my system is not picking up the MonadIO I think it does? JP On Thu, Dec 23, 2010 at 4:13 PM, Daniel Fischer daniel.is.fisc...@googlemail.com wrote: On Thursday 23 December 2010 15:52:40, JP

Re: [Haskell-cafe] Help!! Cannot get RandT and liftIO to work together...

2010-12-23 Thread Daniel Fischer
On Thursday 23 December 2010 16:21:05, JP Moresmau wrote: GHC 6.12.1, base 4.2.0.0, MonadRandom-0.1.6, transformers-0..2.2.0, on Windows. Could it be that my system is not picking up the MonadIO I think it does? Probably. With 6.12.1, you'll probably have an mtl-1.* installed, so the

Re: [Haskell-cafe] Help!! Cannot get RandT and liftIO to work together...

2010-12-23 Thread JP Moresmau
Thanks a million, it worked! Following all the dependencies sometimes is a bit of a headache. But in a sense, I'm happy to see I had understood how to use the monad transformer correctly, it wasn't me being (too) stupid. Thanks again! JP On Thu, Dec 23, 2010 at 4:32 PM, Daniel Fischer

Re: [Haskell-cafe] Help with lhs2TeX

2010-12-11 Thread Ralf Hinze
Hi Dominic, Hi, I wonder if someone could point out what I am doing wrong. My understanding was that I should be able to create a .lhs file and run it e.g. with ghci and then use lhs2TeX to create a nice .pdf file, all from the same source. I can produce nice slides but unfortunately the .lhs

Re: [Haskell-cafe] Help with lhs2TeX

2010-12-11 Thread Dominic Steintiz
the basic approach (originally) is to have an executable Haskell program so that you can typecheck it. Then you add some %format directives to make it look nice, eg. %format Mu f = \mu f %format in_ = in^\circ should do the job. Hth, Ralf It certainly does. Obvious really (as are

Re: [Haskell-cafe] Help defining a Typeable polymorphic-state monad transformer

2010-12-07 Thread Brandon Simmons
On Mon, Dec 6, 2010 at 11:53 PM, Luke Palmer lrpal...@gmail.com wrote: This has nothing to do with a monad.  This is just about data.  You want a type that can contain any Typeable type, and a safe way to cast out of that type into the type that came in.  Such a thing exists, it's called

Re: [Haskell-cafe] Help defining a Typeable polymorphic-state monad transformer

2010-12-06 Thread Luke Palmer
This has nothing to do with a monad. This is just about data. You want a type that can contain any Typeable type, and a safe way to cast out of that type into the type that came in. Such a thing exists, it's called Data.Dynamic. Then your monad is just StateT Dynamic, where your magical

Re: [Haskell-cafe] Help me TH code.

2010-10-27 Thread Serguey Zefirov
2010/10/27 Andy Stewart lazycat.mana...@gmail.com: Hi all, I want use TH write some function like below:  data DataType = StringT                | IntT                | CharT  parse :: [(String,DataType)] - (TypeA, TypeB, ... TypeN) Example:  parse [(string, StringT), (001, IntT), (c,

Re: [Haskell-cafe] Help me TH code.

2010-10-27 Thread Andy Stewart
Serguey Zefirov sergu...@gmail.com writes: 2010/10/27 Andy Stewart lazycat.mana...@gmail.com: Hi all, I want use TH write some function like below:  data DataType = StringT                | IntT                | CharT  parse :: [(String,DataType)] - (TypeA, TypeB, ... TypeN) Example:

Re: [Haskell-cafe] Help me TH code.

2010-10-27 Thread Jonas Almström Duregård
Unless you have a 'real' type for parse sometime during compile time, TH won't be able to generate it. A good rule of thumbs is that if you can't write the code yourself, then you can't get TH to do it either. /J On 27 October 2010 08:50, Andy Stewart lazycat.mana...@gmail.com wrote: Serguey

Re: [Haskell-cafe] Help me TH code.

2010-10-27 Thread Serguey Zefirov
2010/10/27 Andy Stewart lazycat.mana...@gmail.com: Serguey Zefirov sergu...@gmail.com writes: I think that you should use TH properly, without compiler and logical errors. What actually do you want? I'm build multi-processes communication program. You don't need TH here, I think. You can

Re: [Haskell-cafe] HELP

2010-10-21 Thread Brian Troutwine
I'm not sure what you're asking for; it looks like you have to implement the functions from the specifications. On Thu, Oct 21, 2010 at 6:11 PM, Yaadallah Khan yk...@hotmail.com wrote: I am Studying for an exam, and i have just come accross the following 3 questions, i am not familiar with the

Re: [Haskell-cafe] Help to create a function to calculate a n element moving average ??

2010-09-29 Thread Henning Thielemann
S. Doaitse Swierstra schrieb: Avoiding repeated additions: movingAverage :: Int - [Float] - [Float] movingAverage n l = runSums (sum . take n $l) l (drop n l) where n' = fromIntegral n runSums sum (h:hs) (t:ts) = sum / n' : runSums (sum-h+t) hs ts runSums _

Re: [Haskell-cafe] Help to create a function to calculate a n element moving average ??

2010-09-29 Thread S. Doaitse Swierstra
On 29 sep 2010, at 00:58, o...@cs.otago.ac.nz wrote: Avoiding repeated additions: movingAverage :: Int - [Float] - [Float] movingAverage n l = runSums (sum . take n $l) l (drop n l) where n' = fromIntegral n runSums sum (h:hs) (t:ts) = sum / n' : runSums (sum-h+t) hs ts

Re: [Haskell-cafe] Help to create a function to calculate a n element moving average ??

2010-09-28 Thread S. Doaitse Swierstra
Avoiding repeated additions: movingAverage :: Int - [Float] - [Float] movingAverage n l = runSums (sum . take n $l) l (drop n l) where n' = fromIntegral n runSums sum (h:hs) (t:ts) = sum / n' : runSums (sum-h+t) hs ts runSums _ _ [] = [] Doaitse On 28

Re: [Haskell-cafe] Help to create a function to calculate a n element moving average ??

2010-09-27 Thread Richard O'Keefe
On 27/09/2010, at 5:20 AM, rgowka1 wrote: Type signature would be Int - [Double] - [(Double,Double)] Any thoughts or ideas on how to calculate a n-element moving average of a list of Doubles? Let's say [1..10]::[Double] what is the function to calculate the average of the 3 elements?

Re: [Haskell-cafe] Help to create a function to calculate a n element moving average ??

2010-09-26 Thread Serguey Zefirov
2010/9/26 rgowka1 rgow...@gmail.com: Type signature would be Int - [Double] - [(Double,Double)] Any thoughts or ideas on how to calculate a n-element moving average of a list of Doubles? Let's say [1..10]::[Double] what is the function to calculate the average of the 3 elements?

Re: [Haskell-cafe] help me evangelize haskell.

2010-09-07 Thread C K Kashyap
Hi Dan, This presentation is really nice. I went over it a couple of times and I think this ppt will help me try to use Haskell for things that I usually use Perl for :) A quick question - import Process bombs on my GHCI(The Glorious Glasgow Haskell Compilation System, version 6.12.3) -what do I

Re: [Haskell-cafe] help me evangelize haskell.

2010-09-07 Thread Don Stewart
That's a separate module, based on System.Process -- http://code.haskell.org/~dons/code/cpuperf/Process.hs ckkashyap: Hi Dan, This presentation is really nice. I went over it a couple of times and I think this ppt will help me try to use Haskell for things that I usually use Perl for :)

Re: [Haskell-cafe] help me evangelize haskell.

2010-09-07 Thread C K Kashyap
Thanks Don! On Tue, Sep 7, 2010 at 10:51 PM, Don Stewart d...@galois.com wrote: That's a separate module, based on System.Process --    http://code.haskell.org/~dons/code/cpuperf/Process.hs ckkashyap: Hi Dan, This presentation is really nice. I went over it a couple of times and I think

Re: [Haskell-cafe] help me evangelize haskell.

2010-09-06 Thread Stephen Tetley
On 6 September 2010 03:46, Mathew de Detrich dete...@gmail.com wrote: If they are perl programmers, they (should) understand perl very well. I would suggest to try explaining to them the obvious disadvantages of perl and the way that Haskell can cover those disadvantages without (much) of a

Re: [Haskell-cafe] help me evangelize haskell.

2010-09-06 Thread Mathew de Detrich
I Think you misinterpreted what I said. I didn't say you should tell the programmers how to code, I said you should show the perl coders how Haskell has advantages over pearls without much cost On 06/09/2010 5:21 PM, Stephen Tetley stephen.tet...@gmail.com wrote: On 6 September 2010 03:46,

Re: [Haskell-cafe] help me evangelize haskell.

2010-09-06 Thread edgar klerks
Hi All, Not a complete guide, but just something, which can help: Perl6 is inspired by haskell. That was, how I end up by haskell. And I believe a lot of people of the perl community got interested in haskell that way. Maybe this works for some of collegues too. I still like perl, but haskell is

Re: [Haskell-cafe] help me evangelize haskell.

2010-09-05 Thread Ben Lippmeier
On 05/09/2010, at 2:38 AM, Michael Litchard wrote: I'll be starting a new job soon as systems tool guy. The shop is a perl shop as far as internal automation tasks go. But I am fortunate to not be working with bigots. If they see a better way, they'll take to it. So please give me your best

Re: [Haskell-cafe] help me evangelize haskell.

2010-09-05 Thread Chris Eidhof
On 5 sep 2010, at 09:28, Ben Lippmeier wrote: On 05/09/2010, at 2:38 AM, Michael Litchard wrote: I'll be starting a new job soon as systems tool guy. The shop is a perl shop as far as internal automation tasks go. But I am fortunate to not be working with bigots. If they see a better way,

Re: [Haskell-cafe] help me evangelize haskell.

2010-09-05 Thread Donn Cave
Quoth Ben Lippmeier b...@ouroborus.net, ... Grandiose, hand-wavy assertions like strong typing leads to shorter development times and more reliable software don't work on people that haven't already been there and done that. When you try to ram something down someone's throat they tend to

Re: [Haskell-cafe] help me evangelize haskell.

2010-09-05 Thread Don Stewart
Gaius: My usual rhetoric is that one-off, throwaway scripts never are, and not only do they tend to stay around but they take on a life of their own. Today's 10-line file munger is tomorrow's thousand-line ETL batch job on which the business depends for some crucial data - yet the original

Re: [Haskell-cafe] help me evangelize haskell.

2010-09-05 Thread Andrew Coppin
Michael Litchard wrote: I'll be starting a new job soon as systems tool guy. The shop is a perl shop as far as internal automation tasks go. But I am fortunate to not be working with bigots. If they see a better way, they'll take to it. So please give me your best arguments in favor of using

Re: [Haskell-cafe] help me evangelize haskell.

2010-09-05 Thread Mathew de Detrich
If they are perl programmers, they (should) understand perl very well. I would suggest to try explaining to them the obvious disadvantages of perl and the way that Haskell can cover those disadvantages without (much) of a compromise. Perl programs are either ones that are ridiculously

Re: [Haskell-cafe] help me evangelize haskell.

2010-09-05 Thread Alexander Solla
On Sep 5, 2010, at 7:46 PM, Mathew de Detrich wrote: Another thing you can say is that Perl is a very extreme language in design where as Haskell is more general. This means the one thing Perl does, it does very well (expressing programming problems in the most concise/short possible way)

Re: [Haskell-cafe] help me evangelize haskell.

2010-09-04 Thread Vo Minh Thu
2010/9/4 Michael Litchard mich...@schmong.org: I'll be starting a new job soon as systems tool guy. The shop is a perl shop as far as internal automation tasks go. But I am fortunate to not be working with bigots. If they see a better way, they'll take to it. So please give me your best

Re: [Haskell-cafe] help me evangelize haskell.

2010-09-04 Thread Gaius Hammond
My usual rhetoric is that one-off, throwaway scripts never are, and not only do they tend to stay around but they take on a life of their own. Today's 10-line file munger is tomorrow's thousand-line ETL batch job on which the business depends for some crucial data - yet the original author is

Re: [Haskell-cafe] help me evangelize haskell.

2010-09-04 Thread Michael Litchard
I will be going into a situation where there are tasks that have yet to be automated, so I will be going after that before re-writing anything. But if I can come up with here's why, there will be less eyebrows raised. Thanks for all feedback so far. On Sat, Sep 4, 2010 at 10:21 AM, Gaius Hammond

Re: [Haskell-cafe] help me evangelize haskell.

2010-09-04 Thread Jason Dagit
On Sat, Sep 4, 2010 at 5:53 PM, Michael Litchard mich...@schmong.org wrote: I will be going into a situation where there are tasks that have yet to be automated, so I will be going after that before re-writing anything. But if I can come up with here's why, there will be less eyebrows raised.

Re: [Haskell-cafe] Help with Bird problem 1.4.1

2010-05-18 Thread Daniel Fischer
On Tuesday 18 May 2010 21:49:50, R J wrote: Newbie trying to get through Bird. Could someone provide a clean solution, with proof (so I can see how these proofs are laid out), to this: Given: f :: Integer - Integer g :: Integer - (Integer - Integer) h :: ... h x y = f (g x y) Questions:

Re: [Haskell-cafe] Help debugging code broken after upgrading debian to GHC 6.12: invalid argument

2010-05-15 Thread Daniel Fischer
On Saturday 15 May 2010 15:18:28, Brandon Simmons wrote: On May 14, 2010, at 20:24 , Brandon Simmons wrote: The other baffling thing is this: if the debugging line 426 is uncommented, then even running: $ runghc Befunge.hs --quiet mycology.b98 ...will fail. But all we're doing is a

Re: [Haskell-cafe] Help debugging code broken after upgrading debian to GHC 6.12: invalid argument

2010-05-14 Thread Brandon S. Allbery KF8NH
On May 14, 2010, at 20:24 , Brandon Simmons wrote: The other baffling thing is this: if the debugging line 426 is uncommented, then even running: $ runghc Befunge.hs --quiet mycology.b98 ...will fail. But all we're doing is a call to `putStr`! Why would that trigger an error?! Maybe there

Re: [Haskell-cafe] Help debugging code broken after upgrading debian to GHC 6.12: invalid argument

2010-05-14 Thread Daniel Fischer
On Saturday 15 May 2010 02:53:43, Brandon S. Allbery KF8NH wrote: On May 14, 2010, at 20:24 , Brandon Simmons wrote: The other baffling thing is this: if the debugging line 426 is uncommented, then even running: $ runghc Befunge.hs --quiet mycology.b98 ...will fail. But all we're

Re: [Haskell-cafe] help with Haskell programming

2010-04-18 Thread Thomas Davie
I'm not certain exactly what you mean, but I *think* you mean: func :: (a - Bool) - (a - Bool) func = (not .) Bob On 18 Apr 2010, at 16:35, Mujtaba Boori wrote: Hello I am kinda newbie in Haskell you can help help me with some programming I am trying to make function like for example

Re: [Haskell-cafe] help with Haskell programming

2010-04-18 Thread Keith Sheppard
Hello Mujtaba, I wonder is this homework? If that's the case there is nothing wrong with asking homework related questions but they should probably be marked as such. I think the most straight forward solution will use function composition (.) and the (not) function -keith On Sun, Apr 18, 2010

Re: [Haskell-cafe] Help mixing pure and IO code

2009-11-30 Thread Eric Dedieu
There's a nice approach to this problem which is described and implemented in the MonadPrompt package[1]. Thanks a lot for this link. The guessing game example linked to from the documentation is still very hard to understand (I'm still struggling with monads), but it seems to fill my needs.

Re: [Haskell-cafe] Help mixing pure and IO code

2009-11-30 Thread klondike
Eric Dedieu escribió: Still more importantly to me, I understand that anyhow if I intend to use IO or random numbers, I must design my strategy from the beginning as encapsulated in a monad. Something like: class (Monad m) = Strategy m a where ... That's not true at all, you can always

Re: [Haskell-cafe] Help mixing pure and IO code

2009-11-30 Thread Eric Dedieu
Still more importantly to me, I understand that anyhow if I intend to use IO or random numbers, I must design my strategy from the beginning as encapsulated in a monad. Something like: class (Monad m) = Strategy m a where ... That's not true at all, you can always pass this data

Re: [Haskell-cafe] Help mixing pure and IO code

2009-11-30 Thread Hector Guilarte
One time I needed to do use a random number in some places of a completly pure program so I made a infinite list of random numbers and passed it around all the time in the functions as they where called, using the head of the list I passed to the function whenever I needed a random number and

  1   2   3   >