Re: [Haskell-cafe] Re: standard poll/select interface

2006-02-23 Thread Marcin 'Qrczak' Kowalczyk
Simon Marlow <[EMAIL PROTECTED]> writes: > I agree that a generic select/poll interface would be nice. We must be aware that epoll (and I think kqueue too) registers event sources in advance, separately from waiting, which is its primary advantage over poll. The interface should use this model b

Re: [Haskell-cafe] Re: standard poll/select interface

2006-02-23 Thread Marcin &#x27;Qrczak' Kowalczyk
Simon Marlow <[EMAIL PROTECTED]> writes: > I think the reason we set O_NONBLOCK is so that we don't have to test > with select() before reading, we can just call read(). If you don't > use O_NONBLOCK, you need two system calls to read/write instead of > one. This probably isn't a big deal, given

Re: [Haskell-cafe] Re[2]: Streams: the extensible I/O library

2006-02-12 Thread Marcin &#x27;Qrczak' Kowalczyk
Bulat Ziganshin <[EMAIL PROTECTED]> writes: > recoding don't need any startup. each vGetChar or vPutChar > just executes one or more vGetByte/vPutByte calls, according to > encoding rules. this should be fast enough Hmm, your interface for the encoder (String -> [Word8]) doesn't support stateful

Re: [Haskell-cafe] Re[2]: Streams: the extensible I/O library

2006-02-12 Thread Marcin &#x27;Qrczak' Kowalczyk
Bulat Ziganshin <[EMAIL PROTECTED]> writes: > MQK> It should be possible to use iconv for recoding. Iconv works on > MQK> blocks and it should not be applied to one character at a time. > > recoding don't need any startup. Calling iconv (or other similar routine) does need startup. And you really

Re: [Haskell-cafe] Re[2]: Streams: the extensible I/O library

2006-02-12 Thread Marcin &#x27;Qrczak' Kowalczyk
Bulat Ziganshin <[EMAIL PROTECTED]> writes: > i reported only the speed of the buffering transformers. this don't > include speed of char encoding that should be very low at this time. Recoding will be slow if it's done on top of buffering and if encoding itself has heavy startup. Buffering shoul

Re: [Haskell-cafe] Why is $ right associative instead of leftassociative?

2006-02-12 Thread Marcin &#x27;Qrczak' Kowalczyk
"Brian Hulley" <[EMAIL PROTECTED]> writes: > My final suggestion if anyone is interested is as follows: > > 1) Use ":" for types > 2) Use "," instead of ";" in the block syntax so that all brace blocks > can be replaced by layout if desired (including record blocks) > 3) Use ";" for list cons. ";"

Re: [Haskell-cafe] Space questions about intern and sets

2005-06-01 Thread Marcin &#x27;Qrczak' Kowalczyk
Gracjan Polak <[EMAIL PROTECTED]> writes: > intern :: Ord a => a -> a > intern x = unsafePerformIO $ internIO x > > iorefset :: Ord a => IORef(Map.Map a a) > iorefset = unsafePerformIO $ do > newIORef $ Map.empty It will not work because you can't put values of different types as keys of the

Re: On Eq, was Re: [Haskell-cafe] When to use fancy types [Re: NumberTheory library]

2005-05-14 Thread Marcin &#x27;Qrczak' Kowalczyk
"Jacques Carette" <[EMAIL PROTECTED]> writes: > Since +0 and -0 both exist as separate 'entities' (as computer bits), > which are their own normal form, the real question to ask is, why > would they be equal? Because (1.0 - 1.0) == -(1.0 - 1.0) should be true. In general arithmetic on integers wh

Re: On Eq, was Re: [Haskell-cafe] When to use fancy types [Re: NumberTheory library]

2005-05-13 Thread Marcin &#x27;Qrczak' Kowalczyk
"Jacques Carette" <[EMAIL PROTECTED]> writes: > [EMAIL PROTECTED] wrote: >> "Eq" is not merely a function of type a -> a -> Bool. It's a concept >> with semantics. It must be an equivalence relation, and it also must >> mean semantic equality. Functions that respect semantic equality have >> th

Re: [Haskell-cafe] Python?

2005-05-11 Thread Marcin &#x27;Qrczak' Kowalczyk
Quinn Dunkan <[EMAIL PROTECTED]> writes: > Python has first class functions and lexical scoping, and encourages > higher-order functions, though to a much lesser degree than a real > functional language. It's lexical scoping is limited: - The syntax can be heavy, as you can't embed a function co

Re: [Haskell-cafe] Specify array or list size?

2005-05-07 Thread Marcin &#x27;Qrczak' Kowalczyk
Hamilton Richards <[EMAIL PROTECTED]> writes: > That's not the case in C, C++, Java, or Ada. In C and C++, for > example, given two arrays > > int X[50]; > int Y[100]; > > and a function declared as > > void P( int a[] ) > > then these calls > > P( X ) > P( Y ) > > ar

Re: [Haskell-cafe] Specify array or list size?

2005-05-07 Thread Marcin &#x27;Qrczak' Kowalczyk
David Roundy <[EMAIL PROTECTED]> writes: > No, int (*p)[50] is a multidimensional array, one of the most useless > concepts in C, and is equivalent to int p[50][] (or is it p[][50]... > I always get my matrix subscripts messed up). No, it's not equivalent to either. Array type are not the same as

