Re: [Haskell-cafe] HUnit and table-driven tests

2012-08-07 Thread Dean Herington
At 4:30 PM -0700 8/5/12, Matthew wrote: On Sun, Aug 5, 2012 at 12:32 AM, Henk-Jan van Tuyl hjgt...@chello.nl wrote: On Sun, 05 Aug 2012 03:21:39 +0200, Matthew wonderzom...@gmail.com wrote: I've got a function which takes in two chars, describing a playing card and a suit. An example would

Re: [Haskell-cafe] pointer equality

2011-07-21 Thread Dean Herington
For the following expression, I would consider a True result a false positive: let x = x :: Int in x == x Dean ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

[Haskell-cafe] Helsinki Haskellers?

2011-07-21 Thread Dean Herington
Hi, Cafe, My wife, a biologist, will attend a conference outside Helsinki in mid-September. I've decided to accompany her on the trip to Finland. Are there any Haskellers in the area who might be interested in an informal meetup? I'd also welcome any suggestions on what to see, do, eat,

Re: [Haskell-cafe] Unexpected results from ExitCode

2010-11-03 Thread Dean Herington
At 8:45 PM -0700 11/3/10, Peter Schmitz wrote: I have a program (test.hs): module Main (main) where import System.Exit main :: IO ExitCode main = do return (ExitFailure 1) In another program, I invoke it via 'system': exitCode - system .\\test.exe case (exitCode) of

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

2010-10-06 Thread Dean Herington
At 4:43 PM -0400 10/6/10, Sterling Clover wrote: On Oct 6, 2010, at 5:39 AM, Simon Marlow wrote: A slightly different suggestion from Simon PJ and myself (we agreed on something syntax-related :-) is the following: \case 1 - f 2 - g where the two-token sequence '\ case'

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

2010-10-05 Thread Dean Herington Elizabeth Lacey
At 3:36 AM -0600 10/5/10, Luke Palmer wrote: On Mon, Oct 4, 2010 at 9:04 PM, Dean Herington heringtonla...@mindspring.com wrote: With respect to datatype destructing functions, the Prelude has: maybe :: b - (a - b) - Maybe a - b either :: (a - c) - (b - c) - Either a b - c which suggests

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

2010-10-04 Thread Dean Herington
At 12:05 PM +0200 10/4/10, Christopher Done wrote: On 4 October 2010 10:55, Bulat Ziganshin bulat.zigans...@gmail.com wrote: Hello Ketil, Monday, October 4, 2010, 11:30:48 AM, you wrote: Prelude (if then Haskell else Cafe) False lambda-if is easily implemented in terms of usual

Re: [Haskell-cafe] Re: Can we come out of a monad?

2010-08-02 Thread Dean Herington
At 8:29 PM -0400 8/2/10, Brandon S Allbery KF8NH wrote: On 8/2/10 19:59 , aditya siram wrote: Agreed. In fact I have the most trouble imagining what Haskell code looked like before monads. IIRC the type of main was something like [Request] - [Response]. Actually, the Haskell 1.2 report

Re: [Haskell-cafe] music-related problem

2010-07-21 Thread Dean Herington
At 11:53 AM -0700 7/4/10, Michael Mossey wrote: Wondering if I could get some suggestions for coding this problem. A musical document (or score) consists primarily of a list of measures. A measure consists primarily of lists of items. We'll consider only one kind of item: a note. Items have a

[Haskell-cafe] 64-bit #const with hsc2hs?

2010-07-12 Thread Dean Herington
Does anyone know if I can bring a 64-bit (long long or unsigned long long) value from C-land into Haskell via hsc2hs? #const on such a value seems to provide only the low 32 bits, at least in my environment (Haskell Platform 2009.2.0.2 on Windows). I've tried to create a 64-bit variant of

[Haskell-cafe] Re: Asynchronous exception wormholes kill modularity

2010-04-07 Thread Dean Herington
Is there any reason not to use the more standard uninterruptible instead of noninterruptible? Dean ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: Re[Haskell-cafe] [2]: Threading and FFI

2010-02-20 Thread Dean Herington
At 2:53 PM -0800 2/18/10, Yves Parès wrote: Ben Franksen wrote: You can leave them unsafe if you are sure that 1) they do not call (back) any function in your program 2) they do not block (or not long enough that it bothers you) Otherwise they are no less safe that the safe calls. If (1) is

[Haskell-cafe] Re: ANNOUNCE: deepseq-1.0.0.0

2009-11-17 Thread Dean Herington
At 11:00 AM + 11/17/09, Simon Marlow wrote: I've just uploaded deepseq-1.0.0.0 to Hackage http://hackage.haskell.org/package/deepseq This provides a DeepSeq class with a deepseq method, equivalent to the existing NFData/rnf in the parallel package. I'll be using this in a newly

