Re: [Haskell-cafe] Re: Explaining monads

2007-08-13 Thread Arie Peterson
On 8/13/07, David Roundy [EMAIL PROTECTED] wrote: | Try executing: | | do { x - return 2; undefined; return (x*x); } | | in any monad you like It's not just the identity monad: Prelude :m +Control.Monad.State Prelude Control.Monad.State flip evalState () $ do { x - return 2; undefined;

Re: [Haskell-cafe] Explaining monads

2007-08-14 Thread Arie Peterson
Dan Piponi wrote: | On 8/14/07, Lennart Augustsson [EMAIL PROTECTED] wrote: | You don't normally call x::Int a computation of an Int because there's | nothing that distinguishes the value of the x from what it was before | you computed it. | | Can you spell out exactly what you mean by this?

[Haskell-cafe] Unicode vs. System.Directory

2010-05-26 Thread Arie Peterson
After upgrading to haskell-platform-2010.1.0.0, with the improved unicode support for IO in ghc-6.12, I hoped to be able to deal with filenames containing non-ascii characters. This still seems problematic, though: $ ls m×n♯α $ ghci GHCi, version 6.12.1: :? for help

[Haskell-cafe] Resource module

2010-06-01 Thread Arie Peterson
Dear list, For some time, I have maintained a small private module centred around the following type of resource: newtype Resource cap m = Resource { with :: forall a. (cap - m a) - m a } Interpretation: @Resource cap m@ is a resource, providing a capability of type @cap@, which does

Re: [Haskell-cafe] Resource module

2010-06-01 Thread Arie Peterson
On Tue, 1 Jun 2010 21:10:40 +0200, Bas van Dijk wrote: | [...] | Hi Arie, I would love to see some examples of these resources for | which you can't define a Resource[1] instance. | [...] | | [1] |

Re: [Haskell-cafe] Resource module

