Re: [Haskell-cafe] Some thoughts on Type-Directed Name Resolution -record update

2012-02-10 Thread Steve Horne
On 10/02/2012 03:22, Donn Cave wrote: modifyRecord :: RecordType r = (a - a) - (r - a) - r - r data Config { tempo :: Int, ...} f = modifyRecord tempo (+20) I'm hoping I missed something, and that you don't intend the (r - a) part of this in particular to be taken literally.

Re: [Haskell-cafe] Some thoughts on Type-Directed Name Resolution

2012-02-08 Thread Steve Horne
On 07/02/2012 22:56, Richard O'Keefe wrote: On 8/02/2012, at 2:11 AM, Steve Horne wrote: To be fair, field OF record isn't bad in that sense. However, it would defeat the purpose of TDNR - the record isn't first, and therefore cannot be used (given a left-to-right typing direction

Re: [Haskell-cafe] Some thoughts on Type-Directed Name Resolution

2012-02-07 Thread Steve Horne
On 06/02/2012 23:58, Richard O'Keefe wrote: On 4/02/2012, at 12:13 AM, Gábor Lehel wrote: All of this said, record.field is still the most readable, intuitive, and familiar syntax for selecting a field from a record that I know of. Having learned COBOL and Algol 68 before Haskell was dreamed

Re: [Haskell-cafe] how to print out intermediate results in a recursive function?

2012-02-04 Thread Steve Horne
On 04/02/2012 08:46, MigMit wrote: Well, if you want that in production, not for debugging purposes, you should change the type signature of mergesort so that it uses some monad. Printing requires IO monad; however, I would advise to collect all intermediate results using Writer monad, and

Re: [Haskell-cafe] Some thoughts on Type-Directed Name Resolution

2012-02-03 Thread Steve Horne
On 03/02/2012 11:13, Gábor Lehel wrote: The first problem is that mixing prefix and postfix function application within the same line makes it harder to read. When you read code to try to understand what it does, the direction you like to go in is here's some object, first do this to it, then do

Re: [Haskell-cafe] Some thoughts on Type-Directed Name Resolution

2012-01-30 Thread Steve Horne
On 30/01/2012 07:09, Donn Cave wrote: ((separate . crack . .smallEnd) egg).yolk (f egg).yolk where f = separate . crack . .smallEnd Scary - that .smallEnd worries me. It's like a field is being referenced with some magical context from nowhere. Obviously I need to read that full proposal.

Re: [Haskell-cafe] Some thoughts on Type-Directed Name Resolution

2012-01-29 Thread Steve Horne
On 28/01/2012 13:00, Paul R wrote: AntC Steve, I think that proposal has been rather superseeded by AntC http://hackage.haskell.org/trac/ghc/wiki/Records/OverloadedRecordFields, which AntC draws on TDNR. But SORF is best seen as an evolving design space, with precise AntC details yet to be

Re: [Haskell-cafe] Some thoughts on Type-Directed Name Resolution

2012-01-29 Thread Steve Horne
On 30/01/2012 04:23, Steve Horne wrote: On 28/01/2012 13:00, Paul R wrote: AntC Steve, I think that proposal has been rather superseeded by AntC http://hackage.haskell.org/trac/ghc/wiki/Records/OverloadedRecordFields, which AntC draws on TDNR. But SORF is best seen as an evolving design

Re: [Haskell-cafe] Wow you have to check this out Haskell

2012-01-25 Thread Steve Horne
On 25/01/2012 16:13, R J wrote: hello Haskell the holidays are coming up soon and I think this can help http://www.news13open.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

[Haskell-cafe] Re: Wow you have to check this out Haskell - appols accidental resend of this scam spam

2012-01-25 Thread Steve Horne
Lesson = don't open e-mail client while borderline asleep. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

[Haskell-cafe] Some thoughts on Type-Directed Name Resolution

2012-01-23 Thread Steve Horne
There's a proposal at the moment to add support for TDNR to Haskell - to leverage the power of the dot (e.g. for intellisense). http://hackage.haskell.org/trac/haskell-prime/wiki/TypeDirectedNameResolution I approve of the goal, but I'd like to suggest a different approach. My basic idea is

Re: [Haskell-cafe] Monads, do and strictness