Re: [Haskell-cafe] Need some help with an infinite list

2009-06-16 Thread Dean Herington
At 4:25 PM +1200 6/17/09, Richard O'Keefe wrote: On 17 Jun 2009, at 2:01 pm, Richard O'Keefe wrote: On second thoughts, let strings = : [pref++[last] | pref - strings, last - ['a'..'z']] in tail strings seems more Haskellish than the stupidly clever counting-based code I had in mind.

Re: [grapefruit] can't run Grapefruit

2009-05-25 Thread Dean Herington
-0.0.0.0 ... linking ... done. *** Exception: Cannot initialize GUI. At 3:58 PM -0400 5/23/09, Dean Herington wrote: I'm trying to give Grapefruit a try. I installed it as described in section 4.1 of http://www.haskell.org/haskellwiki/Grapefruit. When I tried to run the Simple.hs example, I got

can't run Grapefruit

2009-05-23 Thread Dean Herington
I'm trying to give Grapefruit a try. I installed it as described in section 4.1 of http://www.haskell.org/haskellwiki/Grapefruit. When I tried to run the Simple.hs example, I got the problem shown below. Any ideas? My machine is running Windows XP Pro 2002 SP3. TIA Dean GHCi, version

[Haskell-cafe] hsffig and duplicate typedef declarations

2009-05-13 Thread Dean Herington
I have a large body of C/C++ code at work that I'd like to be able to access from Haskell via FFI. Because the interface to this code is broad, hsffig would seem to be ideal for the task. I've run across one serious hitch, though. The existing #include file graph is complicated and ends up

Re: [Haskell-cafe] hsffig and duplicate typedef declarations

2009-05-13 Thread Dean Herington
At 9:59 PM -0700 5/13/09, Don Stewart wrote: heringtonlacey: I have a large body of C/C++ code at work that I'd like to be able to access from Haskell via FFI. Because the interface to this code is broad, hsffig would seem to be ideal for the task. I've run across one serious hitch,

Re: [Haskell-cafe] hsffig and duplicate typedef declarations

2009-05-13 Thread Dean Herington
At 10:12 PM -0700 5/13/09, Don Stewart wrote: heringtonlacey: At 9:59 PM -0700 5/13/09, Don Stewart wrote: heringtonlacey: I have a large body of C/C++ code at work that I'd like to be able to access from Haskell via FFI. Because the interface to this code is broad, hsffig would seem

Re: [Haskell-cafe] using haskell for a project

2009-05-02 Thread Dean Herington
At 7:17 PM +0200 5/2/09, Nicolas Martyanoff wrote: Content-Type: multipart/signed; micalg=pgp-sha1; protocol=application/pgp-signature; boundary=ibTvN161/egqYuK8 Content-Disposition: inline Hi, I don't think I already presented myself; I'm Nicolas, a 23y french student, trying to learn

Re: [Haskell-cafe] libgmp for GHC 6.10.1 on Mac OS X 10.5

2009-03-17 Thread Dean Herington
, at 10:54 PM, Dean Herington wrote: I'm trying to install GHC 6.10.1 on Mac OS X 10.5 (PowerPC). I installed Xcode 3.1.2. I built libgmp 4.2.4 and installed it in /usr/local/lib. When I do ./configure in GHC's dist directory, however, I get: bash-3.2$ ./configure checking build system type

[Haskell-cafe] libgmp for GHC 6.10.1 on Mac OS X 10.5

2009-03-15 Thread Dean Herington
I'm trying to install GHC 6.10.1 on Mac OS X 10.5 (PowerPC). I installed Xcode 3.1.2. I built libgmp 4.2.4 and installed it in /usr/local/lib. When I do ./configure in GHC's dist directory, however, I get: bash-3.2$ ./configure checking build system type... powerpc-apple-darwin9.6.0

Re: [Haskell-cafe] Proof of induction case of simple foldl identity.

