Re: FFI, signals and exceptions

2010-08-25 Thread Edward Z. Yang
Excerpts from Edward Z. Yang's message of Thu Aug 26 01:22:22 -0400 2010: I spent some time looking at the code, and I've been having a difficult time finding the thread ID of the worker thread that is performing the safe FFI call. The target TSO is the suspended Haskell thread, which afaict

Re: [Haskell-cafe] How to generate dependend values with QuickCheck

2010-08-25 Thread Edward Z. Yang
Excerpts from Jürgen Nicklisch-Franken's message of Wed Aug 25 23:32:51 -0400 2010: instance Arbitrary QCExample where arbitrary = let i1 = arbitrary i2 = fmap (* 2) i1 in liftM2 QCExample i1 i2 What's happening here is that you are evaluating the random

[Haskell-cafe] Failed inference: maybe bug?

2010-08-18 Thread Edward Z. Yang
On the prompting of napping, I humbly submit the following code to haskell-cafe: ezy...@javelin:~/Dev/haskell/generic-typeclass$ cat Bar.hs {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE FlexibleContexts #-} data Foo b = Foo class

[Haskell-cafe] Specific to General to Specific

2010-08-18 Thread Edward Z. Yang
Imagine that I have the following type-class: class (Monad (m n)) = NetworkMonad m n data NT n a instance NetworkMonad NT n data NQ n a instance NetworkMonad NQ n monadicValue :: NetworkMonad m n = m n () It defines some family of phantom monads, in this case NT n and

Re: [Haskell-cafe] Re: String vs ByteString

2010-08-14 Thread Edward Z. Yang
Excerpts from John Millikin's message of Sun Aug 15 01:32:51 -0400 2010: Also, despite the name, ByteString and Text are for separate purposes. ByteString is an efficient [Word8], Text is an efficient [Char] -- use ByteString for binary data, and Text for...text. Most mature languages have

Re: [Haskell-cafe] Re: String vs ByteString

2010-08-13 Thread Edward Z. Yang
Excerpts from Kevin Jardine's message of Fri Aug 13 16:37:14 -0400 2010: I find it disturbing that a modern programming language like Haskell still apparently forces you to choose between a representation for mostly ASCII text and Unicode. Surely efficient Unicode text should always be the

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

2010-08-10 Thread Edward Z. Yang
Excerpts from Ertugrul Soeylemez's message of Tue Aug 10 02:31:14 -0400 2010: There is no evalCont, there is runCont: runCont :: (a - r) - Cont r a - r Note that Cont/ContT computations result in a value of type 'r': newtype Cont r a = Cont ((a - r) - r) Yes, but if you pass in 'id'

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

2010-08-10 Thread Edward Z. Yang
Excerpts from Ertugrul Soeylemez's message of Tue Aug 10 03:40:02 -0400 2010: Then you can only run evalCont, if r = a, which makes that function quite pointless: evalCont :: Cont r r - r evalCont = runCont id Ah, yes, that was what I was imagining. I don't think the function is

Re: [Haskell-cafe] More Flexible Monad Transformer OR Bad Coding Style

2010-08-09 Thread Edward Z. Yang
Excerpts from aditya siram's message of Mon Aug 09 15:05:14 -0400 2010: Until test is called in 'main' we don't know the order of monads. In fact even the base monad is not know. All we know is that it uses the State and Writer monad. In each call to 'test' in main we can determine the stacking

Re: [Haskell-cafe] More Flexible Monad Transformer OR Bad Coding Style

2010-08-09 Thread Edward Z. Yang
Excerpts from Gábor Lehel's message of Mon Aug 09 15:39:49 -0400 2010: Actually, while I haven't even used monad transformers before (just read about them a lot), I was thinking that something like this might be the way to solve the lift . lift . lift . lift . foo problem on the one hand, and

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

2010-08-09 Thread Edward Z. Yang
Excerpts from Luke Palmer's message of Tue Aug 10 01:04:04 -0400 2010: Except, of course, you want the signature evalCont :: Cont r a - a Which is not possible. But I am not sure where all this discussion is coming from, Maybe and (r -) cannot be broken out of. Isn't that example

Re: FFI, signals and exceptions

2010-08-06 Thread Edward Z. Yang
Excerpts from Corey O'Connor's message of Fri Aug 06 16:15:21 -0400 2010: In your test cases that fail are your C computations foreign unsafe imports? First thing I checked. :-) They were safe imports, and the Haskell code did get called--just the C code kept marching on. Cheers, Edward

