Re: [Haskell-cafe] Re: ocr'ed version of The implementation offunctional languages
On Wed, Feb 02, 2005 at 01:27:30PM +0600, Ivan Boldyrev wrote: On 9007 day of my life Harri Haataja wrote: text, but I haven't learned proper spell yet :) I use free tools, so it may be difficult or impossible. Do see http://any2djvu.djvuzone.org/ Unfortunately, creating script for automated (there are 400+ pages!) usage of this site is too complicated. And my Inet connection is too limited. There is a script. First you would only have to turn that set of raster images into a ps(.gz) or pdf document. I believe the site will turn those to djvu. I have done that with a few odd manuals, so I thought that might be one way. It is not guaranteed that the OCR will work or work well. For some things it does and for some it doesn't. But that is a simple way to access the non-free encoders and do the (or a) conversion with relatively little pain. Something to start with maybe. Creation of LaTeX version is much better. Naturally. But as already mentioned, that means much more manual writing work (and/or some other OCR). ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] MonadPlus instance for IO
I'm sure I'm doing something stupid, but somehow ghc isn't recognizing the existance of a MonadPlus instance for IO: DarcsIO.lhs:48: No instance for (MonadPlus IO) arising from use of `mplus' at DarcsIO.lhs:48 In the definition of `foo': foo = (fail aaack) `mplus` (fail foobar) Any idea what I'm doing wrong? I'm using $ ghc --version The Glorious Glasgow Haskell Compilation System, version 6.2.2 packaged for debian. -- David Roundy http://www.darcs.net ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] The Nature of Char and String
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 lose. I'm not sure it's as bad as all that. You lose the correct Unicode code points (i.e. chars will have the wrong values, and strings may be the wrong lenght), but I think you will be able to get the same bytes out as you read in. So in that sense, Char-based IO is somewhat encoding neutral. So one can have Unicode both in IO and internally, it's just that you don't get both at the same time :-) That's the problem. Perl is similar: it uses the same strings for byte arrays and for Unicode strings whose characters happen to be Latin1. The interpretation sometimes depends on the function / library used, and sometimes on other libraries loaded. When I made an interface between Perl and my language Kogut (which uses Unicode internally and converts texts exchanged with the OS, even though conversion may fail e.g. for files not encoded using the locale encoding - I don't have a better design yet), I had trouble with converting Perl strings which have no characters above 0xFF. If I treat them as Unicode, then a filename passed between the two languages is interpreted differently. If I treat them as the locale encoding, then it's inconsistent and passing strings in both directions doesn't round-trip. So I'm currently treating them as Unicode. Perl's handling of Unicode is inconsistent with itself (e.g. for filenames containing characters above 0xFF), I don't think I made it more broken than it already is... -- __( Marcin Kowalczyk \__/ [EMAIL PROTECTED] ^^ http://qrnik.knm.org.pl/~qrczak/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: File path programme
Peter Simons wrote: Hmmm, I'm not really sure what equivalence for file paths should mean in the presence of hard/symbolic links, (NFS-)mounted file systems, etc. Well, there is a sort-of canonic version for every path; on most Unix systems the function realpath(3) will find it. My interpretation is that two paths are equivalent iff they point to the same target. I think that any definition which includes an iff is likely to be overly optimistic. More likely, you will have to settle for a definition such that, if two paths are considered equal, they refer to the same file, but without the converse (i.e. even if they aren't equal, they might still refer to the same file). Even so, you will need to make certain assumptions. E.g. older Unices would allow root to replace the . and .. entries; you probably want to assume that can't happen. You (and the others who pointed it out) are correct, though, that the current 'canon' function doesn't accomplish that. I guess, I'll have to move it into the IO monad to get it right. And I should probably rename it, too. ;-) A version in the IO monad would allow for a tighter definition (i.e. more likely to correctly identify that two different path values actually refer to the same file). [Certainly, you have to use the IO monad if you want to allow for case sensitivity, as that depends upon which filesystems are mounted where.] Within the IO monad, the obvious approach is to stat() both pathnames and check whether their targets have the same device/inode pairs. That's reasonably simple, and probably about as good as you can get. That still won't handle the case where you mount a single remote filesystem via both NFS and SMB though. I doubt that anything can achieve that. There are also issues of definition, e.g. is /dev/tty considered equivalent to the specific /dev/ttyXX device for the current process? -- Glynn Clements [EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: [Haskell-cafe] MonadPlus instance for IO
that instance seems to be only in Control.Monad.Error in the 'mtl' package. It's not in the standard base package. You may need to import an mtl module to tell GHC to look there. Simon | -Original Message- | From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of | David Roundy | Sent: 02 February 2005 13:18 | To: haskell-cafe@haskell.org | Subject: [Haskell-cafe] MonadPlus instance for IO | | I'm sure I'm doing something stupid, but somehow ghc isn't recognizing the | existance of a MonadPlus instance for IO: | | DarcsIO.lhs:48: | No instance for (MonadPlus IO) | arising from use of `mplus' at DarcsIO.lhs:48 | In the definition of `foo': | foo = (fail aaack) `mplus` (fail foobar) | | Any idea what I'm doing wrong? I'm using | | $ ghc --version | The Glorious Glasgow Haskell Compilation System, version 6.2.2 | | packaged for debian. | -- | David Roundy | http://www.darcs.net | ___ | Haskell-Cafe mailing list | Haskell-Cafe@haskell.org | http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: File path programme
Glynn Clements writes: Well, there is a sort-of canonic version for every path; on most Unix systems the function realpath(3) will find it. My interpretation is that two paths are equivalent iff they point to the same target. I think that any definition which includes an iff is likely to be overly optimistic. I see your point. I guess it comes down to how much effort is put into implementing a realpath() derivate in Haskell. Even so, you will need to make certain assumptions. E.g. older Unices would allow root to replace the . and .. entries; you probably want to assume that can't happen. My take on things is that it is hopeless to even try and cover all this weird behavior. I'd like to treat paths as something abstract. What I'm aiming for is that my library can be used to manipulate file paths as well as URLs, namespaces, and whatnot else; so I'll necessarily lose some functionality that an implementation specifically designed for file paths could provide. If you want to be portable, you cannot use any esoteric functionality anyway. There are also issues of definition, e.g. is /dev/tty considered equivalent to the specific /dev/ttyXX device for the current process? No, because the paths differ. ;-) Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] MonadPlus instance for IO
Am Mittwoch, 2. Februar 2005 14:48 schrieb David Roundy: On Wed, Feb 02, 2005 at 02:41:42PM +0100, Daniel Fischer wrote: Probably you haven't imported 'Control.Monad.Error', where the instance is defined. I did and all went well. Thanks, that did it. It's confusing that the instance is documented in Control.Monad. Yes, very confusing, but what could one do? Maybe urge people to mention instance declarations in the module description, so from the absence of one, you are led to look elsewhere. But that might make descriptions unduly large sometimes. Daniel ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe