Re: [Haskell-cafe] Understanding allocation behavior

2006-04-10 Thread Robert Dockins
, though ;-) Rob Dockins Cheers, Daniel Am Sonntag, 9. April 2006 00:54 schrieb Robert Dockins: On Apr 8, 2006, at 1:58 PM, David F. Place wrote: Thanks Bulat and Robert. I implemented Bulat's idea as the following. It tests faster than Roberts. I use Robert's to compute the table

Re: Re[2]: [Haskell-cafe] Understanding allocation behavior

2006-04-08 Thread Robert Dockins
On Apr 8, 2006, at 1:58 PM, David F. Place wrote: Thanks Bulat and Robert. I implemented Bulat's idea as the following. It tests faster than Roberts. I use Robert's to compute the table. The performance seems satisfactory now. size :: Set a - Int size (Set w) = countBits w where

Re: [Haskell-cafe] Justification for Ord inheriting from Eq?

2006-04-07 Thread Robert Dockins
On Apr 7, 2006, at 9:43 AM, Jacques Carette wrote: Robert Dockins wrote: The behaviour of NaN actually makes perfect sense when you realise that it is Not a Number. Things that are not numbers are incomparable with things that are. Yes, NaN can be of type Float. But it's not a Float

Re: [Haskell-cafe] Re: [Haskell] What's up with this Haskell runtime error message:

2006-04-06 Thread Robert Dockins
On Apr 6, 2006, at 11:25 AM, Michael Goodrich wrote: Thanks so much for your help. I should have made clear that I was aware that the definitions were mutually dependent. What I was hoping was that Haskell could solve this for me without my having to resort to effectively finessing any

Re: [Haskell-cafe] Justification for Ord inheriting from Eq?

2006-04-06 Thread Robert Dockins
On Thursday 06 April 2006 06:44 pm, John Meacham wrote: On Thu, Apr 06, 2006 at 10:52:52PM +0100, Brian Hulley wrote: [snip a question about Eq and Ord classes] well, there are a few reasons you would want to use inheritance in haskell, some good, some bad. 1. one really does logically

Re: [Haskell-cafe] show for functional types

2006-04-05 Thread Robert Dockins
On Apr 5, 2006, at 10:49 AM, Brian Hulley wrote: Robert Dockins wrote: On Apr 1, 2006, at 3:23 PM, Brian Hulley wrote: [snip] For particular types T1 and T2, if (f (x::T1))::T2 === g x for all x in T1 then f :: T1-T2 and g ::T1-T2 can be freely substituted since the context T1-T2 cannot

Re: [Haskell-cafe] show for functional types

2006-04-05 Thread Robert Dockins
On Apr 5, 2006, at 12:42 PM, Josef Svenningsson wrote: Sorry to barge in in the middle of your discussion here.. Hey, if we wanted a private conversation, we'd take it off-list. :-) On 4/5/06, Robert Dockins [EMAIL PROTECTED] wrote: There is a fair bit of disagreement about what

Re: [Haskell-cafe] What's up with this Haskell runtime error message:

2006-04-05 Thread Robert Dockins
On Wednesday 05 April 2006 04:51 pm, Michael Goodrich wrote: Oops, I just realized that you gave me the answer, namely that it won't find fixed points of numeric sets of equations. Pity, that would really have made Haskell useful for this kind of scientific computing. See section 4 of:

Re: [Haskell-cafe] show for functional types

2006-04-04 Thread Robert Dockins
On Apr 1, 2006, at 3:23 PM, Brian Hulley wrote: Robert Dockins wrote: [snip] From an earlier post: Now since f and g compute the same results for the same inputs, anywhere in a program that you can use f you could just replace f by g and the observable behaviour of the program would

Re: [Haskell-cafe] show for functional types

2006-04-01 Thread Robert Dockins
On Saturday 01 April 2006 07:50 am, Brian Hulley wrote: Greg Buchholz wrote: Hmm. It must be a little more complicated than that, right? Since after all you can print out *some* functions. That's what section 5 of _Fun with Phantom Types_ is about. Here's a slightly different

Re: [Haskell-cafe] show for functional types

2006-04-01 Thread Robert Dockins
On Saturday 01 April 2006 11:53 am, Brian Hulley wrote: Claus Reinke wrote: the usual way to achieve this uses the overloading of Nums in Haskell: when you write '1' or '1+2', the meaning of those expressions depends on their types. in particular, the example above uses 'T Double', not

Re: [Haskell-cafe] Code Review: Sudoku solver

2006-03-22 Thread Robert Dockins
On Mar 22, 2006, at 2:16 PM, David F. Place wrote: Hi All, I really appreciate all the help I received when I asked you to critique my PrefixMap module a few weeks ago. I think I am making good progress in correcting the lisp in my Haskell programming. I'll be very grateful to anyone

Re: [Haskell-cafe] Returning a list element?

2006-03-20 Thread Robert Dockins
On Mar 20, 2006, at 5:15 PM, Neil Rutland wrote: Hi there, thank you all for your help with regards to the integer addition question that i asked yesterday it was very good in clarifying my ideas. However i would now like to ask for your expert help once again. Basically i have a list

Re: [Haskell-cafe] Dropping trailing nulls from a list of list

2006-03-08 Thread Robert Dockins
On Mar 8, 2006, at 12:08 PM, [EMAIL PROTECTED] wrote:Today, I reviewed a function I wrote a few months ago.  The function, dropTrailNulls, takes a list of lists and drops trailing null lists.  For instance: *Main dropTrailNulls [[1],[2,3],[],[]] [[1],[2,3]] My original implementation was

Re: [Haskell-cafe] Lists of Lists

2006-03-08 Thread Robert Dockins
On Mar 8, 2006, at 1:29 PM, zell_ffhut wrote: Im afraid im baffled again! Im now trying to add a char to a string of strings (eg - [434233434 444929192 909313434] Im sure i can use my previous function to help me achive this, but i can't seem to get it workinging charToGrid :: Char -

Re: [Haskell-cafe] Lists of Lists

2006-03-08 Thread Robert Dockins
On Mar 8, 2006, at 2:27 PM, zell_ffhut wrote: Could you explain what the function does.. I can't seem to peice it together. It takes three things 1) a function 2) an index and 3) a list. It finds the nth element of the list, applies the function to it and then returns a new list

Re: [Haskell-cafe] Comparing programs

2006-03-06 Thread Robert Dockins
On Mar 6, 2006, at 1:05 PM, Harry Chesley wrote: This is more of an algorithm question than a language question, but any insights would be much appreciated. The problem is to input a series of programs and find previous occurrences of the same algorithm. The programs consist of a set of

Re: [Haskell-cafe] PrefixMap: code review request

2006-02-27 Thread Robert Dockins
On Feb 27, 2006, at 2:30 PM, David F.Place wrote: Hi, I'm a newish Haskell hacker with way too much experience hacking Lisp.At first, I found my Haskell code looking very lisp-y. I think my code is becoming more idiomatic haskell. I would be very grateful to anyone who would take

Re: [Haskell-cafe] haskell programming guidelines

2006-02-20 Thread Robert Dockins
On Feb 20, 2006, at 12:48 PM, Christian Maeder wrote: Hi, haskell admits many programming styles and I find it important that several developers of a prject agree on a certain style to ease code review. I've set up guidelines (still as plain text) for our (hets) project in

Re: [Haskell-cafe] haskell programming guidelines

2006-02-20 Thread Robert Dockins
On Feb 20, 2006, at 2:26 PM, Henning Thielemann wrote: On Mon, 20 Feb 2006, Robert Dockins wrote: I personally disagree with your preference for custom datatypes with a value representing failure to lifting types with Maybe. I understood that part of the guidelines as a pleading for Maybe

Re: [Haskell-cafe] Overlapping instance problem

2006-02-13 Thread Robert Dockins
On Feb 13, 2006, at 2:26 PM, [EMAIL PROTECTED] wrote:Hi, I've posted a couple messages to the Haskell Cafe in the last few months.  I'm new to Haskell.  But, I've set out to implement my own vectors, matrices, complex numbers, etc. One goal I have, is to overload operators to work with my new

[Haskell-cafe] question about type lambda and decidability of typechecking

2006-02-10 Thread Robert Dockins
OK. I've been doing a little thinking about type lambda in Haskell. Now, I understand the prevailing wisdom is that adding type lambda and/or partially applied type synonyms to the haskell type system would make type checking/inference undecidable. The reason given is that higher-order

Re: [Haskell-cafe] question about type lambda and decidability of typechecking

2006-02-10 Thread Robert Dockins
For the record, a little more digging turned up this http://portal.acm.org/citation.cfm?id=583852.581496 which answers most of my questions. On Feb 10, 2006, at 2:02 PM, Robert Dockins wrote: OK. I've been doing a little thinking about type lambda in Haskell. Now, I understand

Re: [Haskell-cafe] extending bang proposal Re: strict Haskell dialect

2006-02-06 Thread Robert Dockins
to bolt onto an HM base. Robert Dockins Speak softly and drive a Sherman tank. Laugh hard; it's a long way to the bank. -- TMBG ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] Re: Haskell code for this example of flow control

2006-02-03 Thread Robert Dockins
On Feb 3, 2006, at 11:28 AM, Maurício wrote: Kurt Hutchinson wrote: On 2/2/06, Maurício [EMAIL PROTECTED] wrote: I understand those examples, but I really would like to know how to do that with monads. I would like to ask the same question, but now with this code: double a = 1000;

[Haskell-cafe] library(s) for numeric constant folding?

2006-01-29 Thread Robert Dockins
Does anyone know of a good library or libraries which will allow me to perform arithmetic operations on 1) binary integers (signed and unsigned) of various fixed sizes? 2) IEEE 754 floating point numbers (single and double precision). Pure Haskell is preferable, but I'll make do with C