Re: [Haskell-cafe] Cabal LD errors

2010-08-01 Thread Edward Z. Yang
Excerpts from wren ng thornton's message of Sun Aug 01 21:06:07 -0400 2010: So I'm getting some weird linking errors from cabal-install when doing `cabal configure cabal build` Hello Wren, Could you run cabal with -v3 or so and attach the output somewhere? Cheers, Edward

FFI, signals and exceptions

2010-07-30 Thread Edward Z. Yang
Hello all, I am currently investigating techniques to nicely handle SIGINTs when FFI code is running. Yes, I know it sounds kind of crazy. Ignoring the problems of cleaning up the unceremoniously terminated C computation, I'm having difficulty getting the FFI to /stop/ running when I get the

Re: [Haskell-cafe] Definition of List type?

2010-07-30 Thread Edward Z. Yang
Excerpts from michael rice's message of Fri Jul 30 14:41:44 -0400 2010: One description has the type and associated operations, the other only has the operations. Where can I find the type definition for List, and why isn't it in Data.List? Hello Michael, This is because the List datatype

Re: [Haskell-cafe] Definition of List type?

2010-07-30 Thread Edward Z. Yang
Excerpts from Edward Z. Yang's message of Fri Jul 30 14:48:34 -0400 2010: Const x xs is x:xs (constructor) That should be a Cons, not Const. :o) Cheers, Edward ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] using the orc library

2010-07-30 Thread Edward Z. Yang
Excerpts from Günther Schmidt's message of Fri Jul 30 16:16:38 -0400 2010: I'd like to download 1,000 web pages with up to 6 six concurrent downloads at a time. How can I express such a thread limit within the orc EDSL? One solution that comes to mind is place all 1000 web pages in an MVar

Re: [Haskell-cafe] Is 'flip' really necessary?

2010-07-26 Thread Edward Z. Yang
IMO, if you really want a wildcard, just write a lambda... \x - foo 1 x 3 Cheers, Edward ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] Is 'flip' really necessary?

2010-07-25 Thread Edward Z. Yang
Excerpts from aditya siram's message of Sun Jul 25 17:13:16 -0400 2010: Eta-reducing is nice, and sometimes it makes code more readable. But 'flip' is one of those functions that always seems to hinder rather than help readability, conversely factoring out flip always makes code easier to

Re: mallocForeignPtr vs. C

2010-07-13 Thread Edward Z. Yang
Excerpts from Axel Simon's message of Tue Jul 13 16:03:01 -0400 2010: If your C code has a way to properly unref a pointer then you could wrap your ForeignPtr in a StablePtr and pass that to C land. Once C has freed the StablePtr the ForeignPtr can become dead when Haskell has dropped

Re: mallocForeignPtr vs. C

2010-07-13 Thread Edward Z. Yang
Excerpts from Axel Simon's message of Tue Jul 13 16:28:29 -0400 2010: Well, if the C code hangs on to the StablePtr that wraps the ForeignPtr, its finalizer won't be run. But can run again once the StablePtr is freed. So you can take out the Ptr in the ForeignPtr and use it in C land as

Re: mallocForeignPtr vs. C

2010-07-12 Thread Edward Z. Yang
Excerpts from Evan Laforge's message of Mon Jul 12 14:56:11 -0400 2010: But I'm not convinced that's actually enough because the C code is still running outside of a withForeignPtr. I would have to do something really hairy like call back to C from the haskell callback, wrapping it in

Re: mallocForeignPtr vs. C

