Re: [Haskell-cafe] same function's type accepted in top level, but rejected in where clause

2013-07-08 Thread Chaddaï Fouché
On Fri, Jul 5, 2013 at 11:03 PM, Ömer Sinan Ağacan omeraga...@gmail.comwrote: There's an implicit quantifier in type of `f`, like this: `f :: forall a. a - ListF a a`. When I add `ScopedTypeVariables` and `forall a. ...` in top level definition, it's like all `a`s in scope of top level

Re: [Haskell-cafe] ln, e

2013-01-05 Thread Chaddaï Fouché
log and (exp 1) are the natural logarithm and e. -- Jedaï On Sun, Jan 6, 2013 at 2:03 AM, Christopher Howard christopher.how...@frigidcode.com wrote: Hi. Are natural log and Euler's constant defined somewhere in base, or a convenience math module somewhere? I'm having trouble finding them with

Re: [Haskell-cafe] Substituting values

2012-12-26 Thread Chaddaï Fouché
Since recently, the notion of prisms from the lens library can achieve that : to modify a value only in certain conditions but you have to write the prism so it's not that convenient, though at least you'll have an uniform API. See

Re: [Haskell-cafe] Segment Tree based Set

2012-10-29 Thread Chaddaï Fouché
On Mon, Oct 29, 2012 at 9:43 AM, Tony Morris tonymor...@gmail.com wrote: It is not a Set, but a Map. Of course, I could use it to implement the function I need with something like: type SSet a = STree [()] a, but then I'd have to unnecessarily go beyond Haskell98. Couldn't you just use :

Re: [Haskell-cafe] A clarification about what happens under the hood with foldMap

2012-10-23 Thread Chaddaï Fouché
Le 23 oct. 2012 09:54, Alfredo Di Napoli alfredo.dinap...@gmail.com a écrit : What this code does is straighforward. I was struck from the following sentences in LYAH: Notice that we didn't have to provide the function that takes a value and returns a monoid value. We receive that function as

Re: [Haskell-cafe] A clarification about what happens under the hood with foldMap

2012-10-23 Thread Chaddaï Fouché
On Tue, Oct 23, 2012 at 10:36 AM, Alfredo Di Napoli alfredo.dinap...@gmail.com wrote: I'm sure I'm missing a point, but the minimum definition for a Foldable instance is given in terms of foldMap, so I get the cake for free, foldr included, right? In the example I have defined my treeSum as:

Re: [Haskell-cafe] Interleaving type variables in a tree, has this a name ?

2012-10-13 Thread Chaddaï Fouché
On Sat, Oct 13, 2012 at 11:25 PM, Eric Dedieu papa.e...@free.fr wrote: Hi Haskell Helpers, For a hobby projet to learn haskell, I'm trying to use this kind of interleaved tree structure (simplified): data ANode a b = ANode a [BNode a b] [BNode a b] data BNode a b = BNode b [ANode a b]

Re: [Haskell-cafe] Ordering of BigFloats in numbers-3000.0.0.0

2012-10-09 Thread Chaddaï Fouché
On Sun, Oct 7, 2012 at 8:00 PM, Michael Orlitzky mich...@orlitzky.com wrote: I'm trying to use, http://hackage.haskell.org/package/numbers-3000.0.0.0 to get better precision for free out of some numerical code. I ran into an issue pretty quickly, though. In Data.Number.BigFloat, we have,

Re: [Haskell-cafe] Creating Repa arrays from unboxed vectors

2012-10-04 Thread Chaddaï Fouché
On Thu, Oct 4, 2012 at 1:58 PM, Janek S. fremenz...@poczta.onet.pl wrote: Thanks! This makes it look like you've got two versions of vector installed, This is true, I have vector-0.9.1 and vector-0.10, but with Repa built against the version that _isn't_ 0.9.1. No, no, Repa is build against

Re: [Haskell-cafe] foldl vs. foldr

2012-09-18 Thread Chaddaï Fouché
18.09.2012, 16:32, Jan Stolarek jan.stola...@p.lodz.pl: Hi list, I have yet another question about folds. Reading here and there I encountered statements that foldr is more important than foldl, e.g. in this post on the list:

Re: [Haskell-cafe] how to check thunk

2012-07-02 Thread Chaddaï Fouché
On Mon, Jul 2, 2012 at 7:54 AM, Kazu Yamamoto k...@iij.ad.jp wrote: Hello, vacuum allow that and much more though I don't know if it still works correctly on GHC 7.4. Anyway your isThunk is isThunk a = fmap GHC.Vacuum.ClosureType.isThunk GHC.Vacuum.closureType Great. I confirmed that this

Re: [Haskell-cafe] package to expand TH macros?

2012-07-01 Thread Chaddaï Fouché
On Sun, Jul 1, 2012 at 8:11 PM, Brandon Allbery allber...@gmail.com wrote: On Sun, Jul 1, 2012 at 1:56 PM, Eric devnull1...@yahoo.com wrote: I seem to remember finding a package a few days ago that would take Haskell source with TH, then run and expand the TH macros in-place to produce

Re: [Haskell-cafe] how to check thunk