Re: [Haskell-cafe] How to redirect a handle within a thread (GHC 6.4.1 runtime)?

2006-01-18 Thread Robert Dockins
matching Robert Dockins' 'threadlocal' proposal? Yes, actually. This is precisely the use case that got me thinking about threadlocal storage in the first place. I'm working on Shellac (http://www.mail-archive.com/haskell@haskell.org/msg17871.html) and it turns out that redirecting

[Haskell-cafe] Yet another top-level IO proposal

2006-01-16 Thread Robert Dockins
Fellow haskellers, I have a proposal I would like to enter into the eternal top-level IO debate. The proposal involves a minor language extension and some runtime support for thread local reference cells. I believe it has the potential to meet many of the needs of those requesting top

Re: [Haskell-cafe] Splitting a string into chunks

2006-01-13 Thread Robert Dockins
On Jan 13, 2006, at 4:35 PM, Jon Fairbairn wrote: On 2006-01-13 at 13:32PST Jared Updike wrote: That works except it loses single newline characters. let s = 1234\n5678\n\nabcdefghijklmnopq\n\n,,.,.,. Prelude blocks s [12345678,abcdefghijklmnopq,,,.,.,.] Also the argument to groupBy ought

Re: [Haskell-cafe] Is there a notion for identity?

2006-01-09 Thread Robert Dockins
On Monday 09 January 2006 04:09 am, Tim Walkenhorst wrote: Thanks for all infos. I'll apply that Ref-datatype from the observable sharing paper to my problem and see where this brings me. I'm also looking into the solution Paul Hudak presented in the Detecting Cycles in Datastructures thread

Re: [Haskell-cafe] Is there a notion for identity?

2006-01-08 Thread Robert Dockins
On Sunday 08 January 2006 06:43 am, Tim Walkenhorst wrote: {- Disclaimer: I'm rather new to Haskell and completely new to this board. I may not use the correct terminology in all cases, but I hope my intention becomes clear when you have a look at the code-snippets. -} Hey ho, Is

Re: [Haskell-cafe] How to read this syntax?

2005-12-29 Thread Robert Dockins
On Dec 29, 2005, at 11:26 AM, David F. Place wrote: Hi, I am trying to read _Arrows, Robots, and Functional Reactive Programming_ by Hudak, et al. http://www.haskell.org/yampa/AFPLectureNotes.pdf In section 2.1 there are a number of equations of the form: g’ :: SF A C g’ = arr g =

Re: [Haskell-cafe] Shared/Exclusive Locks

2005-12-28 Thread Robert Dockins
On Dec 28, 2005, at 11:14 AM, Chris Kuklewicz wrote: John Goerzen wrote: Hello, I have the need for a locking object that can provide shared and exclusive locks in much the same manner as the POSIX flock() function. A thread that acquires an exclusive lock has a guarantee that no other

Re: [Haskell-cafe] Shared/Exclusive Locks

2005-12-28 Thread Robert Dockins
On Dec 28, 2005, at 1:38 PM, Tomasz Zielonka wrote: On Wed, Dec 28, 2005 at 05:28:28PM +, Chris Kuklewicz wrote: But STM, wrapped in small pieces, makes for interesting IO commands (untested): waitForZero :: (Num a, Ord a) = (TVar a) - IO () waitForZero tv = atomically $ do v -

Re: [Haskell-cafe] Prime numbers

2005-12-20 Thread Robert Dockins
-divides a b = (mod a b == 0) +divides a b = (mod b a == 0) On Dec 20, 2005, at 11:09 AM, Daniel Carrera wrote: John Peterson wrote: Add a type signature: prime :: Integer - Bool It's defaulting to Int and you're getting overflows Thanks. Hmm... it's still not working. Btw, I

Re: [Haskell-cafe] Re: Bringing Erlang to Haskell

2005-12-13 Thread Robert Dockins
BTW, there has already been some work in this area. http://www-i2.informatik.rwth-aachen.de/~stolz/dhs/ http://www.informatik.uni-kiel.de/~fhu/PUBLICATIONS/1999/ifl.html ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] Tail-call optimization

2005-12-11 Thread Robert Dockins
On Sunday 11 December 2005 06:54 pm, Joel Reymont wrote: Thank you Andrew! Does it have any effect on performance? Is there a speed up of any sort from not passing parameters? Shooting from the hip here, but I doubt it -- AFAIK it all gets lambda-lifted in the compiler anyway. On Dec 11,

Re: [Haskell-cafe] Can't Haskell catch upwith Clean's uniqueness typing?

2005-12-06 Thread Robert Dockins
On Tuesday 06 December 2005 04:00 pm, [EMAIL PROTECTED] wrote: From: Shae Matijs Erisson - [EMAIL PROTECTED] Sent: Tuesday, December 06, 2005 6:16 PM [EMAIL PROTECTED] writes: being occupied with learning both languages, I'm getting curious if Haskell couldn't achieve most of the

Re: [Haskell-cafe] Haskell scripting system (please help me simplify the design)

2005-10-27 Thread Robert Dockins
On Oct 27, 2005, at 11:01 AM, Joel Reymont wrote:Folks,With lots of help from #haskell and haskell-cafe I came up with the following setup. It's working fine but requires quite a bit of boilerplate code. Could you please help me simplify it?I apologize for the very long message and will describe

Re: [Haskell-cafe] Monads as control structures?

2005-10-27 Thread Robert Dockins
On Oct 27, 2005, at 11:54 AM, Creighton Hogg wrote: Hi, so I'm a newbie getting used to Haskell. I'm writing some simple things like genetic algorithms in it for practice, and I keep coming across something that really bugs me: are there any standard libraries that allow you to do imperative

Re: [Haskell-cafe] Parsec, state and/of my cluelessness

2005-10-17 Thread robert dockins
[snip] Now comes the tricky part for me. Since the control can have three different types of children I use a helper that parses the body of the control using other parsers, collecting their results in three lists: ctrlBodyParser :: CharParser ([Value], [Property], [Control])

Re: [Haskell-cafe] Newbie question on Haskell type

2005-10-14 Thread robert dockins
Data.Typeable ? Thank you very much. On 10/13/05, *robert dockins* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: In GHC you can do this: import Data.Typeable isString :: (Typeable a) = a - Bool isString x = typeOf x == typeOf (undefined::String) Why do you want

Re: [Haskell-cafe] Newbie question on Haskell type

2005-10-13 Thread robert dockins
In GHC you can do this: import Data.Typeable isString :: (Typeable a) = a - Bool isString x = typeOf x == typeOf (undefined::String) Why do you want this? It's not the kind of operation one does very often in Haskell. Huong Nguyen wrote: Hi all, I want to write a small functionto

Re: [Haskell-cafe] Typing problems with basic arithmetic - help!

2005-09-23 Thread robert dockins
For the version with type signatures, you are trying to divide integers using the (/) function. This function expects values in the class Fractional, and Integer isn't a member. Replace with div, which does integer division. pnorep days n = (numeratorex days n) `div` (denominatorex days n)

Re: [Haskell-cafe] Growing Trees

2005-09-22 Thread robert dockins
It sounds like you are porting an algorithm which does destructive updates on this tree. If so, you can use the ST (or IO) monad and use STRef (IORef). data Tree a = TreeRoot { stuff:: STRef a , children :: STRef [Tree] } . you would get at the data

Re: [Haskell-cafe] Trapped by the Monads

2005-09-20 Thread robert dockins
Mark Carter wrote: I'm puzzling out how to get a Bool from am IO Bool. I know I'm not supposed to, but I don't see any way around my predicament. The basic setup is: I have an edit box, and a panel. If you click the LMB on the panel when the edit box is checked, this means you want to move

Re: [Haskell-cafe] Eq Type Class: Overloading (==)

2005-09-18 Thread Robert Dockins
On Sunday 18 September 2005 07:59 am, Tom Hawkins wrote: Aaron Denney wrote: On 2005-09-17, Jason Dagit [EMAIL PROTECTED] wrote: A link to supertyping can be found here: http://repetae.net/john/recent/out/supertyping.html After reading that, I wonder why it's not implemented. Not

Re: [Haskell-cafe] Updating the Haskell Standard

2005-07-25 Thread robert dockins
, code gen, linking) which interface via something that looks a lot like external core, as well as making Haskell more amenable to formal verification. Robert Dockins ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman

Re: [Haskell-cafe] How to variables

2005-07-19 Thread robert dockins
Some people may suggest that you to create top-level IORefs using unsafePerformIO, but I don't recommend that for this situation. Well I can't imagine which particular people you have in mind :-) But, as a vocal advocate of sound support for top level mutable state, I would just like to go on