2010-07-12 Thread Edward Z. Yang
Excerpts from Evan Laforge's message of Mon Jul 12 16:23:39 -0400 2010: Well, what I'm worried about is that withForeignPtr says you should only use the pointer from inside it. The situation here is that I've passed a pointer to C. C wants to share ownership of the pointer, so even if all

Re: [Haskell-cafe] [C Binding] Turning the mutable to immutable?

2010-07-07 Thread Edward Z. Yang
To answer the question in your subject, “Very Carefully.” While I don’t know much about your particular problem domain (and it seems others have given useful advice), I can say some general things about making mutable things immutable. There is a very simple way to make something mutable

Re: [Haskell-cafe] whine and solution about programmers not respecting documentations

2010-06-29 Thread Edward Z. Yang
Excerpts from Albert Y.C.Lai's message of Mon Jun 28 15:44:34 -0400 2010: I propose that at each minor version of base, someone picks an implementation randomly. This has actually been done, in a legitimate language implementation. Check out:

Re: [Haskell-cafe] Re: How does one get off haskell?

2010-06-18 Thread Edward Z. Yang
Excerpts from braver's message of Fri Jun 18 12:55:24 -0400 2010: So when your problem is open-ended and the shape of data is in flux, a dynamic language is faster to prototype. I think I can second this comment. However, I would still prefer Haskel for a system intended for production; with

Re: [Haskell-cafe] Re: How does one get off haskell?

2010-06-18 Thread Edward Z. Yang
Excerpts from Bryan O'Sullivan's message of Fri Jun 18 13:16:58 -0400 2010: I'm inclined to disagree. It's precisely when the code is in a state of constant upheaval that I want the type system to be pointing out my dumb errors. In my experience, the type system has forced me to care about

Re: [Haskell-cafe] Re: How does one get off haskell?

2010-06-17 Thread Edward Z. Yang
Excerpts from Paul Lotti's message of Thu Jun 17 15:33:30 -0400 2010: Same feelings here. I work in a company that uses C++/Java and the best I could manage was to use Haskell for prototyping and then deliver in Java. This worked out twice so far. The downside is having to translate it

Re: [Haskell-cafe] How to browse code written by others

2010-06-14 Thread Edward Z. Yang
Excerpts from Luke Palmer's message of Mon Jun 14 19:35:16 -0400 2010: If you go this route, I will shamelessly promote hothasktags instead of ghci. It generates proper tags for qualified imports. Ooh, that's a good time. (Ditches hasktags for hothasktags).

Re: [Haskell-cafe] Terminology

2010-06-14 Thread Edward Z. Yang
Excerpts from Emmanuel Castro's message of Mon Jun 14 18:10:09 -0400 2010: I am looking for the name of the property linking two functions f and g when : [f(a),f(b),f(c)] = g([a,b,c]) Is there a standard name? In practice, g is an optimised version of f when working on large amount of

[Haskell] Re: [Haskell-cafe] ANN: Monad.Reader Issue 16

2010-05-12 Thread Edward Z. Yang
Excerpts from Brent Yorgey's message of Wed May 12 14:12:53 -0400 2010: I am very pleased to announce that Issue 16 of The Monad.Reader is now available [1]. Excellent news! Looking forward to reading. Cheers, Edward ___ Haskell mailing list

Re: [Haskell-cafe] ANN: Monad.Reader Issue 16

2010-05-12 Thread Edward Z. Yang
Excerpts from Brent Yorgey's message of Wed May 12 14:12:53 -0400 2010: I am very pleased to announce that Issue 16 of The Monad.Reader is now available [1]. Excellent news! Looking forward to reading. Cheers, Edward ___ Haskell-Cafe mailing list

Custom reducing functions for DPH

2010-05-10 Thread Edward Z. Yang
Hello all, I was asking this question on #haskell and thoughtpolice directed me here for a possibly more up-to-date information. Some of the important primitives offered by Data Parallel Haskell are reduction primitives such as sumP and prodP, which take a data parallel array and reduce it to a