2012-07-01 Thread Chaddaï Fouché
On Mon, Jul 2, 2012 at 5:29 AM, Kazu Yamamoto k...@iij.ad.jp wrote: Hello, Are there any ways to see if a value is a thunk or memorized? I would like to have a function like: isThunk :: a - IO Bool vacuum allow that and much more though I don't know if it still works correctly on GHC 7.4.

Re: [Haskell-cafe] Understanding GC time

2012-03-10 Thread Chaddaï Fouché
On Sat, Mar 10, 2012 at 4:21 PM, Thiago Negri evoh...@gmail.com wrote: c:\tmp\hspar +RTS -s -N1 par +RTS -s -N1 2000     803,186,152 bytes allocated in the heap     859,916,960 bytes copied during GC     233,465,740 bytes maximum residency (10 sample(s))      30,065,860 bytes maximum

Re: [Haskell-cafe] named pipe interface

2012-01-13 Thread Chaddaï Fouché
On Thu, Jan 12, 2012 at 7:53 PM, Serge D. Mechveliani mech...@botik.ru wrote: People, (I wonder: is this for  beginn...@haskell.org ?) I don't think so. I need to organize a  string interface  for a Haskell function Main.axiom  and a C program                            fifoFromA.c via

Re: [Haskell-cafe] lists of arbitrary depth

2010-07-14 Thread Chaddaï Fouché
On Tue, Jul 13, 2010 at 11:28 AM, Shlomi Vaknin shlomivak...@gmail.com wrote: Thank you Bob, your example clarified how actually using such data type would appear in haskell. I naively thought it would be as simple as defining a regular list, but i see it is slightly more strict than that. I

Re: [Haskell-cafe] Wire GUI

2010-06-03 Thread Chaddaï Fouché
On Wed, Jun 2, 2010 at 5:29 PM, Andrew Coppin andrewcop...@btinternet.com wrote: Thanks to the people who replied about this. I would also like to thank my ISP for classifying the entire lot as spam and not showing it to me. *sigh* Blobs sounds interesting, but seems to require wxHaskell

Re: [Haskell-cafe] Strange random choice algorithm

2010-01-31 Thread Chaddaï Fouché
On Sat, Jan 30, 2010 at 9:38 PM, Daniel Fischer daniel.is.fisc...@web.de wrote: Also, is there a more direct way of printing an array? Sure, printing immutable arrays: print arr ~ array (lo,hi) [(lo,arr!lo), ... , (hi,arr!hi)] print (assocs arr) ~ [(lo,arr!lo), ... , (hi,arr!hi)] print

Re: [Haskell-cafe] Having a look at XMonad window manager

2010-01-19 Thread Chaddaï Fouché
On Mon, Jan 18, 2010 at 11:53 PM, John Millikin jmilli...@gmail.com wrote: I've been quite happy with Ubuntu's xmonad package, though I run it within a GNOME session. Have you tried the instructions on the XMonad wiki for inter-operating with GNOME?

Re: [Haskell-cafe] pointfree-trouble

2009-12-22 Thread Chaddaï Fouché
On Tue, Dec 22, 2009 at 3:09 PM, slemi 0sle...@gmail.com wrote: this works fine, but if i leave the 'a' in the last function's definition like this: reMatr = Matr . (flip (.) unMatr) The correct point free version would be : reMatr = (Matr .) . (. unMatr) -- Jedaï

Re: [Haskell-cafe] How can i set the seed random number generator ?

2009-12-22 Thread Chaddaï Fouché
On Tue, Dec 22, 2009 at 1:16 PM, Scott Turner 1hask...@pkturner.org wrote: In haskell, i just use the following function to get the random number. It seems i donot need to set the seed of random number generator manually? rollDice ::  Int - IO Int rollDice n = randomRIO(1,n) That's correct.

Re: [Haskell-cafe] Haskell-Newbie and Char-Function

2009-12-06 Thread Chaddaï Fouché
On Sat, Dec 5, 2009 at 10:02 PM, ??? ?? m...@rkit.pp.ru wrote: fct a n = (snd $ break (==a) ['a'..'z']) !! n Not bad but you forgot that it might need to wrap around, besides break isn't really the best function to use here since we don't need the first part of the pair : shift n ch =

Re: [Haskell-cafe] Haskell-Newbie and Char-Function

2009-12-05 Thread Chaddaï Fouché
On Sat, Dec 5, 2009 at 4:48 PM, Jochem Berndsen joc...@functor.nl wrote: MeAdAstra wrote: Hi guys, I only started learning Haskell some days ago. Maybe one of you can give me a hint on how to implement a function that needs a character in the range (a,b,...z) and an integer number k and

Re: [Haskell-cafe] Area from [(x,y)] using foldl

2009-11-09 Thread Chaddaï Fouché
On Sun, Nov 8, 2009 at 10:30 PM, michael rice nowg...@yahoo.com wrote: This doesn't. area :: [(Double,Double)] - Double area p = abs $ (/2) $ area' (last p):p where area' [] = 0 area' ((x0,y0),(x,y):ps) = ((x0-x)*(y0+y)) + area' (x,y):ps This function is almost

Re: [Haskell-cafe] Area from [(x,y)] using foldl