Re: [Haskell-cafe] How to variables

2005-07-18 Thread robert dockins
Uhm... and what if I write some runtines in plain C, then bind them to Haskell and and use then as in OOP: [snip] Is this apoarch safe enougth, what do you think? If you do it carefully. But why? It sounds like you are planning to write a transliteration of the code you would write in

Re: [Haskell-cafe] How to variables

2005-07-18 Thread robert dockins
I'm doing a 3D simulation. Now I need something like variables in imperative languages. My mainLoop check for new events and renders scene. Then you want IORef. http://www.haskell.org/ghc/docs/latest/html/libraries/base/Data.IORef.html Consider, however, that this kind of construct can be

Re: [Haskell-cafe] Can't explain this error

2005-07-11 Thread robert dockins
You are trying to divide by an Integer and get a Float. Haskell doesn't do automatic numeric conversion, so you have to do the casts manually. Prelude let sumHam n = sum [ 1 / (fromIntegral x) | x - [1..n] ] Prelude sumHam 5 2.283 Dinh Tien Tuan Anh wrote: could anyone tell me

Re: [Haskell-cafe] Can't explain this error

2005-07-11 Thread robert dockins
Thanks for your reply, i just simply removed the first line and it works, but i dont understand why 1/x is not Float. It depends on the type of 'x'. If 'x' is a Float, (1/x) will be a Float. If 'x' is a Double, (1/x) will be a Double. If 'x' is an Integer (1/x) will not typecheck

Re: [Haskell-cafe] Re: ANNOUNCE: GHC survey results

2005-06-28 Thread robert dockins
you are completely skipped the point that these is just for C++ programmers wanting to program in Haskell and aimed to give them faster learning path and easy to use instruments Not to forget to make learning easier for programmers of Perl, Ruby, Python, Rexx, Tcl, APL, C#, Java, Bash,

Re: [Haskell-cafe] Why distinct tyvars in instance declarations?

2005-06-27 Thread robert dockins
but GHC complains: Illegal instance declaration for `Foo (Either b b)' (The instance type must be of form (T a b c) where T is not a synonym, and a,b,c are distinct type variables) In the instance declaration for `Foo (Either b b)' unless I'm totally mistaken, your

Re: [Haskell-cafe] Trivial question... solve_qe

2005-06-15 Thread robert dockins
So, in a word: I need a tutorial for dummies I don't know of any tutorials like you have described. Perhaps someone else does? Now, my current problem is: my program for solving quadratic equation won't compile... You left out some 'Just' constructors. import System solve_qe ::

Re: [Haskell-cafe] Generic types

2005-06-13 Thread robert dockins
I'm writing a small unit library to excercise my barely existing Haskell skills. However I can't figure out how to make Haskell accept any type of a specific class. [snip] What you want is a technique called existential types. The wiki page is here:

Re: [Haskell-cafe] About ($)

2005-06-02 Thread robert dockins
more esoteric things, but this is about as complex as I try to go to avoid severe headaches :) Robert Dockins ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] Bit fiddling

2005-05-17 Thread robert dockins
Probably you have seen this already, but I thought I'd mention it on the off-chance you missed it: http://www.haskell.org/ghc/docs/latest/html/libraries/base/Data.Bits.html http://www.haskell.org/ghc/docs/latest/html/libraries/base/Data.Word.html Probably you'll want to think about an IOUArray

Re: [Haskell-cafe] Bit fiddling