2012-01-21 Thread Steve Horne
On 21/01/2012 17:29, Victor S. Miller wrote: The do notation translates do {x- a;f} into a=(\x - f) However when we're working in the IO monad the semantics we want requires that the lambda expression be strict in its argument. So is this a special case for IO? If I wanted this behavior

Re: [Haskell-cafe] Monads, do and strictness

2012-01-21 Thread Steve Horne
On 21/01/2012 18:08, Steve Horne wrote: Even so, to see that strictness isn't the issue, imagine that (=) were rewritten using a unary executeActionAndExtractResult function. You could easily rewrite your lamba to contain this expression in place of x, without actually evaluating

Re: [Haskell-cafe] Code generation and optimisation for compiling Haskell

2012-01-12 Thread Steve Horne
On 11/01/2012 15:20, Thomas Schilling wrote: Based on your stated background, the best start would be the (longer) paper on the Spineless Tagless G-machine [1]. Thanks for the tips. I haven't read much yet, but considering [1], I guess I shouldn't have dismissed SPJs early 90's stuff so

[Haskell-cafe] Code generation and optimisation for compiling Haskell

2012-01-10 Thread Steve Horne
Although I'm far from being an expert Haskell programmer, I think I'm ready to look into some of the details of how it's compiled. I've a copy of Modern Compiler Design (Grune, Bal, Jacobs and Langendoen) - I first learned a lot of lexical and parsing stuff from it quite a few years ago.

Re: [Haskell-cafe] Simple type-class experiment turns out not so simple...

2012-01-09 Thread Steve Horne
On 08/01/2012 20:25, Brent Yorgey wrote: On Fri, Jan 06, 2012 at 10:51:58AM +, Steve Horne wrote: If I specify both extensions (-XMultiParamTypeClasses and -XFlexibleInstances) it seems to work, but needing two language extensions is a pretty strong hint that I'm doing it the wrong way

Re: [Haskell-cafe] Simple type-class experiment turns out not so simple...

2012-01-09 Thread Steve Horne
On 08/01/2012 21:13, Brandon Allbery wrote: (Also, de facto I think it's already more or less been decided in favor of type families, just because functional dependencies are (a) a bit alien [being a glob of Prolog-style logic language imported into the middle of System Fc] and (b) [as I

Re: [Haskell-cafe] Motivation for having indexed access in Data.Map?

2012-01-07 Thread Steve Horne
On 07/01/2012 12:17, Christoph Breitkopf wrote: Hello, I wonder why Data.Map provides the indexed access functions: http://hackage.haskell.org/packages/archive/containers/latest/doc/html/Data-Map.html#g:21 These functions seem rather out-of-place to me in the map api. The only use case I

[Haskell-cafe] Simple type-class experiment turns out not so simple...

2012-01-06 Thread Steve Horne
I was messing around with type-classes (familiarization exercises) when I hit a probably newbie problem. Reducing it to the simplest case... module BinTree ( WalkableBinTree, BT (Branch, Empty) ) where -- n : node type -- d : data item type wrapped in each node class WalkableBinTree n

Re: [Haskell-cafe] Simple type-class experiment turns out not so simple...

2012-01-06 Thread Steve Horne
On 06/01/2012 10:29, Steffen Schuldenzucker wrote: On 01/06/2012 11:16 AM, Steve Horne wrote: I was messing around with type-classes (familiarization exercises) when I hit a probably newbie problem. Reducing it to the simplest case... module BinTree ( WalkableBinTree, BT (Branch, Empty

Re: [Haskell-cafe] How to split this string.

2012-01-06 Thread Steve Horne
On 06/01/2012 10:39, Jon Fairbairn wrote: groupBy is currently implemented using span. It strikes me that we ought to specify some properties for what we want. Start by defining: pairwiseInOrderBy p l = all (uncurry p) (l `zip` drop 1 l) giving all (pairwiseInOrderBy p) (groupCut p l) and we

Re: [Haskell-cafe] How to split this string.

2012-01-05 Thread Steve Horne
On 05/01/2012 10:02, Jon Fairbairn wrote: Steve Hornesh006d3...@blueyonder.co.uk writes: Personally, I think this is a tad disappointing. Given that groupBy cannot check or enforce that it's test respects equivalence classes, it should ideally give results that make as much sense as possible

Re: [Haskell-cafe] How to split this string.

2012-01-05 Thread Steve Horne
On 05/01/2012 11:09, Brandon Allbery wrote: On Thu, Jan 5, 2012 at 05:57, Steve Horne sh006d3...@blueyonder.co.uk mailto:sh006d3...@blueyonder.co.uk wrote: -- groupCut - Similar to groupBy, but where groupBy assumes an equivalence relation, -- groupCut takes a function

Re: [Haskell-cafe] How to split this string.

2012-01-05 Thread Steve Horne
On 05/01/2012 11:55, Christian Maeder wrote: Am 05.01.2012 11:57, schrieb Steve Horne: [...] groupCut :: (x - x - Bool) - [x] - [[x]] [...] How about a break function that respects an escape character (1. arg) (and drops the delimiter - 2. arg) and use this function for unfolding

Re: [Haskell-cafe] How to split this string.

2012-01-04 Thread Steve Horne
On 02/01/2012 11:12, Jon Fairbairn wrote: maxm...@mtw.ru writes: I want to write a function whose behavior is as follows: foo string1\nstring2\r\nstring3\nstring4 = [string1, string2\r\nstring3, string4] Note the sequence \r\n, which is ignored. How can I do this? cabal install split then

Re: [Haskell-cafe] How to split this string.

2012-01-04 Thread Steve Horne
On 04/01/2012 16:47, Steve Horne wrote: (a == a) reflexivity : (a == b) = (b == a) transitivity : (a == b) (b == c) = (a == c) Oops - that's... reflexivity : (a == a) symmetry : (a == b) = (b == a) transitivity : (a == b) (b == c) = (a == c) An equivalence relation is a relation

Re: [Haskell-cafe] Grok Monad Transformers - some help needed

2012-01-02 Thread Steve Horne
On 02/01/2012 06:12, Arseniy Alekseyev wrote: I don't know what to actually do with this after putting it in a *.lhs file. You can :load *.lhs into ghci the same way you load .hs-files. I swear I tried this before, but now it suddenly works. Must be the chaos of stupid random assumptions

Re: [Haskell-cafe] How to split this string.

2012-01-02 Thread Steve Horne
On 02/01/2012 09:44, max wrote: I want to write a function whose behavior is as follows: foo string1\nstring2\r\nstring3\nstring4 = [string1, string2\r\nstring3, string4] Note the sequence \r\n, which is ignored. How can I do this? Doing it probably the hard way (and getting it wrong) looks

Re: [Haskell-cafe] On the purity of Haskell

2012-01-02 Thread Steve Horne
On 02/01/2012 10:03, Jerzy Karczmarczuk wrote: But I disagree quite strongly with the idea of /World parameter as purely hypothetical, a trick used to gain an intuition/. I mentioned the language Clean (no reaction, seems that Haskellians continue to ignore it...) I don't know about others,

Re: [Haskell-cafe] On the purity of Haskell

2012-01-01 Thread Steve Horne
On 01/01/2012 22:57, Jerzy Karczmarczuk wrote: Dan Doel : ... Also, the embedded IO language does not have this property. do x- m ; f x x is different from do x- m ; y- m ; f x y and so on. This is why you shouldn't write your whole program with IO functions; it lacks nice

[Haskell-cafe] Grok Monad Transformers - some help needed

2012-01-01 Thread Steve Horne
I'm having another go at figuring out Monad Transformers, starting at the same point I've started and stopped the last couple of times. That's this tutorial... http://blog.sigfpe.com/2006/05/grok-haskell-monad-transformers.html Onion layers, lift etc - I get that. But I've never actually got

Re: [Haskell-cafe] Are all monads functions?

2011-12-31 Thread Steve Horne
On 31/12/2011 13:18, Yves Parès wrote: But still, I maintain my previous view. I could clarify that by saying that (e.g. for Maybe) we could separate it in two types, Maybe itself and its monad: -- The plain Maybe type data Maybe a = Just a | Nothing -- The MaybeMonad newtype MaybeMonad a =

Re: [Haskell-cafe] On the purity of Haskell

2011-12-30 Thread Steve Horne
On 30/12/2011 10:41, Bardur Arantsson wrote: This doesn't sound right to me. To me, a side effect is something which happens as a (intended or unintended) consequence of something else. An effect which you want to happen (e.g. by calling a procedure, or letting the GHC runtime interpreting

Re: [Haskell-cafe] On the purity of Haskell

2011-12-30 Thread Steve Horne
On 30/12/2011 15:23, Gregg Reynolds wrote: Now one way of understanding all this is to say that it implicates the static/dynamic (compile-time/run-time) distinction: you don't know what e.g. IO values are until runtime, so this distinction is critical to distinguishing between pure and

Re: [Haskell-cafe] On the purity of Haskell

2011-12-30 Thread Steve Horne
On 30/12/2011 15:50, Gregg Reynolds wrote: On Dec 30, 2011, at 10:34 AM, Artyom Kazak wrote: Gregg Reynoldsd...@mobileink.com писал(а) в своём письме Fri, 30 Dec 2011 17:23:20 +0200: Regarding side-effects, they can be (informally) defined pretty simply: any non-computational effect

Re: [Haskell-cafe] On the purity of Haskell

2011-12-30 Thread Steve Horne
On 30/12/2011 10:47, Bardur Arantsson wrote: On 12/29/2011 11:06 PM, Steve Horne wrote: Using similar mixed definitions to conclude that every C program is full of bugs (basically equating intentional effects with side-effects, then equating side-effects with unintentional bugs) is a fairly

Re: [Haskell-cafe] On the purity of Haskell

2011-12-30 Thread Steve Horne
On 30/12/2011 20:38, Scott Turner wrote: On 2011-12-30 14:32, Steve Horne wrote: A possible way to implement a Haskell program would be... 1. Apply rewrite rules to evaluate everything possible without executing primitive IO actions. 2. Wait until you need to run the program. 3

Re: [Haskell-cafe] On the purity of Haskell

2011-12-29 Thread Steve Horne
On 29/12/2011 08:48, Heinrich Apfelmus wrote: Steve Horne wrote: Heinrich Apfelmus wrote: Purity has nothing to do with the question of whether you can express IO in Haskell or not. The beauty of the IO monad is that it doesn't change anything about purity. Applying the function

Re: [Haskell-cafe] On the purity of Haskell

2011-12-29 Thread Steve Horne
On 29/12/2011 18:04, Donn Cave wrote: Quoth Steve Hornesh006d3...@blueyonder.co.uk, ... Anyway, if you're using IO actions, your code is not referentially transparent and is therefore impure - by your own definition of impure. Causing side-effects may not be pedantically the issue, but the mix

Re: [Haskell-cafe] On the purity of Haskell

2011-12-29 Thread Steve Horne
On 29/12/2011 18:41, Chris Smith wrote: Entering tutorial mode here... On Thu, 2011-12-29 at 10:04 -0800, Donn Cave wrote: We can talk endlessly about what your external/execution results might be for some IO action, but at the formulaic level of a Haskell program it's a simple function value,

Re: [Haskell-cafe] On the purity of Haskell

2011-12-29 Thread Steve Horne
On 29/12/2011 19:21, Heinrich Apfelmus wrote: Why would IO Int be something special or mysterious? It's an ordinary value like everything else; it's on the same footing as [Char], Maybe Int, Int - String, Bool, and so on. I see no difference between the list [1,2,3] :: [Int] and the

Re: [Haskell-cafe] On the purity of Haskell

2011-12-29 Thread Steve Horne
side effects, why not call - let x = whatever in Something - also a local side-effect? Oh, that you can often transform let in the application of lambda, thus purely functional? Doesn't matter, Steve Horne will explain you that (sorry for the irony): let is a compile-time pure construct

Re: [Haskell-cafe] On the purity of Haskell

2011-12-29 Thread Steve Horne
On 29/12/2011 19:26, Heinrich Apfelmus wrote: Steve Horne wrote: Heinrich Apfelmus wrote: Again, purity refers to the semantics of functions (at run-time): given the same argument, will a function always return the same result? The answer to this question solely decides whether

Re: [Haskell-cafe] On the purity of Haskell

2011-12-29 Thread Steve Horne
On 29/12/2011 19:55, Bardur Arantsson wrote: On 12/29/2011 08:47 PM, Steve Horne wrote: On 29/12/2011 19:21, Heinrich Apfelmus wrote: BTW - why use an IO action for random number generation? There's a perfectly good pure generator. It's probably handy to treat it monadically to sequence

Re: [Haskell-cafe] On the purity of Haskell /Random generators

2011-12-29 Thread Steve Horne
On 29/12/2011 20:39, Jerzy Karczmarczuk wrote: Still, I dont understand what does S.H. mean by a perfectly good pure generator. Tell more please (unless you just mean a stream, say: Probably bad wording, to be honest. I only meant that there's random number handling support in the Haskell

Re: [Haskell-cafe] On the purity of Haskell

2011-12-29 Thread Steve Horne
On 29/12/2011 21:01, Chris Smith wrote: On Thu, 2011-12-29 at 18:07 +, Steve Horne wrote: By definition, an intentional effect is a side-effect. To me, it's by deceptive redefinition - and a lot of arguments rely on mixing definitions - but nonetheless the jargon meaning is correct within

Re: [Haskell-cafe] On the purity of Haskell /Random generators

2011-12-29 Thread Steve Horne
On 29/12/2011 21:51, Jerzy Karczmarczuk wrote: Steve Horne : I only meant that there's random number handling support in the Haskell library and, and least judging by type signatures, it's pure functional code with no hint of the IO monad. Look well at those functions, please. Challenge

Re: [Haskell-cafe] On the purity of Haskell

2011-12-29 Thread Steve Horne
On 30/12/2011 00:16, Sebastien Zany wrote: Steve Horne wrote: I haven't seen this view explicitly articulated anywhere before See Conal Elliott's blog post The C language is purely functional http://conal.net/blog/posts/the-c-language-is-purely-functional. Thanks - yes, that's basically

Re: [Haskell-cafe] On the purity of Haskell

2011-12-29 Thread Steve Horne
On 29/12/2011 23:30, Chris Smith wrote: Sorry to cut most of this out, but I'm trying to focus on the central point here. On Thu, 2011-12-29 at 22:01 +, Steve Horne wrote: In pure functional terms, the result should be equivalent to a fully evaluated value - but putStrLn isn't pure

Re: [Haskell-cafe] On the purity of Haskell /Random generators

2011-12-29 Thread Steve Horne
On 30/12/2011 00:22, Jerzy Karczmarczuk wrote: Steve Horne : Some code (intended to be loaded into GHCi and played with) -- import System.Random -- randSelect this is a list 5 (mkStdGen 9877087) -- ... module P23 (randSelect) where -- ... randSelect' (x:xs) n l g

[Haskell-cafe] Level of Win32 GUI support in the Haskell platform

2011-12-29 Thread Steve Horne
I've been for functions like GetMessage, TranslateMessage and DispatchMessage in the Haskell Platform Win32 library - the usual message loop stuff - and not finding them. Hoogle says no results found. Is this level of Win32 GUI coding supported? (other than by dealing with the FFI myself)

Re: [Haskell-cafe] On the purity of Haskell

2011-12-29 Thread Steve Horne
On 30/12/2011 01:37, Chris Smith wrote: On Fri, 2011-12-30 at 00:44 +, Steve Horne wrote: So, to resurrect an example from earlier... f :: Int - IO Int f = getAnIntFromTheUser= \i - return (i+1) Did you mean f :: IO Int ? If not, then I perhaps don't understand your example, and your

Re: [Haskell-cafe] On the purity of Haskell

2011-12-29 Thread Steve Horne
On 30/12/2011 01:40, Scott Turner wrote: On 2011-12-29 19:44, Steve Horne wrote: [Interaction with its environment] is as much an aspect of what Haskell defines as the functional core. Switching mental models doesn't change the logic But it does. Other languages do not support the distinction

Re: [Haskell-cafe] Level of Win32 GUI support in the Haskell platform

2011-12-29 Thread Steve Horne
On 30/12/2011 03:43, Chris Wong wrote: On Fri, Dec 30, 2011 at 2:53 PM, Steve Horne sh006d3...@blueyonder.co.uk wrote: I've been for functions like GetMessage, TranslateMessage and DispatchMessage in the Haskell Platform Win32 library - the usual message loop stuff - and not finding them

Re: [Haskell-cafe] Level of Win32 GUI support in the Haskell platform

2011-12-29 Thread Steve Horne
On 30/12/2011 04:07, Chris Smith wrote: On Fri, 2011-12-30 at 01:53 +, Steve Horne wrote: I've been for functions like GetMessage, TranslateMessage and DispatchMessage in the Haskell Platform Win32 library - the usual message loop stuff - and not finding them. Hoogle says no results found

[Haskell-cafe] On the purity of Haskell

2011-12-28 Thread Steve Horne
This is just my view on whether Haskell is pure, being offered up for criticism. I haven't seen this view explicitly articulated anywhere before, but it does seem to be implicit in a lot of explanations - in particular the description of Monads in SBCs Tackling the Awkward Squad. I'm entirely

Re: [Haskell-cafe] On the purity of Haskell

2011-12-28 Thread Steve Horne
On 28/12/2011 20:44, Heinrich Apfelmus wrote: Steve Horne wrote: This is just my view on whether Haskell is pure, being offered up for criticism. I haven't seen this view explicitly articulated anywhere before, but it does seem to be implicit in a lot of explanations - in particular

Re: [Haskell-cafe] On the purity of Haskell

2011-12-28 Thread Steve Horne
On 28/12/2011 22:01, Jerzy Karczmarczuk wrote: Le 28/12/2011 22:45, Steve Horne a écrit : Yes - AT COMPILE TIME by the principle of referential transparency it always returns the same action. However, the whole point of that action is that it might potentially be executed (with potentially

Re: [Haskell-cafe] On the purity of Haskell

2011-12-28 Thread Steve Horne
On 28/12/2011 23:56, Bernie Pope wrote: On 29 December 2011 10:51, Steve Hornesh006d3...@blueyonder.co.uk wrote: As Simon Baron-Cohen says in Tackling the Awkward Squad... I think you've mixed up your Simons; that should be Simon Peyton Jones. Oops - sorry about that. FWIW - I'm diagnosed

Re: [Haskell-cafe] On the purity of Haskell

2011-12-28 Thread Steve Horne
Sorry for the delay. I've written a couple of long replies already, and both times when I'd finished deleting all the stupid stuff there was nothing left - it seems I'm so focussed on my own view, I'm struggling with anything else today. Maybe a third try... On 28/12/2011 19:38, AUGER Cédric

Re: [Haskell-cafe] On the purity of Haskell

2011-12-28 Thread Steve Horne
On 29/12/2011 00:57, Thiago Negri wrote: We can do functional programming on Java. We use all the design patterns for that. At the very end, everything is just some noisy, hairy, side-effectfull, gotofull machinery code. The beauty of Haskell is that it allows you to limit the things you need

Re: [Haskell-cafe] On the purity of Haskell

2011-12-28 Thread Steve Horne
On 29/12/2011 01:53, Antoine Latter wrote: The beauty of the IO monad is that it doesn't change anything about purity. Applying the function bar :: Int - IO Int to the value 2 will always give the same result: Yes - AT COMPILE TIME by the principle of referential transparency it always

[Haskell-cafe] Haskell Platform and Windows - where's 2011.4?

2011-12-27 Thread Steve Horne
On haskell.org, the 2011.4.0.0 version is shown as the current stable release - but the most recent download link is for the 2011.2.0.0 version. This is bugging me a little because the documentation in the 2011.2 Haskell Platform download for Windows is broken - there's at least one bug

Re: [Haskell-cafe] Haskell Platform and Windows - where's 2011.4?

2011-12-27 Thread Steve Horne
On 27/12/2011 18:36, Bas van Dijk wrote: On 27 December 2011 19:13, Steve Hornesh006d3...@blueyonder.co.uk wrote: On haskell.org, the 2011.4.0.0 version is shown as the current stable release - but the most recent download link is for the 2011.2.0.0 version. What download link are you

Re: [Haskell-cafe] Haskell Platform and Windows - where's 2011.4?

2011-12-27 Thread Steve Horne
On 27/12/2011 18:57, Steve Horne wrote: OK - I really should have tried that before. But... why would an old page hang around in my Firefox cache so long and not get updated? I've not had this on any other sites. I still should be doing more checking before posting. A look in the source