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

2006-02-23 Thread Marcin '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 that

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

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

2006-02-12 Thread Marcin '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. ; is already used

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

2006-02-12 Thread Marcin '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 should

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

2006-02-12 Thread Marcin '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 don't

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

2006-02-12 Thread Marcin '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] Space questions about intern and sets

2005-06-01 Thread Marcin '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 same

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

2005-05-07 Thread Marcin '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. C, C++ and

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

2005-05-07 Thread Marcin '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 given

Re: [Haskell-cafe] Compiling with NHC98

2005-05-07 Thread Marcin '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 formats.

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

2005-05-07 Thread Marcin '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 never

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

2005-05-07 Thread Marcin '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 '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 ) are both valid,

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

2005-05-04 Thread Marcin '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 '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 of

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

2005-05-03 Thread Marcin '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 not

Re: [Haskell-cafe] Instances of constrained datatypes

2005-04-06 Thread Marcin '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' class with

Re: [Haskell-cafe] invalid character encoding

2005-03-19 Thread Marcin '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)

Re: [Haskell-cafe] invalid character encoding

2005-03-18 Thread Marcin '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 isn't a per-terminal

Re: [Haskell-cafe] invalid character encoding

2005-03-17 Thread Marcin '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-17 Thread Marcin '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-16 Thread Marcin '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 would

Re: [Haskell-cafe] invalid character encoding

2005-03-16 Thread Marcin '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 traditional

Re: [Haskell-cafe] invalid character encoding

2005-03-16 Thread Marcin '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 end

Re: [Haskell-cafe] Re: Bound threads

2005-03-03 Thread Marcin '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() call

Re: [Haskell-cafe] Re: Bound threads

2005-03-02 Thread Marcin '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 that doing this

Re: [Haskell-cafe] Re: Bound threads

2005-03-01 Thread Marcin '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've now implemented

Re: [Haskell-cafe] Re: Bound threads

2005-03-01 Thread Marcin '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

Re: [Haskell-cafe] Re: Bound threads

2005-02-28 Thread Marcin '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* foreign calls

Re: [Haskell-cafe] Re: Bound threads

2005-02-26 Thread Marcin '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 MVars, the

[Haskell-cafe] Bound threads

2005-02-25 Thread Marcin '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

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

2005-02-14 Thread Marcin '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 monad.

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

2005-02-02 Thread Marcin '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-1, you

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

2005-01-31 Thread Marcin '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 as a

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

2005-01-31 Thread Marcin '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 Unix they

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

2005-01-30 Thread Marcin '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 qualified

Re: [Haskell-cafe] File path programme

2005-01-30 Thread Marcin '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 wide. On

Re: [Haskell-cafe] File path programme

2005-01-30 Thread Marcin '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

Re: [Haskell-cafe] File path programme

2005-01-30 Thread Marcin '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 ESC$)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

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

2005-01-30 Thread Marcin '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: mathematical notation and functional programming

2005-01-29 Thread Marcin 'Qrczak' Kowalczyk
Stefan Monnier [EMAIL PROTECTED] writes: OTOH I like the abc shorthand because it's both obvious and 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).

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

2005-01-27 Thread Marcin '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 old

Re: [Haskell-cafe] File path programme

2005-01-27 Thread Marcin '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 remove the

Re: [Haskell-cafe] File path programme

2005-01-27 Thread Marcin '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 ifDefined

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

2005-01-23 Thread Marcin '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 would prevent using

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

2005-01-23 Thread Marcin '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 compatible with these. The

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

2005-01-21 Thread Marcin '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] I/O interface

2005-01-19 Thread Marcin '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

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

2005-01-19 Thread Marcin '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 return the

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

2005-01-19 Thread Marcin '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 will

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

2005-01-18 Thread Marcin '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:* These

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

2005-01-16 Thread Marcin '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

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

2005-01-16 Thread Marcin '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 this? This

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

2005-01-15 Thread Marcin '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 '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 '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 channel

[Haskell-cafe] Re: I/O interface