Re: [Haskell-cafe] haskell on suse?

2010-05-06 Thread Edward Z. Yang
Excerpts from gladstein's message of Thu May 06 14:33:38 -0400 2010: I've been spoiled by package managers that download and install everything for you, and I've forgotten how RPM works. In particular, I want to install Haskell on suse, and I read that RPMs are available from openSUSE. I

Re: [Haskell-cafe] Cabal dependency hell

2010-04-11 Thread Edward Z. Yang
Excerpts from Daniel Fischer's message of Sun Apr 11 16:20:30 -0400 2010: I think in the default cabal config, build-reporting would be turned off and you'd have to turn it on yourself. Turning it on by default wouldn't be sensible. I doubt you'd get very much runtime with that. I'd suggest

Re: [Haskell-cafe] Cabal dependency hell

2010-04-11 Thread Edward Z. Yang
Excerpts from Ivan Lazar Miljenovic's message of Sun Apr 11 17:37:15 -0400 2010: Edward Z. Yang ezy...@mit.edu writes: I doubt you'd get very much runtime with that. I'd suggest prompting the user to submit a failed build report if the build fails. Exactly like how Windows keeps prompting

Re: [Haskell-cafe] Can Haskell enforce the dimension?

2010-04-09 Thread Edward Z. Yang
Excerpts from Haihua's message of Fri Apr 09 12:28:23 -0400 2010: In C++, template can be used to enforce the dimension. For example, F=m*a is OK and F=m*t will issue a compile time error. Is there a way to do this in Haskell? http://hackage.haskell.org/package/dimensional Cheers, Edward

Re: [Haskell-cafe] Why does Haskell not infer most general type?

2010-04-06 Thread Edward Z. Yang
Excerpts from Brandon S. Allbery KF8NH's message of Tue Apr 06 16:46:28 -0400 2010: On Apr 6, 2010, at 15:56 , Job Vranish wrote: Is haskell supposed to always infer the most general type (barring extensions)? Look up the monomorphism restriction. Hey Brandon, I tested the code with

Re: [Haskell-cafe] Hackage accounts and real names

2010-04-05 Thread Edward Z. Yang
This is a pretty terrible reason, but I'm going to throw it out there: I like real names because they're much more aesthetically pleasing. In my younger days, I once decided, Hey, I should get a pseudonym and I picked something fairly ridiculous, just because everyone else was doing it. I would

Re: [Haskell-cafe] A function that makes list of Bool lists from list of Int lists

2010-04-03 Thread Edward Z. Yang
Excerpts from Maur Toter's message of Sat Apr 03 09:54:26 -0400 2010: I am new with Haskell so I think this will be a pretty dumb question. I would like to make a function that makes this: listbool :: [[Int]] - [[Bool]] in this way: listbool [[1,2],[3,4]] == [[True, True],[False, False]]

Re: [Haskell-cafe] A function that makes list of Bool lists from list of Int lists

2010-04-03 Thread Edward Z. Yang
Excerpts from Maur Toter's message of Sat Apr 03 10:29:34 -0400 2010: What does the ($) at zipWith? ($) is function application Prelude :t ($) ($) :: (a - b) - a - b Cheers, Edward ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] benchmarking pure code

2010-03-31 Thread Edward Z. Yang
Excerpts from Paul Brauner's message of Wed Mar 31 03:17:02 -0400 2010: The part I want to benchmark is 2. In particular I would like that: a. \x.t is already evaluated when I run 2 (I don't want to measure the performances of the generator) b. the action of substituting u for x in t

Re: [Haskell-cafe] Optimizing hash array mapped tries

2010-03-01 Thread Edward Z. Yang
Excerpts from Don Stewart's message of Wed Feb 24 16:13:18 -0500 2010: Almost all the vector library generators fill a vector destructively, before doing an unsafeFreeze. Alright. Is there a standard idiom for filling vectors pointing to vectors destructively, and then unsafely freezing all of

Re[2]: [Haskell-cafe] Optimizing hash array mapped tries