2010-06-02 Thread Arie Peterson
On Wed, Jun 2, 2010 at 2:28 PM, Bas van Dijk wrote: Before answering your questions I would like to make sure I understand your Resource type. When I want to create a memory Resource for example is the following what you have in mind? {-# LANGUAGE Rank2Types #-} --

Re: class [] proposal Re: [Haskell-cafe] One thought: Num to 0 as ? to list?

2006-08-22 Thread Arie Peterson
Hello Bryan, On 2006-08-22, Bryan Burgers [EMAIL PROTECTED] wrote: so, while this proposal is rather minor, i think that it is Good thing I disagree. As a new learner to Haskell, I already have a hard time keeping Constructors, Types, and Classes straight. I know what they all are and what

Re: class [] proposal Re: [Haskell-cafe] One thought: Num to 0as ? to list?

2006-08-22 Thread Arie Peterson
Hello Brian and others, On 2006-08-22, Brian Hulley [EMAIL PROTECTED] wrote: I wouldn't like it because I'd like to eventually make the class namespace separate from the tycon namespace so that I could write: class Object a where ... data Object = forall a. Object a =

[Haskell-cafe] Re: type synonym liberalization (was class [] proposal)

2006-08-22 Thread Arie Peterson
Hello Brandon, This could be handled with existential wrappers, except that the wrapping is annoying, and probably interferes with optimizing when a concrete type is known. Instead, a few changes to type synonyms handle Bulat's cases. With the proper interpretation, type synonyms like

[Haskell-cafe] Re: NaN, Infinity literals

2006-09-09 Thread Arie Peterson
Ashley Yakeley wrote: Bertram Felgenhauer wrote: This is correct according to the IEEE 754 standard, which defines that NaN compares unequal to everything, including itself. This is numerically useful, perhaps, but nonetheless disturbing. For it would be helpful to expect that any type

[Haskell-cafe] Re: a monad for secret information

2006-10-10 Thread Arie Peterson
David Roundy wrote: Try module Secret (Secret, classify, declassify) where data Secret a = Secret String a classify :: String - a - Secret a classify pw x = Secret pw x declassify :: Secret a - String - Maybe a declassify (Secret pw x) pw' | pw' == pw = Just x declassify (Secret _ _) _ =

Re: [Haskell-cafe] Automatic fixity allocation for symbolic operators

2006-10-16 Thread Arie Peterson
Hello, Henning Thielemann wrote: [...] I repeat my example of a source code formatting tool which must decide whether to format a + b * c or a + b * c It needs to know the precedences of the used operators, which, as Brian pointed out, is possibly not even defined

[Haskell-cafe] Re: Automatic fixity allocation for symbolic operators

2006-10-16 Thread Arie Peterson
Nicolas Frisby wrote: What if operator precedences were specified as a partial order instead of using numbers? Henning Thielemann wrote: says: great minds think alike Funny, I thought of this too. It seems very natural. You would probably want an implicit taking of transitive

[Haskell-cafe] Re: Automatic fixity allocation for symbolic operators

2006-10-16 Thread Arie Peterson
Good evening, Bulat Ziganshin wrote: but when you want to have user-defined operators, that will mean that you need either to define precedences to all other operators (including those from other libs), or sometimes user programs will not compile because they used combination of operators

Re: [Haskell-cafe] A type class puzzle

2006-10-31 Thread Arie Peterson
Greg Buchholz wrote: ...That first article is the strangest. I couldn't reconcile the fact that if our type signature specifies two arguments, we can pattern match on three arguments in the function definition. Compare the number of arguments in the first and second instances... class

[Haskell-cafe] Re: A type class puzzle

2006-10-31 Thread Arie Peterson
Greg Buchholz wrote: I guess it just looks really strange to my eyes. For example, foo and bar are legal, but baz isn't. That's what I was thinking of the situation, but I guess the type classes iron out the differences. Ah, but here 'baz' is illegal because of the (somewhat arbitrary)

[Haskell-cafe] Re: Fractional/negative fixity?

2006-11-07 Thread Arie Peterson
David House wrote: Also, it provides an infinite space for fixities. I think the problem 'binds tighter than X but not as tight as Y', where X and Y are only fixity integer apart is somewhat common, and this would fix it. It would allow for extensibility into the future, where the operator

[Haskell-cafe] File locked unnecessarily

2006-12-03 Thread Arie Peterson
Hi, After a partial rewrite of my webserver, it is suffering from locked files: /path/to/file: openBinaryFile: resource busy (file is locked) The file in question really shouldn't be locked: - Only my server knows of the file's existence. - Only one thread accesses the file. - The

[Haskell-cafe] Re: File locked unnecessarily

2006-12-03 Thread Arie Peterson
Vyacheslav Akhmechet [EMAIL PROTECTED] wrote: Are you using hGetContents? If you are, take a closer look at the documentation. The function creates a lazy stream and until you finish reading from it the file will be in the semi-closed state (which means it will be locked). No. I read/write

[Haskell-cafe] Re: File locked unnecessarily

2006-12-06 Thread Arie Peterson
Ian Lynagh wrote: Does anyone know what could cause this locking and/or how to prevent it? Nothing else springs to mind. Are you able to send an example that shows the problem? (obviously the smaller the example, the better). I'll try to cut down the offending program to a workable size.

[Haskell-cafe] Re: GADTs vs arrows/typeclasses

2006-12-06 Thread Arie Peterson
Hi Alex, S. Alexander Jacobson wrote: I guess I'm also not sure what belongs in a GADT and what belongs in a typeclass e.g. here is an Arrow GADT data Arrow b c where Arr::(b-c) - Arrow b c Compose::Arrow b c - Arrow c d - Arrow b d First::Arrow a b - Arrow (a,c) (b,c)

[Haskell-cafe] Re: File locked unnecessarily

2006-12-06 Thread Arie Peterson
Vyacheslav Akhmechet wrote: Yes. I've run into similar issues with hs-plugins (albeit not the same). What platform are you running on? How are you compiling your code? Try compiling it with the -threaded flag and see if it fixes your problem. My platform is amd64 (x86_64). I usually compile

[Haskell-cafe] Re: Cannot understand liftM2

2006-12-11 Thread Arie Peterson
I'm loving learning Haskell quite a bit. It is stretching my brain but in a delightfull way. Great! Using the cool lambdabot pointless utility I found out that: \x - snd(x) - fst(x) is the same as: liftM2 (-) snd fst Yes, the '(-) c' monad is very handy. One way to think about it is

Re: [Haskell-cafe] Writing Haskell For Dummies Or At Least For People Who Feel Like Dummies When They See The Word 'Monad'

2006-12-11 Thread Arie Peterson
[...] I think the concept of computer is better to see as sort of telescope or translator. Computers allow to look at processes (and complexity) which would otherwise not conceivable to our limited minds. The idea of computers as telescopes is from Daniel Dennett though. Computer Science is

[Haskell-cafe] Re: Aim Of Haskell

2006-12-12 Thread Arie Peterson
Haskell is just too similar to Pascal. This makes me wonder how people pronounce Pascal. It's probably because I'm from Europe, but I put the stress on the second syllable. Pronouncing it like rascal is, well, funny :-). Greetings, Arie -- making someone not survive must surely count as