2009-03-14 Thread Dean Herington
At 8:45 PM + 3/14/09, R J wrote: Can someone provide the induction-case proof of the following identity: foldl (-) ((-) x y) ys = (foldl (-) x ys) - y If foldl is defined as usual: foldl :: (b - a - b) - b - [a] - b foldl f e [] = e foldl f e (x :

Re: [Haskell-cafe] An ugly zip3 problem..

2008-03-21 Thread Dean Herington
I like Tillmann's cleanup. Here's another variation (warning: untested code). filter3 :: (FilterWindow3 - Double) - Dataset - Dataset filter3 f3 [] = [] filter3 f3 dss@(d:ds) = map f3 $ zip3 (d:dss) dss (shiftForward dss) -- Given a nonempty list, drops the first element and --

Re: [Haskell-cafe] more on the Beautiful Concurrency function withdraw application ...

2007-12-23 Thread Dean Herington
At 12:19 AM -0600 12/24/07, Galchin Vasili wrote: module Main where import Control.Concurrent.STM import Control.Concurrent import System.Random type Account = TVar Int transfer :: Account - Account - Int - IO () transfer from to amount = atomically (do {deposit to amount;

Fwd: Re: [Haskell-cafe] more on the Beautiful Concurrency function withdraw application ...

2007-12-23 Thread Dean Herington
Date: Mon, 24 Dec 2007 01:44:16 -0500 To: Galchin Vasili [EMAIL PROTECTED], haskell-cafe@haskell.org From: Dean Herington [EMAIL PROTECTED] Subject: Re: [Haskell-cafe] more on the Beautiful Concurrency function withdraw application ... Cc: Bcc: X-Attachments: At 12:19 AM -0600 12/24/07

Re: HUnit 1.2.0.0 on 6.8.1 vs 1.1.1 on 6.6.1

2007-12-10 Thread Dean Herington
AM, Ian Lynagh mailto:[EMAIL PROTECTED][EMAIL PROTECTED] wrote: This is caused by a change in the HUnit library, from assertFailure msg = ioError (userError (hunitPrefix ++ msg)) to assertFailure msg = E.throwDyn (HUnitFailure msg) I've had no luck contacting Dean Herington using

Re: [Haskell-cafe] What is the role of $!?

2007-12-10 Thread Dean Herington
Thanks, Tom, for a nice description of lazy evaluation. Besides the minor things Derek pointed out, there's one more subtle but important thing to correct: At 7:29 AM + 11/29/07, Thomas Davie wrote: $! is the special case, which means strictly apply. It evaluates its argument first,

[Haskell-cafe] Text.XHtml link broken

2007-07-28 Thread Dean Herington
The Haddock documentation for Text.XHtml (at http://www.haskell.org/ghc/docs/latest/html/libraries/xhtml/Text-XHtml.html) refers to http://www.cse.ogi.edu/~andy/html/intro.htm, but that link is broken. Does anyone know where to find the intended document?

Re: [Haskell-cafe] avoiding command window with wxHaskell on Windows?

2007-06-30 Thread Dean Herington
At 8:13 PM +0300 6/30/07, Esa Ilari Vuokko wrote: On 6/30/07, Duncan Coutts [EMAIL PROTECTED] wrote: On Fri, 2007-06-29 at 23:22 -0400, Dean Herington wrote: Date: Mon, 25 Jun 2007 20:19:50 -0400 With gtk2hs, using -optl-mwindows as a command line option for GHC lets me get rid

Fwd: Re: [Haskell-cafe] avoiding command window with wxHaskell on Windows?

2007-06-29 Thread Dean Herington
Date: Mon, 25 Jun 2007 20:19:50 -0400 To: Jens Fisseler [EMAIL PROTECTED] From: Dean Herington [EMAIL PROTECTED] Subject: Re: [Haskell-cafe] avoiding command window with wxHaskell on Windows? Cc: haskell-cafe@haskell.org, [EMAIL PROTECTED] At 10:10 PM +0200 6/23/07, Jens Fisseler wrote: On Sat

[Haskell-cafe] avoiding command window with wxHaskell on Windows?

2007-06-23 Thread Dean Herington
I'm experimenting with wxHaskell. I created a small program with it on Windows. (Well, small in source form, not so small in binary form :-) The program runs fine when invoked at a Windows command line. But if I double-click the .exe file, I get a command window that hangs around (but

[Haskell-cafe] WMI via Haskell?

2007-06-21 Thread Dean Herington
Has anyone built a library providing an interface to WMI (Windows Management Instrumentation) in Haskell? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: Re[2]: [Haskell-cafe] Why do I have to specify (Monad m) here again?

2007-02-18 Thread Dean Herington
At 12:42 AM +0400 2/19/07, David Tolpin wrote: On Mon, 19 Feb 2007 00:30:47 +0400, Sebastian Sylvan [EMAIL PROTECTED] wrote: Well, I guess the H98 report would be a good start. But there are multiple tutorials on type classes that will cover this, most of which are available from haskell.org

Re: [Haskell-cafe] State monad strictness - how?

2007-01-10 Thread Dean Herington
At 11:02 AM +0200 1/10/07, Yitzchak Gale wrote: Unfortunately, the current situation is that State is only available as a lazy monad, and StateT is only available as a strict monad. [...] The obvious solution would be to have available both a lazy and a strict version of each monad: State,

[Haskell-cafe] State monad strictness - how?

2007-01-09 Thread Dean Herington
I can't seem to figure out how to achieve strictness in the context of the State monad. Consider: import Control.Monad.State try count = print final where (_,final) = runState prog 0 prog = sequence_ (replicate count tick) tick :: State Int Int tick = do n - get

Re: [Haskell-cafe] 2D Array

2006-12-03 Thread Dean Herington
At 12:25 PM +1000 12/4/06, Tony Morris wrote: I wish to pass a 2 dimensional array to use in a back-tracking algorithm. Since I will be doing lots of inserts, a Data.Array is unsuitable. It seems that a Map Int (Map Int a) is the most suitable structure, but this seems cumbersome. Is there

Re: [Haskell-cafe] Distributing monadic(?) functions across dyadic functions

2006-04-02 Thread Dean Herington
At 11:58 AM -0700 4/2/06, Jared Updike wrote: Is there a common way (standard libs, higher order) to express the lambda part below? It's not particulary complicated but I think it is not higher-order enough unionBy (\x y - fst x == fst y) listOfPairs1 listOfPairs2 Something like distribute

Re: [Haskell] how to write an interactive program ? gui library to use ?

2006-02-25 Thread Dean Herington
At 7:31 PM +0100 2/24/06, minh thu wrote: Hi all, 1/ I'd like to know how can I implement an interactive program (an editor) in haskell where some things have to be updated. The things can be text in a word processor, or a pixel array in a 2d graphics editor, and so on. Have I to pass the

RE: [Haskell-cafe] Where to start about writing web/HTTP apps ?

2005-09-12 Thread Dean Herington
At 11:44 PM + 9/10/05, Thomas Spriggs wrote: From: gary ng [EMAIL PROTECTED] fac n = foldr (\x g n - g (x*n)) id [1..n] 1 Would appreciate if someone can knock on my head and tell me what is going on in it. Well, here goes. The way the lambda function/foldr thing evaluates, the

Re: [Haskell-cafe] Concurrency question

2005-09-05 Thread Dean Herington
At 9:45 PM +0400 9/4/05, Dmitry Vyal wrote: Donald Bruce Stewart wrote: Maybe your loop does no allocations, so the scheduler can't get in and do a context switch. You could put the computation in an external program, and run it over a fork, using unix signals in the external program to

(^) causes crash

2005-08-31 Thread Dean Herington
With GHC 6.4, interpreted or compiled, on Windows and Mac OS X, evaluating the expression (4^(4^44))::Integer causes a crash. On Mac, the message is: ___ ___ _ / _ \ /\ /\/ __(_) / /_\// /_/ / / | | GHC Interactive, version 6.4, for Haskell 98. / /_\\/ __ / /___| |

Re: [Haskell-cafe] Need a concurrency advice

2005-08-22 Thread Dean Herington
At 3:39 PM + 8/22/05, Dinh Tien Tuan Anh wrote: Hi, Basically, my program has 7 threads for 7 rules Rule1 Rule2 .. .. .. and they all use pattern-mattching (a rule MUST be evaluated by a thread) The problem is there are some overlapping rules, which match the same pattern and diifferent

RE: [Haskell] stack overflow - nonobvious thunks?

2005-07-28 Thread Dean Herington
Title: RE: [Haskell] stack overflow - nonobvious thunks? The following version seems to do the trick (and still remain quite readable). It worked for 1 as well. import Data.Map as Map import System.Random import Data.List (foldl') table :: (Ord a) = [a] - [(a,Int)] table xs =

Re: [Haskell-cafe] Looking for lost library

2005-06-09 Thread Dean Herington
At 7:23 PM -0400 6/9/05, Samuel Bronson wrote: On 05/06/05, Dean Herington [EMAIL PROTECTED] wrote: I believe you're describing: http://portal.acm.org/citation.cfm?doid=581478.581482 . I don't suppose you know of any place to get it *free*? I found it online at: http://www.cse.ogi.edu

Re: [Haskell-cafe] Looking for lost library

2005-06-05 Thread Dean Herington
At 8:34 PM +0200 6/5/05, Gracjan Polak wrote: Some time ago I read a beautiful paper about variables that had their dependencies automatically tracked and could trigger recalculation when changed. Prototype was implemented in OCaml, then reimplemented in Haskell (using monads). I would like

Re: simple question

2005-04-02 Thread Dean Herington
At 10:56 PM +0200 4/2/05, Benjamin Franksen wrote: On Saturday 02 April 2005 22:29, Peter Hercek wrote: What is $ function good for? Mostly for avoiding parentheses. $ is right associative and has lowest precedence, whereas normal application is left associative and binds most tightly: f $ g $

[Haskell] client-side web scripting in Haskell?

2005-03-03 Thread Dean Herington
Is there any practical way to do client-side web scripting in Haskell? All the references I have found to HaskellScript seem quite out of date. Dean ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell

Re: [Haskell-cafe] Re: new Haskell hacker seeking peer review

2005-02-18 Thread Dean Herington
At 5:27 PM -0800 2/18/05, Isaac Jones wrote: John Goerzen [EMAIL PROTECTED] writes: Here's an alternative: module Main where (snip john's version) And what list would be complete without a points-free version. It doesn't operate on stdin, though like John's does: pointsFreeCat :: IO ()

Re: DeepSeq.lhs [was: Re: [Haskell] Force evaluation]

2004-12-13 Thread Dean Herington
At 4:05 PM + 12/8/04, Ben Rudiak-Gould wrote: Dean Herington wrote: deepSeq :: DeepSeq a = a - b - b I should point out that deepSeq with this type is the composition of two simpler operations: deepSeq = seq . eval where eval :: DeepSeq a = a - a eval ties a demand for a value

DeepSeq.lhs [was: Re: [Haskell] Force evaluation]

2004-12-06 Thread Dean Herington
Here's the latest version of my DeepSeq module. Dean DeepSeq.lhs -- deep strict evaluation support The `DeepSeq` class provides a method `deepSeq` that is similar to `seq` except that it forces deep evaluation of its first argument before returning its second argument. Instances of `DeepSeq` are

RE: Text.ParserCombinators.Parsec requires -package text.

2004-09-06 Thread Dean Herington
At 1:52 PM +0100 9/6/04, Simon Marlow wrote: On 06 September 2004 13:43, Simon Peyton-Jones wrote: * The link step needs -package flags, because it only gets .o files, and we didn't want it to start hunting through .hi files (though that would be possible) Just to expand on this a little: it's

#! for GHC?

2004-03-08 Thread Dean Herington
Can GHC be invoked somehow via the #! mechanism? Put another way, is there a GHC analogue to runhugs? ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Re: Another fold question

2003-11-06 Thread Dean Herington
At 4:27 AM + 2003/11/06, Patty Fong wrote: data Music = Note Pitch Octave Duration | Silence Duration | PlayerPar Music Music | PlayerSeq Music Music | Tempo (Ratio Int) Music data Pitch = Cf | C | Cs type Octave = Int type Duration = Ratio Int foldMusic

Re: interact behaves oddly if used interactively

2003-10-01 Thread Dean Herington
On Wed, 1 Oct 2003, Keith Wansbrough wrote: Can actually someone supply an implementation of something like interact that does no pipelining for the argument id? Simply doing putStr !$ f !$ s was not enough! Yes, of course. Your code above only forces the evaluation of the first

exitImmediately's signature

2003-10-01 Thread Dean Herington
Is there a good reason why `exitImmediately` (in System.Posix.Process as well as other places) shouldn't return `IO a` instead of `IO ()`? ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell

type class problem

2003-09-29 Thread Dean Herington
Can someone explain why the following doesn't work? Is there some other way to achieve the same effect (declaring a set of instances for pair-like types in one go)? Thanks. Dean swan(108)% cat Test1.hs {-# OPTIONS -fglasgow-exts #-} class R r where rId :: r - String class (R r) = RT r t

Re: can't derive Monad

2003-07-29 Thread Dean Herington
to approximate? Could one try to type check and bail out if that fails? But I'll put your example in a comment in the source code as an example of a safe one that's rejected! Simon | -Original Message- | From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On | Behalf Of Dean Herington

can't derive Monad

2003-07-28 Thread Dean Herington
The following may not be a bug, but it surprised me. Why does the circularity cause GHC fits? swan(106)% cat NestStateT.hs {-# OPTIONS -fglasgow-exts #-} import Control.Monad.State newtype S1 = S1 [T1 ()] newtype T1 a = T1 (StateT S1 IO a ) deriving Monad main = undefined swan(105)% ghci

Re: Function composition and currying

2003-07-17 Thread Dean Herington
Tom Pledger wrote: K. Fritz Ruehr writes: : | But Jerzy Karczmarczuk enlightened me as to the full generality possible | along these lines (revealing the whole truth under the influence of at | least one beer, as I recall). Namely, one can define a sequence of | functions (let's use a

shorthand `case` for if/else if chain

2003-07-17 Thread Dean Herington
I've thought for a while that it would be nice to have a shorthand for `if` / `else if` chains. For example: if a b then less else if a == b then equal else greater can be rendered with more structure as: case () of _ | a b - less | a == b- equal

showing Handle is impure

2003-07-15 Thread Dean Herington
The `shows` function for type `Handle` is inappropriately impure. In my opinion, showing a handle should merely identify it as a handle and distinguish it from other handles. The information currently provided by showing a handle should be provided with some other function; that function should

Re: Overlapping instances in existentials

2003-06-20 Thread Dean Herington
Dylan Thurston wrote: On Thu, Jun 19, 2003 at 11:08:35AM -0500, Ed Komp wrote: | type BaseType = Either Integer ( Either Bool () ) | | type Value = (Either Double BaseType) | | data Foo = forall x. (SubType x BaseType) = MkFoo x | | test :: Foo - Value | test

broken web link

2003-06-16 Thread Dean Herington
FYI: On page http://www.haskell.org/ghc/ the text The Haskell Wish List is linked to http://www.pms.informatik.uni-muenchen.de/forschung/haskell-wish-list/. That page is woefully out of date; in particular, access to the wish list fails. ___

Re: problems with working with Handles

2003-06-13 Thread Dean Herington
Niels Reyngoud wrote: Hello all, Thanks for your replies on our previous posts. To avoid the lazy behaviour, we tried to write our own IO module IOExts2 which basically redifnes readFile, writeFile and appendFile to make sure they use binary-mode and strict behaviour. The libary is as

Re: problems with working with Handles

2003-06-12 Thread Dean Herington
On Thu, 12 Jun 2003, Niels Reyngoud wrote: Hello, We're two students from the department of computer science at the University of Utrecht (the Netherlands), and we're havind some severe difficulties in working with file handles in Haskell. Consider for example the following program:

Re: IOError

2003-06-12 Thread Dean Herington
On Thu, 12 Jun 2003, Wolfgang Jeltsch wrote: On Thursday, 2003-06-12, 18:01, CEST, Filip wrote: Hi, I wrote something like let t = try (hGetLine h1) and I would like to check is it EOFError or not. How can I do this ?? Thanks Hello, the above code assigns the I/O action

Re: floating point literals

2003-03-18 Thread Dean Herington
Simon Marlow wrote: On Mon, Mar 17, 2003 at 10:33:47AM +, Ross Paterson wrote: GHC doesn't recognize literals like 9e2, and nor does lex. Correction: GHC doesn't recognize 9e2 lex is confused by 0xy, 0oy, 9e+y and 9.0e+y Fixed GHC, I'll leave lex to someone more familiar with

Re: data vs. newtype, abstractly

2003-03-09 Thread Dean Herington
On Sun, 9 Mar 2003, Hal Daume III wrote: well, yes, but if you export: mkN :: Int - N mkD :: Int - D or something like that, then they'll still bea ble to tell the difference, right? Well, yes, but I don't. In fact the type in question is an MVar which my abstraction ensures is always

deriving problem

2003-03-08 Thread Dean Herington
The attached program works under hugs -98 but fails with GHC 5.04.2 with: Params2b.hs:6: No instance for `Show (r String)' When deriving the `Show' instance for type `S' Params2b.hs:6: No instance for `Show (r Int)' When deriving the `Show' instance for type `S'

data vs. newtype, abstractly

2003-03-08 Thread Dean Herington
If a type that could be defined either by `data` or `newtype` (i.e., a single-constructor type) is exported abstractly (without its constructor), can the user of the type tell how the type was declared? Dean ___ Haskell mailing list [EMAIL PROTECTED]

Re: Posix.getFileStatus

2003-02-28 Thread Dean Herington
George Russell wrote: (2) The logical way of spotting whether a file is actually there is the queryFile function, documented for example here: http://haskell.cs.yale.edu/ghc/docs/latest/html/hslibs/files-and-directories.html But sadly the queryFile function does not appear to be in the

Re: child process statistics

2003-02-27 Thread Dean Herington
to wait4(), but I'm over my head here. Thanks in advance. Dean - Original Message - From: Dean Herington [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, February 26, 2003 16:17 Subject: child process statistics Does anyone know how to get the process statistics

no input files

2003-02-25 Thread Dean Herington
buzzard(150)% cat Two-part.hs main = return () buzzard(151)% ghc --make Two-part.hs ghc-5.04.2: chasing modules from: Two-part.hs Compiling Main ( Two-part.hs, ./Two-part.o ) ghc: linking ... buzzard(152)% ghc --make Two-part ghc-5.04.2: no input files Usage: For basic information, try

RE: thread blocked indefinitely

2003-02-25 Thread Dean Herington
On Tue, 25 Feb 2003, Simon Marlow wrote: Something like the following seems to be occurring. The program `Concurrent.forkIO`s several threads. Two of these auxiliary threads each fork a process (with `GHC.Conc.forkProcess`). Just as the second forked process is about to

Re: can this be written more easily?

2003-02-22 Thread Dean Herington
Ah, I see. Finite maps might be appropriate, then. Here's a sketch of how you might implement arraylike objects with finite maps. -- Array-like objects built from FiniteMaps -- Dean Herington, Feb. 22, 2003 module FMArray (FMArray, fmArray, get, set, update) where import Array import

Re: Simple problem from Hudak's SOE

2003-02-22 Thread Dean Herington
On Fri, 21 Feb 2003, M. Parker wrote: I'm a real newbie to Haskell, and I'm having trouble with a particular problem dealing with higher-order functions. Exercise 5.9 in Hudak's School of Expression asks us to write a function, makeChange, s.t. it makes change for a given amount using

thread blocked indefinitely

2003-02-20 Thread Dean Herington
I'm getting intermittent thread blocked indefinitely errors with GHC 5.04.2. My program uses modules Concurrent and Posix heavily. In particular, I fork processes (now with GHC.Conc.forkProcess) and handle SIGCHLD signals to determine when the processes have finished. The symptoms seem similar

Re: thread blocked indefinitely

2003-02-20 Thread Dean Herington
I've attached some clues below the quoted message. On Thu, 20 Feb 2003, Dean Herington wrote: I'm getting intermittent thread blocked indefinitely errors with GHC 5.04.2. My program uses modules Concurrent and Posix heavily. In particular, I fork processes (now with GHC.Conc.forkProcess

Re: two easy questions

2003-02-20 Thread Dean Herington
You can't derive Enum Player automatically, but you can program it. Here's one way how, using shorter example names. -- Dean data E1 = E1a | E1b | E1c deriving (Enum, Bounded, Show, Read) data E2 = E2a | E2b | E2c deriving (Enum, Bounded, Show, Read) data E = E1 E1 | E2 E2deriving (Show,

Re: two easy questions

2003-02-20 Thread Dean Herington
Oops! Small bug. See below. Dean Herington wrote: You can't derive Enum Player automatically, but you can program it. Here's one way how, using shorter example names. -- Dean data E1 = E1a | E1b | E1c deriving (Enum, Bounded, Show, Read) data E2 = E2a | E2b | E2c deriving (Enum

Re: MArray and runST

2003-02-14 Thread Dean Herington
Simon Peyton-Jones wrote: Interesting example! | Coincidentally, I tripped over this subtlety myself just last night. (I, | too, often use '$' to avoid nested parentheses.) I concluded it was an | instance of the partial-application restriction that I found described in | section 7.11.4

Re: Yet another weakly defined bug report

2003-02-14 Thread Dean Herington
: Dean Herington [EMAIL PROTECTED] writes: Ketil Z. Malde wrote: -- | add data from a file to the histogram addFile :: FiniteMap String Int - String - IO (FiniteMap String Int) addFile fm name = do x - readFile name return (addHist fm x) I changed this to read x

Re: Yet another weakly defined bug report

2003-02-14 Thread Dean Herington
: Dean Herington [EMAIL PROTECTED] writes: Ketil Z. Malde wrote: -- | add data from a file to the histogram addFile :: FiniteMap String Int - String - IO (FiniteMap String Int) addFile fm name = do x - readFile name return (addHist fm x) I changed this to read x

Re: silly questions about 'seq'

2003-02-14 Thread Dean Herington
On Fri, 14 Feb 2003, John Meacham wrote: This seems to be contrary to how i thought haskell was implemented in ghc (and probably other systems). I was under the impression that thunks in ghc were opaque except for the code address at the begining of them. in order to evaluate something you

Re: Yet another weakly defined bug report

2003-02-13 Thread Dean Herington
Ketil Z. Malde wrote: Simon Marlow [EMAIL PROTECTED] writes: -- | add data from a file to the histogram addFile :: FiniteMap String Int - String - IO (FiniteMap String Int) addFile fm name = do x - readFile name return (addHist fm x) -- |

MArray and newSTUArray

2003-02-13 Thread Dean Herington
The MArray class in Data.Array.MArray is a very nice abstraction. However, when creating an array whose type partakes of MArray, say STUArray, I find myself defining and using a type-specific creation function, such as: newSTUArray :: (MArray (STUArray s) e (ST s), Ix i) = (i, i) - e

Re: a monadic if or case?

2003-02-13 Thread Dean Herington
Here's another way to sugar if-then-else that works like C's ?: and Lisp's cond: import Monad (liftM3) import Directory (doesFileExist, doesDirectoryExist) infix 1 ?, ?? (?) :: Bool - a - a - a (c ? t) e = if c then t else e (??) :: (Monad m) = m Bool - m a - m a - m a (??) = liftM3 (?) main

too hard for cunning newtype deriving

2003-02-05 Thread Dean Herington
buzzard(131)% cat Bug6.hs {-# OPTIONS -fglasgow-exts #-} import Control.Monad.State data S1 = S1 (M1 Int) newtype M1 a = M1 { unM1 :: StateT S1 IO a } deriving (Monad) data S2 = S2 (M2 Int) newtype M2 a = M2 { unM2 :: S2 - (a, S2) } instance Monad M2 where return a = M2 $ \s - (a, s) m = k

confusing error message

2003-02-05 Thread Dean Herington
buzzard(118)% cat Bug5.hs import Control.Monad.State data S = S Int newtype M a = M (StateT S IO a) deriving (Monad) main = return () buzzard(119)% ghc -c Bug5.hs Bug5.hs:3: Can't make a derived instance of `Monad M' (too hard for cunning newtype deriving) When deriving instances

garbled error message

2003-01-27 Thread Dean Herington
With the attached files, I get an apparently garbled error message during compilation. buzzard(105)% make ghc --make -package data -package concurrent -package posix Data ghc-5.04.2: chasing modules from: Data Compiling Repr ( Repr.hs, Repr.o ) Compiling Data ( Data.hs,

Re: existential typing question

2003-01-27 Thread Dean Herington
2003, Dean Herington wrote: Can someone explain why the type declaration for `g` is required in the following? class RT r t where rt :: r - t data D t = Dt t | forall r. RT r t = Dr r f :: D t - D t f = g where -- g :: D t - D t g (Dr r) = Dt (rt r) As given

Re: seeking ideas for short lecture on type classes

2003-01-26 Thread Dean Herington
On Sun, 26 Jan 2003, Norman Ramsey wrote: In a fit of madness, I have agreed to deliver a 50-minute lecture on type classes to an audience of undergraduate students. These students will have seen some simple typing rules for F2 and will have some exposure to Hindley-Milner type

existential typing question

2003-01-26 Thread Dean Herington
Can someone explain why the type declaration for `g` is required in the following? class RT r t where rt :: r - t data D t = Dt t | forall r. RT r t = Dr r f :: D t - D t f = g where -- g :: D t - D t g (Dr r) = Dt (rt r) As given above, the program evokes these error messages: with

RE: Exception handling in GHC

2003-01-24 Thread Dean Herington
On Fri, 24 Jan 2003, Sarah Thompson wrote: I've noticed some interesting behaviour: Prelude Control.Exception try (return (error e)) Prelude Control.Exception it Right *** Exception: e It would appear that when the result of this function is evaluated, the exception fires during

Re: A problem about hGetContents -- with another question

2003-01-23 Thread Dean Herington
I was unhappy with the use of `error` in my first solution, so I wrote a second solution that's more robust. It also demonstrates monadic style. The new solution is at the bottom. Dean On Thu, 23 Jan 2003, Dean Herington wrote: On Sun, 19 Jan 2003, Nick Name wrote: I got another

newtype deriving panic

2003-01-22 Thread Dean Herington
Given this program: {-# OPTIONS -fglasgow-exts #-} module Bug1 where import Control.Monad.State newtype T a = T (StateT Int IO a) deriving (MonadState) GHC 5.04.2 chokes: ghc-5.04.2: chasing modules from: Bug1 Compiling Bug1 ( Bug1.hs, ./Bug1.o ) ghc-5.04.2: panic! (the

higher-order typing errors

2003-01-22 Thread Dean Herington
I don't understand why GHC (I was using 5.04.2) should reject these two programs. {-# OPTIONS -fglasgow-exts #-} swap1 :: (forall a. a - a, forall a. a - a - a) - (forall a. a - a - a, forall a. a - a) swap1 (a, b) = (b, a) yields: Bug2.hs:3: parse error on input `,'

MonadPlus IO

2003-01-22 Thread Dean Herington
According to the Haddock documentation for Control.Monad at http://www.haskell.org/ghc/, `IO` is an instance of `MonadPlus`. 1. Where in documentation is this instance described? 2. Where in source code is this instance implemented? 3. Could links to the answers to 1 and 2 be added to the Haddock

Re: A problem about hGetContents -- with another question

2003-01-22 Thread Dean Herington
On Sun, 19 Jan 2003, Nick Name wrote: I got another trouble: I need to build a record type like Package { name :: String, version :: Int , mantainer :: String ... other fields ... } from a list of string of the form [Package: ... , Mantainer: ... , Version: ... , ... ] where the

  1   2   >