2005-01-12 Thread Marcin '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 - they

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

2005-01-12 Thread Marcin '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 which

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

2005-01-11 Thread Marcin '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. -- __(

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

2005-01-11 Thread Marcin '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*| Nd

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

2005-01-11 Thread Marcin '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 which

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

2005-01-11 Thread Marcin '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 dup()

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

2005-01-10 Thread Marcin 'Qrczak' Kowalczyk
Jrmy 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 tables with

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

2005-01-09 Thread Marcin '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 support

Re: [Haskell-cafe] Some random newbie questions

2005-01-09 Thread Marcin '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 work with

Re: [Haskell-cafe] Some random newbie questions

2005-01-09 Thread Marcin '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 the first

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

2005-01-02 Thread Marcin '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 '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 '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 '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 structure,

Re: [Haskell-cafe] Mutable data design question

2004-12-03 Thread Marcin '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 logarithmic

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

2004-12-01 Thread Marcin '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 = Success a |

Re: [Haskell-cafe] ACIO versus Execution Contexts

2004-11-30 Thread Marcin '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 a

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

2004-11-30 Thread Marcin '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 -

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

2004-11-27 Thread Marcin '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

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

2004-11-25 Thread Marcin '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 get

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

2004-11-24 Thread Marcin '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 couldn't

Re: [Haskell-cafe] IO and State

2004-11-17 Thread Marcin '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

Re: [Haskell-cafe] Currying and errors

2004-11-08 Thread Marcin '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: isSubsumedByWith

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

2004-11-05 Thread Marcin '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 argument

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

2004-10-26 Thread Marcin '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

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

2004-10-25 Thread Marcin '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 memory

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

2004-10-25 Thread Marcin '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 other

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

2004-10-24 Thread Marcin '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 than

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

2004-10-08 Thread Marcin 'Qrczak' Kowalczyk
Andrew Butterfield [EMAIL PROTECTED] writes: I though clean was always strict, and that was the major difference between clean and haskell (that and the fact clean is a proprietry language) No - Clean is pure and lazy like Haskell, But it uses explicit strictness annotations a lot, and

Re: [Haskell-cafe] Exceptions

2004-10-01 Thread Marcin 'Qrczak' Kowalczyk
John Goerzen [EMAIL PROTECTED] writes: 1. Can exceptions be used in pure functions (outside of monads?) For the theoretical background of this, see A Semantics for Imprecise Exceptions http://citeseer.ist.psu.edu/196569.html. -- __( Marcin Kowalczyk \__/ [EMAIL PROTECTED]

Re: [Haskell-cafe] Optmiization of recursion

2004-09-28 Thread Marcin 'Qrczak' Kowalczyk
John Goerzen [EMAIL PROTECTED] writes: The OCaml compiler was able to optimize tail-recursive functions such that they could be compiled using a loop. This would achieve two main benefits: performance due to not needing to allocate/deallocate stack frames, and the ability to work on very

Re: [Haskell-cafe] Optmiization of recursion

2004-09-28 Thread Marcin 'Qrczak' Kowalczyk
John Goerzen [EMAIL PROTECTED] writes: If I instead wrote: sum [] = 0 sum (x:xs) = x + sum(xs) then I have the same problem. What is the proper way to solve this little problem then? sum n [] = n sum n (x:xs) = (sum $! n + x) xs It's unfortunate that it requires $! or seq, but it's

Re: [Haskell-cafe] Writing binary files?

2004-09-18 Thread Marcin 'Qrczak' Kowalczyk
Glynn Clements [EMAIL PROTECTED] writes: Ok, but let it be in addition to, not instead treating them as character strings. Provided that you know the encoding, nothing stops you converting them to strings, should you have a need to do so. There are already APIs which use Strings for

Re: [Haskell-cafe] Writing binary files?

2004-09-17 Thread Marcin 'Qrczak' Kowalczyk
Glynn Clements [EMAIL PROTECTED] writes: What I'm suggesting in the above is to sidestep the encoding issue by keeping filenames as byte strings wherever possible. Ok, but let it be in addition to, not instead treating them as character strings. And program-generated email notifications

Re: [Haskell-cafe] Layered I/O

2004-09-16 Thread Marcin 'Qrczak' Kowalczyk
[EMAIL PROTECTED] writes: The discussion of i18n i/o highlighted the need for general overlay streams. We should be able to place a processing layer onto a handle -- and to peel it off and place another one. The layers can do character encoding, subranging (limiting the stream to the

Re: [Haskell-cafe] Writing binary files?

2004-09-16 Thread Marcin 'Qrczak' Kowalczyk
Glynn Clements [EMAIL PROTECTED] writes: But this seems to be assuming a closed world. I.e. the only files which the program will ever see are those which were created by you, or by others who are compatible with your conventions. Yes, unless you set the default encoding to Latin1. Some

Re: [Haskell-cafe] Writing binary files?

2004-09-15 Thread Marcin 'Qrczak' Kowalczyk
Glynn Clements [EMAIL PROTECTED] writes: Unless you are the sole user of a system, you have no control over what filenames may occur on it (and even if you are the sole user, you may wish to use packages which don't conform to your rules). For these occasions you may set the encoding to

Re: [Haskell-cafe] Writing binary files?

2004-09-15 Thread Marcin 'Qrczak' Kowalczyk
Glynn Clements [EMAIL PROTECTED] writes: [Actually, regarding on-screen display, this is also an issue for Unicode. How many people actually have all of the Unicode glyphs? I certainly don't.] If I don't have a particular character in fonts, I will not create files with it in filenames.

Re: [Haskell-cafe] FilePath handling

2004-09-15 Thread Marcin 'Qrczak' Kowalczyk
Henning Thielemann [EMAIL PROTECTED] writes: I even plead for an abstract data type FilePath which supports operations like 'enter a directory', 'go one level higher' and so on. Beware of Common Lisp history: http://www.gigamonkeys.com/book/practical-a-portable-pathname-library.html As we

[Haskell-cafe] Unicoded filenames

2004-09-15 Thread Marcin 'Qrczak' Kowalczyk
Here is what happens when a language provides only narrow-char API for filenames: Start of forwarded message Date: Wed, 15 Sep 2004 15:18:00 +0100 From: Peter Jolly [EMAIL PROTECTED] To: [EMAIL PROTECTED] CC: caml-list [EMAIL PROTECTED] Subject: Re:

Re: [Haskell-cafe] Writing binary files?

2004-09-13 Thread Marcin 'Qrczak' Kowalczyk
Glynn Clements [EMAIL PROTECTED] writes: 1. API for manipulating byte sequences in I/O (without representing them in String type). Note that this needs to include all of the core I/O functions, not just reading/writing streams. E.g. FilePath is currently an alias for String, but (on

Re: [Haskell-cafe] Writing binary files?

2004-09-12 Thread Marcin 'Qrczak' Kowalczyk
Sven Panne [EMAIL PROTECTED] writes: Hmmm, the Unicode tables start with ISO-Latin-1, so what would exactly break when we stipulate that the standard encoding for string I/O in Haskell is ISO-Latin-1? Additional encodings could be specified e.g. via a new open variant. That the encoding of

Re: [Haskell-cafe] Writing binary files?

2004-09-12 Thread Marcin 'Qrczak' Kowalczyk
Glynn Clements [EMAIL PROTECTED] writes: But the default encoding should come from the locale instead of being ISO-8859-1. The problem with that is that, if the locale's encoding is UTF-8, a lot of stuff is going to break (i.e. anything in ISO-8859-* which isn't limited to the 7-bit ASCII

Re: [Haskell-cafe] exceptions vs. Either

2004-08-03 Thread Marcin 'Qrczak' Kowalczyk
W licie z wto, 03-08-2004, godz. 13:05 +0200, Bjoern Knafla napisa: Herb Sutter gave these rules : An error is any failure that prevents a function from succeeding. Three main kind of errors: [...] These kinds don't explain much. They don't give a clue which errors to report by exceptions

  1   2   >