2005-05-17 Thread robert dockins
If you want C compatibility, you need http://www.haskell.org/ghc/docs/latest/html/libraries/base/Data.Array.Storable.html which is similar. You then use the withStorableArray to call out to your C functions. Florian Weimer wrote: * robert dockins: Probably you have seen this already, but I

Re: [Haskell-cafe] Where do you use Haskell?

2005-05-03 Thread robert dockins
Hi all, Again, I'm the new guy slowly learning this fuctional programming thing. :-) [snip] So, I'm tempted to conclude that FP is only applicable to situations where user interaction is a small part of the program. For example, for simulations. Now, I'm sure I'm not the first person to have

Re: [Haskell-cafe] How to join two lists of lists?

2005-05-03 Thread robert dockins
Hi all! I'm trying to join to lists of lists. The problem is, i would like to get a new list of lists of tuples and not list of tuples of lists (that what zip makes). list1 = [[1,2],[3,4],[5,6]] list2 = [[a,b],[c,d],[e,f]] desiredlist = [[(1,a),(2,b)],[(3,c),(4,d)],[(5,e),(6,f)]] Prelude

Re: [Haskell-cafe] Clarification on proof section of HS: The Craft of FP

2005-05-02 Thread robert dockins
Well, I also omited the word countable. I figure it's understood since computers only deal with finite data. And given an infinite list, any finite head of it would meet the criteria, so the distinction is moot. Unless Haskell has some neat property I am not aware of :-) Due to lazyness, we can

[Haskell-cafe] interesting IO oriented code

2005-03-17 Thread robert dockins
after all) and see how that goes. I'd also like to try gzip and gunzip transformer layers. Any ideas for improvements (including patches!) are welcome. Robert Dockins PS the code currently includes a number of vestigial remnants of false starts, and is generally kind of ugly; you are warned

Re: [Haskell-cafe] interesting IO oriented code

2005-03-17 Thread robert dockins
2) It is performant (mostly). At least it outperforms other Haskell IO methods I have tried. My 'wc' is about twice as fast as the current shootout version in informal tests (the shootout code is included in the repo). My md5 can sum somewhere between 2-4Mb/Sec on my hardware. You know

Re: [Haskell-cafe] Parser problem continued

2005-03-15 Thread robert dockins
expr :: Parser Int expr = do t - term do symbol + e - expr return e return (t + e) +++ return t- 't' is not in scope at the arrow. t only exists inside the do block, and your code parses like this ( do t - return (t+e) ) +++

Re: [Haskell-cafe] Re: File path programme

2005-01-31 Thread robert dockins
I have been ruminating on the various responses my attempted file path implementation has generated. I have a design beginning to form in the back of my head which attempts to address the file path problem as I lay out below. Before I develop it any further, are there any important

Re: [Haskell-cafe] Re: File path programme

2005-01-31 Thread robert dockins
Well, there is a sort-of canonic version for every path; on most Unix systems the function realpath(3) will find it. Here is the BUGS listing from 'man realpath' on my system: Never use this function. It is broken by design since it is impossible to determine a suitable size for the output

Re: [Haskell-cafe] File path programme

2005-01-28 Thread robert dockins
I don't pretend to fully understand various unicode standard but it seems to me that these problems are deeper than file path library. The equation (decode . encode) /= id seems confusing for me. Can you give me an example when this happen? I am pretty sure that ISO 2022 encoded strings can have

Re: [Haskell-cafe] File path programme

2005-01-27 Thread robert dockins
Warning: I'm not interested in a path parsing/combining library, so my criticisms are perhaps unrelated to your goals. One thing that I'd be interested in seeing for any Path class would be a simple instance for FilePath (or String, if you want to imagine FilePath will be changed). Not everyone

Re: [Haskell-cafe] File path programme

2005-01-27 Thread robert dockins
While true, I don't see what this has to do with the choice between PathStart and Maybe PathRoot. The types are isomorphic; we can detect and simplify the /.. case either way. True Because of the above problem, I'm willing to treat path fragments (Relative in both lattices) as a special case.

Re: [Haskell-cafe] File path programme

2005-01-27 Thread robert dockins
- Keep the existing System.IO API the same. openFile, createDirectory ... will take the file path as string. The problem is that string means different things in haskell and in C. A C string is really just a contiguous sequence of octets in memory. A haskell string has a particular

Re: [Haskell-cafe] File path programme

