Re: [Haskell-cafe] Function application layout

2011-05-26 Thread Neil Brown
On 25/05/11 10:00, Jonas Almström Duregård wrote: As an equivalent to: f (x a) (y b) (z c) Of course my intention is that the new keyword should initiate layout syntax so we can write this: f applied to x a y b z c Here's a (tongue-in-cheek) trick that allows for layout close to

Re: [Haskell-cafe] Inconsistent window updates with SDL library

2011-05-17 Thread Neil Brown
On 17/05/11 01:42, Michael Serra wrote: eventLoop w cs = do drawCells w cs e - waitEventBlocking checkEvent e where checkEvent (KeyUp (Keysym SDLK_ESCAPE _ _)) = return () checkEvent (KeyUp (Keysym SDLK_n _ _)) = eventLoop w $ nextgen cs checkEvent _

Re: [Haskell-cafe] Type Classes in Haskell - how can I make GHC make a choice of types, when the type chosen doesn't matter?

2011-04-14 Thread Neil Brown
On 14/04/11 13:00, Chris Dew wrote: class Stream a b c d where (-) :: a - (b - c) - d instance Stream (IO d) d (IO c) (IO c) where f - g = f= g instance Stream d d (IO c) (IO c) where f - g = g f instance Stream d d c c where x - y = y $ x I notice that in all

Re: [Haskell-cafe] BlockedIndefinitelyOnMVar exception

2011-03-31 Thread Neil Brown
On 31/03/11 11:03, Gregory Collins wrote: I'm guessing the trigger condition for BlockedIndefinitelyOnMVar is blocked and mvar refcount == 1 It's not simply a reference count (the thread that's blocked forever can hold multiple references to the MVar and it's still blocked indefinitely).

Re: [Haskell-cafe] Possible bug in Control.Concurrent

2011-02-09 Thread Neil Brown
On 09/02/11 15:34, Krzysztof Skrzętnicki wrote: Hello Cafe, Here is a simple program that yields strange results: module Main where import Control.Concurrent import Control.Concurrent.Chan import Control.Monad main = do c - newChan writeChan c 1 forkIO $ forever $ do i - readChan c

Re: [Haskell-cafe] 3GB allocation, 75% CPU usage from a callback function

2011-01-29 Thread Neil Brown
Hi, First of all, don't be fooled by the alloc statistic. That is not 3GB memory residency, that's 3GB allocation, which was interspersed with lots of garbage collections, in the same way that measuring how many times malloc was called in a C program doesn't necessarily indicate memory

Re: [Haskell-cafe] MonadRandom-computation that does not terminate

2011-01-12 Thread Neil Brown
On 11/01/11 23:19, Tim Baumgartner wrote: Hi, I'm having difficulties with this function I wrote: iterateR :: (MonadRandom m) = (a - m a) - a - m [a] iterateR g s = do s' - g s return (s:) `ap` iterateR g s' I'm running the computation with evalRandIO and surprisingly the first call of

Re: [Haskell-cafe] Misleading MVar documentation

2011-01-12 Thread Neil Brown
On 12/01/11 15:53, Edward Z. Yang wrote: These are interesting, opposed perspectives, and I suspect what would be good is to treat both situations. I think perhaps what would be good to put in the introduction is the conceptual model of MVars: that is, take and put are the fundamental

Re: [Haskell-cafe] [ANNOUNCE] Parallel Haskell project underway

2010-11-15 Thread Neil Brown
On 15/11/10 15:23, Dmitry Astapov wrote: == Dragonfly == http://www.dragonfly.co.nz/ Participants: Finlay Thompson, Edward Abraham Cloudy Bayes: Hierarchical Bayesian modeling in Haskell The Cloudy Bayes project aims to develop a fast Bayesian model fitter that takes advantage of

Re: [Haskell-cafe] Typeable state map

2010-11-10 Thread Neil Brown
Hi, You have a problem with your function getPhi. It has type: getPhi :: forall a e m. (MutableMatrix a e m, Typeable a, Typeable e, Floating e, Ord e) = VarStateT m () where MutableMatrix is: class (PrimMonad m) = MutableMatrix a e m | a - e m where No matter how you call getPhi, you

Re: [Haskell-cafe] Type Directed Name Resolution

2010-11-10 Thread Neil Brown
On 10/11/10 12:36, Yves Parès wrote: I think this idea is a stairway to duck typing. I exagerate, of course, but here is my point: It shouldn't be difficult to make a class: class HasName a where name :: a - String For accessing parts of data structures that have the same type, I agree

Re: [Haskell-cafe] Re: change in overlapping instance behavior between GHC 6.12 and GHC 7 causes compilation failure