[Haskell-cafe] Re: what are the points in pointsfree?

2006-12-15 Thread Arie Peterson
Hello, Please view my claims with a healthy dose of scepticism: I know a little category theory, but only from the mathematical point of view, not as employed in computer science. Scott Brickner wrote: Anyway, as I understood it, the points were the terminal objects of the category in which

[Haskell-cafe] File locked unnecessarily (the continuation)

2007-01-19 Thread Arie Peterson
Hi all, Some time ago I reported a strange file locking problem. I have reduced my offending program to a relatively small size. This reduction process was quite entertaining. At one point, I could reliably turn the locking off and on by removing and reintroducing a certain unused import :s. I

[Haskell-cafe] File locked unnecessarily (the file)

2007-01-19 Thread Arie Peterson
Except that the example was not attached. Sorry. Greetings, Arie min.tar.gz Description: application/gzip ___ Haskell-Cafe mailing list

[Haskell-cafe] Re: ANNOUNCE: binary: high performance, pure binary serialisation

2007-01-26 Thread Arie Peterson
Joel Reymont wrote: May I ask why TH is easier to maintain than DrIFT? I'm not familiar with DrIFT. The reason is personal, and very silly. I only use ghc, so TH is available automatically. Like you, I have never used DrIFT, so I would have to get to know it, and install it everywhere I want

Re: [Haskell-cafe] State of OOP in Haskell

2007-01-29 Thread Arie Peterson
Steve Downey wrote: | OO, at least when done well, maps well to how people think. Things | that can be directed to perform actions. There is also a well | developed practice of OO analysis and design. It's not clear (at least | to me) that there is an equivalent set of practices for functional |

[Haskell-cafe] Re: ANNOUNCE: The Monad.Reader - Issue 6

2007-01-31 Thread Arie Peterson
Pixel wrote: i ended up with this one: dwBool predicate l = (foldr combine (\_ - []) l) True where combine e fl beg = if beg predicate e then fl True else e : fl False higher-order, like solutions 3 4, but simpler IMO :p This

Re: [Haskell-cafe] Unnecessarily strict implementations

2010-09-02 Thread Arie Peterson
On Thu, 2 Sep 2010 19:30:17 +0200, Daniel Fischer wrote: Why would one consider using Ord for Map an abuse? A kludge, for performance reasons, but an abuse? Because it forces one to declare Ord instances for types which have no natural ordering. It is useful to *not*

Re: [Haskell-cafe] Unnecessarily strict implementations

2010-09-03 Thread Arie Peterson
On Fri, 3 Sep 2010 12:02:22 +1000, Ivan Lazar Miljenovic wrote: What precisely do you mean by natural ordering? An ordering that has relevant meaning for the information represented by the datatype. Ideally, it should also be alone in being the order anyone would expect

[Haskell-cafe] Re: Unwrapping newtypes

2010-09-08 Thread Arie Peterson
On Wed, 8 Sep 2010 05:51:22 -0700 (PDT), Kevin Jardine wrote: Ah, I was missing an important piece of the puzzle. If I write: class ToObj a where toObj :: a - Obj instance ToObj Obj where toObj a = a then newtype Blog = Blog Obj deriving ToObj