Re: [Haskell-cafe] Specify array or list size?

2005-05-07 Thread Marcin &#x27;Qrczak' Kowalczyk
Antti-Juhani Kaijanaho <[EMAIL PROTECTED]> writes: >> No, it introduces a variable of type "array of 50 ints", which can be >> converted to "pointer to int". > > ISO 9899:1999 (C99) section 6.7.5.2:3 says that its type is "array of > int", not "array of 50 ints": Ok, so in C terminology "type" is

Re: [Haskell-cafe] Specify array or list size?

2005-05-07 Thread Marcin &#x27;Qrczak' Kowalczyk
Thomas Davie <[EMAIL PROTECTED]> writes: > I'm not familiar with your C++ example (not being familiar with C++), > but I think that it's a bit of a stretch of the imagination to say > that C "introduces a variable of type "array of 50 ints"", the fact > that this is now an array of 50 integers is

Re: [Haskell-cafe] Compiling with NHC98

2005-05-07 Thread Marcin &#x27;Qrczak' Kowalczyk
Daniel Carrera <[EMAIL PROTECTED]> writes: > $ nhc98 prng.hs -o prng > I/O error (user-defined), call to function `userError': >In file ./RC4.hi: > 1:1-1:6 Found _module_ but expected a interface GHC and NHC confuse each other with prng.hi files they produce and examine, in incompatible forma

Re: [Haskell-cafe] Specify array or list size?

2005-05-07 Thread Marcin &#x27;Qrczak' Kowalczyk
Sebastian Sylvan <[EMAIL PROTECTED]> writes: > A "list" is, for me, more of a "logical" entity (as opposed to > structural). It's a sequence of "stuff" not a particular way to > store it (singly-linked, doubly-linked, arraylists etc.). I call it "sequence". A list is usually a concrete type in a

Re: [Haskell-cafe] Specify array or list size?

2005-05-07 Thread Marcin &#x27;Qrczak' Kowalczyk
Antti-Juhani Kaijanaho <[EMAIL PROTECTED]> writes: >> > As far as I know, the last programming language that included >> > arrays' sizes in their types was Standard Pascal, >> >> There have been many such languages since Standard Pascal. For >> example C, C++, C#, Java, Ada, VHDL, and NU-Prolog.

Re: [Haskell-cafe] Re: Haskell vs OCaml

2005-05-04 Thread Marcin &#x27;Qrczak' Kowalczyk
Donn Cave <[EMAIL PROTECTED]> writes: > I have been able to build ocaml everywhere I have wanted it, including > the native code compiler. And it builds itself much faster than GHC. (I couldn't measure how much, because GHC didn't build at all, failing to find HsBaseConfig.h.in.) -- __("<

Re: [Haskell-cafe] Re: Haskell vs OCaml

2005-05-03 Thread Marcin &#x27;Qrczak' Kowalczyk
Michael Vanier <[EMAIL PROTECTED]> writes: > I also learned ocaml before learning haskell, and the biggest single > difference I found is that haskell is a lazy, purely functional language > and ocaml is a strict, "mostly functional" language. Indeed. In contrast to this one, my differences were

Re: [Haskell-cafe] Re: Haskell vs OCaml

2005-05-03 Thread Marcin &#x27;Qrczak' Kowalczyk
John Goerzen <[EMAIL PROTECTED]> writes: > I'd say that there are probably no features OCaml has that Haskell > lacks that are worth mentioning. Its type system has some interesting features: polymorphic variants, parametric modules, labeled and optional arguments, objects, variance annotations o

Re: [Haskell-cafe] Haskell vs OCaml

2005-05-03 Thread Marcin &#x27;Qrczak' Kowalczyk
Daniel Carrera <[EMAIL PROTECTED]> writes: > Marcin, > > Are you sure that OCaml is similar to Haskell? At first glance, it > doesn't even look functional. It looks like an imperative language. It's not purely functional, but it supports algebraic types and first-class functions, uses similar con

Re: [Haskell-cafe] Speed comparison?

2005-05-03 Thread Marcin &#x27;Qrczak' Kowalczyk
Daniel Carrera <[EMAIL PROTECTED]> writes: > My next question is about speed. How fast would you consider Haskell? > (say, for computational work). How would you compare it to C, Python > and Ruby? > > I suggest C, Python and Ruby as a basis of comparison because: I suggest adding OCaml, because

Re: [Haskell-cafe] Instances of constrained datatypes

2005-04-05 Thread Marcin &#x27;Qrczak' Kowalczyk
Arjun Guha <[EMAIL PROTECTED]> writes: > > data (Eq v) => EqList v = EqList [v] > > I'd like to make it an instance of Functor. However, fmap takes an > arbitrary function of type a -> b. I need an Eq constraint on a and > b. Is there any way to do this without creating my own `EqFunctor' > c

Re: [Haskell-cafe] invalid character encoding

2005-03-19 Thread Marcin &#x27;Qrczak' Kowalczyk
Wolfgang Thaller <[EMAIL PROTECTED]> writes: > Also, IIRC, Java strings are supposed to be unicode, too - > how do they deal with the problem? Java (Sun) -- Filenames are assumed to be in the locale encoding. a) Interpreting. Bytes which cannot be converted are replaced by U+FFFD. b) C

Re: [Haskell-cafe] invalid character encoding