2010-11-09 Thread Neil Brown
On 09/11/10 11:53, Neil Brown wrote: XMLGenerator.lhs:64:16: Overlapping instances for EmbedAsChild (IdentityT IO) (XMLGenT m (XML m)) arising from a use of `asChild' at XMLGenerator.lhs:64:16-22 Matching instances: instance [overlap ok] (XML m

Re: [Haskell-cafe] Re: change in overlapping instance behavior between GHC 6.12 and GHC 7 causes compilation failure

2010-11-09 Thread Neil Brown
I'm not sure whether to reply to the list(s) or the ticket; maybe if you think my comments are valid they can be copied to the ticket. From looking, it seems to me that you do have overlapping instances, and I wonder if it's actually a 6.12 bug for accepting the code, not a 7 bug for

Re: [Haskell-cafe] Convert Either to Tree - Occurs check

2010-10-22 Thread Neil Brown
On 22/10/10 09:23, André Batista Martins wrote: Tks for the answer, the data structure of Either is: data Either a b = Left a | Right bderiving (Eq, Ord, Read, Show) one example of what i want convert is: Left(Right(Left(Left( Hi, The problem here is that the

Re: [Haskell-cafe] tried to use the example given in the source of network.browser

2010-10-22 Thread Neil Brown
Hi, On 22/10/10 14:58, Michael Litchard wrote: main = do rsp- Network.Browser.browse $ do setAllowRedirects True -- handle HTTP redirects request $ getRequest http://google.com/; fmap (take 100) (getResponseBody rsp) but I got this

Re: [Haskell-cafe] Re: Lazy evaluation from Why Functional programming matters

2010-10-06 Thread Neil Brown
On 06/10/10 11:00, C K Kashyap wrote: My ultimate aim it to write an EDSL for x86 - as in, describe a micro-kernel in haskell, compiling and running which would generate C code ( not sure if it's even possible - but I am really hopeful). Have you seen Potential

Re: [Haskell-cafe] Lambda-case / lambda-if

2010-10-05 Thread Neil Brown
On 05/10/10 07:52, Nicolas Wu wrote: I'd prefer to see something like \ 1 - f | 2 - g but I'm sure something could be worked out. While I think the case of is a good idea, multiple clauses in lambdas seems more canonical to me. Alternatively, we could abandon

Re: [Haskell-cafe] EDSL for Makefile

2010-09-30 Thread Neil Brown
On 30/09/10 09:41, C K Kashyap wrote: Hi All, I was thinking about doing an EDSL for Makefile (as an exercise) I put down my line of thought here - http://hpaste.org/40233/haskell_makefile_edsl I'd appreciate some feedback on the approach. Also, I wanted some idea on how(in the current

Re: [Haskell-cafe] ANNOUNCE: http-enumerator 0.0.0

2010-09-22 Thread Neil Brown
On 22/09/10 11:22, C K Kashyap wrote: Hey Michael, I'd like to announce the first release of http-enumerator[1], an HTTP client package with support for HTTPS connections. This release is very experimental; bug reports and API feedback are very welcome. This sounds nice (I'll

Re: [Haskell-cafe] try, seq, and IO

2010-09-15 Thread Neil Brown
On 15/09/10 10:13, Jeroen van Maanen wrote: The past year I have been working on a port of my machine learning project named LExAu from Java to Haskell. I'm still very glad I took the jump, because the complexity curve appears to be log shaped rather than exp shaped. In one year I almost got

Re: [Haskell-cafe] Question on concurrency

2010-09-14 Thread Neil Brown
On 14/09/10 07:45, Arnaud Bailly wrote: What surprised me is that I would expect the behaviour of the two functions to be different: - in doRunMvnInIO, I would expect stdout's content to be printed before stderr, ie. the 2 threads are ordered because I call takeMVar in between calls to forkIO

Re: [Haskell-cafe] Full strict functor by abusing Haskell exceptions

2010-09-14 Thread Neil Brown
On 13/09/10 17:25, Maciej Piechotka wrote: import Control.Exception import Foreign import Prelude hiding (catch) data StrictMonad a = StrictMonad a deriving Show instance Monad StrictMonad where return x = unsafePerformIO $ do (return $! x) `catch` \(SomeException _) - return x

[Haskell-cafe] ANNOUNCE: game-probability-1.1

2010-09-08 Thread Neil Brown
Hi, I've just released version 1.1 of my game-probability library. It's intended to be an easy way to investigate the probability of various dice rolls and card draws (the latter is the new addition for the 1.1 release), using a Haskell library/EDSL. It has various examples in the

Re: [Haskell-cafe] Restricted type classes

2010-09-07 Thread Neil Brown
On 07/09/10 05:24, wren ng thornton wrote: that other class would (most likely) be a subclass of pointed functors. In any case, it does mean there's something of a mismatch between singleton vs return/pure/point/unit. Not quite sure what you mean by a mis-match Of course, I'd expect

Re: [Haskell-cafe] overloaded list literals?

2010-09-06 Thread Neil Brown
On 06/09/10 11:23, Johannes Waldmann wrote: We have overloaded numerical literals (Num.fromInteger) and we can overload string literals (IsString.fromString), so how about using list syntax ( [], : ) for anything list-like (e.g., Data.Sequence)? I would have thought you have two obvious

Re: [Haskell-cafe] Unnecessarily strict implementations

2010-09-03 Thread Neil Brown
On 03/09/10 11:11, Henning Thielemann wrote: Ivan Lazar Miljenovic schrieb: On 3 September 2010 04:57, Arie Peterson ar...@xs4all.nl wrote: On Thu, 2 Sep 2010 19:30:17 +0200, Daniel Fischer daniel.is.fisc...@web.de wrote: Why would one consider using Ord for Map an abuse? A kludge, for

Re: [Haskell-cafe] Unnecessarily strict implementations

2010-09-02 Thread Neil Brown
On 02/09/10 17:10, Stephen Sinclair wrote: On Thu, Sep 2, 2010 at 3:25 AM, Jan Christiansen j...@informatik.uni-kiel.de wrote: I prefer False= _|_ = True Sorry to go a bit off topic, but I find it funny that I never really noticed you could perform less-than or greater-than

Re: [Haskell-cafe] Having a connection between kind * and kind * - *

2010-08-19 Thread Neil Brown
On 19/08/10 14:26, Ivan Lazar Miljenovic wrote: , | -- | Indicates what kind of value may be stored within a type. Once | -- superclass constraints are available, the @v@ parameter will | -- become an associated type. | class Stores c v | c - v | | data family Constraints :: (* - *) -

Re: [Haskell-cafe] Heavy lift-ing

2010-08-18 Thread Neil Brown
On 17/08/10 17:13, Tilo Wiklund wrote: On 24/07/2010, aditya siramaditya.si...@gmail.com wrote: Perhaps I'm being unclear again. All I was trying to say was that: liftM2 (-) [0,1] [2,3] /= liftM2 (-) [2,3] [0,1] -deech I'm sorry if I'm bumping an old thread, but why should liftM2 f

Re: [Haskell-cafe] zip-archive performance/memmory usage

2010-08-10 Thread Neil Brown
On 10/08/10 00:29, Pieter Laeremans wrote: Hello, I'm trying some haskell scripting. I'm writing a script to print some information from a zip archive. The zip-archive library does look nice but the performance of zip-archive/lazy bytestring doesn't seem to scale. Executing :

Re: [Haskell-cafe] ANNOUNCE: approximate-equality 1.0 -- Newtype wrappers for approximate equality

2010-08-03 Thread Neil Brown
On 03/08/10 05:32, Gregory Crosswhite wrote: I am pleased to announce the release of the package approximate-equality, which provides newtype wrappers that allow one to effectively override the equality operator of a value so that it is/approximate/ rather than/exact/. The wrappers use type

Re: [Haskell-cafe] Actors and message-passing a la Erlang

2010-07-26 Thread Neil Brown
On 25/07/10 21:55, Yves Parès wrote: Hello ! I've been studying Erlang and Scala, and I was wondering if someone has already implemented an actors and message passing framework for concurrent and distributed programs in Haskell. Hi, Take a look at the concurrency section on Hackage:

Re: [Haskell-cafe] use of modules to save typing

2010-07-08 Thread Neil Brown
On 08/07/10 09:08, Michael Mossey wrote: data PlayState = PlayState { playState_cursor :: Int , playState_verts :: [Loc] , playState_len :: Int , playState_doc :: MusDoc } Notice how often the characters

Re: [Haskell-cafe] Re: chart broken under 6.12 according to criterion

2010-07-01 Thread Neil Brown
On 01/07/10 10:19, Tom Doris wrote: According to the criterion.cabal file shipped with the latest (0.5.0.1) version of criterion, the Chart package is broken under GHC 6.12: flag Chart description: enable use of the Chart package -- Broken under GHC 6.12 so far Does anyone know the

Re: [Haskell-cafe] functional dependencies question

2010-07-01 Thread Neil Brown
On 01/07/10 12:37, Patrick Browne wrote: Why do some cases such as 1) fail to run even if they are the only instantiation. -- 1) Compiles but does not run instance LocatedAt Int String where spatialLocation(1)=home That instance is fine. I presume the problem is that you are trying

Re: [Haskell-cafe] functional dependencies question

2010-07-01 Thread Neil Brown
On 01/07/10 13:11, Patrick Browne wrote: Neil, Does the following sum up the situation? The class Num has subclasses containing various numeric types and the literal 1 is a value for one or more of those types. Hence the Haskell compiler says the instance 1) is OK. But at run time, without the

Re: [Haskell-cafe] Re: chart broken under 6.12 according to criterion

2010-07-01 Thread Neil Brown
On 02/07/2010 00:03, wren ng thornton wrote: OS= OSX 10.5.8 GHC = 6.12.1 Cabal-Install = 0.8.2 Cabal = 1.8.0.2 $ cabal install criterion -fChart --reinstall Resolving dependencies... ... Configuring cairo-0.11.0... setup: gtk2hsC2hs is required but it

Re: [Haskell-cafe] MonadCatchIO and bracket.

2010-06-28 Thread Neil Brown
On 28/06/2010 20:02, Carl Howells wrote: While working this weekend on the Snap web framework, I ran into a problem. Snap implements MonadCatchIO, so I thought I could just use bracket to handle resource acquisition/release in a safe manner. Imagine my surprise when bracket simply failed to run

Re: [Haskell-cafe] Control.Alternative --- some and many?

2010-06-23 Thread Neil Brown
On 23/06/10 06:54, Christopher Done wrote: I'm not sure how Alternative differs from MonadPlus, other than being defined for Applicative rather than Monad. They have the same laws (identity and associativity). Importantly, MonadPlus must satisfy some laws for (=) and (), whereas

Re: [Haskell-cafe] MonadCatchIO-transformers and ContT

2010-06-21 Thread Neil Brown
Hi, Here's my guess. Take a look at this version, and try running it: === {-# LANGUAGE PackageImports #-} import qualified MonadCatchIO-transformers Control.Monad.CatchIO as C import Control.Monad.IO.Class import Control.Monad.Trans.Cont bracket_' :: C.MonadCatchIO m = m a -- ^

Re: [Haskell-cafe] learning advanced haskell

2010-06-14 Thread Neil Brown
On 14/06/10 06:42, Aran Donohue wrote: Hi Cafe, I've been doing Haskell for a few months, and I've written some mid-sized programs and many small ones. I've read lots of documentation and many papers, but I'm having difficulty making the jump into some of the advanced concepts I've read

Re: [Haskell-cafe] TDD in Haskell

2010-05-25 Thread Neil Brown
On 25/05/10 12:36, Ionut G. Stan wrote: Hi, I'm doing TDD in pretty much all of the languages that I know, and I want to introduce it early in my Haskell learning process. I wonder though, if there's some established process regarding TDD, not unit testing. I've heard of QuickCheck and

Re: [Haskell-cafe] mixing map and mapM ?

2010-05-06 Thread Neil Brown
Bill Atkins wrote: Almost - liftM modificationTime has type Status - IO EpochTime. Like other IO functions (getLine, putStrLn), it returns an IO action but accepts a pure value (the modification time) Also, I like this style: import Control.Applicative (($)) blah = do times - mapM

Re: [Haskell-cafe] What do _you_ want to see in FGL?

2010-04-26 Thread Neil Brown
Hi, Primarily I want to see in FGL: documentation, documentation and more documentation. The library has lots of undocumented functions (especially the queries, e.g. http://hackage.haskell.org/packages/archive/fgl/5.4.2.2/doc/html/Data-Graph-Inductive-Query-DFS.html has no documentation at

Re: [Haskell-cafe] and [] = True; or [] = False

2010-04-26 Thread Neil Brown
Bjorn Buckwalter wrote: Dear all, Does it make good sense that 'and []' returns 'True' and 'or []' returns 'False'? It's certainly what I would expect it to do, based on several ways of thinking. 1: If we define the function using explicit recursion: and (x:xs) = x and xs Therefore and []

[Haskell-cafe] The Poor Man's PVP-Checking Tool

2010-04-26 Thread Neil Brown
Hi, The issue of a tool to help with checking packages against the Package Versioning Policy (PVP: http://www.haskell.org/haskellwiki/Package_versioning_policy) has come up several times on this list, and it seems to be a generally wanted tool. One of the things desired in such a tool is

Re: [Haskell-cafe] ANN: forkable-monad 0.1

2010-04-21 Thread Neil Brown
Hi, This is quite a neat generalisation of forkIO, and something I've wanted in the past. My comment would be about the MonadIO m requirement for ForkableMonad. I understand that conceptually it's a nice thing to have. But practically, I don't think it's necessary, and could be a little

Re: [Haskell-cafe] GHC, odd concurrency space leak

2010-04-15 Thread Neil Brown
Jason Dagit wrote: On Wed, Apr 14, 2010 at 3:13 PM, Daniel Fischer daniel.is.fisc...@web.de mailto:daniel.is.fisc...@web.de wrote: Am Mittwoch 14 April 2010 23:49:43 schrieb Jason Dagit: It will be interesting to hear what fixes this! forever' m = do _ - m

Re: [Haskell-cafe] What is the consensus about -fwarn-unused-do-bind ?

2010-04-09 Thread Neil Brown
Ivan Lazar Miljenovic wrote: As of 6.12.1, the new -fwarn-unused-do-bind warning is activated with -Wall. This is based off a bug report by Neil Mitchell: http://hackage.haskell.org/trac/ghc/ticket/3263 . However, does it make sense for this to be turned on with -Wall? For starters, why

Re: [Haskell-cafe] Re: Haskell.org re-design

2010-04-07 Thread Neil Brown
Thomas Schilling wrote: Here's a matching Wiki style: http://i.imgur.com/XkuzH.png I like your designs (I liked the blue and orange version, but all the colour schemes seem fine). For the wiki design, it would be good to re-think and cull those links at the top of the page. For

Re: [Haskell-cafe] chp-plus doesn't install

2010-03-28 Thread Neil Brown
Neil Brown wrote: Colin Paul Adams wrote: I'm getting these errors (ghc 6.10.4 on Linux x86_64): Building chp-plus-1.1.0... [1 of 9] Compiling Control.Concurrent.CHP.Test ( Control/Concurrent/CHP/Test.hs, dist/build/Control/Concurrent/CHP/Test.o ) [2 of 9] Compiling

Re: [Haskell-cafe] chp-plus doesn't install

2010-03-27 Thread Neil Brown
Colin Paul Adams wrote: I'm getting these errors (ghc 6.10.4 on Linux x86_64): Building chp-plus-1.1.0... [1 of 9] Compiling Control.Concurrent.CHP.Test ( Control/Concurrent/CHP/Test.hs, dist/build/Control/Concurrent/CHP/Test.o ) [2 of 9] Compiling Control.Concurrent.CHP.Console (

[Haskell-cafe] Re: Benchmarking and Garbage Collection

2010-03-05 Thread Neil Brown
Simon Marlow wrote: import Control.Concurrent import Control.Concurrent.CML import Control.Monad main :: IO () main = do let numChoices = 2 cs - replicateM numChoices channel mapM_ forkIO [replicateM_ (10 `div` numChoices) $ sync $ transmit c () | c - cs] replicateM_ 10 $ sync $

[Haskell-cafe] Benchmarking and Garbage Collection

2010-03-04 Thread Neil Brown
Hi, I'm looking at benchmarking several different concurrency libraries against each other. The benchmarks involve things like repeatedly sending values between two threads. I'm likely to use Criterion for the task. However, one thing I've found is that the libraries have noticeably

Re: [Haskell-cafe] Benchmarking and Garbage Collection

2010-03-04 Thread Neil Brown
Jesper Louis Andersen wrote: On Thu, Mar 4, 2010 at 7:16 PM, Neil Brown nc...@kent.ac.uk wrote: However, one thing I've found is that the libraries have noticeably different behaviour in terms of the amount of garbage created. In fact, CML relies on the garbage collector for some

Re: [Haskell-cafe] Benchmarking and Garbage Collection

2010-03-04 Thread Neil Brown
Jesper Louis Andersen wrote: On Thu, Mar 4, 2010 at 8:35 PM, Neil Brown nc...@kent.ac.uk wrote: CML is indeed the library that has the most markedly different behaviour. In Haskell, the CML package manages to produce timings like this for fairly simple benchmarks: %GC time 96.3

Re: [Haskell-cafe] Re: Proper round-trip HughesPJ/Parsec for Doubles?

2010-02-25 Thread Neil Brown
Andy Gimblett wrote: 1. break the line after do (to avoid a layout change when change name or arguments of float' or rename the variable e) I'm not convinced by this; perhaps while editing the code it's useful, but those changes don't happen very often, and when they do, any half-decent

Re: [Haskell-cafe] CURL and threads

2010-02-18 Thread Neil Brown
Hi, Your code forks off N threads to do HTTP response checking, then waits for the reply (invokeThreads). Each thread (runHTTPThread) calls curlGetResponse and *immediately* sends the answer back down the channel to invokeThreads (checkAuthResponse) -- then waits for half a second before

Re: [Haskell-cafe] RFC: concurrent-extra

2010-02-17 Thread Neil Brown
Roel van Dijk wrote: 2010/2/16 Neil Brown nc...@kent.ac.uk: I had a look at the code for Event (both versions) and Lock (but not the others just yet) and it seemed fine. If you do lots of calls to waitTimeout before a set you will accumulate old locks in the list, but that won't cause any

Re: [Haskell-cafe] Pointfree composition for higher arity

2010-02-17 Thread Neil Brown
Sean Leather wrote: I find myself often writing this pattern: someFun x y z = ... fun y z = runFun $ someFun someDefault y z or, alternatively: fun y = runFun . someFun someDefault y I very often write this too (wanting function composition, but with a two-argument

Re: [Haskell-cafe] RFC: concurrent-extra

2010-02-16 Thread Neil Brown
Hi, I had a look at the code for Event (both versions) and Lock (but not the others just yet) and it seemed fine. If you do lots of calls to waitTimeout before a set you will accumulate old locks in the list, but that won't cause any error that I can see, so it would only be a problem in

Re: [Haskell-cafe] Using Cabal during development

2010-02-10 Thread Neil Brown
Don't you simply need to do what the error message says, and add (*in the Executable section*, at the end of the file): build-depends: SFML ? Limestraël wrote: I think I must be dumb or something. I did my SFML.cabal exactly the way the packager of vty-ui did vty-ui.cabal, and I still have

[Haskell-cafe] ANN: progression-0.1

2010-02-04 Thread Neil Brown
Hi all, I've just uploaded the first release of Progression to Hackage. Progression is a small library that pulls together several other libraries and utilities (particularly Criterion) to support the optimisation of Haskell programs. To use it, you wrap up your benchmarks in a program

Re: [Haskell-cafe] GHC/base API documentation has been generated incorrectly

2010-02-03 Thread Neil Brown
Hi, I noticed this on another package recently. Turned out it's already been reported as a haddock bug (http://trac.haskell.org/haddock/ticket/128) and fixed. I guess this will be sorted when the fixed version of haddock is used to re-generate the docs. Thanks, Neil. John Millikin

Re: [Haskell-cafe] scheduling an alarm

2010-01-28 Thread Neil Brown
Brian Denheyer wrote: On Tue, 26 Jan 2010 22:41:44 -0800 Thomas DuBuisson thomas.dubuis...@gmail.com wrote: doEvent f usDelay = forkIO $ threadDelay usDelay doEvent f usDelay f Are you sure that's right ? It seems to be a memory-gobbling infinite loop... Why

Re: [Haskell-cafe] foldl in terms of foldr

2010-01-26 Thread Neil Brown
Xingzhi Pan wrote: On Tue, Jan 26, 2010 at 11:24 PM, Eduard Sergeev eduard.serg...@gmail.com wrote: Xingzhi Pan wrote: The first argument to foldr is of type (a - b - a), which takes 2 arguments. But 'step' here is defined as a function taking 3 arguments. What am I missing here?

Re: [Haskell-cafe] could we get a Data instance for Data.Text.Text?

2010-01-23 Thread Neil Brown
Jeremy Shaw wrote: Hello, Would it be possible to get a Data instance for Data.Text.Text? This would allow us to create a Serialize instance of Text for use with happstack -- which would be extremely useful. Last time this came up, I had a look at providing a Data instance for Text, and I

Re: [Haskell-cafe] Existential Types (I guess)

2010-01-22 Thread Neil Brown
Ozgur Akgun wrote: data NumHolder = forall a. Num a = NumHolder a instance Show NumHolder where show (NumHolder n) = show n liftNum :: (Num a) = (a - a) - NumHolder - NumHolder liftNum f (NumHolder c) = NumHolder (f c) The problem here is that you declare that liftNum will work for any

[Haskell-cafe] ANN: chp-2.0.0, chp-plus-1.0.0

2010-01-11 Thread Neil Brown
Hi, I've just released version 2.0.0 of the Communicating Haskell Processes (CHP) message-passing concurrency library onto Hackage. The main change from 1.x is that I have split the functionality into two libraries: the core functionality remains in the chp package (now version 2.0.0), while

Re: [Haskell-cafe] [Very long] (CHP?) Compressing, MD5 and big files

2010-01-05 Thread Neil Brown
Hi, Sorry for the slightly delayed reply -- I didn't have time to look through all your code and understand it until just now. Your code has one (no doubt frustratingly!) small problem, which is in the deadlocking pipeline3: Maciej Piechotka wrote: pipeline3 :: CHP () pipeline3 =

Re: [Haskell-cafe] Does the TMVar and TChan really obey STM rules?

2009-12-24 Thread Neil Brown
Andrey Sisoyev wrote: Hi everyone, isEmptyTMVar :: TMVar a - STM Bool Source Check whether a given TMVar is empty. Notice that the boolean value returned is just a snapshot of the state of the TMVar. By the time you get to react on its result, the TMVar may have been filled (or

Re: [Haskell-cafe] GHC magic optimization ?

2009-12-04 Thread Neil Brown
Emmanuel CHANTREAU wrote: I will take an example: f x y= x+y The program ask the user to enter two numbers and print the sum. If the user enter 1 2 f 1 2=3 is stored and a gargage collector is used to remove this dandling expression later ? If the user enter again 1 2, ghc search in dandling

Re: [Haskell-cafe] You are in a twisty maze of concurrency libraries, all different ...

2009-12-04 Thread Neil Brown
Patrick Caldon wrote: I'm looking for the right concurrency library/semantics for what should be a reasonably simple problem. I have a little simulator: runWorldSim :: MTGen - SimState - IO SimState it takes about a second to run on a PC. It's functional except it whacks the rng, which

Re: [Fwd: Re: [Haskell-cafe] Implicit newtype unwrapping]

2009-12-03 Thread Neil Brown
Sjoerd Visscher wrote: In the case of Dual [1] `mappend` Dual [2] there's no need to do any unwrapping. There is if you say: l :: [Int] l = Dual [1] `mappend` Dual [2] The way I think this could work is that when the type checker detects a type error, it will first try to resolve it by

Re: [Haskell-cafe] Re: Are there standard idioms for lazy, pure error handling?

2009-12-03 Thread Neil Brown
wren ng thornton wrote: Nicolas Pouillard wrote: Excerpts from Heinrich Apfelmus's message of Tue Dec 01 11:29:24 +0100 2009: For mnemonic value, we could call it a train: data Train a b = Wagon a (Train a b) | Loco b I rather like it too. The mnemonic version sounds

Re: [Haskell-cafe] Optimization with Strings ?

2009-12-03 Thread Neil Brown
Emmanuel CHANTREAU wrote: Le Thu, 3 Dec 2009 13:20:31 +0100, David Virebayre dav.vire+hask...@gmail.com a écrit : It doesn't work this way : Strings are just lists of Chars. Comparison is made recursively, Char by Char. You can have a look at the source to make sure : instance (Eq a) = Eq

Re: [Haskell-cafe] Possible FGL bug

2009-11-25 Thread Neil Brown
It looks like a bug to me. Can you show an exact list of nodes and edges that is causing mkGraph to fail? Or is that what you have displayed, and I can't parse it properly? Thanks, Neil. Ivan Lazar Miljenovic wrote: When developing my QuickCheck-2 test-suite for graphviz, I wrote the

Re: [Haskell-cafe] Possible FGL bug

2009-11-25 Thread Neil Brown
David Menendez wrote: From what I can tell, insEdge inserts an edge between two nodes which are already in the graph. The code is calling insEdge on arbitrarily-labeled nodes, which may not exist in the graph. That's what I thought initially, but in fact what it is doing is exactly what you

Re: [Haskell-cafe] Scrap your boilerplate traversals

2009-11-25 Thread Neil Brown
Hi, You want gmapT (or gmapM for the monadic version). If you look at the source to the everywhere function, you'll see that everywhere is defined in terms of gmapT: everywhere f = f . gmapT (everywhere f) Thanks, Neil. rodrigo.bonifacio wrote: Hi all, Is there a non-recursive

Re: [Haskell-cafe] (possibly) a list comprehensions question

2009-11-19 Thread Neil Brown
Ozgur Akgun wrote: Anyway, just forget the fact that these funstions do not do a check on the length of the input list for a moment. My question is, how can I generalize this function to accept a list of lists of arbitrary length, and produce the required result. Hi, The concise solution is

Re: [Haskell-cafe] Status of TypeDirectedNameResolution proposal?

2009-11-17 Thread Neil Brown
Simon Peyton-Jones wrote: | What's the status of the TDNR proposal [1]? It's stalled. As far as I know, there's been very little discussion about it. It's not a trivial thing to implement, and it treads on delicate territory (how . is treated). Having skimmed the page, it seems like the

Re: [Haskell-cafe] Strange parallel behaviour with Ubuntu Karmic / GHC 6.10.4

2009-11-16 Thread Neil Brown
Michael Lesniak wrote: Hello, I've written a smaller example which reproduces the unusual behaviour. Should I open a GHC-Ticket, too? Hi, I get these results: $ time ./Temp +RTS -N1 -RTS 16 real0m16.010s user0m10.869s sys0m5.144s $ time ./Temp +RTS -N2 -RTS 16 real

Re: [Haskell-cafe] Strange parallel behaviour with Ubuntu Karmic / GHC 6.10.4

2009-11-16 Thread Neil Brown
Michael Lesniak wrote: Hello, getTime? I wonder if that number might be causing the problem; can you replicate it with lower sys times? That was it! Thanks Neil! When I'm using some number crunching without getTime it works (with more or less the expected speedup and usage of two

Re: [Haskell-cafe] Strange parallel behaviour with Ubuntu Karmic / GHC 6.10.4

2009-11-15 Thread Neil Brown
Michael Lesniak wrote: Hello, I'm currently developing some applications with explicit threading using forkIO and have strange behaviour on my freshly installed Ubuntu Karmic 9.10 (Kernel 2.6.31-14 SMP). Setup: Machine A: Quadcore, Ubuntu 9.04, Kernel 2.6.28-13 SMP Machine B: AMD Opteron 875,

Re: [Haskell-cafe] What does the `forall` mean ?

2009-11-12 Thread Neil Brown
Eugene Kirpichov wrote: 2009/11/12 Andrew Coppin andrewcop...@btinternet.com: Even I am still not 100% sure how placing forall in different positions does different things. But usually it's not something I need to worry about. :-) To me it does not look like it does different things:

Re: [Haskell-cafe] Cabal upload issue

2009-11-12 Thread Neil Brown
Jeremy O'Donoghue wrote: Hi all, I'm in the process of trying update the revisions of wx (part of wxHaskell) on hackage. I'm getting an error I find slightly surprising: ... Library if flag(splitBase) build-depends: base = 3, wxcore = 0.12.1.1, stm Change this last line to base

Re: [Haskell-cafe] Observer pattern in Haskell?

2009-11-09 Thread Neil Brown
Andy Gimblett wrote: Hi all, I've been doing some GUI programming recently, using wx. To help manage dependencies between state and UI elements, I looked for a Haskell version of the Observer design pattern, and I found an implementation written by Bastiaan Heeren of ou.nl [1]. Now,

Re: [Haskell-cafe] Observer pattern in Haskell?

2009-11-09 Thread Neil Brown
Andy Gimblett wrote: was a bit surprised at first that the observers were called synchronously. Asynchronous is what I'd expect, and it's also harder to code the asynchronous handlers wrongly. One blocking call (such as putMVar) in a synchronous handler can screw up your whole program by

Re: [Haskell-cafe] Names for properties of operators

2009-11-08 Thread Neil Brown
Hi, Thanks for the replies so far. If it helps, after I sent my post, I spotted a couple of arithmetic examples: Neil Brown wrote: 2: (a % b) % c = (a % c) % b Division (on rationals) obeys this property (a / b) / c = (a / c) / b -- which is actually equal to a / (b * c), but that doesn't

[Haskell-cafe] Names for properties of operators

2009-11-07 Thread Neil Brown
Hi, We have names for properties of operators/functions. For example, if this holds: a % b = b % a for some operator %, we say that % is commutative. Similarly, if this holds: (a % b) % c = a % (b % c) we say that % is associative. Is there a name for this property, which I'm

[Haskell-cafe] Are all arrows functors?

2009-11-03 Thread Neil Brown
Hi, I was thinking about some of my code today, and I realised that where I have an arrow in my code, A b c, the type (A b) is also a functor. The definition is (see http://www.haskell.org/ghc/docs/latest/html/libraries/base/Control-Arrow.html): fmap = (^) -- Or, in long form: fmap f x =

Re: [Haskell-cafe] is proof by testing possible?

2009-10-12 Thread Neil Brown
Dan Piponi wrote: On Mon, Oct 12, 2009 at 10:42 AM, muad muad.dib.sp...@gmail.com wrote: Is it possible to prove correctness of a functions by testing it? consider a function of signature swap :: (a,b) - (b,a) We don't need to test it at all, it can only do one thing, swap its

Re: [Haskell-cafe] ANN: text 0.5, a major revision of the Unicode text library

2009-10-11 Thread Neil Brown
Bryan O'Sullivan wrote: On Fri, Oct 9, 2009 at 8:33 AM, Jeremy Shaw jer...@n-heptane.com mailto:jer...@n-heptane.com wrote: What are the chances of seeing a, instance Data Text, some day? I might as well follow up here, since I've sent Jeremy a couple of messages on this subject. I

Re: [Haskell-cafe] apply function arguments in a list

2009-10-05 Thread Neil Brown
Michael Mossey wrote: If I have a list containing the arguments I want to give to a function, is there a general way to supply those arguments in a compact syntax? In other words, I could have args = [1,2,3] f x y z = ... I would write t = f (args!!0) (args!!1) (args!!2) but there may be

[Haskell-cafe] Control.Exception base-3/base-4 woes

2009-09-11 Thread Neil Brown
Hi, In my CHP library I need to do some exception catching. I want the library to work on GHC 6.8 (with base-3 -- this is the current version in Ubuntu Hardy and Jaunty, for example) and GHC 6.10 (which comes with base-4). But base-3 and base-4 need different code for exception catching

Re: [Haskell-cafe] Got problems with classes

2009-08-17 Thread Neil Brown
Hi, One reason (there may be more) is as follows: Grigory Sarnitskiy wrote: class Configuration c where getParticleI :: (Particle p) = c - Int - p This type signature declares that for any type c that has a Configuration instance (and an Int), you can give me back something that is of

Re: [Haskell-cafe] Line drawing algorithm

2009-07-17 Thread Neil Brown
CK Kashyap wrote: Hi All, I am working on a diagraming utility in Haskell. I started with line drawing. I am doing the basic stuff using the y = mx + c formula to draw a line between (x1,y1) and (x2,y2) Hi, Are you doing this to learn Haskell, learn about drawing lines, or to just get it

Re: [Haskell-cafe] coding standard question

2009-06-22 Thread Neil Brown
Jules Bean wrote: I've been using GHC for years and my honest opinion is that the warnings very rarely flag an actual maintainability problem in the code I write, and very frequently annoying highlight something I knew I was doing, and did quite deliberately - most often inexhaustive patterns

Re: [Haskell-cafe] how to #include files within parsec ... without unsafePerformIO?

2009-06-18 Thread Neil Brown
Leonard Siebeneicher wrote: Dear reader, I wonder whether there is a 'general' working solution to include files within a parsec parser. Without the need of unsafePerformIO. At least in parsec 2, I don't think so. Our solution was to read in the main file, tokenise it (using Alex),

Re: [Haskell-cafe] Confusion on the third monad law when using lambda abstractions

2009-06-18 Thread Neil Brown
Clicking on the source code link reveals that enum2 is used in the where clause. It's not important to the transformation that Jake was performing. In essence, = is the monadic version of . (function composition) and as explained, it can be used to do some pointfree-like programming in the

  1   2   >