2010-02-24 Thread Edward Z. Yang
Excerpts from Bulat Ziganshin's message of Wed Feb 24 14:48:53 -0500 2010: I'd be really curious about techniques that permit mutation during the construction of functional datastructures; this seems like a cool way to get fast performance w/o giving up any of the benefits of immutability.

Re: [Haskell-cafe] Optimizing hash array mapped tries

2010-02-24 Thread Edward Z. Yang
Excerpts from Don Stewart's message of Wed Feb 24 16:13:38 -0500 2010: These are exported from vector, though. Aha! I was looking in Data.Vector for them; they're actually in Data.Vector.Generic. Awesome. Cheers, Edward ___ Haskell-Cafe mailing list

[Haskell-cafe] Optimizing hash array mapped tries

2010-02-21 Thread Edward Z. Yang
Hello all, I spent this weekend attempting to impement Phil Bagwell's Hash Array Mapped Tries in Haskell. You can view the fruits of this work at this repository: http://github.com/ezyang/hamt Unfortunately, I'm getting pretty abysmal performance out of the implementation I wrote, so I'm

Re: [Haskell-cafe] Maybe, maybe not.

2010-01-26 Thread Edward Z. Yang
Excerpts from michael rice's message of Tue Jan 26 21:34:42 -0500 2010: fromMaybe d x = case x of {Nothing - d;Just v  - v} fromMaybe z = maybe z id They're equivalent. Here the definition of maybe: maybe :: b - (a - b) - Maybe a - b maybe n _ Nothing = n maybe _ f (Just x) = f x

Re: [Haskell-cafe] Maybe, maybe not.

2010-01-26 Thread Edward Z. Yang
Excerpts from Daniel Peebles's message of Tue Jan 26 23:25:28 -0500 2010: There are actually only two (extensionally) possible total functions with that type, as far as I can see :) Is the other one... const? Cheers, Edward ___ Haskell-Cafe mailing

Re: [Haskell-cafe] Use of the Try typeclass

2010-01-01 Thread Edward Z. Yang
I upgraded, but now both Control.Monad.Failure and Control.Monad.Error claim to be exporting Error. Is this correct, and if so, which one should I hide? Cheers, Edward ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] Use of the Try typeclass

2010-01-01 Thread Edward Z. Yang
Excerpts from Edward Z. Yang's message of Fri Jan 01 13:27:49 -0500 2010: I upgraded, but now both Control.Monad.Failure and Control.Monad.Error claim to be exporting Error. Is this correct, and if so, which one should I hide? Sorry my bad; I should have been importing

[Haskell-cafe] Use of the Try typeclass

2009-12-30 Thread Edward Z. Yang
Hello all, I am currently playing with the new cadre of failure libraries, and I'm trying to figure out how to use the monadic version of Failure while also getting the Try typeclass, which appears to be the standardized mechanism for marshalling values from specific monads into the failure

Re: [Haskell-cafe] Use of the Try typeclass

2009-12-30 Thread Edward Z. Yang
Excerpts from Alexander Dunlap's message of Thu Dec 31 00:06:58 -0500 2009: Why are you importing both Control.Failure and Control.Monad.Failure when the latter just re-exports the former? Are you using the latest versions of the two packages? Try importing just Control.Monad.Failure.MTL; that

Re: [Haskell-cafe] Use of the Try typeclass

2009-12-30 Thread Edward Z. Yang
Excerpts from Michael Snoyman's message of Thu Dec 31 00:43:52 -0500 2009: What version of the packages are you using? Can you give the output of: ghc-pkg list|grep failure Sure thing: (control-monad-failure-0.4), (control-monad-failure-0.5.0), control-monad-failure-mtl-0.5.0,

[Haskell-cafe] Broken GHC doc links

2009-12-16 Thread Edward Z. Yang
Hello, I think the recent GHC 6.12 release broke all of the old links to Haddock documentation; as of writing Hoogle still points to the wrong Haddock docs and stuff like: http://www.haskell.org/ghc/staging/docs/latest/html/libraries/mtl/Control-Monad-Cont.html is now 404ing despite being the

