Re: [Haskell-cafe] ghc panic when compiling blaze-builder
On 11/21/2010 3:20 AM, JosИ Romildo Malaquias wrote: When compiling blaze-builder-0.2.0.1 with ghc-7.0.1 on my ~amd64 gentoo system, I am getting the shown below. Any clues? Romildo [...] Building blaze-builder-0.2.0.1... [1 of 8] Compiling Blaze.ByteString.Builder.Internal ( Blaze/ByteString/Builder/Internal.hs, dist/build/Blaze/ByteString/Builder/Internal.o ) ghc: panic! (the 'impossible' happened) (GHC version 7.0.1 for x86_64-unknown-linux): dsLet: unlifted Look here: http://hackage.haskell.org/trac/ghc/ticket/4498 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Same compiled program behaving differently when called from ghci and shell
Hello, I have a very strange (for me) problem that I manage to reduce to this : I have a small program that reads a file with 1 only character (è = e8) The program is ftest2.hs : import IO import Data.Maybe tfind s = lookup (head s) $ zip ['\xe8', '\xde'] "12" main= do h<- readFile "g:\\CODE\\rlib\\test.txt" putStrLn h print $ tfind h I compile it from command line : ghc --make ftest2.hs Now the weird results : 1/ cmd line: ftest2.exe è Just '2' 2/ ghci Prelude> :!ftest2.exe è Just '2' 3/WinGHci Prelude> :! ftest2.exe è Just '1' I tested different variants, there is always a difference. Any idea to help me trace this behaviour ? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Interactive OpenGL-based graphics and ghci?
I've always had issues with GLUT under ghci. If GHC 7 fixes this it will make me happy :) On Sun, Nov 21, 2010 at 7:54 AM, Luke Palmer wrote: > On Sat, Nov 20, 2010 at 4:46 PM, Conal Elliott wrote: >> I'm trying to find some way to do interactive, OpenGL-based graphics in >> Haskell on Mac OS X. >> Does anyone here use GLUT or SDL on Mac OS X with ghci, or maybe an >> alternative library? > > I was reading the GHC 7 release notes and saw this: > > * There is a new -fno-ghci-sandbox flag, which stops GHCi running > computations in a separate thread; in particular, this works around an > issue running GLUT from GHCi on OS X > > So that seems to indicate that GLUT would fulfill your needs. > > Luke > ___ > 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
Re: [Haskell-cafe] Downloading web page in Haskell
Most likely you also have the zlib package (cabal-install needs it), so let's use it. Attached therefore.hs import qualified Data.ByteString.Lazy as LB import Codec.Compression.GZip(decompress) import Network.URI(parseURI) import Network.HTTP url = "http://www.adorocinema.com/common/search/search_by_film/?criteria=Bourne"; -- steal from getRequest but change type -- it's lazy bytestring because the GZip library specifies it myGetRequest :: String -> Request LB.ByteString myGetRequest s = case parseURI s of Nothing -> error "url syntax error" Just uri -> mkRequest GET uri main = do result <- simpleHTTP (insertHeader HdrAcceptEncoding "gzip" (myGetRequest url)) case result of Left e -> print e Right rsp -> do let src = case findHeader HdrContentEncoding rsp of Nothing -> rspBody rsp Just "gzip" -> decompress (rspBody rsp) Just _ -> error "TODO: other decompressions" LB.writeFile "test.html" src LB.putStrLn src ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Downloading web page in Haskell
Albert Y. C. Lai wrote: > ...truncates when the web server chooses the identity encoding > The server chooses identity when > your request's Accept-Encoding field specifies identity or simply your > request has no Accept-Encoding field Excellent work! > My methodology of discovering and confirming this is a great lesson in the > triumph of the scientific methodology (over the prevailing opinionative > methodology, for example). Haha, indeed! > Actually the > truncation strongly suggests that javascript is not involved: the truncation > ends with an incomplete end-tag " javascript-heavy web pages. Well, no, the theory was that the server sends some random number of bytes from the body to ensure that the browser starts loading the scripts in the head. So it could stop anywhere. In the end, I think you didn't really need the W3C validator. You also could have triangulated on the headers sent by your own browser. So, there you have it, folks. The Haskell community debugs a broken web server, without being asked, and without access to the server. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] doesDirectoryExist is always returning False
On Sat, Nov 20, 2010 at 6:55 AM, Marcelo Sousa wrote: > Hi, > I'm having currently a problem with System.Directory in my mac os. > System Version: Mac OS X 10.6.5 > Kernel Version: Darwin 10.5.0 > Prelude System.Directory> let dirTest = do {dir <- getCurrentDirectory; > doesDirectoryExist dir} > Prelude System.Directory> dirTest > False What's the output of getCurrentDirectory? I just tried that on OS X 10.6.4 and dirTest returned True for me. -Judah ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] ghc panic when compiling blaze-builder
When compiling blaze-builder-0.2.0.1 with ghc-7.0.1 on my ~amd64 gentoo system, I am getting the shown below. Any clues? Romildo [...] Building blaze-builder-0.2.0.1... [1 of 8] Compiling Blaze.ByteString.Builder.Internal ( Blaze/ByteString/Builder/Internal.hs, dist/build/Blaze/ByteString/Builder/Internal.o ) ghc: panic! (the 'impossible' happened) (GHC version 7.0.1 for x86_64-unknown-linux): dsLet: unlifted AbsBinds [b{tv aUH} [sk]] [] [pe{v axd} [lid] <= [b{tv aUH} [sk]] pe{v aUG} [lid]] pe{v axd} [lid] :: forall b{tv aUH} [sk]. base:GHC.Ptr.Ptr{tc 33A} b{tv aUH} [sk] [LclId] { {273:19-54} {273:19-54} !((pe{v aUG} [lid] :: base:GHC.Ptr.Ptr{tc 33A} b{tv aUH} [sk])) = {273:30-54} {273:33-41} (base:GHC.Ptr.plusPtr{v r4X} [gid]) @ base:GHC.Word.Word8{tc 32U} @ b{tv aUH} [sk] pf{v axc} [lid] firstBufSize{v arR} [lid] } EvBinds{{}} base:GHC.Base.>>={v 01P} [gid[ClassOp]] @ ghc-prim:GHC.Types.IO{tc 32I} $dMonad{v aUI} [lid] @ blaze-builder-0.2.0.1:Blaze.ByteString.Builder.Internal.BuildSignal{tc rre} @ bytestring-0.9.1.8:Data.ByteString.Lazy.Internal.ByteString{tc rg5} (step0{v arY} [lid] pf{v axc} [lid] (pe{v axd} [lid] @ base:GHC.Word.Word8{tc 32U})) (\ (next{v axT} [lid] :: blaze-builder-0.2.0.1:Blaze.ByteString.Builder.Internal.BuildSignal{tc rre}) -> let { ds_d15b{v} [lid] :: blaze-builder-0.2.0.1:Blaze.ByteString.Builder.Internal.BuildSignal{tc rre} [LclId] ds_d15b{v} [lid] = next{v axT} [lid] } in case ds_d15b{v} [lid] {ghc-prim:GHC.Types.IO{tc 32I} bytestring-0.9.1.8:Data.ByteString.Lazy.Internal.ByteString{tc rg5}} of (wild_B1{v} [lid] :: blaze-builder-0.2.0.1:Blaze.ByteString.Builder.Internal.BuildSignal{tc rre}) { blaze-builder-0.2.0.1:Blaze.ByteString.Builder.Internal.Done{d rrk} (rb_d15l{v} [lid] :: ghc-prim:GHC.Prim.Addr#{(w) tc 33}) -> let { pf'{v axU} [lid] :: base:GHC.Ptr.Ptr{tc 33A} base:GHC.Word.Word8{tc 32U} [LclId] pf'{v axU} [lid] = base:GHC.Ptr.Ptr{v rcP} [gid[DataCon]] @ base:GHC.Word.Word8{tc 32U} rb_d15l{v} [lid] } in let { fail_d15c{v} [lid] :: ghc-prim:GHC.Prim.State#{(w) tc 32q} ghc-prim:GHC.Prim.RealWorld{(w) tc 31E} -> ghc-prim:GHC.Types.IO{tc 32I} bytestring-0.9.1.8:Data.ByteString.Lazy.Internal.ByteString{tc rg5} [LclId] fail_d15c{v} [lid] = \ (ds_d15d{v} [lid] :: ghc-prim:GHC.Prim.State#{(w) tc 32q} ghc-prim:GHC.Prim.RealWorld{(w) tc 31E}) -> base:GHC.Base.${v 019} [gid] @ bytestring-0.9.1.8:Data.ByteString.Lazy.Internal.ByteString{tc rg5} @ (ghc-prim:GHC.Types.IO{tc 32I} bytestring-0.9.1.8:Data.ByteString.Lazy.Internal.ByteString{tc rg5}) (base:GHC.Base.return{v 01T} [gid[ClassOp]] @ ghc-prim:GHC.Types.IO{tc 32I} $dMonad{v aUN} [lid] @ bytestring-0.9.1.8:Data.ByteString.Lazy.Internal.ByteString{tc rg5}) (bytestring-0.9.1.8:Data.ByteString.Lazy.Internal.$WChunk{v reF} [gid[DataConWrapper]] (mkbs{v axe} [lid] @ base:GHC.Word.Word8{tc 32U} pf'{v axU} [lid]) k{v arT} [lid]) } in case base:GHC.Classes.=={v 01L} [gid[ClassOp]] @ (base:GHC.Ptr.Ptr{tc 33A} base:GHC.Word.Word8{tc 32U}) $dEq{v aUK} [lid] pf'{v axU} [lid] pf{v axc} [lid] {ghc-prim:GHC.Types.IO{tc 32I} bytestring-0.9.1.8:Data.ByteString.Lazy.Internal.ByteString{tc rg5}} of (wild_B1{v} [lid] :: ghc-prim:GHC.Bool.Bool{(w) tc 3c}) { ghc-prim:GHC.Bool.False{(w) d 68} -> fail_d15c{v} [lid] ghc-prim:GHC.Prim.realWorld#{(w) v 0o} [gid]; ghc-prim:GHC.Bool.True{(w) d 6u} -> base:GHC.Base.return{v 01T} [gid[ClassOp]] @ ghc-prim:GHC.Types.IO{tc 32I} $dMonad{v aUL} [lid] @ bytestring-0.9.1.8:Data.ByteString.Lazy.Internal.ByteString{tc rg5} k{v arT} [lid] }; blaze-builder-0.2.0.1:Blaze.ByteString.Builder.Internal.BufferFull{d rri} (rb_d15n{v} [lid] :: ghc-prim:GH
Re: [Haskell-cafe] Downloading web page in Haskell
On 10-11-20 02:54 PM, José Romildo Malaquias wrote: In order to download a given web page, I wrote the attached program. The problem is that the page is not being full downloaded. It is being somehow intettupted. The specific website and url http://www.adorocinema.com/common/search/search_by_film/?criteria=Bourne truncates when the web server chooses the identity encoding (i.e., as opposed to compressed ones such as gzip). The server chooses identity when your request's Accept-Encoding field specifies identity or simply your request has no Accept-Encoding field, such as when you use simpleHTTP (getRequest url), curl, wget, elinks. When the server chooses gzip (its favourite), which is when your Accept-Encoding field includes gzip, the received data is complete (but then you have to gunzip it yourself). This happens with mainstream browsers and W3C's validator at validator.w3.org (which destroys the "you need javascript" hypothesis). I haven't tested other compressed encodings. Methodology My methodology of discovering and confirming this is a great lesson in the triumph of the scientific methodology (over the prevailing opinionative methodology, for example). The first step is to confirm or deny a Network.HTTP problem. For a maximally controlled experiment, I enter HTTP by hand using nc: $ nc www.adorocinema.com 80 GET /common/search/search_by_film/?criteria=Bourne HTTP/1.1 Host: www.adorocinema.com It still truncates, so at least Network.HTTP is not alone. I also try elinks. Other people try curl and wget for the same reason and the same result. The second step is to confirm or deny javascript magic. Actually the truncation strongly suggests that javascript is not involved: the truncation ends with an incomplete end-tag "for very buggy javascript-heavy web pages. To certainly deny javascript magic, I first try Firefox with javascript off (also java off, flash off, even css off), and then I also ask validator.w3.org to validate the page. Both receive complete data. Of course the validator is going to say "many errors", but the point is that if the validator reports errors at locations way beyond our truncation point, then the validator sees data we don't see, and the validator doesn't even care about javascript. The validator may be very sophisticated in parsing html, but in sending an HTTP request it ought to be very simple-minded. The third step is to find out what extra thing the validator does to deserve complete data. So I try diagonalization: I give this CGI script to the validator: #! /bin/sh echo 'Content-Type: text/html' echo '' e=`env` catsave.gz GET /common/search/search_by_film/?criteria=Bourne HTTP/1.1 Host: www.adorocinema.com Accept-Encoding: gzip Now save.gz contains both header and body, and it only makes sense to uncompress the body. So edit save.gz to delete the header part. Applying gunzip to the body will give some "unexpected end of file" error. Don't despair. Do this instead: $ zcat save.gz > save.html It is still an error but save.html has meaningful and complete content. You can examine it. You can load it in a web browser and see. At least, it is much longer, and it ends with "" rather than " ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Interactive OpenGL-based graphics and ghci?
On Sat, Nov 20, 2010 at 4:46 PM, Conal Elliott wrote: > I'm trying to find some way to do interactive, OpenGL-based graphics in > Haskell on Mac OS X. > Does anyone here use GLUT or SDL on Mac OS X with ghci, or maybe an > alternative library? I was reading the GHC 7 release notes and saw this: * There is a new -fno-ghci-sandbox flag, which stops GHCi running computations in a separate thread; in particular, this works around an issue running GLUT from GHCi on OS X So that seems to indicate that GLUT would fulfill your needs. Luke ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Downloading web page in Haskell
On Nov 20, 2010, at 5:10 PM, Yitzchak Gale wrote: > José Romildo Malaquias wrote: >> Web browsers like Firefox and Opera does not seem to have the same >> problem with this web page. >> I would like to be able to download this page from Haskell. > > Hi Romildo, > > This web page serves the head, including a lot of JavaScript, > and the first few hundred bytes of the body, then pauses. > That causes web browsers to begin loading and executing > the JavaScript. Apparently, the site only continues serving > the rest of the page if the JavaScript is actually loaded and > executed. If not, it aborts. Actually, I think it's just a misconfigured proxy. The curl executable fails, at the same point, but a curl --compressed call succeeds. The curl bindings don't allow you to automatically get and decompress gzip data, so you could either set the accept: gzip header yourself, then pipe the output through the appropriate decompression routine, or, more simply, just get the page via using System.Process to drive the curl binary directly. Cheers, Sterl___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Interactive OpenGL-based graphics and ghci?
I'm trying to find some way to do interactive, OpenGL-based graphics in Haskell on Mac OS X. Does anyone here use GLUT or SDL on Mac OS X with ghci, or maybe an alternative library? Using ghci is very important to me, as my programs are pretty high-level and are often half-liners. I'm using gtk2hs for now, but I want something that works more natively, i.e., without the awkwardness of going through the X server. Thanks, - Conal ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] category-extras clash with transformers
On 21 November 2010 09:59, Tony Morris wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > On 21/11/10 08:41, Edward Z. Yang wrote: >> No, you're not totally screwed; you just need to bug >> xmonad-contrib and category-extras to fix their code. >> >> Edward > I am wondering if upgrading from 6.12.1 to 6.12.3 will allow me to > compile xmonad-contrib* and therefore, be ride of the old version of > mtl and therefore, can install category extras. No; since xmonad-contrib doesn't have bounds on the version of mtl being used, cabal-install will take the latest version. You need to use --constraint="mtl < 2". -- Ivan Lazar Miljenovic ivan.miljeno...@gmail.com IvanMiljenovic.wordpress.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] category-extras clash with transformers
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 21/11/10 08:41, Edward Z. Yang wrote: > No, you're not totally screwed; you just need to bug > xmonad-contrib and category-extras to fix their code. > > Edward I am wondering if upgrading from 6.12.1 to 6.12.3 will allow me to compile xmonad-contrib* and therefore, be ride of the old version of mtl and therefore, can install category extras. * $ cabal install xmonad-contrib Resolving dependencies... Configuring xmonad-contrib-0.9.1... Preprocessing library xmonad-contrib-0.9.1... Building xmonad-contrib-0.9.1... [ 1 of 180] Compiling XMonad.Util.Replace ( XMonad/Util/Replace.hs, dist/build/XMonad/Util/Replace.o ) XMonad/Util/Replace.hs:1:0: Warning: Module `Prelude' is deprecated: You are using the old package `base' version 3.x. Future GHC versions will not support base version 3.x. You should update your code to use the new base version 4.x. [ 2 of 180] Compiling XMonad.Util.CustomKeys ( XMonad/Util/CustomKeys.hs, dist/build/XMonad/Util/CustomKeys.o ) XMonad/Util/CustomKeys.hs:80:23: Not in scope: data constructor `Reader' cabal: Error: some packages failed to install: xmonad-contrib-0.9.1 failed during the building phase. The exception was: ExitFailure 1 - -- Tony Morris http://tmorris.net/ -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkzoUrYACgkQmnpgrYe6r60E4QCfXjGuWsu9xLcEVn142+lJkzRQ +0QAoJpbYpioJaIeuygxZXKLHKb7fRBk =dBSD -END PGP SIGNATURE- ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] category-extras clash with transformers
No, you're not totally screwed; you just need to bug xmonad-contrib and category-extras to fix their code. Edward ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] category-extras clash with transformers
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 21/11/10 04:43, Ross Paterson wrote: > On Sat, Nov 20, 2010 at 10:58:44PM +1000, Tony Morris wrote: >> I have installed mtl-1.1.1.0 so that xmonad-contrib-0.9.1 would >> compile with GHC 6.12.1. >> http://permalink.gmane.org/gmane.comp.lang.haskell.xmonad/10603 >> >> Then I tried to installed category-extras-0.53.5, which clashed >> with transformers-0.2.2.0 for the Applicative/Monad instances for >> Either. >> >> Is there any way out of this problem? Thanks for any pointers. > > The instance in question is in the base package from GHC 7, which > should avoid this problem of clashing orphans in the future. > Unfortunately that doesn't help you -- I think both xmonad-contrib > and category-extras need to be updated. > ___ Haskell-Cafe > mailing list Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe Thanks Ross, I just wish to confirm -- I'm totally screwed, right? - -- Tony Morris http://tmorris.net/ -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkzoSnsACgkQmnpgrYe6r62K3QCgnxkRqnQbv0FlKBy1sfrxcoKC 1zcAoM295VGFZBo/OQR1Qq4jW1zI3C+D =FRrh -END PGP SIGNATURE- ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Downloading web page in Haskell
José Romildo Malaquias wrote: > Web browsers like Firefox and Opera does not seem to have the same > problem with this web page. > I would like to be able to download this page from Haskell. Hi Romildo, This web page serves the head, including a lot of JavaScript, and the first few hundred bytes of the body, then pauses. That causes web browsers to begin loading and executing the JavaScript. Apparently, the site only continues serving the rest of the page if the JavaScript is actually loaded and executed. If not, it aborts. Either intentionally or unintentionally, that effectively prevents naive scripts from accessing the page. Cute technique. So if you don't want to honor the site author's intention not to allow scripts to load the page, try looking through the JavaScript and find out what you need to do to get the page to continue loading. However, if the site author is very determined to stop you, the JavaScript will be obfuscated or encrypted, which would make this an annoying task. Good luck, Yitz ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Downloading web page in Haskell
On Sat, Nov 20, 2010 at 10:26:49PM +0100, Daniel Fischer wrote: > On Saturday 20 November 2010 21:47:52, Don Stewart wrote: > > > 2010/11/20 José Romildo Malaquias : > > > > In order to download a given web page, I wrote the attached program. > > > > The problem is that the page is not being full downloaded. It is > > > > being somehow intettupted. > > > > > > > > Any clues on how to solve this problem? > > > > FWIW, with this url, I get the same problem using the Curl package > > Just for the record, wget also gets a truncated (at the same point) file, > so it's not a Haskell problem. Web browsers like Firefox and Opera does not seem to have the same problem with this web page. I would like to be able to download this page from Haskell. Romildo ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Codec.Crypto.RSA question
The problem in this example is the use of Data.Binary. When using Data.ByteString.Lazy.Char8 instead, the problem does not exist. import qualified Codec.Crypto.RSA as Crypto import System.Random (mkStdGen) import Data.ByteString.Lazy.UTF8 (toString) import qualified Data.ByteString.Lazy.Char8 as C8 import qualified Data.ByteString.Lazy n = 1024 (pubKey,privKey,_) = Crypto.generateKeyPair (mkStdGen n) n encrypt :: String -> Data.ByteString.Lazy.ByteString encrypt str = fst $ Crypto.encrypt (mkStdGen n) pubKey (C8.pack str) decrypt :: Data.ByteString.Lazy.ByteString -> String decrypt = toString . Crypto.decrypt privKey decrypt $ encrypt "haskell" = "haskell" Regards, Mathias Am 20.11.2010 13:15, schrieb Charles-Pierre Astolfi: > > Here's a working example: > > > > import qualified Codec.Crypto.RSA as Crypto > > import System.Random (mkStdGen) > > import Data.Binary (encode) > > import Data.ByteString.Lazy.UTF8 (toString) > > > > n = 1024 > > (pubKey,privKey,_) = Crypto.generateKeyPair (mkStdGen n) n > > > > encrypt :: (Data.Binary.Binary a) => a -> > > Data.ByteString.Lazy.Internal.ByteString > > encrypt str = fst $ Crypto.encrypt (mkStdGen n) pubKey (encode str) > > > > decrypt :: Data.ByteString.Lazy.Internal.ByteString -> String > > decrypt = toString . Crypto.decrypt privKey > > > > Thus, > > decrypt $ encrypt "haskell" = "\NUL\NUL\NUL\NUL\NUL\NUL\NUL\ahaskell" > > > > > > I'm using Codec.Crypto.RSA and you're quoting Codec.Encryption.RSA, > > which is not the same thing; unfortunately I need to use RSAES-OAEP > > (SHA1) so I guess I have to stick with Codec.Crypto.RSA. > > Any ideas? > > -- > > Cp > > > > > > > > On Sat, Nov 20, 2010 at 12:50, Dominic Steinitz > > wrote: >> >> Charles-Pierre Astolfi crans.org> writes: >> >> >>> >>> Hi -cafe, >>> >>> >>> >>> I have a question about Codec.Crypto.RSA: how to enforce that >>> >>> (informally) decrypt . encrypt = id >>> >>> Consider this code: >>> >>> >> >> That's certainly what I would expect and one of the unit tests that >> >> comes with >> >> http://hackage.haskell.org/packages/archive/Crypto/4.2.2/doc/html/Codec-Encryption-RSA.html >> >> checks for this. I wasn't able to get you code to compile so I couldn't >> >> investigate further. Maybe you could post a fully compiling example? >> >> >> >> ___ >> >> 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 mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Downloading web page in Haskell
On Saturday 20 November 2010 21:47:52, Don Stewart wrote: > > 2010/11/20 José Romildo Malaquias : > > > In order to download a given web page, I wrote the attached program. > > > The problem is that the page is not being full downloaded. It is > > > being somehow intettupted. > > > > > > Any clues on how to solve this problem? > > FWIW, with this url, I get the same problem using the Curl package Just for the record, wget also gets a truncated (at the same point) file, so it's not a Haskell problem. > > Not a problem on e.g. http://haskell.org > > -- Don ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Downloading web page in Haskell
michael: > 2010/11/20 José Romildo Malaquias : > > In order to download a given web page, I wrote the attached program. The > > problem is that the page is not being full downloaded. It is being > > somehow intettupted. > > > > Any clues on how to solve this problem? > > My guess is that there's a character encoding issue. Another approach > would be using the http-enumerator package[1]. The equivalent program > is: > > module Main where > > import Network.HTTP.Enumerator (simpleHttp) > import qualified Data.ByteString.Lazy as L > > main = > do src <- simpleHttp > "http://www.adorocinema.com/common/search/search_by_film/?criteria=Bourne"; > L.writeFile "test.html" src > L.putStrLn src > FWIW, with this url, I get the same problem using the Curl package (via the download-curl): import Network.Curl.Download import qualified Data.ByteString as B main = do edoc <- openURI "http://www.adorocinema.com/common/search/search_by_film/?criteria=Bourne"; case edoc of Left err -> print err Right doc -> B.writeFile "test.html" doc Not a problem on e.g. http://haskell.org -- Don ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Downloading web page in Haskell
2010/11/20 José Romildo Malaquias : > In order to download a given web page, I wrote the attached program. The > problem is that the page is not being full downloaded. It is being > somehow intettupted. > > Any clues on how to solve this problem? My guess is that there's a character encoding issue. Another approach would be using the http-enumerator package[1]. The equivalent program is: module Main where import Network.HTTP.Enumerator (simpleHttp) import qualified Data.ByteString.Lazy as L main = do src <- simpleHttp "http://www.adorocinema.com/common/search/search_by_film/?criteria=Bourne"; L.writeFile "test.html" src L.putStrLn src Michael [1] http://hackage.haskell.org/package/http-enumerator ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Downloading web page in Haskell
In order to download a given web page, I wrote the attached program. The problem is that the page is not being full downloaded. It is being somehow intettupted. Any clues on how to solve this problem? Romildo module Main where import Network.HTTP (getResponseBody, getRequest, simpleHTTP) openURL x = simpleHTTP (getRequest x) >>= getResponseBody main = do src <- openURL "http://www.adorocinema.com/common/search/search_by_film/?criteria=Bourne"; writeFile "test.html" src putStrLn src ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] category-extras clash with transformers
On Sat, Nov 20, 2010 at 10:58:44PM +1000, Tony Morris wrote: > I have installed mtl-1.1.1.0 so that xmonad-contrib-0.9.1 would compile > with GHC 6.12.1. > http://permalink.gmane.org/gmane.comp.lang.haskell.xmonad/10603 > > Then I tried to installed category-extras-0.53.5, which clashed with > transformers-0.2.2.0 for the Applicative/Monad instances for Either. > > Is there any way out of this problem? Thanks for any pointers. The instance in question is in the base package from GHC 7, which should avoid this problem of clashing orphans in the future. Unfortunately that doesn't help you -- I think both xmonad-contrib and category-extras need to be updated. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Codec.Crypto.RSA question
Charles-Pierre Astolfi wrote: > Here's a working example: > > import qualified Codec.Crypto.RSA as Crypto > import System.Random (mkStdGen) > import Data.Binary (encode) > import Data.ByteString.Lazy.UTF8 (toString) > > n = 1024 > (pubKey,privKey,_) = Crypto.generateKeyPair (mkStdGen n) n > > encrypt :: (Data.Binary.Binary a) => a -> > Data.ByteString.Lazy.Internal.ByteString > encrypt str = fst $ Crypto.encrypt (mkStdGen n) pubKey (encode str) > > decrypt :: Data.ByteString.Lazy.Internal.ByteString -> String > decrypt = toString . Crypto.decrypt privKey > > Thus, > decrypt $ encrypt "haskell" = "\NUL\NUL\NUL\NUL\NUL\NUL\NUL\ahaskell" > > > I'm using Codec.Crypto.RSA and you're quoting Codec.Encryption.RSA, > which is not the same thing; unfortunately I need to use RSAES-OAEP > (SHA1) so I guess I have to stick with Codec.Crypto.RSA. > Any ideas? > -- > I was quoting Codec.Encryption.RSA only to suggest that I would expect that decrypt . encrypt == id. Here's an example using RSAES-OAEP that demonstrates the desired property. I'm not sure what your application is but if you want to interoperate e.g. with openssl, it's pretty essential to be able to be able to handle certificates. Unfortunately, it looks like the asn1 package is now bit-rotted. At one point there was a test against openssl together with instructions on how to interoperate. I still have the instructions if you are interested. > module Main(main) where > > import Codec.Utils > import Data.Digest.SHA1(hash,Word160(Word160)) > import Codec.Encryption.RSA.MGF > import Codec.Encryption.RSA.EMEOAEP > import Codec.Encryption.RSA > import Test.HUnit > > import qualified Codec.Crypto.RSA as Crypto > import System.Random (mkStdGen) > import qualified Data.Binary as Binary > import Data.ByteString.Lazy.UTF8 (toString) > > import Data.Char > import qualified Codec.Encryption.RSA.EMEOAEP as E > import Codec.Encryption.RSA.MGF > > > n1 = 1024 > (pubKey,privKey,_) = Crypto.generateKeyPair (mkStdGen n1) n1 > > encrypt1 str = fst $ Crypto.encrypt (mkStdGen n1) pubKey > (Binary.encode str) > > decrypt1 = toString . Crypto.decrypt privKey > > randomSeed :: [Octet] > randomSeed = hash' [3] > > hash' xs = let (Word160 a b c d e) = hash xs in concatMap (toOctets > 256) [a,b,c,d,e] > > ciphertext :: [Octet] -> [Octet] -> String -> [Octet] > ciphertext n d x = >encrypt (n,d) $ >E.encode mgf hash' [] randomSeed n $ >map (fromIntegral . ord) x > > plaintext :: [Octet] -> [Octet] -> [Octet] -> String > plaintext n e x = >map (chr . fromIntegral) $ >E.decode mgf hash' [] $ >decrypt (n,e) $ x > > ciphertext1 privKey x = >ciphertext (toOctets 256 $ Crypto.private_n privKey) (toOctets 256 > $ Crypto.private_d privKey) x > > plaintext1 pubKey x = >plaintext (toOctets 256 $ Crypto.public_n pubKey) (toOctets 256 $ > Crypto.public_e pubKey) x > > main = putStrLn $ plaintext1 pubKey $ ciphertext1 privKey "Hello" ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] doesDirectoryExist is always returning False
Hi, I'm having currently a problem with System.Directory in my mac os. System Version: Mac OS X 10.6.5 Kernel Version: Darwin 10.5.0 Prelude System.Directory> let dirTest = do {dir <- getCurrentDirectory; doesDirectoryExist dir} Prelude System.Directory> dirTest False I noticed also that I can't change the searchable field in the permissions record. Prelude System.Directory> getPermissions "." Permissions {readable = True, writable = True, executable = True, searchable = False} I tried different versions of directory and filepath packages but with no success at the moment. Any suggestions?! Regards, Marcelo Sousa___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Re: Reply-To: Header in Mailinglists (was: About "Fun with type functions" example)
On Fri, 2010-11-19 at 15:25 +0100, Arnaud Bailly wrote: > I personnally use most of the time gmail, so I don't have access to a > Reply-To-List feature (or do I?). > I usually do Reply-to-all which I think is as I guess most mailers > remove duplicate mails. Am I right? > > Arnaud As message have the same Message-ID the servers have to (or at least should - I'm too lazy right now to check the RFC) considered it 'the same' message (i.e. say - oh. I've already received this message). I tend to use reply-to-all or reply-to-list if the latter is present. Regards PS. Please note that sometimes people do not subscribe to receive messages. For example I asked a few times on various mailing lists for help when I was not interested in general discussion on topic asking to add me to CC. If the mailing list replaced Reply-To header it would required additional effort for responders instead of just pressing reply-to-all. signature.asc Description: This is a digitally signed message part ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] category-extras clash with transformers
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 I have installed mtl-1.1.1.0 so that xmonad-contrib-0.9.1 would compile with GHC 6.12.1. http://permalink.gmane.org/gmane.comp.lang.haskell.xmonad/10603 Then I tried to installed category-extras-0.53.5, which clashed with transformers-0.2.2.0 for the Applicative/Monad instances for Either. Is there any way out of this problem? Thanks for any pointers. $ ghc-pkg list | grep mtl mtl-1.1.1.0 mtl-2.0.1.0 $ ghc-pkg list | grep transformers transformers-0.2.2.0 $ cabal install category-extras ... [39 of 99] Compiling Control.Monad.Either ( src/Control/Monad/Either.hs, dist/build/Control/Monad/Either.o ) src/Control/Monad/Either.hs:44:9: Duplicate instance declarations: instance Monad (Either e) -- Defined at src/Control/Monad/Either.hs:44:9-24 instance Monad (Either e) -- Defined in transformers-0.2.2.0:Control.Monad.Trans.Error src/Control/Monad/Either.hs:49:9: Duplicate instance declarations: instance Applicative (Either e) -- Defined at src/Control/Monad/Either.hs:49:9-30 instance Applicative (Either e) -- Defined in transformers-0.2.2.0:Control.Monad.Trans.Error src/Control/Monad/Either.hs:53:9: Duplicate instance declarations: instance MonadFix (Either e) -- Defined at src/Control/Monad/Either.hs:53:9-27 instance MonadFix (Either e) -- Defined in transformers-0.2.2.0:Control.Monad.Trans.Error cabal: Error: some packages failed to install: category-extras-0.53.5 failed during the building phase. The exception was: ExitFailure 1 - -- Tony Morris http://tmorris.net/ -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkznxgQACgkQmnpgrYe6r60dkACfZQkYKbMOQuGfaVpFb2MfhJWD asAAn1/hoX+m/YpUOch3r4NsR99y2htz =IsZc -END PGP SIGNATURE- ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Musings on type systems
On 20 November 2010 12:05, Tillmann Rendel wrote: > I would expect the "exponential type" to be (a -> b): > Terminologically, "Bananas in Space" (!) agrees with you. http://www.cs.nott.ac.uk/~gmh/bananas.pdf Regards Stephen ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Codec.Crypto.RSA question
Here's a working example: import qualified Codec.Crypto.RSA as Crypto import System.Random (mkStdGen) import Data.Binary (encode) import Data.ByteString.Lazy.UTF8 (toString) n = 1024 (pubKey,privKey,_) = Crypto.generateKeyPair (mkStdGen n) n encrypt :: (Data.Binary.Binary a) => a -> Data.ByteString.Lazy.Internal.ByteString encrypt str = fst $ Crypto.encrypt (mkStdGen n) pubKey (encode str) decrypt :: Data.ByteString.Lazy.Internal.ByteString -> String decrypt = toString . Crypto.decrypt privKey Thus, decrypt $ encrypt "haskell" = "\NUL\NUL\NUL\NUL\NUL\NUL\NUL\ahaskell" I'm using Codec.Crypto.RSA and you're quoting Codec.Encryption.RSA, which is not the same thing; unfortunately I need to use RSAES-OAEP (SHA1) so I guess I have to stick with Codec.Crypto.RSA. Any ideas? -- Cp On Sat, Nov 20, 2010 at 12:50, Dominic Steinitz wrote: > Charles-Pierre Astolfi crans.org> writes: > >> >> Hi -cafe, >> >> I have a question about Codec.Crypto.RSA: how to enforce that >> (informally) decrypt . encrypt = id >> Consider this code: >> > That's certainly what I would expect and one of the unit tests that comes > with > http://hackage.haskell.org/packages/archive/Crypto/4.2.2/doc/html/Codec-Encryption-RSA.html > checks for this. I wasn't able to get you code to compile so I couldn't > investigate further. Maybe you could post a fully compiling example? > > ___ > 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
Re: [Haskell-cafe] Musings on type systems
Ketil Malde wrote: data Sum a b = A a | B b -- values = values in a + values in b data Prod a b = P a b-- values = values in a * values in b I guess this makes [X] an exponential type, although I don't remember seeing that term :-) I would expect the "exponential type" to be (a -> b): > type Exp b a = a -> b -- values = values in b ^ values in a Tillmann ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Codec.Crypto.RSA question
Charles-Pierre Astolfi crans.org> writes: > > Hi -cafe, > > I have a question about Codec.Crypto.RSA: how to enforce that > (informally) decrypt . encrypt = id > Consider this code: > That's certainly what I would expect and one of the unit tests that comes with http://hackage.haskell.org/packages/archive/Crypto/4.2.2/doc/html/Codec-Encryption-RSA.html checks for this. I wasn't able to get you code to compile so I couldn't investigate further. Maybe you could post a fully compiling example? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Musings on type systems
Andrew Coppin writes: > Now here's an interesting thought. Haskell has "algebraic data > types". "Algebraic" because they are sum types of product types (or, > equivilently, product types of sum types). Now I don't actually know > what those terms mean, The quick rule to remember this that the size of the resulting types correspond to the arithmetic names. I.e. data Sum a b = A a | B b -- values = values in a + values in b data Prod a b = P a b-- values = values in a * values in b I guess this makes [X] an exponential type, although I don't remember seeing that term :-) -k -- If I haven't seen further, it is by standing in the footprints of giants ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Musings on type systems
Hi Andrew, Andrew Coppin wrote: Now, what about type variables? What do they do? Well now, that seems to be slightly interesting, since a type variable holds an entire type (whereas normal program variables just hold a single value), and each occurrance of the same variable is statically guaranteed to hold the same thing at all times. It's sort of like how every instance of a normal program variable holds the same value, except that you don't explicitly say what that value is; the compiler infers it. What do you mean by "hold the same thing at all times"? Consider the following program: id :: forall a . a -> a id x = x call1 :: Bool call1 = id True call2 :: Int call2 = id 42 This program contains a type variable a, and a value variable x. Now, these variables do *not* mean the same thing at all times. In the first call of id, a is Bool and x is True; but in the second call of id, a is Int and x is 42. If these variables would mean the same thing at all times, I would expect them to be called constants, wouldn't you? Tillmann ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] RegEx versus (Parsec, TagSoup, others...)
On 19 November 2010 22:17, Brandon S Allbery KF8NH wrote: > If a Perl "expert" tells you that regexps are the way to parse HTML/XML, you > can safely conclude they've never actually tried to do it. For the original message it sounded like the Perl expert recommended regexps to scrape facts from Html. That's a quite different scenario from parsing and not unreasonable for regexps. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Quasi quotation question
Sure. Just use http://hackage.haskell.org/package/haskell-src-meta-0.0.6. You are probably interested in parsePat or parseExp. I've used parseExp in a package. -- Oscar ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe