Re: [Haskell-cafe] Subcategories in Hackage

2010-09-12 Thread Evan Laforge
> Perhaps, this is madness, but I wanted to read other opinions on this topic. Packages already have multiple tags, right? So how about a search box that uses ANDed tags (in addition to description etc), and a browsing interface where you can see tags of packages matching the current search, and

Re: [Haskell-cafe] Unwrapping newtypes

2010-09-08 Thread Evan Laforge
Here's a different approach: If you just want to make the typechecker distinguish between some values but still have some functions that don't care what "subtype" they are, you can use phantom types: data Obj x = Obj X Y Z data BlogObj type Blog = Obj BlogObj data CommentObj type Comment = Obj

[Haskell-cafe] circular imports

2010-09-06 Thread Evan Laforge
Lately I've been spending more and more time trying to figure out how to resolve circular import problems. I add some new data type and suddenly someone has a new dependency and now the modules are circular. The usual solution is to move the mutually dependent definitions into the same module, bu

Re: [Haskell-cafe] (automatic) type classes context inference

2010-08-28 Thread Evan Laforge
On Sat, Aug 28, 2010 at 12:22 PM, Carter Schonwald wrote: >  i believe that a valid idiom is to define a class C that has no  functions, > but requires  any instance   to also be of type classes A and B, so that you > can write: C a => blah > rather than (A a,B a)=> blah, though I don't know how o

Re: [Haskell-cafe] lazy skip list?

2010-08-21 Thread Evan Laforge
On Sat, Aug 21, 2010 at 6:52 PM, Michael D. Adams wrote: > Could you be more specific about what operations you want and their > properties (e.g. performance laziness, etc.)?  For example, do you > need to be able to cons onto the front or is the list generated once > and never consed onto?  Do yo

Re: [Haskell-cafe] A cabal odyssey

2010-08-21 Thread Evan Laforge
> I wonder... How many people are actually working on Cabal? > > When I first started using Haskell, I got the impression that there were > hundreds, maybe even thousands, of developers working on GHC. (After all, > how else could you write such a huge codebase in less than two centuries?) > But no

Re: [Haskell-cafe] lazy skip list?

2010-08-19 Thread Evan Laforge
> However, I haven't thought about how operations such as 'cons' and > 'tail' would be implemented =).  OP just asked about indexing ;-). Hah, serves me right I suppose. I figured the promise of some type fanciness would be catnip to some well-typed cats out there, but your implementation is even

[Haskell-cafe] lazy skip list?

2010-08-19 Thread Evan Laforge
Is there a data type that's spine lazy like a list, but can be seeked (sought?) efficiently? IntMap and Sequence are spine strict so if you take the head element all the elements are forced even if their contents are not. E.g., 'Sequence.index (Sequence.fromList [0..]) 0' will diverge, but obviou

Re: [Haskell-cafe] A cabal odyssey

2010-08-18 Thread Evan Laforge
> It sounds to me like your life would be a lot easier if you knew about > cabal-install's root-cmd configuration parameter! Open your > .cabal/config file and uncomment and set: > > root-cmd: sudo I didn't know about this either. As an aside, is the cabal config file documented at all? I haven'

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

2010-08-13 Thread Evan Laforge
On Fri, Aug 13, 2010 at 6:41 PM, Brandon S Allbery KF8NH wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > On 8/13/10 16:37 , Kevin Jardine wrote: >> Surely efficient Unicode text should always be the default? And if the > > Efficient for what?  The most efficient Unicode representation

Re: [Haskell-cafe] Preview the new haddock look and take a short survey

2010-08-04 Thread Evan Laforge
This is something I've wanted for a long time, but I always intended to just submit a patch since it would be trivial, but maybe other people have an opinion about it too: I've always wanted a button to collapse or maybe toggle all expanded branches. Once a library gets large, it's easier to navi

Re: [Haskell-cafe] Why do "unsafe" foreign calls block other threads?

2010-08-03 Thread Evan Laforge
>> Just think of "unsafe" in relation to "unsafeIndex" or something. >> It's faster, but you have to be sure the index is in bounds. > Yes, but the whole reason to use "unsafe" is to get higher performance > at the cost of safety.  If the result of calling an "unsafe" foreign > function is that you

Re: [Haskell-cafe] Why do "unsafe" foreign calls block other threads?