Re: [Haskell-cafe] Token parsers in parsec consume trailing whitespace

2009-12-15 Thread Edward Z. Yang
Excerpts from Greg Fitzgerald's message of Mon Dec 14 18:44:37 -0500 2009: It's too bad that the 'nat' function in Token is not defined in Parsec's Char module, and because of that, you need to copy-paste that code or roll your own. Maybe I should write a patch for that. That's correct.

[Haskell-cafe] Token parsers in parsec consume trailing whitespace

2009-12-12 Thread Edward Z. Yang
I recently ran into a nasty little bug where token parsers in parsec consume trailing whitespace, which were consuming newlines and thus bamboozling a higher-level sepBy combinator. I replaced my instances of 'natural' with 'read $ many1 digit', but this gave rise to the following questions: 1.

Re: [Haskell-cafe] control-monad-failure and mtl

2009-11-30 Thread Edward Z. Yang
Excerpts from Jose Iborra's message of Sun Nov 29 10:41:50 -0500 2009: There is indeed an Monad instance for Either in mtl, declared in the module Control.Monad.Error. I can't explain why your compiler cannot find it. Can you paste a blurb of code somewhere? {-# LANGUAGE PackageImports,

[Haskell-cafe] control-monad-failure and mtl

2009-11-28 Thread Edward Z. Yang
Hello folks, I took advantage of Thanksgiving weekend to port my application to use Control.Monad.Failure, and learned (slightly painfully) that I still needed to pick some mechanism to instantiate my failure monads as. After the experience, I have three questions/comments: 1. Why isn't there an

Re: [Haskell-cafe] ghci + user prelude

2009-11-17 Thread Edward Z. Yang
Excerpts from Sean McLaughlin's message of Mon Nov 16 19:06:06 -0500 2009: Hi. I'm aware of this option, and use it frequently to override the default prelude, but it doesn't help this problem: I suppose this is the appropriate quote from the GHC manual: GHC normally imports Prelude.hi files

Re: [Haskell-cafe] ghci + user prelude

2009-11-16 Thread Edward Z. Yang
Excerpts from Sean McLaughlin's message of Mon Nov 16 15:27:55 -0500 2009: Is there a way around this? I often like to have a modified Prelude file in a subdirectory of my project, and this behavior keeps me from being able to start ghci there.

Re: [Haskell-cafe] ANNOUNCE: control-monad-failure and safe-failure

2009-11-16 Thread Edward Z. Yang
Excerpts from Michael Snoyman's message of Mon Nov 16 14:39:14 -0500 2009: control-monad-failure provides a basic notion of failure which does not commit to any concrete representation. It is just a version of the MonadError class without the annoying bits. Excellent! I've used MonadError in

Re: [Haskell-cafe] Monadic correctness

2009-10-17 Thread Edward Z. Yang
Excerpts from Andrew Coppin's message of Sat Oct 17 15:21:28 -0400 2009: Suppose we have newtype Foo x instance Monad Foo runFoo :: Foo x - IO x What sort of things can I do to check that I actually implemented this correctly? I mean, ignoring what makes Foo special for a

Re: [Haskell-cafe] better way to do this?

2009-10-07 Thread Edward Z. Yang
Excerpts from Ketil Malde's message of Wed Oct 07 05:13:19 -0400 2009: One could argue that IO should be broken down into a set of sub-monads encapsulating various subsets of the functionality - file system, network access, randomness, and so on. This could extend the safe spot to cover much

Re: [Haskell-cafe] HList and Type signatures / synonyms

2009-09-06 Thread Edward Z. Yang
Excerpts from Günther Schmidt's message of Sun Sep 06 19:40:05 -0400 2009: I keep accumulating values and right now use plain tuples for that. I end up with a 12 element tuple and things are a bit messy. Hi, you may want to consider using the Writer monad. [1] I'd like to use extensible

<    1   2   3   4