2005-01-27 Thread robert dockins
Even simple manipulations break in the presence of encoding issues, or even just of unusual paths. What is the extension of \\.\TAPE0 ? Its not \TAPE0. BTW this is a valid path on Windows 2000 upwards. If you don't care about corner cases, then you have no worries. It would be nice to

Re: [Haskell-cafe] File path programme

2005-01-26 Thread robert dockins
After the discussion about file paths over the last several days I went home and put together a quick trial implementation for unix file paths, with the idea of adding windows, SMB and maybe VMS (why not?) paths. It is based on a Path class. I'll post it later when I get home. However, I

Re: [Haskell-cafe] File path programme

2005-01-26 Thread Robert Dockins
I would say that all paths are relative to something, whether it's the Unix root, or the current directory, or whatever. Therefore I would call this something like PathStart, and add: | CurrentDirectory | CurrentDirectoryOfWindowsDrive Char | RootOfCurrentWindowsDrive This

Re: [Haskell-cafe] File path programme

2005-01-26 Thread Robert Dockins
Here is my first cut at this. The unix implementation mostly works, the windows one just has some datatypes sketched out, but it typechecks. -- module FilePath where import Data.Word (Word8) import Text.ParserCombinators.Parsec import Text.ParserCombinators.Parsec.Error import System

[Haskell-cafe] The implementation of Functional

2005-01-06 Thread robert dockins
The following discussion occurred last September. Is there any kind of update on any version of this book? - John Meacham writes: I am looking for the book The implementation of Functional Programming languages by S. L. Peyton Jones. This book is

Re: [Haskell-cafe] ReadS with Maybe

2005-01-03 Thread Robert Dockins
From the GHC docs: type ReadS a = String - [(a, String)] A parser for a type a, represented as a function that takes a String and returns a list of possible parses (a,String) pairs. So it returns all possible parses, hence the list. This is useful if the encoding is ambiguous. Henning

Re: [Haskell-cafe] safe code to run in finalizers: ACIO revisited

2004-12-29 Thread Robert Dockins
wrote: On Saturday 18 December 2004 20:15, Robert Dockins wrote: Due to one of the threads on cafe recently, I have been doing some thinking about finalizers. Iirc, there was a rather large discussion on finalizers on the Java memory model list. Perhaps some useful ideas can be gathered from

[Haskell-cafe] safe code to run in finalizers: ACIO revisited

2004-12-18 Thread Robert Dockins
Due to one of the threads on cafe recently, I have been doing some thinking about finalizers. There is this sort of intuitive notion that some things shouldn't be done inside finalizers. For example, no output should be produced, because the output handles may have been finalized already, and

Re: [Haskell-cafe] safe code to run in finalizers: ACIO revisited

2004-12-18 Thread Robert Dockins
On Sat, 2004-12-18 at 21:19 +0100, Marcin 'Qrczak' Kowalczyk wrote: Robert Dockins [EMAIL PROTECTED] writes: So, to be safe, the action of a finalizer must commute with every other finalizer (they must be central). What does should mean? I am suggesting that being affine central

Re: [Haskell-cafe] FFI woes!

2004-12-18 Thread Robert Dockins
Well that shouldn't affect the functionality. The weak pointer was only a way of attatching a finalizer to the Playback object. It is true that I should probably wrap up the the SoundPlaybackRaw inside the SoundPlayback as well, to save CPU, but it shouldn't matter for the core

Re: [Haskell-cafe] FFI woes!

2004-12-16 Thread Robert Dockins
1) Finalizers are not (some say cannot) be guaranteed to run, even on normal program termination, even if you force GC before exiting. I only need a guarantee that it will be run if the Ptr is no longer being referenced. This is exactly the guarantee you _don't_ have. The only guarantee you

Re: [Haskell-cafe] FFI woes!

2004-12-16 Thread Robert Dockins
-- play a sample samplePlay :: SoundSample - IO SamplePlayback samplePlay sample = do ch - withForeignPtr sample (fsound_PlaySound (-1)) let spb = SP ch sample -- SamplePlaybackRaw mkWeakPtr spb (Just (samplePlaybackFinalizer spb)) From the

Re: [Haskell-cafe] Flattening tail recursion?

2004-12-10 Thread Robert Dockins
countLines [] = 0 countLines (_:ls) = 1 + countLines ls I would have thought that this was tail recursive and would be flattened into iteration by the compiler. Can anyone explain why? This function isn't tail recursive, because you do additional operations to the result of the function

Re: [Haskell-cafe] Flattening tail recursion?