2009-11-08 Thread Chaddaï Fouché
On Sun, Nov 8, 2009 at 9:04 PM, michael rice nowg...@yahoo.com wrote: Of course! Back to the drawing board. If I understand the problem correctly, I'm not convinced that foldl is the right approach (nevermind that foldl is almost never what you want, foldl' and foldr being the correct choice

Re: [Haskell-cafe] help with Haskell performance

2009-11-07 Thread Chaddaï Fouché
2009/11/7 Eugene Kirpichov ekirpic...@gmail.com: Ah, you're right. Then we need a foldl' insertWith with a strict plus. We only need a foldl' insertWith' : (+) is already strict for all the numeric types in the Prelude. -- Jedaï ___ Haskell-Cafe

Re: [Haskell-cafe] AND/OR Perceptron

2009-10-31 Thread Chaddaï Fouché
On Sat, Oct 31, 2009 at 8:09 PM, Ryan Ingram ryani.s...@gmail.com wrote: where is just syntactic sugar for let...in That's not perfectly true : where and let...in don't attach to the same syntactic construction, where attaches to a definition and can works for several guard clauses whereas let

Re: [Haskell-cafe] How come pattern match does not recognize this code style?

2009-10-26 Thread Chaddaï Fouché
On Mon, Oct 26, 2009 at 6:08 AM, Magicloud Magiclouds magicloud.magiclo...@gmail.com wrote: Ah, I see. The reason I have to use my style is the same as others: the list is too long You don't have to put everything on the same line, you just have to indent the rest of the pattern a bit more

Re: [Haskell-cafe] Need feedback on my Haskell code

2009-07-31 Thread Chaddaï Fouché
On Fri, Jul 31, 2009 at 2:12 PM, CK Kashyapck_kash...@yahoo.com wrote: I personally find map maySwitch (unfoldr go (x1,y1,0)) and map maySwitch $ unfoldr go (x1,y1,0) more intuitive. I can read it as map the maySwitch function over the list generated from the unfolding. Is there any

Re: [Haskell-cafe] Need feedback on my Haskell code

2009-07-28 Thread Chaddaï Fouché
On Tue, Jul 28, 2009 at 3:04 PM, CK Kashyapck_kash...@yahoo.com wrote: Hi Everyone, I managed to write up the line drawing function using the following links - http://www.cs.helsinki.fi/group/goa/mallinnus/lines/bresenh.html http://rosettacode.org/wiki/Bresenham%27s_line_algorithm#Haskell I

Re: [Haskell-cafe] Are GADTs what I need?

2009-07-13 Thread Chaddaï Fouché
On Mon, Jul 13, 2009 at 12:41 PM, Kev Mahoneymaill...@kevinmahoney.co.uk wrote: So far, I've learnt you can do this: data Value where VInt :: Integer - Value ... VWrapper :: a - Value which can let you encode arbitrary 'dynamic' types into Value. I was hoping to be able to pattern match

Re: [Haskell-cafe] Using Parsec with ByteString ?