2010-08-03 Thread Evan Laforge
On Tue, Aug 3, 2010 at 3:06 PM, Gregory Crosswhite wrote: > But you've got it backwards:  if the function I am calling can call back > into Haskell (i.e., is marked as "safe"), then GHC *doesn't* block the > world, but if the function I am calling will never call back into Haskell > (i.e., is mark

Re: [Haskell-cafe] Error Monad and strings

2010-07-28 Thread Evan Laforge
> I've always thought that being able to write: > >> catMaybes :: [Maybe a] -> [a] >> catMaybes xs = [ x | Just x <- xs ] > > is really cool, which relies on: > >> fail _ = [] > > being in the Monad instance for List. Really? I thought that's just a feature of list comprehensions. List comps are

Re: [Haskell-cafe] Re: Haskell Forum

2010-07-26 Thread Evan Laforge
On Mon, Jul 26, 2010 at 12:54 PM, Kevin Jardine wrote: > On Jul 26, 6:45 pm, Nick Bowler wrote: > >> Since when do mailing lists not have threading?  Web forums with proper >> support for threading seem to be few and far apart. > > Most of the email clients I'm familiar with don't support threade

Re: [Haskell-cafe] Hot-Swap with Haskell

2010-07-16 Thread Evan Laforge
On Fri, Jul 16, 2010 at 11:21 AM, Don Stewart wrote: > Generally, in Erlang or Haskell, the semantics we use is to keep > all the old code in memory, for  the case of closures and thunks that > point back into that code. > > You can imagine a fine-grained semantics where as each top level > functi

Re: [Haskell-cafe] Monad transformers

2010-07-03 Thread Evan Laforge
> As I say, every time I've tried to do this, I end up writing a function to > "run this stuff", and it typically takes a few hours to reach the point > where it type-checks. It took me a while the first time, but then I just learned the pattern and I do it that way every time. Here's my pattern:

Re: [Haskell-cafe] checking types with type families

2010-06-23 Thread Evan Laforge
> I'm interested in situations where you think fundeps work and type families > don't.  Reason: no one knows how to make fundeps work cleanly with local type > constraints (such as GADTs). > > If you think you have such as case, do send me a test case. Well, from looking at the documentation, it

Re: [Haskell-cafe] checking types with type families

2010-06-22 Thread Evan Laforge
> I think your problem here is that there's no mention of `a' on the > left-hand size of from_val's type signature; you either need to use > MPTC+fundep to associate what result is compared to a, or else use a > phantom type parameter of Val to make it "data Val result a = ..." and > then "from_val

[Haskell-cafe] checking types with type families

2010-06-22 Thread Evan Laforge
I have a parameterized data type: > data Val result = VNum Double | VThunk (SomeMonad result) > type Environ result = Map Symbol (Val result) I have a class to make it easier to typecheck Vals: > class Typecheck a where > from_val :: Val result -> Maybe a > > instance Typecheck Double where >

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

2010-06-17 Thread Evan Laforge
>> So how does one get off haskell? Are there people in similar situations >> that have managed? How did you do it? I used to get annoyed about all the java boilerplate and awkwardness. But then I learned that if I relax and stop thinking so much about the aesthetics of what I'm writing, I can jus

Re: [Haskell-cafe] How to "Show" an Operation?

2010-06-07 Thread Evan Laforge
> How should I work around that. I could use two different "name" function, but > I don't like this. Would I have to define a typeclass "namedFunction" which > all have a "name" function? How about a "named" type: data Named a = Named { val_of :: a, name_of :: String } You can put it in Fu

Re: [Haskell-cafe] Cabal -j

2010-06-03 Thread Evan Laforge
On Thu, Jun 3, 2010 at 3:05 PM, Don Stewart wrote: > wasserman.louis: >> What, if anything, stands in the way of parallelizing Cabal installs, make -j >> style? > > Parallelizing ghc --make > >    http://vimeo.com/6572966 Something I wondered from watching that talk, rather than trying to make gh

Re: [Haskell-cafe] Difference between div and /

2010-06-01 Thread Evan Laforge
> [1] By co I mean Ruby, Python, Perl and others. There are no so many > languages that do recognize the difference. % python -Q new Python 2.4.6 (#1, Aug 3 2009, 17:05:16) [GCC 4.0.1 (Apple Inc. build 5490)] on darwin Type "help", "copyright", "credits" or "license" for more information. 10 / 3

Re: [Haskell] Re: [Haskell-cafe] Work on Video Games in Haskell

2010-05-26 Thread Evan Laforge
> So, sadly, I think your chances of shipping your a title written in Haskell > on the iPhone are shot to hell. +1 for the android version. Disclaimer: biased google employee :P Unfortunately then you get another cockamamie restriction in the whole JVM vs. tail calls thing... but if you can ge

Re: [Haskell-cafe] Proposal to solve Haskell's MPTC dilemma

2010-05-20 Thread Evan Laforge
> Hi Evan, hasn't EHC had something like this for a while with 'type > class directives'? I dunno, I don't even know what ehc is. Is it this? http://www.cs.uu.nl/wiki/Ehc/WebHome I turned up a paper that mentioned type class directives, but I haven't read it yet. In any case, the EHC page says

Re: [Haskell-cafe] Proposal to solve Haskell's MPTC dilemma

2010-05-20 Thread Evan Laforge
> I wonder: Of cases where overload resolution via available instances > would be reasonable, how many would also make sense as a closed type > class? By comparison, it seems that many uses of OverlappingInstances > are really just trying to express a closed type class with one or more > default in

Re: [Haskell-cafe] Re: Haskell and scripting

2010-05-07 Thread Evan Laforge
> On the one hand, this is doable with the GHC API.  On the other, that more > or less means your program contains what amounts to a full copy of GHC. And the result is that your binary will grow by 35mb, add a few seconds to launch time, the first expression will take 3 or 4 seconds to evaluate,

Re: [Haskell-cafe] Re: Is anyone using Haddock's support for frames?

2010-05-04 Thread Evan Laforge
On Tue, May 4, 2010 at 1:23 PM, David Waern wrote: > 2010/5/4 Sean Leather : >> Somewhat OT, but is there a place where we can request/review features in >> the new HTML presentation of Haddock. Are there any mockups of what the >> pages might look like? I've had some ideas pop around my head ever

Re: [Haskell-cafe] GSoC Project: A Haddock + Pandoc documentation tool

2010-04-09 Thread Evan Laforge
> 3) Configuration > > I haven't looked at this yet but I suspect people will not want > another configuration file in their projects. Perhaps you could > propose some kind of Cabal integration instead. It would be a shame if I had to figure out how to write a cabal file for my project and replace

Re: [Haskell-cafe] Announce: hothasktags

2010-04-07 Thread Evan Laforge
Ohh, and the other issue I had was that setting iskeyword causes 'w' to skip over '.'s. This causes trouble for me because I'm used to using 'w' to skip between components of the symbol and 'W' to skip it entirely. Is there a workaround you use, maybe a better way to navigate? ___

Re: [Haskell-cafe] Announce: hothasktags

2010-04-07 Thread Evan Laforge
On Thu, Apr 1, 2010 at 1:46 PM, Luke Palmer wrote: > Hi, > > I'd like to draw attention to a little script I wrote.  I tend to use > qualified imports and short names like "new" and "filter".  This makes > hasktags pretty much useless, since it basically just guesses which > one to go to.  hothask

Re: [Haskell-cafe] Re: Haskellers hate GUIs!!

2010-04-02 Thread Evan Laforge
This may not be helpful for you, but when I did GUI stuff with haskell I wrote the GUI part in c++ with fltk, exposed a medium-level api specific to that gui, and then call that api through the FFI. This is sort of like the web browser + backend thing, except switch c++ and fltk for javascript and

Re: [Haskell-cafe] Re: generalized newtype deriving allows the definition of otherwise undefinable functions

2010-03-09 Thread Evan Laforge
> The difference (in work) between map Wrapped and conv is the difference > between map id and id :: [a] -> [a]. In the absence of any fusion/rewrite > rules, the former breaks down a list, and builds up a new one with exactly the > same elements (or, every element x becomes an id x thunk, perhaps)

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

2010-02-26 Thread Evan Laforge
> real :: Parser String > real = do >  d <- decimal >  f <- option "" $ do >    p <- char '.' >    n <- many1 digit >    return $ p : n Just to throw two bits in here, this is the only style that doesn't require leaning on the space bar and squinting to line things up, doesn't require any fancy ed

Re: [Haskell-cafe] Testing and module export lists

2010-02-24 Thread Evan Laforge
On Wed, Feb 24, 2010 at 3:10 PM, Ivan Miljenovic wrote: > On 24 February 2010 20:17, Magnus Therning wrote: >> I often find that I do want an export list to reduce clutter in the >> finished code, but for testing I'd like to expose everything in a >> module.  Is there a nice way to deal with this

Re: [Haskell-cafe] Re: Implementing "unionAll"

2010-02-18 Thread Evan Laforge
On Thu, Feb 18, 2010 at 5:22 PM, Leon Smith wrote: > On Thu, Feb 18, 2010 at 3:07 AM, Evan Laforge wrote: >> BTW, I notice that your merges, like mine, are left-biased.  This is a >> useful property (my callers require it), and doesn't seem to cost >> anything to imp

Re: [Haskell-cafe] Re: Implementing "unionAll"

2010-02-18 Thread Evan Laforge
BTW, I notice that your merges, like mine, are left-biased. This is a useful property (my callers require it), and doesn't seem to cost anything to implement, so maybe you could commit to it in the documentation? By left-biased I mean that when elements compare equal, pick the leftmost one, e.g.

Re: [Haskell-cafe] Re: Implementing "unionAll"

2010-02-17 Thread Evan Laforge
By purest coincidence I just wrote the exact same function (the simple mergeAll', not the VIP one). Well, extensionally the same... intensionally mine is 32 complicated lines and equivalent to the 3 line mergeAll'. I even thought of short solution by thinking that pulling the first element destro

Re: [Haskell-cafe] What is the meaning of tilde ("~") symbol

2010-02-14 Thread Evan Laforge
> I'm no fan of (!!) on lists or other containers where it isn't O(1), > but lookup/member are a bit more promising. However are there any > useful derived operations or constructions that can be defined only in > terms of a Lookup type class? For comparison, Monoid has mconcat as a > derived op an

Re: [Haskell-cafe] What is the meaning of tilde ("~") symbol

2010-02-14 Thread Evan Laforge
On Sun, Feb 14, 2010 at 2:22 PM, Stephen Tetley wrote: > On 14 February 2010 22:11, Evan Laforge wrote: > >> There's still no consensus on typeclasses for collections, so these >> are all separate functions.  Has anyone taken a shot at a set of >> AT-using classes

Re: [Haskell-cafe] What is the meaning of tilde ("~") symbol

2010-02-14 Thread Evan Laforge
>> Finally, it is the array subscript operator: >> >> let x = arr ! 10 > > Shouldn't this be > > let x = arr !! 10 !! is the list subscript. Look in Data.Array.IArray for (!). Or Data.Map. There's still no consensus on typeclasses for collections, so these are all separate functions. Has anyon

Re: [Haskell-cafe] Re: How many "Haskell Engineer I/II/III"s are there?

2010-02-11 Thread Evan Laforge
On Thu, Feb 11, 2010 at 1:49 PM, John Van Enk wrote: > Perhaps just defining the interface and demonstrating that different RTS's > are swappable would be enough? I read a paper by (I think) a Simon, in which he described a haskell RTS. It would make it easier to experiment with GC, scheduling,

Re: [Haskell-cafe] Parse error

2010-01-18 Thread Evan Laforge
> It's an improvement. It's still not pretty, but I guess that's as good as > it's going to get... > > Maybe this is an instance of Haskell trying to tell me "if you need to write > a 20-line do-block in the middle of your function, you're doing it wrong". 20 lines is a lot, but I have smaller one

Re: [Haskell-cafe] wildcards for type variables?

2010-01-14 Thread Evan Laforge
On Thu, Jan 14, 2010 at 5:19 AM, Ozgur Akgun wrote: > Can someone give an example of a "reasonable" function that never uses one > of its parameters, and justify the existence of that parameter in this case, > please? As I mentioned, this is not only about parameters, but about type variables. F

Re: [Haskell-cafe] Language simplicity

2010-01-14 Thread Evan Laforge
>> Unicode identifiers are fun but this is a good point.  The line has >> to be somewhere, so it might as well be in the historical position >> unless there are widely agreed on benefits to moving it. > > I have already crossed that line: Ha, well haskell programmers wouldn't be haskell programmer

Re: [Haskell-cafe] Language simplicity

2010-01-14 Thread Evan Laforge
Wow, that's kind of cute: {-# LANGUAGE UnicodeSyntax #-} (*) = (*) (/) = (/) 公式 高 中 低=高*中*低/整數 整數 = 123 Oddly, if I change the order of these definitions I get syntax errors. Very mysterious. Nice how it knows that * is a symbol, but I'm not sure how I'm supposed to name a type. It certainly s

Re: [Haskell-cafe] Name overloading

2010-01-13 Thread Evan Laforge
> Now, in Haskell we have type inference, which is "The Good Thing" as > it allows to "validate" your program at compile time. Hence, the idea > coming up to my mind is that type inference actually forbids a > type-directed resolution of names as in C++ or Java. > > Is this correct? There is a pro

Re: [Haskell-cafe] wildcards for type variables?

2010-01-13 Thread Evan Laforge
>> Isn't that what we have here? a function of type (a -> A -> B) cannot >> use the first argument in any meaningful way. > > I think, he wants to document that the type variable 'a' is not used in the > *type*. Yeah, that's the idea, sorry if I wasn't clear. In the case of const, I might write

[Haskell-cafe] wildcards for type variables?

2010-01-12 Thread Evan Laforge
Occasionally I have a function with an unused argument, whose type I don't want to restrict. Thus: f :: _unused -> A -> B f _ a = b Since it's a little unusual, I try to make it clear that the type is intentionally ignored. But it makes me wonder, would it make sense to allow _ as a type variab

Re: [Haskell-cafe] lazily-loaded structures

2010-01-01 Thread Evan Laforge
> What do you mean by "completely abort"? Couldn't it simply raise an > exception that could be handled in main? Yeah, that's what I meant by complete abort. You don't get to save the work you did get done. You could checkpoint progress, but of course that's an impure operation.

Re: [Haskell-cafe] lazily-loaded structures

2010-01-01 Thread Evan Laforge
> My question is this: how do I change my program to make StringMap a > lazily-loaded structure based on getStringMapValue without changing f? You can't, because 'f' has a pure signature, but you want it to run network operations, which are not pure. You could say it's logically pure if you guara

Re: [Haskell-cafe] naming naming conventions (was: Re: Allowing hyphens in identifiers)

2009-12-18 Thread Evan Laforge
I used to refer to them as dromedaryCase and BactrianCase, but the names never caught on :( ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] Re: Optimizing Parsec 3 -- was: Wiki software?

2009-12-15 Thread Evan Laforge
> So my biggest reservation is if I can even call my branch the same > parser as Parsec. Maybe we could go the way regexes: say "parsec" is an API, and allow multiple backends with different characteristics as long as they basically implement that API. In practice, a lot of parser combinator libr

[Haskell-cafe] Yay 6.12.1!

2009-12-15 Thread Evan Laforge
So far, this new release has let me remove: - The new "Import of xyz is redundant" warning pointed out tons of cruft in my imports: 117 of them! Apparently it's better than the 6.10 algorithm. It's amazing how much cruft builds up in import lists over time even with -Wall. One issue is that I c

Re: [Haskell-cafe] fun with 6.12

2009-12-14 Thread Evan Laforge
Ohh, it's for *patches*, not just warnings. Never mind then... On Mon, Dec 14, 2009 at 4:08 PM, Evan Laforge wrote: > I noticed noise on the cabal list about updating for 6.12, and that it > was nontrivial. > > Also, haddock won't compile with 6.12, and I couldn't

Re: [Haskell-cafe] fun with 6.12

2009-12-14 Thread Evan Laforge
I noticed noise on the cabal list about updating for 6.12, and that it was nontrivial. Also, haddock won't compile with 6.12, and I couldn't find anything about a new release. If someone else doesn't get there first, I'll add them to the wiki tonight. _

Re: [Haskell-cafe] Re: Allowing hyphens in identifiers

2009-12-09 Thread Evan Laforge
On Wed, Dec 9, 2009 at 3:26 PM, John D. Earle wrote: > The problem that I see with elision resulting in juxtaposition is that it > would alter the layout. Each line would not have the same number of > characters before and after the makeover. Visual appearance would also be > altered. Replacing hy

Re: [Haskell-cafe] Re: Optimizing Parsec 3 -- was: Wiki software?

2009-12-04 Thread Evan Laforge
On Fri, Dec 4, 2009 at 1:09 PM, John MacFarlane wrote: >> On Mon, Nov 23, 2009 at 12:29 PM, Antoine Latter wrote: > >> I finally had some time to test it.  After running it multiple times >> (of course, it would be nice to use criterion here), I'm getting >> numbers in this neighborhood: >> > > I

Re: [Haskell-cafe] Is Haskell a Fanatic?

2009-12-03 Thread Evan Laforge
> I'd just like to point out or reiterate the odd rise in trolling and the > recent announcements of haskell-2010... Just wait until haskell-2012 is announced with nonexistential aka eschatological types spelled "notany a. World". It evaluates to a new form of bottom that blackholes the entire wo

Re: [Haskell-cafe] GHC magic optimization ?

2009-12-03 Thread Evan Laforge
> 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 results to

[Haskell-cafe] lazy logging (was: Are there standard idioms for lazy, pure error handling?)

2009-12-01 Thread Evan Laforge
This is only peripherally related, but I also have a lot of list functions that can possibly be an error, but usually processing can continue. So they tend to return [Either Error Result]. I have another function thus: -- A foldr version is not lazy enough and overflows the stack. partition_eith

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

2009-11-18 Thread Evan Laforge
The proposal has this sentence, apparently in reference to using qualified imports: "This is sufficient, but it is just sufficiently inconvenient that people don't use it much." Does this mean qualified imports? I use them exclusively, and I'd love it if everyone else used them too. Anyway, a f

Re: [Haskell-cafe] faster compiling for ghc

2009-11-12 Thread Evan Laforge
e a huge win for GHC, at least on > linux.  Does GHC on windows use GNU ld? Improving GNU ld would be a huge win in a lot of places, and the fact that no one has done it (excepting gold of course) goes to show it's a lot easier said than done! On Thu, Nov 12, 2009 at 4:58 PM, Richard O

Re: [Haskell-cafe] faster compiling for ghc

2009-11-12 Thread Evan Laforge
On Wed, Nov 11, 2009 at 11:22 PM, David Virebayre wrote: > On Thu, Nov 12, 2009 at 7:18 AM, Bulat Ziganshin > wrote: >> >> Hello Evan, >> >> Thursday, November 12, 2009, 4:02:17 AM, you wrote: >> >> > Recently the "go" language was announced at golang.org.  There's not a >> > lot in there to make

[Haskell-cafe] faster compiling for ghc

2009-11-11 Thread Evan Laforge
Recently the "go" language was announced at golang.org. There's not a lot in there to make a haskeller envious, except one real big one: compilation speed. The go compiler is wonderfully speedy. Anyone have any tips for speeding up ghc? Not using -O2 helps a lot. I spend a lot of time linking (

Re: [Haskell-cafe] What's the deal with Clean?

2009-11-05 Thread Evan Laforge
> And this is confusing to those of us who are not compiler experts. > > Haskell knows when I have a list of Doubles, you know, because it's strongly > typed. > > Then it proceeds to box them. Huh ? > > The laziness thing has many example od _reducing_ efficiency, but there > seems to be a real lac

Re: [Haskell-cafe] What's the deal with Clean?

2009-11-03 Thread Evan Laforge
> So what's the deal with Clean? Why is it preferable to Haskell? Why is it not? Purely from glancing through the language reference, two things that it looks like clean has that I would love to have in haskell are better records and better arrays. The records don't implement any of the fancy sub

Re: [Haskell-cafe] How to convert records into Haskell structure in Haskell way?

2009-11-02 Thread Evan Laforge
On Mon, Nov 2, 2009 at 5:29 PM, Magicloud Magiclouds wrote: > Hi, >  Say I have something like this: > [ Record { item = "A1", value = "0" } > , Record { item = "B1", value = "13" } > , Record { item = "A2", value = "2" } > , Record { item = "B2", value = "10" } ] >  How to convert it into: > [ XX

Re: [Haskell-cafe] Is there a null statement that does nothing?

2009-10-27 Thread Evan Laforge
On Tue, Oct 27, 2009 at 10:08 AM, Kim-Ee Yeoh wrote: > > Hi Brent, > > Re: '"if" expressions, not statements' is an elegant clarification, one > definitely for the haskellwiki, if not there already. > > Just for completeness' sake, bottom is a value for any expression. > Wouldn't making the else c

Re: [Haskell-cafe] How to use "bracket" properly ?

2009-10-19 Thread Evan Laforge
On Sun, Oct 18, 2009 at 11:50 PM, zaxis wrote: > > The original code is: > > winSSQ count noRed noBlue = do >    let yesRed =  [1..33] \\ noRed >    let yesBlue = [1..16] \\ noBlue >    bracket (openFile "ssqNum.txt" WriteMode) (hClose) (\hd1 -> pickSSQ > count yesRed yesBlue hd1) > > It works ver

[Haskell-cafe] Re: source locations (was: best practices for monad transformers and exceptions?)

2009-09-24 Thread Evan Laforge
Sorry! Never mind all that. I just stumbled across http://hackage.haskell.org/trac/ghc/wiki/ExplicitCallStack *sigh* ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

[Haskell-cafe] source locations (was: best practices for monad transformers and exceptions?)

2009-09-24 Thread Evan Laforge
I forgot to mention this, but control-monad-exception reminded me: Is there any interest in a way for ghc to report source locations? I have a preprocessor that basically works and is really useful but also awkward and not scalable. control-monad-exception has TH which is more scalable but requi

Re: [Haskell-cafe] best practices for monad transformers and exceptions?

2009-09-24 Thread Evan Laforge
On Thu, Sep 24, 2009 at 8:11 AM, pepe wrote: > Exceptions in the ErrorT monad are not compositional. > It's the first time I see the approach of stacking > several ErrorT monads. It seems slightly better than > having a 'global' exception type, although the explicit > lifting looks quite painful.

[Haskell-cafe] best practices for monad transformers and exceptions?

2009-09-23 Thread Evan Laforge
I don't have an especially deep understanding of monad transformers... basically, I asked around (thanks #haskell!) and struggled and with helpful advice came up with something that seemed to work for me, only now I'm having trouble. What I'm trying to do is hardly revolutionary or even advanced,

Re: [Haskell-cafe] accessible layout proposal?

2009-09-22 Thread Evan Laforge
> It would be so much better if we could discuss a _real_ > example. Or implement one. Unlike some proposals, this could be implemented with a preprocessor and -F -pgmF, right? As far as the parsing job, I don't know how hard this would be to plug into the haskell parsing library, but in case it

Re: [Haskell-cafe] instance Monad (Either String) in Prelude or Data.Either?

2009-09-11 Thread Evan Laforge
> if I understand you correctly, all libraries that software I write depends > on, directly or indirectly, must be free of namespace conflicts.  Is that > correct? Well, it may be more accurate to say that class instances have no namespaces, and are all implicitly global. When you import a module

Re: [Haskell-cafe] instance Monad (Either String) in Prelude or Data.Either?

2009-09-11 Thread Evan Laforge
On Fri, Sep 11, 2009 at 6:10 AM, Edward Kmett wrote: > Unfortunately, the instance of Monad for Either a is somewhat misguided in > Haskell. > > There is a spurious restraint that the Left value in your Either be a member > of some Error class, which was brought about by the deletion of MonadZero

[Haskell-cafe] instance Monad (Either String) in Prelude or Data.Either?

2009-09-10 Thread Evan Laforge
Is there any particular reason to not move the instance to the prelude? A module was failing when imported from one place and ok when imported from another, so I spent a frustrating 10 minutes searching for the instance. I couldn't find a way to search haddock for instances (not even grep on the

Re: [Haskell-cafe] generalize RecordPuns and RecordWildCards to work with qualified names?

2009-08-12 Thread Evan Laforge
> | Even is suggesting that instead of reporting an error, in the second > | case we could use the translation: > | > |   f (A.A { A.a }) = a   -->   f (A.A { A.a = a }) > | > | (i.e., when punning occurs with a qualified name, use just the > | unqualified part of the name in the pattern) > > Yes,

Re: [Haskell-cafe] Proposal: TypeDirectedNameResolution

2009-08-01 Thread Evan Laforge
One issue I have which I haven't seen anyone mention is that it's not useful with qualified names, by which I mean always importing qualified. Of course if you have no problem always using qualified names, the problem this extension is solving doesn't exist. Though I do like short names I'm not t

Re: [Haskell-cafe] generalize RecordPuns and RecordWildCards to work with qualified names?

2009-07-30 Thread Evan Laforge
On Fri, Jul 24, 2009 at 4:48 PM, Iavor Diatchki wrote: > Hello, > I think that Even refers to an example like this: ... Yeah, that's exactly what I meant, sorry if it wasn't clear initially. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://w

[Haskell-cafe] generalize RecordPuns and RecordWildCards to work with qualified names?

2009-07-17 Thread Evan Laforge
Record punning is not all that useful with qualified module names. If I write '(M.Record { M.rec_x })' it says " Qualified variable in pattern" and if I write '(M.Record { rec_x })' it says 'Not in scope: `rec_x''. Could it be this extension be further extended slightly so that 'f (M.Record { M.r

Re: [Haskell-cafe] Can this be done?

2009-02-11 Thread Evan Laforge
On Wed, Feb 11, 2009 at 9:34 PM, Alistair Bayley wrote: > 2009/2/11 Cristiano Paris : >> I wonder whether this can be done in Haskell (see muleherd's comment): >> >> http://www.reddit.com/r/programming/comments/7wi7s/how_continuationbased_web_frameworks_work/ > > WASH did/does something similar. Y

Re: [Haskell-cafe] Data.Map: Enumerating ordered subset of keys

2009-02-08 Thread Evan Laforge
On Mon, Feb 9, 2009 at 2:57 PM, Jared Updike wrote: > I would like to enumerate a subset of keys in a Map satisfying \ key >>= key1 && key <= key2 but in the expected, reasonable amount of time > (e.g. < O(log(n)) + O(m) for n total keys and m keys in the subset). > (Or key > key1 and/or key < key

Re: [Haskell-cafe] Re: Why binding to existing widget toolkits doesn't make any sense

2009-01-29 Thread Evan Laforge
> Conal> As Meister Eckhart said, "Only the hand that erases can write the > Conal> true thing." > > Nicely said... > > I'm sure you're not the only one desiring to write GUI in "genuinely > functional" toolkit, but, being realistic and considering how many people > are working on bindings for thos

Re: [Haskell-cafe] Can I destructive rebind a local variable in haskell?

2009-01-06 Thread Evan Laforge
> Nice. Good solution. ``imperative style'' is not a bad idea when I'm > not used to the ``pure functional style'' > > E.g. > > filename <- return $ combine filename "Makefile" > > Similar to the other imperative language > > filename = joinPath(filename,"Makefile") I wouldn't consider it

Re: [Haskell-cafe] Can I destructive rebind a local variable in haskell?

2009-01-06 Thread Evan Laforge
2009/1/6 Luke Palmer : > 2009/1/6 Wang, Chunye (NSN - CN/Beijing) > Dear haskeller, >> >> >> Can I destructive rebind a local variable like this >> >> import System.Directory >> test filename = do >> is_dir <- doesDirectoryExist filename >> let filename = if not is_dir then filename else f

Re: [Haskell-cafe] How to check object's identity?

2009-01-04 Thread Evan Laforge
>> So it *looks* like there's only one list created in 'lvl1', but I >> can't see where it's turning into a tuple, and I don't understand the >> ' = : ' stuff, > > You're reading it wrong. : is a name. > It's lvl5 = (:) @ Char a2 ([] @ Char) where @ is type application > (instantiation). Triming t

Re: [Haskell-cafe] How to check object's identity?

2009-01-04 Thread Evan Laforge
> Although equal? treats the two as the *same*, they're different lists > because if we modify one (e.g by set-car!) the other won't be affected. > > So here comes another question: when we say a function always give the > same output for the same input, what the *same* means here? ídentity > or eq

Re: [Haskell-cafe] IORef vs TVar performance: 6 seconds versus 4 minutes

2008-12-29 Thread Evan Laforge
> In the short term, yes. But it's my opinion that most anything that's > a win for ease of modification is a win for performance in the long > run, if it gets more people writing code. Also agreed, in theory. The language is definitely also in line with this philosophy. In practice, though, it

Re: [Haskell-cafe] IORef vs TVar performance: 6 seconds versus 4 minutes

2008-12-29 Thread Evan Laforge
> It's always possible to decompose the final program down into one that > could be based on locks. But this is often at the cost of > maintainability; the code becomes one mess of spaghetti locking in > order to maintain whatever invariants need to be maintained to prevent > deadlock and compose

Re: [Haskell-cafe] IORef vs TVar performance: 6 seconds versus 4 minutes

2008-12-28 Thread Evan Laforge
On Mon, Dec 29, 2008 at 1:15 PM, Ryan Ingram wrote: > Both readTVar and writeTVar are worse than O(1); they have to look up > the TVar in the transaction log to see if you have made local changes > to it. > > Right now it looks like that operation is O(n) where n is the number > of TVars accessed

Re: [Haskell-cafe] global variables for foreign C functions

2008-12-01 Thread Evan Laforge
On Mon, Dec 1, 2008 at 4:39 PM, Andrea Rossato <[EMAIL PROTECTED]> wrote: > Hello, > > I'm writing the bindings to a C library which uses, in some functions, > global variables. > > To make it clearer, those functions need a global variable to be > defined. A C program using my_function, one of the

clojure's data structures (was: Re: [Haskell-cafe] implementing python-style dictionary in Haskell)

2008-11-18 Thread Evan Laforge
This actually brings up something I was wondering about lately. I recently stumbled across a language called clojure, which is a lisp-like that runs on the JVM. The interesting thing is that mutations go through a transactional mutable reference system, and the other datastructures are all immuta

Re: [Haskell-cafe] An irritating Parsec problem

2008-10-15 Thread Evan Laforge
Here's what I have in one file: -- | Parse the text of an event with the given parser @[EMAIL PROTECTED] parse :: (Monad m) => P.CharParser () a -> String -> Derive.DeriveT m a parse p text = do (val, rest) <- case P.parse (p_rest p) "" text of Left err -> Derive.throw $ "p

Re: [Haskell-cafe] Shooting your self in the foot with Haskell

2008-10-01 Thread Evan Laforge
On Wed, Oct 1, 2008 at 3:39 PM, Bill <[EMAIL PROTECTED]> wrote: > On Wed, 2008-10-01 at 16:46 -0400, John Van Enk wrote: > . . . >> I fully realize how un-clever this is. Some one please give me >> something more worth of the original list. :) > > You shoot the gun but nothing happens (Haskell is

Re: [Haskell-cafe] Injecting Haskell into C

2008-09-24 Thread Evan Laforge
> As I understand, there are two ways to do that. Either Haskell code is > called from C, or C code is called for Haskell. So my questions are: > 1. Are they both possible? Yep. > 2. If yes, which is better performance-wise? (C function is > performance-critical). If generated function is calle

Re: [Haskell-cafe] Random question

2008-09-24 Thread Evan Laforge
On Wed, Sep 24, 2008 at 2:03 PM, Iain Barnett <[EMAIL PROTECTED]> wrote: > Hi, > > I have a function, that produces a random number between two given numbers > > rand :: Int -> Int -> IO Int > rand low high = getStdRandom (randomR (low,high)) > > > (Naively) I'd like to write something like > > tak

Re: [Haskell-cafe] [m..n] question

2008-09-21 Thread Evan Laforge
> In Haskell, > "The sequence enumFromTo e1 e3 is the list [e1,e1+1,e1+2,...e3]. > The list is empty if e1 > e3." I like it, since it means that things like [n .. n + length m - 1] work as expected when m is []. Or say 'map (array!) [bsearch x .. bsearch y - 1]'. Tangent: Of course, I would pr

<    1   2   3   4   >