Re: [Haskell-cafe] A question regarding cmdargs package

2010-10-04 Thread Arie Peterson
On Sun, 03 Oct 2010 19:18:08 +0200, Ben Franksen wrote: How can I disable the standard arguments 'help' and 'version'? If you're not fully committed to the cmdargs package, you might try my package 'console-program' instead

[Haskell-cafe] Re: MonadCatchIO, finally and the error monad

2010-10-17 Thread Arie Peterson
On Thu, 14 Oct 2010 12:01:59 +0200, Michael Snoyman wrote: [...] which I believe is a flawed design in the MonadCatchIO-transformers package. Here are my thoughts on this and what I think needs to be done to fix it. [...] Try running the code with each version of go

[Haskell-cafe] Re: Haskell version of Norvig's Python Spelling Corrector

2007-04-21 Thread Arie Peterson
Hi Pete, Recently I read an interesting article by Peter Norvig[1] on how to write a spelling corrector in 21-lines of Python. I wanted to try and implement it in Haskell. My implementation is terribly slow and I was hoping for some tips on how to improve it and make it idiomatic. I had a

[Haskell-cafe] Re: The danger of Monad ((-) r)

2007-05-15 Thread Arie Peterson
Hi Tomek! In a CGI application I was gathering SQL statements I wanted to run in the final transaction. Because I use haskelldb, it was most convenient to use (Database - IO ()) as the type of the statement or a group of statements. In this representation concatenating two statement groups

[Haskell-cafe] Re: Bug in GADT Implementation?

2007-05-26 Thread Arie Peterson
Dominic Steinitz wrote: I suppose I could read my example as if there is anything that matches Range BITSTRING _ _ then do the following and since nothing can ever match it then it's a redundant case. But I would expect the compiler to at least warn me that nothing can ever match this. Why

[Haskell-cafe] Re: I just don't get it (data structures and OO)

2007-06-03 Thread Arie Peterson
You could also use 'compositional functional references'. These are introduced in the paper A Functional Programming Technique for Forms in Graphical User Interfaces by Sander Evers, Peter Achten and Jan Kuper. === Introduction === There are two things one typically wants to do when working with

[Haskell-cafe] Ref and Derive

2007-06-03 Thread Arie Peterson
Hello, Stefan O'Rear wrote: I've implemented this in Derive[1] in 12 minutes, counting the time required to re-familiarize with the code. The patch is at [2] and has also been darcs sent. Neil Mitchell wrote: It's been applied, and is now in the main repo. Wow, that was fast. I didn't

[Haskell-cafe] Re: I just don't get it (data structures and OO)

2007-06-04 Thread Arie Peterson
David Menendez wrote: | That's a neat idiom. I wonder how far one could usefully generalize it. | | For example, | | type Ref cx t = forall f. Functor f = (t - f t) - cx - f cx | | newtype Id a = Id { unId :: a } | instance Functor Id where fmap f = Id . f . unId | | newtype K t a

Re: [Haskell-cafe] Practical Haskell question.

2007-06-25 Thread Arie Peterson
As others have explained, you can't analyse your do-constructs, because functions are opaque -- at the value level. The canonical option would indeed seem to be to use arrows (or applicative functors), instead of monads. -- If you want to stick to monads, there is another possibility: carry

Re: [Haskell-cafe] Practical Haskell question.

2007-06-25 Thread Arie Peterson
I wrote: If you want to stick to monads, there is another possibility: carry around the necessary checks *at the type level*. Below is a sketch of how you could do this. Importantly, the given code still requires you to specify the checks by hand, when running the action; it only checks that

[Haskell-cafe] Status of MIME Strike Force

2007-06-27 Thread Arie Peterson
Hi, What is the status of the MIME Strike Force? The goals proposed at promise a very useful library. Has the design been initiated? Kind regards, Arie ___ Haskell-Cafe mailing

Re: [Haskell-cafe] Status of MIME Strike Force