2009-06-19 Thread Chaddaï Fouché
On Fri, Jun 19, 2009 at 1:51 PM, Fernandquarantedeu...@yahoo.fr wrote: but the parser one needs to write must parse ByteStrings instead of Strings (that is, something like having a Parsec Bytestring () type, unless I'm completely misunderstanding the situation). My problem is that I do not

Re: [Haskell-cafe] Re: curious about sum

2009-06-18 Thread Chaddaï Fouché
On Thu, Jun 18, 2009 at 6:38 PM, Alberto G. Coronaagocor...@gmail.com wrote: My question is: Why the process does not grow also in the lazy case and instead produces a stack overflow inmediately? This question is answered in detail on the Wiki

Re: [Haskell-cafe] force evaluation beginners question

2009-06-15 Thread Chaddaï Fouché
On Mon, Jun 15, 2009 at 6:46 PM, Nico Rollenro...@web.de wrote: Hi there I'm trying to compile a code snipped that i've go from a tutorial which uses the function force. But when I'm trying to compile it ghc reports an error that it couldn't find the defenition of force. my ghc verion is

Re: [Haskell-cafe] A small puzzle: inTwain as function of foldr

2009-06-04 Thread Chaddaï Fouché
On Thu, Jun 4, 2009 at 4:22 PM, Martijn van Steenbergen mart...@van.steenbergen.nl wrote: Bonjour café, A small puzzle: Consider the function inTwain that splits a list of even length evenly into two sublists: inTwain Hello world! (Hello ,world!) Is it possible to implement inTwain such

Re: [Haskell-cafe] How to use Data.ByteString ?

2009-05-19 Thread Chaddaï Fouché
On Tue, May 19, 2009 at 8:46 AM, Brandon S. Allbery KF8NH allb...@ece.cmu.edu wrote: On May 19, 2009, at 01:42 , Jason Dagit wrote: I've often seen this bit of scary code in VB: Dim i as Integer = 5 If i = 5 Then  ' Do something, because 5 = 5 End If Sure, that works in Perl too. That's

Re: [Haskell-cafe] Re: ANN: diagrams 0.2

2009-02-06 Thread Chaddaï Fouché
On Wed, Feb 4, 2009 at 4:56 PM, Gwern Branwen gwe...@gmail.com wrote: Now, to implement it, I would probably say to myself, well, we'll create a temporary file, we'll write some basic imports into it, then we'll write the user's expression into it as the definition of a function 'foo', and

Re: Re[2]: [Haskell-cafe] Climbing up the shootout...

2008-09-22 Thread Chaddaï Fouché
2008/9/23 Bulat Ziganshin [EMAIL PROTECTED]: http://haskell.org/haskellwiki/Wc seems to do fine; you'll notice it drops lines after the first version. actually it counts lines using built-in function. you may find that naive C is 6x fatser than naive Haskell and difference is so small only

Re: Re[2]: [Haskell-cafe] Climbing up the shootout...

2008-09-22 Thread Chaddaï Fouché
2008/9/23 Bulat Ziganshin [EMAIL PROTECTED]: Hello Don, Tuesday, September 23, 2008, 4:22:19 AM, you wrote: bulat.ziganshin: when gcc developers will start to add to C libraries functions performing shootout benchmarks we will continue this discussion :D atoi(3). it isn't the same as

Re: [Haskell-cafe] How to check if two Haskell files are the same?

2008-09-17 Thread Chaddaï Fouché
2008/9/16 Mauricio [EMAIL PROTECTED]: Hi, I would like to write a Haskell pretty-printer, using standard libraries for that. How can I check if the original and the pretty-printed versions are the same? For instance, is there a file generated by GHC at the compilation pipe that is always

Re: [Haskell-cafe] Haskell Weekly News: Issue 85 - September 13, 2008

2008-09-14 Thread Chaddaï Fouché
2008/9/14 Rafael Almeida [EMAIL PROTECTED]: One thing have always bugged me: how do you prove that you have correctly proven something? I mean, when I write a code I'm formaly stating what I want to happen and bugs happen. If I try to prove some part of the code I write more formal text

Re: [Haskell-cafe] Haskell as a scripting language.

2008-09-11 Thread Chaddaï Fouché
2008/9/10 David F. Place [EMAIL PROTECTED]: Hi, All. I needed to make a batch of edits to some input files after a big change in my program. Normally, one would choose some scripting language, but I can't bear to program in them. The nasty thing about using Haskell is that giving regexes

Re: [Haskell-cafe] monadic map on a Data.IntMap

2008-09-08 Thread Chaddaï Fouché
2008/9/8 minh thu [EMAIL PROTECTED]: Hi, Is there something like a fmapM_ ? In particular, I'd like to mapM_ a Data.IntMap instead of a List The Traversable class (from Data.Traversable) includes a mapM function. Unfortunately Data.IntMap don't provide an instance for IntMap (though Data.Map

Re: [Haskell-cafe] whatever happened to sendFile?

2008-08-13 Thread Chaddaï Fouché
2008/8/13 Jason Dusek [EMAIL PROTECTED]: I found an old lib for it: http://www.haskell.org/ghc/docs/6.0/html/unix/System.Sendfile.html Hoogle turns up nothing, though. That don't sound very useful... Maybe when we only had String it was much more performant for big transfert, but now

Re: [Haskell-cafe] whatever happened to sendFile?

2008-08-13 Thread Chaddaï Fouché
2008/8/13 Brandon S. Allbery KF8NH [EMAIL PROTECTED]: I should clarify: what sendfile() is supposed to optimize isn't writing large strings, or even the user-kernel roundtrips; it's an optimization to the kernel network stack (network buffer management, to be specific). Web servers use it

Re: [Haskell-cafe] a really dumb posting question ;^(

2008-08-01 Thread Chaddaï Fouché
2008/7/31 Galchin, Vasili [EMAIL PROTECTED]: Hello, What do I do to do a followup haskell cafe posting? E.g. I want to put a posting on the category theory thread! You respond to it. Sometimes it is not sufficient (haskell-cafe@haskell.org isn't in the to or cc field), then you probably

Re: [Haskell-cafe] Libevent FFI problems

2008-07-25 Thread Chaddaï Fouché
2008/7/25 Levi Greenspan [EMAIL PROTECTED]: Regarding your remark, that the RTS multiplexes IO already I am usure how this works out in practice. The reason I write this wrapper is that I want a network server which can handle thousands of connections. And to not require a permanent thread for

Re: [Haskell-cafe] Newbie: Replacing substring?

2008-07-23 Thread Chaddaï Fouché
2008/7/22 Ronald Guida [EMAIL PROTECTED]: 2008/7/22 Dmitri O.Kondratiev [EMAIL PROTECTED]: On the side: The more I use Haskell - the more I like it ! It helps me think about the problem I solve much more clearly then when I use imperative language. If I want to replace a substring in a

Re: [Haskell-cafe] Re: Optimizing 'sequence'

2008-07-22 Thread Chaddaï Fouché
2008/7/22 Luke Palmer [EMAIL PROTECTED]: A little formal reasoning reveals that sequence1 = sequence2 exactly when (=) is strict in its left argument. There are four common monads which are _not_: Identity, Reader, Writer, State (and RWS by extension). Still if that makes that much of a

Re: [Haskell-cafe] Trouble with non-exhaustive patterns

2008-07-21 Thread Chaddaï Fouché
2008/7/21 Fernando Rodriguez [EMAIL PROTECTED]: Suddenly, the function stoped working with a rather cryptic (for a newbie at least) error message: *Temp final [4,5] interactive:1:9: No instance for (Num [a]) arising from the literal `5' at interactive:1:9 Possible fix: add an

Re: [Haskell-cafe] Re: Help using Network.Curl

2008-07-21 Thread Chaddaï Fouché
2008/7/19 Jim Burton [EMAIL PROTECTED]: opts = [CurlEncoding text/xml , CurlHttpHeaders [X-EBAY-API-COMPATIBILITY-LEVEL=++compatLevel , X-EBAY-API-DEV-NAME=++devName , X-EBAY-API-APP-NAME=++appName ,

Re: [Haskell-cafe] ansi2html - one program, several issues

2008-07-19 Thread Chaddaï Fouché
2008/7/19 Krzysztof Skrzętnicki [EMAIL PROTECTED]: Hi all 1) Profiling shows that very simple functions are source of great memory and time consumption. However, if I turn them off and simply print their input arguments instead, the overall time and memory consumption doesn't change. But now

Re: [Haskell-cafe] ansi2html - one program, several issues

2008-07-19 Thread Chaddaï Fouché
2008/7/19 Krzysztof Skrzętnicki [EMAIL PROTECTED]: I forgot to mention that the memory consumption is several times higher than file size. On 8,3 Mb file: 532 MB total memory in use (4 MB lost due to fragmentation). Having that 8 Mb in memory is not the problem. 532 Mb is another story. In

Re: Re[2]: [Haskell-cafe] ansi2html - one program, several issues

2008-07-19 Thread Chaddaï Fouché
2008/7/20 Krzysztof Skrzętnicki [EMAIL PROTECTED]: On Sun, Jul 20, 2008 at 12:34 AM, Bulat Ziganshin [EMAIL PROTECTED] wrote: Hello Krzysztof, Sunday, July 20, 2008, 1:55:45 AM, you wrote: 532 MB total memory in use (4 MB lost due to fragmentation). i think that Parsec library should

Re: [Haskell-cafe] Profiling nested case

2008-07-18 Thread Chaddaï Fouché
2008/7/12 Mitar [EMAIL PROTECTED]: So that I can easily change the type everywhere. But it would be much nicer to write: data Quaternion a = Q !a !a !a !a deriving (Eq,Show) Only the performance of Num instance functions of Quaternion is then quite worse. You can probably use a

Re: [Haskell-cafe] Newbie: Appending arrays?

2008-07-11 Thread Chaddaï Fouché
2008/7/11 Dmitri O.Kondratiev [EMAIL PROTECTED]: I don't quite understand how Data.Array.Diff work. I tried this: let arr = listArray (1,3) [1..3] :: DiffArray Int Int then: replaceDiffArray arr [(1, 777)] array (1,3) [(1,1),(2,777),(3,3)] Why when replacing first element the second one

Re: [Haskell-cafe] Newbie: Appending arrays?

2008-07-11 Thread Chaddaï Fouché
2008/7/11 Dmitri O.Kondratiev [EMAIL PROTECTED]: How does Data.Sequence http://www.haskell.org/ghc/docs/latest/html/libraries/containers/Data-Sequence.html compares with ArrayRef for appending and accessing arrays efficiently ? It doesn't since Data.Sequence doesn't use arrays, it uses a

Re: [Haskell-cafe] Help with generalizing function

2008-06-25 Thread Chaddaï Fouché
2008/6/25 leledumbo [EMAIL PROTECTED]: Hi, I'm back. I have some troubles understanding your code: ( 1:1:? is never reached. ) Why would 1:1 be reached when we search for lists with a sum of 1 ?? Your derivation is incorrect, when you're reading a list comprehension you

Re: [Haskell-cafe] message passing style like in Haskell?

2008-06-19 Thread Chaddaï Fouché
2008/6/19 jinjing [EMAIL PROTECTED]: encode xs = xs.group.map token where token x = (x.length, x.head) Working in this direction is a question of taste, but the choice of the dot for the operator is a pretty bad idea... On the other hand, my favourite would be : encode = map (length head) .

Re: [Haskell-cafe] Memory profiling

2008-06-16 Thread Chaddaï Fouché
2008/6/16 Pieter Laeremans [EMAIL PROTECTED]: Hi, Which tools do you recommand for memory profiling haskell programs on a *nix system. I'm using haskell to develop a CGI program/script. The application has to be deployed on shared hosting infrastructure. Since I would like to be a good

Re: [Haskell-cafe] Re: [Haskell] ANN: random-access-list-0.1

2008-06-12 Thread Chaddaï Fouché
2008/6/12 Stephan Friedrichs [EMAIL PROTECTED]: For index, don't use Monad, use Maybe (I think that's what the recent [EMAIL PROTECTED] discussion concluded, in the context of switching Data.Map back to Maybe). I was just copying the idea from Data.Map and it's usually a good thing to have

Re: [Haskell-cafe] Re: Damnit, we need a CPAN.

2008-05-30 Thread Chaddaï Fouché
2008/5/30 Achim Schneider [EMAIL PROTECTED]: I already was pleasantly surprised when discovering cabal-install, I think it deserves some more prominence, or even integration into cabal itself, to make everyone aware of the fact that there's such a thing as automatic installation and tempt

Re: [Haskell-cafe] Re: Aren't type system extensions fun? [Further analysis]

2008-05-27 Thread Chaddaï Fouché
2008/5/27 Andrew Coppin [EMAIL PROTECTED]: Gleb Alexeyev wrote: foo :: (forall a . a - a) - (Bool, String) foo g = (g True, g bzzt) So, after an entire day of boggling my mind over this, I have brought it down to one simple example: (id 'J', id True) -- Works perfectly. \f - (f 'J',

Re: [Haskell-cafe] GHC API GSoc project (was: ANN: Haddock version 2.1.0)

2008-05-14 Thread Chaddaï Fouché
2008/5/15 Claus Reinke [EMAIL PROTECTED]: Feel free to CC me or the ticket with things like that. I'll be IMHO, trying to support a semantics- and comment-preserving roundtrip in (pretty . parse) would be a good way to start (David says he's going to look at the extracting

Re: [Haskell-cafe] Stack vs Heap allocation

2008-05-11 Thread Chaddaï Fouché
2008/5/10 Edsko de Vries [EMAIL PROTECTED]: The key reason why nested additions take stack space, is because (+) on Integers is *strict* in both arguments. If it were somehow non-strict instead, then the unevaluated parts of the number would be heap-allocated rather than stack-allocated. I

Re: [Haskell-cafe] Re: dropping hyphens and \n in words

2008-05-11 Thread Chaddaï Fouché
2008/5/11 Achim Schneider [EMAIL PROTECTED]: Excuse my bluntness, but I utterly fail to make sense of this. Reformulating your understanding of it would surely be beneficial. He has a routine that gives him a list of words classified by line, and he want the hyphens to be accounted for. So

Re: Re[2]: a faster, accumulating mapM (was Re: [Haskell-cafe] mapM vs mapM_ performance)

2008-04-25 Thread Chaddaï Fouché
2008/4/25, Niklas Broberg [EMAIL PROTECTED]: Wow. A 10x slowdown for a very commonly used function that in 99.8% of all use cases has no need for the extra laziness at all. No wonder some people say Haskell is a toy language... A toy language that is still much faster than many currently

Re: [Haskell-cafe] translating from fundeps into type families

2008-04-08 Thread Chaddaï Fouché
2008/4/8, Manuel M T Chakravarty [EMAIL PROTECTED]: You need to write the instance as instance (b ~ TheFoo a, Foo a) = Bar (Either a b) where bar (Left a) = foo' a bar (Right b) = foo' (foo b :: a) If you do that, the program compile, but res still raise a panic in GHC6.8.2 .

Re: [Haskell-cafe] [GSoC] Porting HaRe to use the GHC API

2008-04-03 Thread Chaddaï Fouché
2008/4/1, Claus Reinke [EMAIL PROTECTED]: as for the project, the are actually two APIs to consider, GHC's and HaRe's, and the main stumbling points are those things that are not in those APIs (explicitly or at all): snip Many thanks for the valuable insights. I intend to work in close

Re: [Haskell-cafe] [Newbie] Problem with Data.Map (or something else ?)

2008-04-01 Thread Chaddaï Fouché
2008/4/1, Bruno Carnazzi [EMAIL PROTECTED]: Because I don't know anything about arrays in Haskell. Thank you for pointing this, I have to read some more Haskell manuals :) A good place to learn about Haskell's array (which come in many flavours) is this wiki page :

Re: [Haskell-cafe] lexicographic order

2008-03-31 Thread Chaddaï Fouché
2008/3/31, Simeon Mattes [EMAIL PROTECTED]: why I should take as right (a,b) = (a',b') iff (a a' or (a == a' and b = b')) and not (a,b) = (a',b') iff (a = a' or (a == a' and b = b')) The latter seems more logical, doesn't it? No, it doesn't, since in the latter (1,2) = (1,1) because 1

Re: [Haskell-cafe] [Newbie] Problem with Data.Map (or something else ?)

2008-03-31 Thread Chaddaï Fouché
2008/3/31, Bruno Carnazzi [EMAIL PROTECTED]: Dears Haskellers, As an Haskell newbie, I'm learning Haskell by trying to resolve Euler Project problems (http://projecteuler.net/ ). I'm hanging on problem 14 (Collatz problem). I've written the following program... Which does not end in

Re: [Haskell-cafe] lexicographic order

2008-03-30 Thread Chaddaï Fouché
2008/3/30, Bulat Ziganshin [EMAIL PROTECTED]: although the last alternative, (Branch l r) = (Branch l' r') = l == l' r = r' || l = l' seems suspicious to me. isn't it the same as (Branch l r) = (Branch l' r') = l = l' Yes, it should be : (Branch l r) = (Branch l' r') = l l' ||

Re: [Haskell-cafe] Re: (flawed?) benchmark : sort

2008-03-10 Thread Chaddaï Fouché
2008/3/11, David Menendez [EMAIL PROTECTED]: I think Adrian is just arguing that a == b should imply f a == f b, for all definable f, in which case it doesn't *matter* which of two equal elements you choose, because there's no semantic difference. (Actually, it's probably not desirable to

Re: [Haskell-cafe] (flawed?) benchmark : sort

2008-03-04 Thread Chaddaï Fouché
2008/3/4, Krzysztof Skrzętnicki [EMAIL PROTECTED]: Hi I was playing with various versions of sorting algorithms. I know it's very easy to create flawed benchmark and I don't claim those are good ones. However, it really seems strange to me, that sort - library function - is actually the

Re: [Haskell-cafe] Doubting Haskell

2008-03-04 Thread Chaddaï Fouché
2008/3/4, Alan Carter [EMAIL PROTECTED]: I've written up some reflections on my newbie experience together with both versions, which might be helpful to people interested in popularizing Haskell, at: http://the-programmers-stone.com/2008/03/04/a-first-haskell-experience/ This is truly

Re: [Haskell-cafe] (flawed?) benchmark : sort

2008-03-04 Thread Chaddaï Fouché
2008/3/4, Krzysztof Skrzętnicki [EMAIL PROTECTED]: Thanks for improved code. My point was to measure which programming patterns are faster than the others so I can learn which ones I should use. However, the thing that is really bad is the fact, that even oneliner qsort_i is faster than

Re: [Haskell-cafe] Generating a random list

2008-03-01 Thread Chaddaï Fouché
2008/3/1, Milos Hasan [EMAIL PROTECTED]: OK, thanks, this is an important point. So maybe I should have done this? main = print $ foldl1' (+) $! take 100 randFloats My intuition tells me that the $! (and `seq`) just reduces one level (to WHNF?). If so, is there a way to force complete

Re: [Haskell-cafe] haskellwiki and Project Euler

2008-02-24 Thread Chaddaï Fouché
2008/2/24, Rodrigo Queiro [EMAIL PROTECTED]: The only time I have found the solutions page useful is when I was working on problem 100, which I'd been thinking about on and off for several months. Eventually, I gave up and looked at the solution there, and was absolutely none the wiser as to

Re: [Haskell-cafe] haskellwiki and Project Euler

2008-02-24 Thread Chaddaï Fouché
2008/2/24, Cale Gibbard [EMAIL PROTECTED]: I encourage you to put your solutions back up, that would be good. Referencing OEIS is a bit of a cheesy way to do things. (Though if it's going to be done, one could at least make use of the excellent Math.OEIS library :) Indeed !! But I don't

Re: [Haskell-cafe] A beginners question

2008-02-23 Thread Chaddaï Fouché
2008/2/23, Harri Kiiskinen [EMAIL PROTECTED]: Dear All, banging my head against Haskell, but liking the feeling of hurting brains. Just a simple question: If fmap (^4) [1,2,3] = \i - shows i gives 1 16 81 In the List Monad, (=) is defined as concatMap, so this code can be

Re: [Haskell-cafe] Embedded Functions in Algebraic Data Types?

2008-02-10 Thread Chaddaï Fouché
2008/2/10, Michael Feathers [EMAIL PROTECTED]: On a lark, I loaded this into Hugs this morning, and it didn't complain: data Thing = Thing (Integer - Integer) But, I've never seen that sort of construct in an example. Do people ever embed functions in ADTs? Yes, anyway you can embed

Re: [Haskell-cafe] nub vs. find + (:) Is this abysmal code?

2008-02-10 Thread Chaddaï Fouché
2008/2/10, Michael Feathers [EMAIL PROTECTED]: How bad is this: addProduct :: [Product] - Product - [Product] addProduct inventory product = nub (product : inventory) This is pretty terrible, if the list is consumed afterward (which we assume it will be) we should have something like a

Re: [Haskell-cafe] Mutable arrays

2008-02-08 Thread Chaddaï Fouché
Après avoir un peu manipulé la solution de John pour qu'elle fasse la même chose que la mienne, je peux affirmer qu'elle est légèrement moins rapide (c'est infime et normal vu que ses leftFold passent plus d'informations), mais que les deux solutions ont au moins cet avantage d'être rapides (2s

Re: [Haskell-cafe] Mutable arrays

2008-02-08 Thread Chaddaï Fouché
Sorry for the french, I was a little bit confused... On 08/02/08, Chaddaï Fouché [EMAIL PROTECTED] wrote : After I changed John's code so that it worked on the same dataset as mine, I could benchmark both of them : My solution is a bit faster (but that's a very tiny difference and to be expected

Re: [Haskell-cafe] Mutable arrays

2008-02-07 Thread Chaddaï Fouché
2008/2/7, Jeff φ [EMAIL PROTECTED]: I played with your foldl1MArray' last night. I noticed it can be reduced to . . . foldl1MArray' :: (MArray a e m, Ix i) = (e - e - e) - a i e - m e foldl1MArray' f a = do (l,u) - getBounds a foldl1' (liftM2 f) (map (readArray a) (range (l,u)))

Re: [Haskell-cafe] Mutable arrays

2008-02-06 Thread Chaddaï Fouché
2008/2/6, Jeff φ [EMAIL PROTECTED]: I have solved both of these problems in Clean using a lazy list without resorting to unsafe operations. So, it seems to me that uniqueness types are more general than monads. Are you aware that your code in Clean has some issues, like the lst not being so

Re: [Haskell-cafe] Mutable arrays

2008-02-02 Thread Chaddaï Fouché
2008/2/2, Rodrigo Queiro [EMAIL PROTECTED]: Sorry, I was lazy. New maximum': maximum' = foldl1' max Sorry but none of those propositions change the heart of the problem : the list of elements is totally produced before she can be consumed due to the strict monadic (IO or ST) nature of getElems.

Re: [Haskell-cafe] Field updates in a state monad

2008-01-10 Thread Chaddaï Fouché
2008/1/10, Lutz Donnerhacke [EMAIL PROTECTED]: * Michael Roth wrote: Exists there a way to write this cleaner without writing countless set_xyz helper functions? The syntactic sugar for record modifications is simply that: sugar. You might write your own modifier functions: set_bla x y

Re: [Haskell-cafe] How to convert number types.

2007-12-31 Thread Chaddaï Fouché
2007/12/31, L.Guo [EMAIL PROTECTED]: Hi MailList Haskell-Cafe: I am a new haskeller. And was farmilar with C. When tring to do some calculate, like this: input = 5 :: Int factor = 1.20 :: Float output = factor ** (toFloat input) I found that I do not know any function could do just what

Re: [Haskell-cafe] ReRe: Basic question concerning data constructors

2007-12-30 Thread Chaddaï Fouché
2007/12/30, Joost Behrends [EMAIL PROTECTED]: . Now, let's say we had tried defining ClockTime with parameters as you suggested. ClockTime' :: Integer - Integer - * Do you see the problem? In order to use the ClockTime type constructor, we would have to use Integer values.

Re: [Haskell-cafe] Re: Wikipedia on first-class object

2007-12-30 Thread Chaddaï Fouché
2007/12/30, Cristian Baboi [EMAIL PROTECTED]: A simple question: Can you write the value of x to a file where x = (1:x) ? Yes, but you'll have to write it yourself, because Haskell can't decide by itself that this value is infinite and try to print it with a recursive definition, if it could

Re: [Haskell-cafe] Re: Wikipedia on first-class object

2007-12-30 Thread Chaddaï Fouché
2007/12/30, Chaddaï Fouché [EMAIL PROTECTED]: 2007/12/30, Cristian Baboi [EMAIL PROTECTED]: A simple question: Can you write the value of x to a file where x = (1:x) ? Yes, but you'll have to write it yourself, because Haskell can't decide by itself that this value is infinite and try

Re: [Haskell-cafe] what does @ mean?.....

2007-12-28 Thread Chaddaï Fouché
2007/12/28, Alfonso Acosta [EMAIL PROTECTED]: @ works as an aliasing primitive for the arguments of a function f x@(Just y) = ... using x in the body of f is equivalent to use Just y. Perhaps in this case is not really useful, but in some other cases it saves the effort and space of

Re: [Haskell-cafe] what does @ mean?.....

2007-12-28 Thread Chaddaï Fouché
2007/12/28, Nicholls, Mark [EMAIL PROTECTED]: So in the example given... mulNat a b | a = b = mulNat' a b b | otherwise = mulNat' b a a where mulNat' x@(S a) y orig | x == one = y | otherwise = mulNat' a (addNat orig y) orig

Re: [Haskell-cafe] Re: Comments on reading two ints off Bytestring

2007-12-24 Thread Chaddaï Fouché
2007/12/24, Paulo J. Matos [EMAIL PROTECTED]: On Dec 24, 2007 11:55 AM, Paulo J. Matos [EMAIL PROTECTED] wrote: On Dec 23, 2007 12:44 PM, Isaac Dupree [EMAIL PROTECTED] wrote: -- this should work too parseHeader3 :: BS.ByteString - Maybe (Int, Int) --note accurate type signature,

Re: [Haskell-cafe] Re: Printing and Referential transparency excuse

2007-12-24 Thread Chaddaï Fouché
2007/12/24, Cristian Baboi [EMAIL PROTECTED]: On Mon, 24 Dec 2007 11:27:11 +0200, apfelmus [EMAIL PROTECTED] wrote: Cristian Baboi wrote: How can I define a function to do the inverse operation ? g :: String - ( a - b ) This time I cannot see how referential transparency will deny

Re: [Haskell-cafe] string literals and haskell'

2007-10-23 Thread Chaddaï Fouché
2007/10/23, Justin Bailey [EMAIL PROTECTED]: My two cents - I haven't found another language that handles heredocs as nicely as Ruby does. Perl Heredocs do the same things and predates Ruby's (at least they do all you described and a bit more). But what would be really nice is a way to write

Re: [Haskell-cafe] Puzzled

2007-10-06 Thread Chaddaï Fouché
2007/10/6, Peter Verswyvelen [EMAIL PROTECTED]: But great to know about the new strictness on vars! I really should get GHC 6.8 RC1 for Windows... Just in case you misunderstood : this functionality was already there in GHC 6.4, it's just the new syntax to active it that is available only in

Re: [Haskell-cafe] Re: PROPOSAL: New efficient Unicode string library.

2007-09-27 Thread Chaddaï Fouché
2007/9/27, Duncan Coutts [EMAIL PROTECTED]: Infrequent, but they exist, which means you can't seek x/2 bytes ahead to seek x characters ahead. All such seeking must be linear for both UTF-16 *and* UTF-8. And in [Char] for all these years, yet I don't hear people complaining. Most string

  1   2   >