2005-03-19 Thread Marcin &#x27;Qrczak' Kowalczyk
Glynn Clements <[EMAIL PROTECTED]> writes: >> A separate setting would force users to configure an encoding just >> for the purposes of Haskell programs, as if the configuration wasn't >> already too fragmented. > > encoding <- localeEncoding > Curses.setupTerm encoding handle In a pr

Re: [Haskell-cafe] invalid character encoding

2005-03-18 Thread Marcin &#x27;Qrczak' Kowalczyk
Glynn Clements <[EMAIL PROTECTED]> writes: >> > If you provide "wrapper" functions which take String arguments, >> > either they should have an encoding argument or the encoding should >> > be a mutable per-terminal setting. >> >> There is already a mutable setting. It's called "locale". > > It i

Re: [Haskell-cafe] invalid character encoding

2005-03-17 Thread Marcin &#x27;Qrczak' Kowalczyk
Glynn Clements <[EMAIL PROTECTED]> writes: > E.g. Gtk-2.x uses UTF-8 almost exclusively, although you can force the > use of the locale's encoding for filenames (if you have filenames in > multiple encodings, you lose; filenames using the "wrong" encoding > simply don't appear in file selectors).

Re: [Haskell-cafe] invalid character encoding

2005-03-17 Thread Marcin &#x27;Qrczak' Kowalczyk
Glynn Clements <[EMAIL PROTECTED]> writes: > The (non-wchar) curses API functions take byte strings (char*), > so the Haskell bindings should take CString or [Word8] arguments. Programmers will not want to use such interface. When they want to display a string, it will be in Haskell String type.

Re: [Haskell-cafe] invalid character encoding

2005-03-16 Thread Marcin &#x27;Qrczak' Kowalczyk
John Meacham <[EMAIL PROTECTED]> writes: > In any case, we need tools to be able to conform to the common cases > of ascii-only (withCAStrirg) and current locale (withCString). > > withUTF8String would be a nice addition, but is much less important to > come standard as it can easily be written by

Re: [Haskell-cafe] invalid character encoding

2005-03-16 Thread Marcin &#x27;Qrczak' Kowalczyk
Glynn Clements <[EMAIL PROTECTED]> writes: >> It should be possible to specify the encoding explicitly. > > Conversely, it shouldn't be possible to avoid specifying the > encoding explicitly. What encoding should a binding to readline or curses use? Curses in C comes in two flavors: the traditio

Re: [Haskell-cafe] invalid character encoding

2005-03-16 Thread Marcin &#x27;Qrczak' Kowalczyk
Duncan Coutts <[EMAIL PROTECTED]> writes: >> It doesn't affect functions added by the hierarchical libraries, >> i.e. those functions are safe only with the ASCII subset. (There is >> a vague plan to make Foreign.C.String conform to the FFI spec, >> which mandates locale-based encoding, and thus w

Re: [Haskell-cafe] Re: Bound threads

2005-03-03 Thread Marcin &#x27;Qrczak' Kowalczyk
Wolfgang Thaller <[EMAIL PROTECTED]> writes: >> Indeed, my brain is melting, but I did it :-) > > Congratulations. How about we found a "Bound-thread-induced brain > melt victims' support group"? The melt was entertaining :-) > Besides simplicity, one of the main reasons for moving our select()

Re: [Haskell-cafe] Re: Bound threads

2005-03-02 Thread Marcin &#x27;Qrczak' Kowalczyk
"Simon Marlow" <[EMAIL PROTECTED]> writes: >> I've now implemented a threaded runtime in my language Kogut, based >> on the design of Haskell. The main thread is bound. The thread which >> holds the capability performs I/O multiplexing itself, without a >> separate service thread. > > We found tha

Re: [Haskell-cafe] Re: Bound threads

2005-03-01 Thread Marcin &#x27;Qrczak' Kowalczyk
Benjamin Franksen <[EMAIL PROTECTED]> writes: >> Producer/consumer ping-pong is 15 times slower between threads >> running on different OS threads than on two unbound threads. > > Which OS? Linux/NPTL. A context switch which changes OS threads involves: setitimer pthread_sigmask pthread

Re: [Haskell-cafe] Re: Bound threads

2005-03-01 Thread Marcin &#x27;Qrczak' Kowalczyk
Marcin 'Qrczak' Kowalczyk <[EMAIL PROTECTED]> writes: > Why is the main thread bound? I can answer myself: if the main thread is unbound, the end of the program can be reached in a different OS thread, which may be a problem if we want to return cleanly to the calling code. I

Re: [Haskell-cafe] Re: Bound threads

2005-02-28 Thread Marcin &#x27;Qrczak' Kowalczyk
"Simon Marlow" <[EMAIL PROTECTED]> writes: >> Is it important which thread executes Haskell code (I bet no) and >> unsafe foreign calls (I don't know)? If not, couldn't the same OS >> thread execute code of both threads until a safe foreign call is made? > > Actually in a bound thread, *all* forei

Re: [Haskell-cafe] Re: Bound threads

2005-02-26 Thread Marcin &#x27;Qrczak' Kowalczyk
Wolfgang Thaller <[EMAIL PROTECTED]> writes: >> Since the main thread is bound, and unbound threads are never executed >> on an OS thread which has some Haskell thread bound, this would imply >> that when the main thread spawns a Haskell thread and they synchronize >> a lot with each other using M

[Haskell-cafe] Bound threads

2005-02-25 Thread Marcin &#x27;Qrczak' Kowalczyk
I'm trying to understand the semantics and implementation of bound threads basing on the conc-ffi paper and others. Since the main thread is bound, and unbound threads are never executed on an OS thread which has some Haskell thread bound, this would imply that when the main thread spawns a Haskel

Re: [Haskell-cafe] What is MonadPlus good for?

2005-02-14 Thread Marcin &#x27;Qrczak' Kowalczyk
Josef Svenningsson <[EMAIL PROTECTED]> writes: > You claimed that monad transformers break the > mzero-is-right-identity-for-bind law because they can be applied to > IO. I say, it's not the monad transformers fault. They cannot possibly > be expected to repair the law if they are given a faulty m

Re: [Haskell-cafe] The Nature of Char and String

2005-02-02 Thread Marcin &#x27;Qrczak' Kowalczyk
Ketil Malde <[EMAIL PROTECTED]> writes: >> The Haskell functions accept or return Strings but interface to OS >> functions which (at least on Unix) deal with arrays of bytes (char*), >> and the encoding issues are essentially ignored. If you pass strings >> containing anything other than ISO-8859-

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

2005-01-31 Thread Marcin &#x27;Qrczak' Kowalczyk
Peter Simons <[EMAIL PROTECTED]> writes: > http://cryp.to/pathspec/PathSpec.hs > There also is a function which changes a path specification > into its canonic form, meaning that all redundant segments > are stripped. It's incorrect: canon (read "x/y/.." :: RelPath Posix) gives "x", yet on Uni

[Haskell-cafe] Re: UTF-8 BOM, really!?

2005-01-31 Thread Marcin &#x27;Qrczak' Kowalczyk
Graham Klyne <[EMAIL PROTECTED]> writes: > How can it make sense to have a BOM in UTF-8? UTF-8 is a sequence of > octets (bytes); what ordering is there here that can sensibly be > varied? The *name* "BOM" doesn't make sense when applied to UTF-8, but some software uses UTF-8 encoded U+FEFF it

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

2005-01-30 Thread Marcin &#x27;Qrczak' Kowalczyk
Aaron Denney <[EMAIL PROTECTED]> writes: > Better yet would be to have the standard never allow the BOM. If I could decide, I would ban the BOM in UTF-8 altogetger, but I'm afraid the Unicode Consortium doesn't want to do this. Miscosoft Notepad puts a BOM in UTF-8 encoded files. -- __("<

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

2005-01-30 Thread Marcin &#x27;Qrczak' Kowalczyk
Aaron Denney <[EMAIL PROTECTED]> writes: >> It provides variants of UTF-16/32 with and without a BOM, but >> UTF-8 only has the variant with a BOM. This makes UTF-8 a stateful >> encoding. > > I think you mean "UTF-8 only has the variant without a BOM". No, unfortunately. Unicode standard section

Re: [Haskell-cafe] File path programme

2005-01-30 Thread Marcin &#x27;Qrczak' Kowalczyk
Glynn Clements <[EMAIL PROTECTED]> writes: > And it isn't a theoretical issue. E.g. in an environment where EUC-JP > is used, filenames may begin with $)B (designate JISX0208 to G1), > or they may not (because G1 is assumed to contain JISX0208 initally). I think such encodings are never used as d

Re: [Haskell-cafe] File path programme

2005-01-30 Thread Marcin &#x27;Qrczak' Kowalczyk
David Roundy <[EMAIL PROTECTED]> writes: > No, it's not Unix-specific, it's portable. If you want to write > portable C code, you have to use the standard library, which means > that file names are represented as Ptr CChar. I disagree. We are talking about portable Haskell, not portable C. The n

Re: [Haskell-cafe] File path programme

2005-01-30 Thread Marcin &#x27;Qrczak' Kowalczyk
Glynn Clements <[EMAIL PROTECTED]> writes: >> Then of course there's the issue that Win32 edge >> labels are Unicode, while Posix edge labels are [Word8]. Hmm. > > Strictly speaking, they're [CChar], but I doubt that anyone will ever > implement Haskell on a platform where a byte isn't 8 bits wid

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

2005-01-30 Thread Marcin &#x27;Qrczak' Kowalczyk
Stefan Monnier <[EMAIL PROTECTED]> writes: >> The various UTF encodings do not have this particular problem; if a UTF >> string is valid, then it is a unique representation of a unicode string. >> However, decoding is still a partial function and can fail. > > And while it is partly true, it is qu

Re: [Haskell-cafe] Re: mathematical notation and functional programming

2005-01-29 Thread Marcin &#x27;Qrczak' Kowalczyk
Stefan Monnier <[EMAIL PROTECTED]> writes: > OTOH I like the a unambiguous (as long as the return value of < can't be passed as an > argument to <, which is typically the case when the return value is > boolean and there's no ordering defined on booleans). It's unambiguous even if the return valu

Re: [Haskell-cafe] File path programme

2005-01-27 Thread Marcin &#x27;Qrczak' Kowalczyk
John Meacham <[EMAIL PROTECTED]> writes: > too bad we can't do things like > > #if exists(module System.Path) > import System.Path > #else > ... > #endif > > I still find it perplexing that there isn't a decent standard haskell > preprocessor For my language Kogut I designed a syntax if

Re: [Haskell-cafe] File path programme

2005-01-27 Thread Marcin &#x27;Qrczak' Kowalczyk
Gregory Wright <[EMAIL PROTECTED]> writes: > Actually, Common Lisp specifies a special data type to handle > logical filepaths, which are distinct from file path strings. Having > had to debug common lisp code that uses this (written by other > people) I've observed that this attempt to do the "Ri

Re: [Haskell-cafe] File path programme

2005-01-27 Thread Marcin &#x27;Qrczak' Kowalczyk
Robert Dockins <[EMAIL PROTECTED]> writes: > More than you would think, if you follow the conventions of modern > unix shells. eg, "foo/.." is always equal to ".", For the OS it's not the same if foo is a non-local symlink. Shells tend to resolve symlinks themselves on cd, and "cd .." means to r

Re: [Haskell-cafe] Looking for these libraries...

2005-01-27 Thread Marcin &#x27;Qrczak' Kowalczyk
John Goerzen <[EMAIL PROTECTED]> writes: > I'm looking for libraries / interfaces to these systems from Haskell: > > LDAP > ncurses > zlib (the one in darcs doesn't suit my needs) > bz2lib I once wrapped ncurses (incomplete), zlib and bz2lib. http://sourceforge.net/projects/qforeign/ It's quite

[Haskell-cafe] Non-blocking I/O (was: Re: Hugs vs GHC)

2005-01-26 Thread Marcin &#x27;Qrczak' Kowalczyk
Glynn Clements <[EMAIL PROTECTED]> writes: >> > The point is that the Unix documentation does not consider the short >> > pause as data is read off your hard drive to be blocking. So that's why >> > select will always report that data is available when you use it with a >> > file handle. >> >> Is

Re: [Haskell-cafe] File path programme

2005-01-25 Thread Marcin &#x27;Qrczak' Kowalczyk
Ben Rudiak-Gould <[EMAIL PROTECTED]> writes: > >Doing a reasonable job on System.FilePath, even if it isn't > >perfect, will help prevent lots of applications from falling into > >common traps, and help make more code portable. > > But the library code itself falls into the same traps! It's a g

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

2005-01-23 Thread Marcin &#x27;Qrczak' Kowalczyk
Aaron Denney <[EMAIL PROTECTED]> writes: >> What about splitFileExt "foo.bar."? ("foo", "bar.") or ("foo.bar.", "")? > > The latter makes more sense to me, as an extension of the first case > you give and splitting "foo.tar.gz" to ("foo.tar", "gz"). It's not that obvious: both choices are compati

Re: [Haskell-cafe] File path programme

2005-01-23 Thread Marcin &#x27;Qrczak' Kowalczyk
Isaac Jones <[EMAIL PROTECTED]> writes: > You might be interested in the new FilePath module that's in the > works. There's been a lot of work to make these functions portable. > > http://cvs.haskell.org/cgi-bin/cvsweb.cgi/fptools/libraries/base/System/FilePath.hs splitFileExt "foo" = ("foo", ""

Re: [Haskell-cafe] Re: what is inverse of mzero and return?

2005-01-23 Thread Marcin &#x27;Qrczak' Kowalczyk
Ashley Yakeley <[EMAIL PROTECTED]> writes: > But only some instances (such as []) satisfy this: > > (mplus a b) >>= c = mplus (a >>= c) (b >>= c) > > Other instances (IO, Maybe) satisfy this: > > mplus (return a) b = return a > > I think mplus should be separated into two functions. This woul

Re: [Haskell-cafe] Re: Can't do basic time operations with System.Time

2005-01-21 Thread Marcin &#x27;Qrczak' Kowalczyk
Peter Simons <[EMAIL PROTECTED]> writes: > I was wondering: Does this calculation account for leap > years? Does it have to? C itself leaves unspecified the question whether its time calculations take leap seconds into account. All other systems I know of ignore leap seconds: POSIX C, Common Lisp

Re: [Haskell-cafe] Re: Hugsvs GHC (again)was: Re: Somerandomnewbiequestions

2005-01-19 Thread Marcin &#x27;Qrczak' Kowalczyk
Glynn Clements <[EMAIL PROTECTED]> writes: >> We do use a thread pool. But you still need as many OS threads as there >> are blocked read() calls, unless you have a single thread doing select() >> as I described. > > How does the select() help? AFAIK, select() on a regular file or block > device

Re: [Haskell-cafe] Re: Hugs vs GHC (again)was: Re: Somerandomnewbiequestions

2005-01-19 Thread Marcin &#x27;Qrczak' Kowalczyk
Glynn Clements <[EMAIL PROTECTED]> writes: > They're similar, but not identical. Traditionally, Unix non-blocking > I/O (along with asynchronous I/O, select() and poll()) were designed > for "slow" streams such as pipes, terminals, sockets etc. Regular > files and block devices are assumed to retu

Re: [Haskell-cafe] I/O interface

2005-01-19 Thread Marcin &#x27;Qrczak' Kowalczyk
Ben Rudiak-Gould <[EMAIL PROTECTED]> writes: > Yes, this is a problem. In my original proposal InputStream and > OutputStream were types, but I enthusiastically embraced Simon M's > idea of turning them into classes. As you say, it's not without its > disadvantages. This is my greatest single com

[Haskell-cafe] Re: [Haskell] Re: Why is getArgs in the IO monad?

2005-01-18 Thread Marcin &#x27;Qrczak' Kowalczyk
Keean Schupke <[EMAIL PROTECTED]> writes: > Surely both requirements can be satisfied if the programs arguments are made > parameters of main: > > main :: [String] -> IO () >From info '(libc)Error Messages', about program_invocation_name and program_invocation_short_name: *Portability Note:*

Re: [Haskell-cafe] Re: FFI and C99 "complex"

2005-01-16 Thread Marcin &#x27;Qrczak' Kowalczyk
Aaron Denney <[EMAIL PROTECTED]> writes: > So, I have heard claims that C 99 specifies that a variable v > of type "complex t" is stored as if declared as t v[2], with > v[0] the real part and v[1] the imaginary part. > > I don't have a copy of the spec at hand. Could someone who does verify > th

[Haskell-cafe] I/O interface (was: Re: Hugs vs GHC)

2005-01-16 Thread Marcin &#x27;Qrczak' Kowalczyk
John Meacham <[EMAIL PROTECTED]> writes: > I was thinking of it as a better implementation of a stream interface > (when available). I'm not convinced that the stream interface (http://www.haskell.org/~simonmar/io/System.IO.html) works at all, i.e. whether it's complete, implementable and conveni

Re: [Haskell-cafe] Re: Re: Hugs vs GHC (again)was: Re: Somerandomnewbiequestions

2005-01-15 Thread Marcin &#x27;Qrczak' Kowalczyk
Pete Chown <[EMAIL PROTECTED]> writes: >> of course, [mmap] can only be done on a limited type of file on some >> architectures, so it should be an optimization under the hood rather >> than an exposed interface. > > In particular, you have to be careful not to run out of address space on > 32-bit

Re: [Haskell-cafe] Linear shuffle

2005-01-14 Thread Marcin &#x27;Qrczak' Kowalczyk
Henning Thielemann <[EMAIL PROTECTED]> writes: > I did some shuffling based on mergesort, that is a list is randomly split > (unzipped) into two lists and the parts are concatenated afterwards. You > must repeat this some times. It even works for infinite lists. I think it doesn't guarantee equal

Re: [Haskell-cafe] Re: I/O interface

2005-01-13 Thread Marcin &#x27;Qrczak' Kowalczyk
Ketil Malde <[EMAIL PROTECTED]> writes: > It seemed to me, though, that streams are related to channels, I'm not sure what exactly do you mean by streams (because they are only being designed), but differences are: - A stream is either an input stream or an output stream, while a single channe

Re: [Haskell-cafe] Re: I/O interface

2005-01-12 Thread Marcin &#x27;Qrczak' Kowalczyk
Ben Rudiak-Gould <[EMAIL PROTECTED]> writes: > is there *any* way to get, without an exploitable race condition, > two filehandles to the same file which don't share a file pointer? AFAIK it's not possible if the only thing you know is one of the descriptors. Of course independent open() calls wh

[Haskell-cafe] Re: I/O interface

2005-01-12 Thread Marcin &#x27;Qrczak' Kowalczyk
Ben Rudiak-Gould <[EMAIL PROTECTED]> writes: > First of all, I don't think any OS shares file pointers between > processes. Unix does. It's because shared files are usually stdin/stdout/stderr (I mean that they are visible as stdin/stdout/stderr, rather than about their nature as terminals - the

Re: [Haskell-cafe] Re: Hugs vs GHC (again)was: Re: Somerandomnewbiequestions

2005-01-11 Thread Marcin &#x27;Qrczak' Kowalczyk
Aaron Denney <[EMAIL PROTECTED]> writes: > Does open("/dev/fd/n") or ("/proc/self/fd/n") act as dup() or a fresh > open() to underlying file?) As a dup(), with a side effect of resetting the file pointer to the beginning. It would not help anyway: if it's a terminal or pipe, it *has* to act as a

I/O interface (was: Re: [Haskell-cafe] Re: Hugs vs GHC (again))

2005-01-11 Thread Marcin &#x27;Qrczak' Kowalczyk
Ben Rudiak-Gould <[EMAIL PROTECTED]> writes: > fileRead can be implemented in terms of OS primitives, Only if they already support reading from a fixed offset (like pread). I'm not sure if we can rely on something like this being always available, or whether it should be emulated using lseek whic

Character predicates (was: Re: [Haskell-cafe] Hugs vs GHC (again))

2005-01-11 Thread Marcin &#x27;Qrczak' Kowalczyk
Dimitry Golubovsky <[EMAIL PROTECTED]> writes: >|Sebastien's| Marcin's | Hugs > ---+---+--+-- > alnum | L* N* | L* N*| L*, M*, N* <1> > alpha | L*| L* | L* <1> > cntrl | Cc| Cc Zl Zp | Cc > digit | N*

Re: [Haskell-cafe] Re: Hugs vs GHC (again) was: Re: Some randomnewbiequestions

2005-01-11 Thread Marcin &#x27;Qrczak' Kowalczyk
Ben Rudiak-Gould <[EMAIL PROTECTED]> writes: > http://www.haskell.org/~simonmar/io/System.IO.html "fileRead :: File -> FileOffset -> Integer -> Buffer -> IO ()" This is unimplementable safely if the descriptor is read concurrently by different processes. The current position is shared. --

Re: [Haskell-cafe] Hugs vs GHC (again) was: Re: Some random newbiequestions

2005-01-10 Thread Marcin &#x27;Qrczak' Kowalczyk
Jérémy Bobbio <[EMAIL PROTECTED]> writes: >> Once this is agreed, it would be easy to make scripts which generate >> C code from UnicodeData.txt tables from Unicode. I think table-driven >> predicates and toUpper/toLower should better be implemented in C; >> Haskell is not good at static constant

Re: [Haskell-cafe] Some random newbie questions

2005-01-09 Thread Marcin &#x27;Qrczak' Kowalczyk
Jorge Adriano Aires <[EMAIL PROTECTED]> writes: >> No, it would work with strict foldl too. In fact in the absence >> of optimization it would work better (uses less time and space). >> The optimization required is inlining and strictness analysis. > > Is this also true if your just going to use t

Re: [Haskell-cafe] Some random newbie questions

2005-01-09 Thread Marcin &#x27;Qrczak' Kowalczyk
Jorge Adriano Aires <[EMAIL PROTECTED]> writes: >> Naive use of foldl.  I tend to think the default foldl should be >> strict (ie. replaced by foldl') -- are there important cases where it >> needs to be lazy? > > Hi, > One simple example would be, >> reverse = foldl (flip (:)) [] No, it would w

Re: [Haskell-cafe] Hugs vs GHC (again) was: Re: Some random newbiequestions

2005-01-09 Thread Marcin &#x27;Qrczak' Kowalczyk
"Simon Marlow" <[EMAIL PROTECTED]> writes: > - Do the character class functions (isUpper, isAlpha etc.) work >correctly on the full range of Unicode characters? This is true in >Hugs. It's true with GHC on some systems (basically we were lazy >and used the underlying C library's sup

Re: [Haskell-cafe] Re: Problem with fundeps.

2005-01-02 Thread Marcin &#x27;Qrczak' Kowalczyk
[EMAIL PROTECTED] writes: > This is what I want. For a given set of vectors, the associated > scalars are unique, otherwise I would have problems with norm. In the instance Vspace a a the compiler doesn't know that "a" is supposed to be a scalar only. It matches vector types (functions) too. And

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

2004-12-18 Thread Marcin &#x27;Qrczak' Kowalczyk
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? There are useful finalizers which don't have this property. E.g. a finalizer can remove an entry from a weak dictionary

Re: [Haskell-cafe] The difference between ($) and application

2004-12-14 Thread Marcin &#x27;Qrczak' Kowalczyk
Andres Loeh <[EMAIL PROTECTED]> writes: > The function ($) is the identity function, restricted to functions. Almost. With the standard definition of f $ x = f x it happens that ($) undefined `seq` () = () id undefined `seq` () = undefined -- __("< Marcin Kowalczyk \__/

Re: [Haskell-cafe] Mutable data design question

2004-12-03 Thread Marcin &#x27;Qrczak' Kowalczyk
Keean Schupke <[EMAIL PROTECTED]> writes: > What happens with this method when the display needs refreshing, does > the current state have to be recomputed every time ... No. The new state is constructed from bits of old state and the changed data. Applying a change on average requires logarithmi

Re: [Haskell-cafe] Mutable data design question

2004-12-03 Thread Marcin &#x27;Qrczak' Kowalczyk
GoldPython <[EMAIL PROTECTED]> writes: > 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 functional language? This is specific to text editors: 1. Use a traditional mutable data structu

Re: [Haskell-cafe] Re: not possible with monad transformers ?

2004-12-01 Thread Marcin &#x27;Qrczak' Kowalczyk
Jules Bean <[EMAIL PROTECTED]> writes: >> When writing a compiler, it makes sense to collect errors as by the >> writer monad, and not abort anything - producing dummy values instead >> (except perhaps some fatal errors when it's inconvenient). > > Or you could use the monad: > > data Perhaps a =

Re: [Haskell-cafe] Re: not possible with monad transformers ?

2004-11-30 Thread Marcin &#x27;Qrczak' Kowalczyk
Ben Rudiak-Gould <[EMAIL PROTECTED]> writes: > I may be confused, but I don't think it does. It seems like the OP > wants a type like > > data Perhaps a = Success a | Failure [Error] When writing a compiler, it makes sense to collect errors as by the writer monad, and not abort anything - pro

Re: [Haskell-cafe] ACIO versus Execution Contexts

2004-11-30 Thread Marcin &#x27;Qrczak' Kowalczyk
Keean Schupke <[EMAIL PROTECTED]> writes: > I disagee - Allowing unique state is a mistake in my opinion. > I want Haskell to be the operating system - how can I do > this if I cannot create new process contexts. Why does it matter if you can't compile code for new programs at runtime, to become

Re: [Haskell-cafe] Re: Lexically scoped type variables

2004-11-27 Thread Marcin &#x27;Qrczak' Kowalczyk
[EMAIL PROTECTED] writes: > and use "`asTypeOf` result" wherever we need to refer to resType. I don't like being left with only asTypeOf, because when the desired type has its structure shuffled, it forces to invent a transformation on unused expressions which yields the given transformation on t

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

2004-11-25 Thread Marcin &#x27;Qrczak' Kowalczyk
George Russell <[EMAIL PROTECTED]> writes: > Your implementation is probably much simpler than mine because > you don't implement withEmptyDict. I'm really quite keen about > withEmptyDict, because one of the MAJOR conceptual problems I have > with unsafePerformIO global variables is that you only

Re: [Haskell-cafe] Re: [Haskell] Top Level TWI's again

2004-11-24 Thread Marcin &#x27;Qrczak' Kowalczyk
Benjamin Franksen <[EMAIL PROTECTED]> writes: >> stdin = makeHandle 0 >> stdout = makeHandle 1 >> stderr = makeHandle 2 >> >> in absolutely pure Haskell, only the things that manipulate them need >> be in the IO monad. > > If they were simple wrappers around the integers, you'd be right and I > c

Re: [Haskell-cafe] IO and State

2004-11-17 Thread Marcin &#x27;Qrczak' Kowalczyk
"Iavor S. Diatchki" <[EMAIL PROTECTED]> writes: > I find the argument a bit disturbing, as it seems to imply that it > is OK for the compiler to produce code without any context switches > at all Note that in this case if the main program doesn't explicitly block on MVars, I/O nor timeout, then f

Re: [Haskell-cafe] Currying and errors

2004-11-08 Thread Marcin &#x27;Qrczak' Kowalczyk
Graham Klyne <[EMAIL PROTECTED]> writes: > > isSubsumedByWith :: TBox c -> c -> c -> Bool > > isSubsumedByWith [] c d = isALSubsumedBy c d > > isSubsumedByWith _ _ _ = error "TBox reasoning not supported for AL" > > and immediately noticed that I might also write this: > > >

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

2004-11-05 Thread Marcin &#x27;Qrczak' Kowalczyk
Benjamin Franksen <[EMAIL PROTECTED]> writes: >> It's worse: Since according to IEEE +0 is not equal to -0, atan2 is not a >> function! > > Sorry, I meant to write: Since according to IEEE +0 *is* to be regarded as > equal to -0, atan2 is not a function. (Because it gives different values for >

Re: [Haskell-cafe] Re: exitFailure under forkProcess

2004-10-27 Thread Marcin &#x27;Qrczak' Kowalczyk
John Goerzen <[EMAIL PROTECTED]> writes: > I wonder what the behavior of fwrite() in this situation is. I don't > know if it ever performs buffering such that write() is never called > during a call to fwrite(). On Linux it duplicates unflushed output (hmm, I thought they fixed this a few years

Re: [Haskell-cafe] Are handles garbage-collected?

2004-10-26 Thread Marcin &#x27;Qrczak' Kowalczyk
Sam Mason <[EMAIL PROTECTED]> writes: > The best idea I've seen is another one from Microsoft Research. > It's an extension to C that allows the the programmer to use the > type system to specify the lifetime of things. I'm worried about putting too many thing in types. For example many people be

Re: [Haskell-cafe] Are handles garbage-collected?

2004-10-25 Thread Marcin &#x27;Qrczak' Kowalczyk
Tomasz Zielonka <[EMAIL PROTECTED]> writes: >> P.S. Why do so many people (including me) seem to come to Haskell >> from Python? It can't be just the indentation, can it? ;) > > How many? I don't. And I don't either. But indeed I've seen more references to Haskell on Python lists than on ot

Re: [Haskell-cafe] Are handles garbage-collected?

2004-10-25 Thread Marcin &#x27;Qrczak' Kowalczyk
Remi Turk <[EMAIL PROTECTED]> writes: > Hm, I'm not sure about the "should". Garbage collection is meant > for memory, and anything making that less clear makes people > more likely to depend on incorrect assumptions. > And redefining GC to be a collection of _all_ garbage, instead of > just memor

Re: [Haskell-cafe] Are handles garbage-collected?

2004-10-25 Thread Marcin &#x27;Qrczak' Kowalczyk
"Simon Marlow" <[EMAIL PROTECTED]> writes: > At the moment performGC doesn't actually run any finalizers. It > schedules a thread to run the finalizers, and you hope the thread runs > soon. So if you're running performGC for the purposes of finalization, > then almost certainly (performGC >> yie

Re: [Haskell-cafe] Are handles garbage-collected?

2004-10-24 Thread Marcin &#x27;Qrczak' Kowalczyk
"Conal Elliott" <[EMAIL PROTECTED]> writes: > I'm puzzled why explicit bracketing is seen as an acceptable solution. > It seems to me that bracketing has the same drawbacks as explicit memory > management, namely that it sometimes retains the resource (e.g., memory > or file descriptor) longer tha

Re: [Haskell-cafe] Re: Are handles garbage-collected?

2004-10-24 Thread Marcin &#x27;Qrczak' Kowalczyk
Peter Simons <[EMAIL PROTECTED]> writes: > I wish that were possible! I use bracket-style resource > allocation wherever I can, but in this case the Handle is > the _result_ of a rather complex computation, so it has to > leave the scope in which is was opened. A finalizer is all I > can use. It

Re: [Haskell-cafe] Re: OCaml list sees abysmalLanguage Shootoutresults

2004-10-08 Thread Marcin &#x27;Qrczak' Kowalczyk
MR K P SCHUPKE <[EMAIL PROTECTED]> writes: > This sounds like the best idea to me... with each list cell being a > full buffer you could effectively write nieve [Char] code and have it > implemented in about as fast a way as possible... If the representation of some lists was changed, it would co

  1   2   3   >