2004-12-10 Thread Robert Dockins
Jules Bean wrote: On 10 Dec 2004, at 15:34, Robert Dockins wrote: So it should get flattened, but it still doesn't run in constant space because the x parmeter isn't strict, so it will accumulate a bunch of closures like (((0)+1)+1)+1)+1)+1) To make it strict, do something like

Re: [Haskell-cafe] Parse text difficulty

2004-12-09 Thread Robert Dockins
And I thought that most programmers used zipWith, which has to be prefix. Is this true? Can you not use backticks on a partially applied function? If so, it seems like such a thing would be pretty useful (although I've never actually had occasion to need it, so) I'll dig out the report

Re: [Haskell-cafe] Parse text difficulty

2004-12-09 Thread Robert Dockins
Ketil Malde wrote: Robert Dockins [EMAIL PROTECTED] writes: And I thought that most programmers used zipWith, which has to be prefix. [1..5] `zipWith (+)` [7..] You don't have a computer at your end of the internet? :-) Yes, but I'm at work, and I try to limit the amount of time I spend

[Haskell-cafe] More on dynlinking

2004-12-07 Thread Robert Dockins
footprint advantages. OK, those are my thoughts, flame away, :) Robert Dockins ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] Re: Non-technical Haskell question

2004-12-06 Thread Robert Dockins
Ketil Malde wrote: John Goerzen [EMAIL PROTECTED] writes: sensibly share libraries between apps. Anyway, disc is cheap. Memory not so much, though. One advantage of having something in .so form is that every instance of every application that uses it shares the same in-memory image of the

Re: [Haskell-cafe] Re: Non-technical Haskell question

2004-12-06 Thread Robert Dockins
On 6 Dec 2004, at 17:29, John Goerzen wrote: That is an excellent point. Who would use an ls or cp that requires 10MB of RAM, especially on embedded devices? This is presumably just because we don't have 'smart' linking, so the whole library is bundled in. I imagine in principle smart linking

Re: [Haskell-cafe] Mutable data design question

2004-12-03 Thread Robert Dockins
I imagine you would want to use a truly mutable data structure in the IO monad -- something like an STUArray of Chars. GoldPython wrote: In the case of writing something like a text editor where the data involved is by its very nature mutable, what sort of design paradigm would you use in a

Re: [Haskell-cafe] emtpy fundep LHS

2004-11-29 Thread Robert Dockins
Keean Schupke wrote: Martin Sulzmann wrote: Well, if there's only instance which is not exported, then you can use functional dependencies. Assume class C a instance ... = C t Internally, use class C a | - a instance ... = C t The cases I was looking at had more than one instance, but thats

Re: [Haskell-cafe] One-shot? (was: Global variables and stuff)

2004-11-12 Thread Robert Dockins
Should values really depend on the order of includes? Even if you limit things to just newChan in top level '-' you still don't know if A.a in B the same A.a in C. Perhaps it is enough to say A.a only exists once no matter how many times it is directly or indirectly imported? This strikes me

Re: [Haskell-cafe] Re: [Haskell] Re: Global Variables and IO initializers

2004-11-08 Thread Robert Dockins
As a purely practical matter, it seems like the easiest solution (to this particular use case) is to write a small wrapper initializer in C which is idempotent, then use FFI to call the wrapper, rather than calling the initialization directly. This is easy enough to do with a static local

Re: [Haskell-cafe] Re: Double - CDouble, realToFrac doesn't work

2004-11-05 Thread Robert Dockins
My guess is because irrationals can't be represented on a discrete computer (unless you consider a computaion, the limit of which is the irrational number in question). A single irrational might not just be arbitrarily long, but it may have an _infinite_ length representation! What you have

Re: [Haskell-cafe] Re: Double - CDouble, realToFrac doesn't work

2004-11-05 Thread Robert Dockins
[...] Thus (a-b) is not the same as -(b-a) for IEEE floats! Nor is x*0 equal to 0 for every x; nor does x == y imply f(x) == f(y) for every x, y, f; nor is addition or multiplication associative. There aren't many identities that do hold of floating point numbers. Yes, but they DO hold for

Re: [Haskell-cafe] Re: OCaml list sees abysmal Language Shootoutresults

2004-10-08 Thread Robert Dockins
Actually, I've been wondering about this. If my understanding is correct, Haskell lists are basicly singly-linked lists of cons cells (is that correct?) A simple (I think) thing to do would be to make the lists doubly-linked and circular. That would let us do nice things like have O(1)

<    1   2