2007-06-28 Thread Arie Peterson
Jeremy Shaw wrote: What is the status of the MIME Strike Force? Currently it is on hold while I work on some other higher priority projects. But, I do hope to get back to it soon. (Or, perhaps someone else will have time to work on it). OK. Good to hear it is still alive, if slumbering. I

Re: [Haskell-cafe] let vs do?

2007-06-29 Thread Arie Peterson
Dave Bayer wrote: [...] In the Haskell do expression, every line is equally special, and type information is used to combine the lines, inserting implied combinators.[...] Desugaring do-notation is a syntactic transformation, requiring no type information. (In practice, the parts may be

Re: [Haskell-cafe] advice: instantiating/duplicating modules

2007-06-30 Thread Arie Peterson
Dave Bayer wrote: I've since done some experiments with Template Haskell, and I see that Arie Peterson has suggested how you could proceed. However, are you sure that you can't find a way to get this to work in vanilla Haskell without extensions? Or, for that matter, are you sure there isn't

[Haskell-cafe] Re: Parsers are monadic?

2007-07-02 Thread Arie Peterson
Gregory Propf wrote: Right, I read more about it and found this out. The 'main' function is apparently magical at runtime and allows you to break the with pure functionality just once but since it can call other functions this allows for useful programs to be written. There is more than one

Re: [Haskell-cafe] Very simple parser

2007-07-02 Thread Arie Peterson
Gregory Propf wrote: As a programming exercise I'm trying to use the State monad to create a simple parser. It's for a very simple assembly language for a simple virtual machine. The state is a string of instructions. I want to be able to call something like getNextInstruction to pull out

Re: [Haskell-cafe] Very simple parser

2007-07-02 Thread Arie Peterson
Gregory Propf wrote: | [...] For example, am I to assume that I need to | create my own instance of State and then define get and put for it? No, there is a 'State s' monad provided (for arbitrary state type 's'), which implements the 'get' and 'put' methods. In other words, 'State s' is an

Re: [Haskell-cafe] Very simple parser

2007-07-04 Thread Arie Peterson
Alexis Hazell wrote: | This may be a stupid question, but i don't understand how (indeed, if) one | can | maintain multiple states using the State monad, since 'get' etc. don't | seem | to require that one specify which particular copy of a State monad one | wishes | to 'get' from, 'put' to etc.?

Re: [Haskell-cafe] Re: monads and groups -- instead of loops

2007-08-01 Thread Arie Peterson
Math alert: mild category theory. Greg Meredith wrote: But, along these lines i have been wondering for a while... the monad laws present an alternative categorification of monoid. At least it's alternative to monoidoid. I wouldn't call monads categorifications of monoids, strictly speaking.

Re: [Haskell-cafe] Newbie question (again!) about phantom types

2007-08-08 Thread Arie Peterson
I’m having difficulty to understand what phantom types are good for. Is this just for improving runtime performance? No. As the wiki says, you can use them to add static guarantees. I read the wiki, and it says this is useful if you want to increase the type-safety of your code, but the

Re: [Haskell-cafe] Incompatibility of different (monad transformer) libraries

2009-03-16 Thread Arie Peterson
On Sat, 14 Mar 2009 02:14:53 +0100 (CET), Henning Thielemann wrote: I think 'transformers' exports Control.Monad.Trans.State. This should not conflict with MTL. However, MTL's State type is different from transformer's one. Is that your problem? No. The

Re: [Haskell-cafe] Solving integer equations in Haskell

2012-10-15 Thread Arie Peterson
Can anyone suggest a library written in Haskell which can solve equations of the form xM(transpose(x)) = y, where x should be an integer vector, M is an integer matrix and y is an integer? I'm aware that Mathematica can do this, but I would like something written in Haskell. I haven't been

[Haskell-cafe] Computed promoted natural

2012-11-08 Thread Arie Peterson
Hi, I'm trying to use data kinds, and in particular promoted naturals, to simplify an existing program. The background is as follows: I have a big computation, that uses a certain natural number 'd' throughout, which is computed from the input. Previously, this number was present as a field

Re: [Haskell-cafe] Computed promoted natural

2012-11-09 Thread Arie Peterson
Hello Iavor, One way to achieve the additional static checking is to use values of type `Sing (n :: Nat)` in the places where you've used `Integer` (and parameterize data structures by the `n`). If the code is fully polymorphic in the `n`, then you can use it with values whose types as not

Re: [Haskell-cafe] Computed promoted natural

2012-11-09 Thread Arie Peterson
On Thursday 08 November 2012 17:15:49 Ertugrul Söylemez wrote: | […] | The idea is that reifyNum takes a polymorphic (!) function in 'n', such | that the function can guarantee that it can handle any 'n', as long as | it's an instance of ReflectNum. Now since the argument function is |

Re: [Haskell-cafe] Computed promoted natural

2012-11-09 Thread Arie Peterson
On Friday 09 November 2012 17:53:54 Ertugrul Söylemez wrote: I'm not sure if you're supposed to use the reflection library that way. The idea is simply this: reify :: a - (forall s. Reifies s a = Proxy s - r) - r You pass in a value, any value you like actually ('reify' is fully

Re: [Haskell-cafe] Computed promoted natural

2012-11-10 Thread Arie Peterson
On Friday 09 November 2012 17:53:54 Ertugrul Söylemez wrote: I'm not sure if you're supposed to use the reflection library that way. The idea is simply this: […] All right, I switched to this method, and it workes like a charm. It is also more general than my attempt using data kinds, in the

[Haskell-cafe] Future of MonadCatchIO

2013-03-03 Thread Arie Peterson
Hi all, The function 'block' and 'unblock' (from Control.Exception) have been deprecated for some time, and are apparantly now being removed (in favour of 'mask'). Generalisations of these functions are (part of) the interface of MonadCatchIO-transformers (the 'MonadCatchIO' class has

Re: [Haskell-cafe] Future of MonadCatchIO

2013-03-03 Thread Arie Peterson
On Sunday 03 March 2013 17:07:18 Ertugrul Söylemez wrote: Would anyone have a problem with a deprecation of MonadCatchIO-transformers, and a failure to update it to work with a base without 'block' and 'unblock'? Yes. This is a simplified variant of a monad I use: newtype Continue

Re: [Haskell-cafe] catching IO errors in a monad transformer stack

2013-07-21 Thread Arie Peterson
On Thursday 18 July 2013 23:05:33 Eric Rasmussen wrote: […] Would there be any interest in cleaning that up and adding it (or something similar) to Control.Monad.CatchIO? […] MonadCatchIO-transformers is being deprecated, as recently GHC has removed the 'block' and 'unblock' functions,

[Haskell-cafe] Increasing memory use in stream computation

2013-10-10 Thread Arie Peterson
(Sorry for the long email.) Summary: why does the attached program have non-constant memory use? Introduction I've written a program to do a big computation. Unfortunately, the computation takes a very long time (expectedly), and the memory use increases slowly (unexpectedly),

Re: [Haskell-cafe] Increasing memory use in stream computation

2013-10-10 Thread Arie Peterson
Hi Claude, Looking at the heap profile graph (generated with +RTS -h, no need to compile with profiling) I see the increasing memory use is split about evenly between STACK and BLACKHOLE. I don't know what that means or why it occurs, but replacing `small` solved that problem for me:

Re: [Haskell-cafe] Increasing memory use in stream computation

2013-10-10 Thread Arie Peterson
Hi Bertram, Unfortunately, I don't know. I'll intersperse some remarks and propose an alternative to stream fusion at the end, which allows your test program to run in constant space. A quicker way to spot the increased memory usage is to look at GC statistics. I used ./Test +RTS

Re: [Haskell-cafe] Increasing memory use in stream computation

2013-10-14 Thread Arie Peterson
Hi Claude, On Thursday 10 October 2013 20:05:37 I wrote: Although, maybe I can do all the logic of the small function in the list monad, and stream the resulting list, as you do in the above. I tried a corresponding variant of my full program, but the memory use is quite a lot higher at the