[Haskell] The Point of this List
I have been subscribed to this list for over 20 years but these days all I ever see are announcements of conferences which have at best a tangential relationship with Haskell. Maybe it is time to call it a day? Dominic Steinitz domi...@steinitz.org http://idontgetoutmuch.org Twitter: @idontgetoutmuch ___ Haskell mailing list Haskell@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell
[Haskell] New Haddock
I couldn’t find an announcement of the new version of Haddock. You can now document your libraries even more beautifully. For example, > -- \[ > -- f(k;n,p) = \Pr(X = k) = \binom n k p^k(1-p)^{n-k} > -- \] will render as https://hackage.haskell.org/package/random-fu-0.2.7.0/docs/Data-Random-Distribution-Binomial.html#v:integralBinomialPDF <https://hackage.haskell.org/package/random-fu-0.2.7.0/docs/Data-Random-Distribution-Binomial.html#v:integralBinomialPDF> Also don’t forget you can put really nice diagrams in your documentation e.g. http://hackage.haskell.org/package/diagrams-contrib-1.3.0.7/docs/Diagrams-Example-Logo.html <http://hackage.haskell.org/package/diagrams-contrib-1.3.0.7/docs/Diagrams-Example-Logo.html> and http://hackage.haskell.org/package/diagrams-contrib-1.3.0.7/docs/Diagrams-TwoD-Layout-Tree.html <http://hackage.haskell.org/package/diagrams-contrib-1.3.0.7/docs/Diagrams-TwoD-Layout-Tree.html>. Dominic Steinitz domi...@steinitz.org http://idontgetoutmuch.wordpress.com ___ Haskell mailing list Haskell@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell
Re: [Haskell] Haskell Summer of Code
Sad news. I'd like to say a very big thank you to you and everyone else involved in organising our GSoC participation. I know it must have been a considerable amount of work. I for one really appreciate the efforts you have made on all our behalves. On 01/03/2016 12:00, haskell-requ...@haskell.org wrote: > I'm sorry to announce that this year haskell.org was not accepted for the > 2016 Google Summer of Code. > > Dominic Steinitz domi...@steinitz.org http://idontgetoutmuch.wordpress.com ___ Haskell mailing list Haskell@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell
[Haskell] Haskell Platform Release
Hi, The release timetable http://trac.haskell.org/haskell-platform/wiki/ReleaseTimetable says there will be a new release of the Haskell Platform in May. Can someone give an update on this? Many thanks, Dominic. ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
[Haskell] Re: deriving Show for GADT?
Norman Ramsey cs.tufts.edu> writes: > > I've got a fairly large GADT for which I wished to use >deriving (Show) You will have to write one by hand. I tend to use Text.Pretty and then the output is much more readable. It doesn't take long even for a what I would consider a large GADT. ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
[Haskell] Re: seeking papers with good examples of the use of GADTs
> I am hoping some of you may have suggestions about other papers that > would be good tutorials in the use of GADTs. > > Norman > Norman, This is very much in a state of flux but it may be worth taking a look at http://code.haskell.org/asn1/ASNTYPE.lhs. There's also http://www.haskell.org/haskellwiki/QuickCheck_/_GADT which may be of interest. Dominic. ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
[Haskell] www.haskell.org Problem?
I'm doing darcs get http://www.haskell.org/crypto at the moment but it's just hanging. Is there a problem on the server? Thanks, Dominic. ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
[Haskell] ANN: Haskell Cryptographic Library 4.1.0
I'd like to announce the release of a new version of the library following various contributions (contributors are bcc'd). Additions include: BubbleBabble, TEA, HMAC and more large word support. It no longer includes Base64. This is provided by http://hackage.haskell.org/cgi-bin/hackage-scripts/package/dataenc-0.10.1. Many thanks to all contributors. Dominic. PS I always mention this but the library really needs to be reviewed holistically and possibly restructured given the advent of bytestrings. If anyone would like to volunteer to do this or take over as library maintainer, please let me know. ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
[Haskell] ANN: Haskell Cryptographic Library 4.0.3
I should like to announce the release of a new version of the Haskell Cryptographic Library based on the proposal at http://www.haskell.org/haskellwiki/Crypto_Library_Proposal. See http://www.haskell.org/crypto/ for more details. There is now no dependency on NewBinary. The downside is the library contains no support for ASN.1 which will be released in separate package. Dominic. ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
[Haskell] Fast Packed Strings Question
After a lay off from Haskell for a few months and preparatory to Hac 07, I thought I had better check my laptop was appropriately set up. However, I encountered the following: C:\Documents and Settings\Owner\crypto>Setup build Preprocessing library Crypto-3.1.0... Preprocessing executables for Crypto-3.1.0... Building Crypto-3.1.0... Data/Digest/SHA1.hs:36:17: Could not find module `Data.ByteString': it was found in multiple packages: fps-0.8 base What's the story with fast packed strings these days? Is it now part of base and I shouldn't have installed it? If not, can someone remind me how I hide the module in base? Thanks, Dominic. ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
[Haskell] ANNOUNCE: Another Haskell MIME Library
What's the betting they all have Base64 in them. Base64 is like a virus; everyone seems to have their own copy. I put it in the crypto library (along with MD5 another virus-like module) in the hope that we would end up with one version of both. Clearly that hasn't worked. Any suggestions? Dominic. ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
Re: [Haskell] Yampa Arcade
Henrik Nilsson wrote: Hi Dominic, > Does anyone know where the source code for Yampa Arcade can be found? It's included with the (now very old) afrp-0.4 distribution available from www.haskell.org/yampa It's in the examples/SpaceInvaders directory. Hope that helps! All the best, /Henrik Henrik, Thanks. I tried ghc --make Main.hs on the code from http://www.cs.hmc.edu/courses/2006/spring/cs182-3/afrp but got Compiling ObjectBehavior ( ./ObjectBehavior.hs, ./ObjectBehavior.o ) ./ObjectBehavior.hs:37:56: parse error on input `->' The code in examples/SpaceInvaders for ObjectBehavior.as is identical so I assume that won't compile either. Why .as? If anyone has got this working please let me know. I tried making www.haskell.org/yampa but got [EMAIL PROTECTED] afrp-0.4]$ make make -C src make[1]: Entering directory `/home/dom/yampa/nilsson/afrp-0.4/src' ghc -c -fglasgow-exts -O -package lang -package concurrent -o AFRPUtilities.o AFRPUtilities.hs AFRPUtilities.hs:169:46: Ambiguous occurrence `>>^' It could refer to either `AFRPUtilities.>>^', defined at AFRPUtilities.hs:106:2 or `Control.Arrow.>>^', imported from AFRP at AFRPUtilities.hs:90:0-10 So it looks like the code has rotted a bit. I'm assuming the code from hmc is in better shape (as it seems to be in a Spring '06 directory and the compilation got a few modules further) and may have a go at seeing if I can get it to compile. Dominic. ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
[Haskell] Yampa Arcade
Does anyone know where the source code for Yampa Arcade can be found? Googling "yampa arcade" turned up this http://www.cs.hmc.edu/courses/2006/spring/cs182-3/afrp/ but I was expecting to find it stand alone rather than as part of a lecture course. Thanks, Dominic. ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
Re: [Haskell] (.) . (.)
Taral wrote: On 5/28/06, Dominic Steinitz <[EMAIL PROTECTED]> wrote: Is this defined in some library? Thanks, Dominic. Don't think so. I use: \a b -> f (g a b) Taral, Thanks. What prompted this question is that I find myself writing things like: foo = ((.).(.)) concat intersperse I think foo' = \a b -> concat (intersperse a b) is probably clearer but I ended up writing infixr $. ($.) = (.) . (.) and then foo' = concat $. intersperse Of course one could go on and define infixr $.. ($..) = (.) . (.) . (.) and so on. I just wondered if there was a standard nomenclature for such functions a la liftM, liftM2 etc? The answer seems to be no. Thanks, Dominic. ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
[Haskell] (.) . (.)
Is this defined in some library? Thanks, Dominic. ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
[Haskell] My brain just exploded
What a great error message: qcgadt.hs:115:7: My brain just exploded. I can't handle pattern bindings for existentially-quantified constructors. In the binding group (Rep x) = uncompressRep s In the definition of `uncompressRep': uncompressRep (0 : 1 : 0 : s) = let (Rep x) = uncompressRep s in Rep (RList x) Failed, modules loaded: none. Here's the offending line: uncompressRep (0:1:1:s) = let (Rep x) = uncompressRep s in Rep (RList x) But this works: uncompressRep (0:1:0:s) = let x = uncompressRep s in case x of (Rep y) -> Rep (RList y) Can someone explain this? Thanks, Dominic. ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
[Haskell] QuickCheck & GADTs
Has anyone got any examples of these working together? Thanks, Dominic. ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
[Haskell] Non-exhaustive pattern in Socket.hsc
I'm getting [EMAIL PROTECTED] pcap]# ./test test: Socket.hsc:(1434,17)-(1523,20): Non-exhaustive patterns in case The problem is caused because pcap_findalldevs is returning an address family value of 17 #define PF_PACKET 17 /* Packet family. */ #define AF_PACKET PF_PACKET and the ghc Family datatype doesn't support it :-( data Family = AF_UNSPEC | AF_UNIX | AF_INET | AF_INET6 | AF_SNA | AF_DECnet | AF_APPLETALK | AF_ROUTE | AF_X25 | AF_AX25 | AF_IPX -- Imported from Network.Socket *Main> map packFamily [AF_UNSPEC,AF_UNIX,AF_INET,AF_INET6,AF_SNA,AF_DECnet,AF_APPLETALK,AF_ROUTE,AF_X25,AF_AX25,AF_IPX] [0,1,2,10,22,12,5,16,9,3,4] I think I have two choices: 1. Amend ghc. I haven't built ghc for a long time. Would I have to build the whole of ghc? I presume I would have to because of dependencies. 2. Use Network.Alt since http://www.cs.helsinki.fi/u/ekarttun/network-alt/doc/Network.Alt.Types.html defines type Family = Int Any advice? What is the long term plan for Network anyway? Thanks, Dominic. ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
[Haskell] ANNOUNCE: Crypto-3.0.3
I should like to announce a new version of the Haskell Cryptography Library. Version 3.0.3 supports: • DES • Blowfish • AES • Cipher Block Chaining (CBC) • PKCS#5 and nulls padding • SHA-1 • MD5 • RSA • OAEP-based encryption (Bellare-Rogaway) • PKCS#1v1.5 signature scheme • ASN.1 • PKCS#8 • X.509 Identity Certificates • X.509 Attribute Certificates It also includes Base64, a hexdump function, support for Word128, Word192, Word256 (key sizes for AES) and beyond. The ASN.1 handling has been re-written. Details on how to use it are contained in the user guide http://www.haskell.org/crypto/ReadMe.pdf. Haddock documentation is available at http://www.haskell.org/crypto/doc/html. See the home page (http://www.haskell.org/crypto) for downloading. Dominic. ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
[Haskell] Re: Simple IO Regions
Simon Peyton-Jones microsoft.com> writes: > > I really like the way you use a set of constraints > (IN m1 ms, IN m2 ms, IN m3 ms) > to maintain the set of marks. Previously I've thought of using a nested > tuple type > (m1, (m2, (m3 ( > to maintain the set, but that is far less convenient. Very neat. > > Why do you need the > instance IN () b > ? This makes me realise I understand this less than I thought. Can someone give an explanation of how the marks get built up? Thanks, Dominic. ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
[Haskell] Re: darcsweb installed
Simon Marlow microsoft.com> writes: > > I have installed darcsweb on darcs.haskell.org. To browse the available > darcs repositories, go here: > > http://darcs.haskell.org/darcsweb > > It's also available as http://hackage.haskell.org/darcsweb. > > Note that currently I have omitted GHC, the reason being that the GHC > repository is so big that some of the operations on a file (eg. history, > annotate) cause darcs to eat up CPU for several minutes on the server. > So to avoid the server becoming bogged down with darcs processes I've > just omitted the GHC repository for now. > > Cheers, > Simon > I'm a bit baffled here. We have http://hackage.haskell.org/trac/hackage/wiki/CabalPackages. Someone has very kindly added the Crypto package. However, it seems to point to the wrong version (Package-url http://hackage.haskell.org/packages/Crypto-2.0.0.tgz). The current version is http://www.haskell.org/crypto/src/Crypto-2.0.3.tar.gz. I'm not sure how I update this. There is also a darcs respository for the Crypto package at http://www.haskell.org/crypto/src. Should this be added to http://hackage.haskell.org/darcsweb somehow? As package maintainer, are there some instructions I should be following? Thanks, Dominic. ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
Re: [Haskell] Re: Haddock Problem
On Sunday 15 May 2005 8:24 pm, Dominic Steinitz wrote: > >On Sun, 2005-05-15 at 18:51 +0100, Dominic Steinitz wrote: > >>/ > Dominic Steinitz writes: > > > >/>/ > > >/>/ I've downloaded > >/>/ > > http://www.haskell.org/ghc/docs/latest/html/libraries/base/base.haddock > > and I />/ still get the same errors. Is this incompatible with Haddock > > version 0.6? / > >Probably so because the current ghc library documentation is generated > >with Haddock 0.7 (which is the current cvs version of Haddock). We're > >hoping it will be released officially in the not to distant future > >(though if you like you can use the cvs version now as it's perfectly > >usable). > > > >The .haddock files are in a binary format and so are almost certainly > >not compatible between versions (like ghc .hi files). > > > >It would be nice if haddock gave some sort of error message in this case > >rather than ignoring the file. And downloading http://www.haskell.org/ghc/docs/6.2.1/html/libraries/base/base.haddock solves the problem. Dominic. ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
[Haskell] Re: Haddock Problem
On Sun, 2005-05-15 at 18:51 +0100, Dominic Steinitz wrote: / > Dominic Steinitz writes: />/ > />/ I've downloaded />/ http://www.haskell.org/ghc/docs/latest/html/libraries/base/base.haddock and I />/ still get the same errors. Is this incompatible with Haddock version 0.6? / Probably so because the current ghc library documentation is generated with Haddock 0.7 (which is the current cvs version of Haddock). We're hoping it will be released officially in the not to distant future (though if you like you can use the cvs version now as it's perfectly usable). The .haddock files are in a binary format and so are almost certainly not compatible between versions (like ghc .hi files). It would be nice if haddock gave some sort of error message in this case rather than ignoring the file. Duncan I think that's the answer. I just tried it on my windows machine and I got the following: C:\Documents and Settings\Dom\Codec>haddock -v -h -o docs -i http://haskell.org/ ghc/docs/latest/html/libraries/base,c:\ghc\ghc-6.4\doc\html\libraries\base\base. haddock haddock: Warning: The interface file "c:\\ghc\\ghc-6.4\\doc\\html\\libraries\\ba se\\base.haddock" could not be read. Maybe it's from a later version of Haddock? C:\Documents and Settings\Dom\Codec>haddock -v C:\Documents and Settings\Dom\Codec>haddock -V Haddock version 0.6, (c) Simon Marlow 2003 Why does the windows version give a warning when the linux one doesn't when they both appear to be the same version? And more importantly, can we have a version of haddock that is compatible with the latest release of ghc? I've tried building from source but run into problems. I'll post these separately if I have time. Yours, frustrated of Kingston. ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
[Haskell] Re: Haddock Problem
> Dominic Steinitz writes: > > > I've now used the -v option and it looks like haddock > > can't find the html files even though they are there :-( > > Anyone have any ideas? > > Maybe the interface description files are broken, > incomplete, or incompatible with your Haddock version? > > budweis:~/work/Codec$ mkdir docs > budweis:~/work/Codec$ url=http://haskell.org/ghc/docs/latest/html/libraries > budweis:~/work/Codec$ hdi=/usr/local/ghc-current/share/ghc-6.5/html/libraries > budweis:~/work/Codec$ haddock -v -h -o docs \ > -i ${url}/base,${hdi}/base/base.haddock Codec/Utils.hs > budweis:~/work/Codec$ > > No error here, and the external links worked too. > > Peter > I've downloaded http://www.haskell.org/ghc/docs/latest/html/libraries/base/base.haddock and I still get the same errors. Is this incompatible with Haddock version 0.6? [EMAIL PROTECTED] Codec]$ haddock -V Haddock version 0.6, (c) Simon Marlow 2002 I don't think haddock gets as far as searching url=http://haskell.org/ghc/docs/latest/html/libraries because if I put url=http://gaskell.org/ghc/docs/latest/html/libraries I still get the same errors. On the other hand if I put hdi=/usr/local/ghc-current/share/ghc-6.5/html/mibraries then I get a different error message: Fail: does not exist Action: openFileEx Reason: No such file or directory File: /usr/share/doc/ghc-6.4/mibraries/base/base.haddock So it looks like haddock is finding base.haddock but for some reason ignores what is in it :-( Dominic. ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
Re: [Haskell] Haddock Problem
On Saturday 14 May 2005 2:01 pm, Dominic Steinitz wrote: > > On Sat, 2005-05-14 at 13:05 +0100, Dominic Steinitz wrote: > > > Can someone point out what I am doing wrong? > > > > > > Thanks, Dominic. > > > > > > [dom at tility Codec]$ haddock Codec/Utils.hs > > --read-interface=http://www.haskell.org/ghc/docs/latest/html/base,/usr/shar >e/doc/ghc-6.4/libraries/base/base.haddock > > > > Warning: Codec.Utils: the following names could not be resolved: > > > Integral Word8 Int > > > > I don't believe that Haddock will download from a URL. > > > > Try downlading the base.haddock file first: > > $ haddock Codec/Utils.hs --read-interface=base.haddock > > > > In this case it would be better if Haddock gave you an error about there > > being no such (local) file as "http://www.haskell.org/g...";, rather than > > ignoring it. I'd call this a user interface bug. > > > > Duncan > > I still get the same problem: > > [EMAIL PROTECTED] Codec]$ haddock Codec/Utils.hs --read-interface=base.haddock > Warning: Codec.Utils: the following names could not be resolved: > Integral Word8 Int > > Dominic. I've now used the -v option and it looks like haddock can't find the html files even though they are there :-( Anyone have any ideas? [EMAIL PROTECTED] Codec]$ haddock Codec/Utils.hs --read-interface=/usr/share/doc/ghc-6.4/libraries/base,/usr/share/doc/ghc-6.4/libraries/base/base.haddock -v Warning: Codec.Utils: imported module not found: Prelude Warning: Codec.Utils: imported module not found: Data.Word Warning: Codec.Utils: imported module not found: Data.Bits Warning: Codec.Utils: the following names could not be resolved: Integral Word8 Int [EMAIL PROTECTED] Codec]$ ls /usr/share/doc/ghc-6.4/libraries/base/Prelude.html /usr/share/doc/ghc-6.4/libraries/base/Prelude.html [EMAIL PROTECTED] Codec]$ ls /usr/share/doc/ghc-6.4/libraries/base/Data.Word.html /usr/share/doc/ghc-6.4/libraries/base/Data.Word.html [EMAIL PROTECTED] Codec]$ ls /usr/share/doc/ghc-6.4/libraries/base/Data.Bits.html /usr/share/doc/ghc-6.4/libraries/base/Data.Bits.html [EMAIL PROTECTED] Codec]$ ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
[Haskell] Haddock Problem
> On Sat, 2005-05-14 at 13:05 +0100, Dominic Steinitz wrote: > > Can someone point out what I am doing wrong? > > > > Thanks, Dominic. > > > > [dom at tility Codec]$ haddock Codec/Utils.hs > > --read-interface=http://www.haskell.org/ghc/docs/latest/html/base,/usr/share/doc/ghc-6.4/libraries/base/base.haddock > > > > Warning: Codec.Utils: the following names could not be resolved: > > Integral Word8 Int > > I don't believe that Haddock will download from a URL. > > Try downlading the base.haddock file first: > $ haddock Codec/Utils.hs --read-interface=base.haddock > > In this case it would be better if Haddock gave you an error about there > being no such (local) file as "http://www.haskell.org/g...";, rather than > ignoring it. I'd call this a user interface bug. > > Duncan I still get the same problem: [EMAIL PROTECTED] Codec]$ haddock Codec/Utils.hs --read-interface=base.haddock Warning: Codec.Utils: the following names could not be resolved: Integral Word8 Int Dominic. ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
[Haskell] Haddock Problem
Can someone point out what I am doing wrong? Thanks, Dominic. [EMAIL PROTECTED] Codec]$ haddock Codec/Utils.hs --read-interface=http://www.haskell.org/ghc/docs/latest/html/base,/usr/share/doc/ghc-6.4/libraries/base/base.haddock Warning: Codec.Utils: the following names could not be resolved: Integral Word8 Int ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
[Haskell] Should inet_ntoa Be Pure?
Axel Simon wrote: > > > Does anyone know why these are in the IO monad? Aren't they > pure functions > > > > converting between dotted-decimal strings and a 32-bit network byte ordered > > > > binary value? > > > > I guess the answer is no for both: The first one can fail > That doesn't mean that it should be in the IO monad; using Maybe would suffice. Agreed. Perhaps I wasn't clear enough in my original question. There appears to be no intrinsic reason why they should be in the IO monad. > > > > Hence ntoa needs to be an IO action so that the value is read > > immediately before the next ntoa call is executed. > > That shouldn't be an issue so long as the buffer contents are > converted to a Haskell String before the function is called again > within the same thread. > > However, I wouldn't rely upon all implementations of inet_ntoa() being > thread-safe. > What you could do is to apply unsafePerformIO to > > [snip] > > Or you could just re-implement the functions in Haskell. > > Apart from the re-entrancy issues with inet_ntoa(), many > implementations of inet_addr() have misfeatures, e.g. allowing octets > to be expressed in octal or hex, or allowing numbers outside of the > 0-255 range (in which case, the top bits overflow into the next > octet). Perhaps better would be: inet_addr' :: (Octet,Octet,Octet,Octet) -> HostAddress inet_ntoa' :: HostAddress -> (Octet,Octet,Octet,Octet) I see Peter Simons has already written something: http://cryp.to/hsdns/docs/Network.IP.Address.html#v%3Aha2tpl Dominic. ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
[Haskell] Should inet_ntoa Be Pure?
Does anyone know why these are in the IO monad? Aren't they pure functions converting between dotted-decimal strings and a 32-bit network byte ordered binary value? Dominic. http://www.haskell.org/ghc/docs/latest/html/libraries/network/Network.Socket.html#v%3Ainet_addr http://www.haskell.org/ghc/docs/latest/html/libraries/network/Network.Socket.html#v%3Ainet_ntoa ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
[Haskell] Announce: Haskell Cryptographic Library 2.0.1
I would like to announce the release of a new version of the Haskell Cryptographic Library. It now uses darcs and cabal and provides the modules listed below. The most significant change is in the way ASN.1 is handled. This has been made generic enough to handle PKCS#8 private keys and X.509 certificates. For further information see http://www.haskell.org/crypto. Dominic. Codec.ASN1 Codec.ASN1.BER Codec.ASN1.PKCS8 Codec.ASN1.TLV Codec.ASN1.X509 Codec.Binary.Base64 Codec.Encryption.AES Codec.Encryption.Blowfish Codec.Encryption.DES Codec.Encryption.Modes Codec.Encryption.Padding Codec.Encryption.RSA Codec.Encryption.RSA.EMEOAEP Codec.Encryption.RSA.MGF Codec.Encryption.RSA.NumberTheory Codec.Utils Data.Digest.MD5 Data.Digest.SHA1 Data.LargeWord ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
[Haskell] Monad Unification
Can someone explain why this works? I would have expected an error when the typechecker tries to unify m with (StateT [Encoding] m). Dominic. *Codec.ASN1.BER> :t (tc absInteger (Primitive Universal 2 1 [0])) (tc absInteger (Primitive Universal 2 1 [0])) :: forall m e. (MonadError e m) => m Defaulted *Codec.ASN1.BER> :t (\x -> k [] []) (\x -> k [] []) :: forall m t e. (MonadError e m) => t -> StateT [Encoding] m [Maybe Defaulted] *Codec.ASN1.BER> :t (>>=) (>>=) :: forall m b a. (Monad m) => m a -> (a -> m b) -> m b *Codec.ASN1.BER> :t ((tc absInteger (Primitive Universal 2 1 [0])) >>= (\x -> k [] [])) ((tc absInteger (Primitive Universal 2 1 [0])) >>= (\x -> k [] [])) :: forall m e e1. (MonadError e1 (StateT [Encoding] m), MonadError e m) => StateT [Encoding] m [Maybe Defaulted] ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
[Haskell] Re: ANN: Codec 1.0
On Sunday 09 Jan 2005 12:43 pm, Dominic Steinitz wrote: > some utilities in it, see http://www.haskell.org/Codec/index.html. Of course that should have been http://www.haskell.org/Codec ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
[Haskell] ANN: Codec 1.0
Partly by way of experiment with darcs and Cabal and partly because I am restructuring the cryptographic library, I have set up a Codec package with some utilities in it, see http://www.haskell.org/Codec/index.html. Currently it contains only the module Codec.Utils. To get the package: darcs get http://www.haskell.org/Codec To build, you need the Cabal libraries installed: ghc -package Setup.lhs -o setup -package Cabal ./setup configure ./setup build ./setup install The latter needs to be done as root. base64 encoding / decoding should probably be included in Codec.Utils (I've seen copies of the same code all over the place) and if anyone has the time, they are very welcome to add it. I'd also welcome feedback on whether this is the right place in the hierarchy for such a package and modules. Finally, I don't want to tread on any toes and if anyone feels that this is their area then I would be happy to hand this over and submit it as a contribution. Dominic. PS I'd also like to thank the darcs and Cabal teams for their tools. ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
[Haskell] Re: Why Does This Typecheck?
Please ignore my last message. I assume the answer is that Char' a is replaced everywhere by Char before the typechecker gets a look in. Dominic. ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
[Haskell] Why Does This Typecheck?
Main> :t baz baz :: Foo a => Char' a -> a Main> :t v v :: Char' BW Main> :t test1 test1 :: Bool Main> :t (baz v) baz v :: Foo a => a Why doesn't the typechecker unify Char' BW with a and therefore the type of test1 = baz v becomes Char' BW resulting in a type error by not being able to unify Char' BW with Char' Bool? Dominic. class Foo a where foo :: Char -> a instance Foo Bool where foo 'F' = False foo 'T' = True data BW = Black | White deriving Show instance Foo BW where foo 'B' = Black foo 'W' = White type Char' a = Char baz :: Foo a => Char' a -> a baz x = foo x v :: Char' BW v = 'B' test1 :: Bool test1 = baz v ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
[Haskell] HaXml
I'd be grateful for some help on using HaXml. 1. I can parse a String into a Document but it's not clear how you operate on it as the combinators all operate on Content. The only function I could find that operated on a Document was "document" in Pretty. 2. I can construct a CFilter but it's not clear how you operate on it. How do I calculate the number of components of an Element? What I would like to do is accept "vname" (with 3 elements) and reject "iname" (with 4 elements). I'd also like to check that the characters in givenName, initial and familyName are in a given range (for example upper case or between ' ' and '~'). Thanks, Dominic. import Text.XML.HaXml import Text.XML.HaXml.Pretty xmlName = "John" ++ "P" ++ "Smith" ++ "" d = document $ xmlParse "tmp" xmlName gn = mkElemAttr "givenName" [] [literal "John"] i = mkElemAttr "initial" [] [literal "P"] fn = mkElemAttr "familyName" [] [literal "Smith"] validName = mkElemAttr "Name" [] [gn,i,fn] invalidName = mkElemAttr "Name" [] [gn,i,i,fn] vname = processXmlWith validName iname = processXmlWith invalidName *Main> d JohnPSmith *Main> *Main> vname JohnPSmith *Main> ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Re: [Haskell] GHC / Hugs Disagree on Constraints
[EMAIL PROTECTED] wrote: instance (Ord a, Bits a, Bounded a, Integral a, LargeWord a, Bits b, Bounded b, Integral b, LargeWord b) => Bounded (LargeKey a b) where minBound = 0 maxBound = fromIntegral $ (1 + fromIntegral (maxBound::b))* (1 + fromIntegral (maxBound::a)) - 1 Hugs rejects it with +N -98 with One fix is to bring type variables into the local scope, for example, instance (Ord a, Bits a, Bounded a, Integral a, LargeWord a, Bits b, Bounded b, Integral b, LargeWord b) => Bounded (LargeKey a b) where minBound = 0 maxBound :: (LargeKey a b) = fromIntegral $ (1 + fromIntegral (maxBound::b))* (1 + fromIntegral (maxBound::a)) - 1 You still need -98 flag for Hugs. Another solution is totally Haskell98: introduce two functions aoflk:: (LargeKey a b) -> a; aoflk = undefined boflk:: (LargeKey a b) -> b; boflk = undefined then maxBound can be implemented as maxBound = result where result = fromIntegral $ (1 + fromIntegral (maxBound `asTypeOf` (boflk result)))* (1 + fromIntegral (maxBound `asTypeOf` (aoflk result))) - 1 The apparent recursion in the above definition is superficial. The definition isn't actually recursive. We merely need the type of the 'result' rather than its value. Oleg, Did you get the first solution to work? When I tried it with hugs -98 I got ERROR "Codec/Encryption/LargeKey.hs":109 - Syntax error in input (unexpected `=') ghc with -fglasgow-exts accepts it. Dominic. ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Re: [Haskell] GHC / Hugs Disagree on Constraints
[EMAIL PROTECTED] wrote: instance (Ord a, Bits a, Bounded a, Integral a, LargeWord a, Bits b, Bounded b, Integral b, LargeWord b) => Bounded (LargeKey a b) where minBound = 0 maxBound = fromIntegral $ (1 + fromIntegral (maxBound::b))* (1 + fromIntegral (maxBound::a)) - 1 Hugs rejects it with +N -98 with One fix is to bring type variables into the local scope, for example, instance (Ord a, Bits a, Bounded a, Integral a, LargeWord a, Bits b, Bounded b, Integral b, LargeWord b) => Bounded (LargeKey a b) where minBound = 0 maxBound :: (LargeKey a b) = fromIntegral $ (1 + fromIntegral (maxBound::b))* (1 + fromIntegral (maxBound::a)) - 1 You still need -98 flag for Hugs. Another solution is totally Haskell98: introduce two functions aoflk:: (LargeKey a b) -> a; aoflk = undefined boflk:: (LargeKey a b) -> b; boflk = undefined then maxBound can be implemented as maxBound = result where result = fromIntegral $ (1 + fromIntegral (maxBound `asTypeOf` (boflk result)))* (1 + fromIntegral (maxBound `asTypeOf` (aoflk result))) - 1 The apparent recursion in the above definition is superficial. The definition isn't actually recursive. We merely need the type of the 'result' rather than its value. Oleg, Thanks for this. It seems strange that the scope of the universal quantifier is the function definition (in your first solution) rather than the whole of the instance. Is asTypeOf really Haskell 98? Dominic. ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Re: [Haskell] GHC / Hugs Disagree on Constraints
This seems counter-intuitive. If I declare a type variable in the context of an instance, I'd expect to be able to use it in the body. Is there any reason for Haskell 98 doesn't allow you to do this? More importantly is there a way round this? I have a fairly simple requirement: a new type is created out of two types which are elements of Bounded and I'd like to declare the new type as Bounded based on the values of maxBound for each of the constituent types. Doing what the compiler suggests of declaring maxBound::(Bounded b => b) isn't going to help. Interestingly, Bits has a function bitSize :: Bits a => a -> Int rather than a value so this issue doesn't arise (although you have use irrefutable pattern matching). Dominic. Simon Peyton-Jones wrote: Hugs does support scoped type variables bound by *type sigs in patterns*, but not by class or instance declarations. So when you say (maxBound :: b) you are really saying (maxBound :: forall b. b) and it's that universal quantification that has no Bounded b context. That's why you need -fglasgow-exts to compile it with GHC, to get the scoped type variables. I've gotten so used to scoped type variables that I couldn't see why it wasn't Haskell 98, until I tried to compile without -fglasgow-exts. Then GHC says Key.hs:99: Could not deduce (Bounded b) from the context () arising from use of `maxBound' at Key.hs:99 Probable fix: Add (Bounded b) to the expected type of an expression When checking the type signature of the expression: maxBound :: forall b. b which does at least point to the error. Simon | -Original Message- | From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Dominic | Steinitz | Sent: 02 October 2004 12:04 | To: [EMAIL PROTECTED] | Subject: [Haskell] GHC / Hugs Disagree on Constraints | | GHC accepts this with -fglasgow-exts | | instance (Ord a, Bits a, Bounded a, Integral a, LargeWord a, | Bits b, Bounded b, Integral b, LargeWord b) => | Bounded (LargeKey a b) where |minBound = 0 |maxBound = | fromIntegral $ | (1 + fromIntegral (maxBound::b))* | (1 + fromIntegral (maxBound::a)) - 1 | | Hugs rejects it with +N -98 with | | ERROR "Codec/Encryption/LargeKey.hs":94 - Cannot justify constraints in | type annotation | *** Expression: maxBound | *** Type : b | *** Given context : () | *** Constraints : Bounded b | | Since I've already declared b to be Bounded, it looks like a bug in Hugs. | | Dominic. | | === | | | module Codec.Encryption.LargeKey | (Word128,Word192,Word256,LargeWord) where | | import Data.Word | import Data.Bits | import Numeric | import Char | | -- Keys have certain capabilities. | | class LargeWord a where | largeWordToInteger :: a -> Integer | integerToLargeWord :: Integer -> a | largeWordPlus :: a -> a -> a | largeWordAnd :: a -> a -> a | largeWordOr :: a -> a -> a | largeWordShift :: a -> Int -> a | largeWordXor :: a -> a -> a | largeBitSize :: a -> Int | | -- Word64 is a key in the obvious way. | | instance LargeWord Word64 where | largeWordToInteger = toInteger | integerToLargeWord = fromInteger | largeWordPlus = (+) | largeWordAnd = (.&.) | largeWordOr = (.|.) | largeWordShift = shift | largeWordXor = xor | largeBitSize = bitSize | | -- Define larger keys from smaller ones. | | data LargeKey a b = LargeKey a b | deriving (Eq, Ord) | | instance (Ord a, Bits a, LargeWord a, Bits b, LargeWord b) => | LargeWord (LargeKey a b) where |largeWordToInteger (LargeKey lo hi) = | largeWordToInteger lo + (2^(bitSize lo)) * largeWordToInteger hi |integerToLargeWord x = | let (h,l) = x `quotRem` (2^(bitSize lo)) | (lo,hi) = (integerToLargeWord l, integerToLargeWord h) in | LargeKey lo hi |largeWordPlus (LargeKey alo ahi) (LargeKey blo bhi) = | LargeKey lo' hi' where | lo' = alo + blo | hi' = ahi + bhi + if lo' < alo then 1 else 0 |largeWordAnd (LargeKey alo ahi) (LargeKey blo bhi) = | LargeKey lo' hi' where | lo' = alo .&. blo | hi' = ahi .&. bhi |largeWordOr (LargeKey alo ahi) (LargeKey blo bhi) = | LargeKey lo' hi' where | lo' = alo .|. blo | hi' = ahi .|. bhi |largeWordOr (LargeKey alo ahi) (LargeKey blo bhi) = | LargeKey lo' hi' where | lo' = alo .|. blo | hi' = ahi .|. bhi |largeWordXor (LargeKey alo ahi) (LargeKey blo bhi) = | Larg
[Haskell] QuickCheck
Can someone remind me how to change the number of tests that QuickCheck performs? I'm sure I knew how to do this but I can't find it in the documentation and a web search revealed no examples. Thanks, Dominic. ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
[Haskell] GHC / Hugs Disagree on Constraints
GHC accepts this with -fglasgow-exts instance (Ord a, Bits a, Bounded a, Integral a, LargeWord a, Bits b, Bounded b, Integral b, LargeWord b) => Bounded (LargeKey a b) where minBound = 0 maxBound = fromIntegral $ (1 + fromIntegral (maxBound::b))* (1 + fromIntegral (maxBound::a)) - 1 Hugs rejects it with +N -98 with ERROR "Codec/Encryption/LargeKey.hs":94 - Cannot justify constraints in type annotation *** Expression: maxBound *** Type : b *** Given context : () *** Constraints : Bounded b Since I've already declared b to be Bounded, it looks like a bug in Hugs. Dominic. === module Codec.Encryption.LargeKey (Word128,Word192,Word256,LargeWord) where import Data.Word import Data.Bits import Numeric import Char -- Keys have certain capabilities. class LargeWord a where largeWordToInteger :: a -> Integer integerToLargeWord :: Integer -> a largeWordPlus :: a -> a -> a largeWordAnd :: a -> a -> a largeWordOr :: a -> a -> a largeWordShift :: a -> Int -> a largeWordXor :: a -> a -> a largeBitSize :: a -> Int -- Word64 is a key in the obvious way. instance LargeWord Word64 where largeWordToInteger = toInteger integerToLargeWord = fromInteger largeWordPlus = (+) largeWordAnd = (.&.) largeWordOr = (.|.) largeWordShift = shift largeWordXor = xor largeBitSize = bitSize -- Define larger keys from smaller ones. data LargeKey a b = LargeKey a b deriving (Eq, Ord) instance (Ord a, Bits a, LargeWord a, Bits b, LargeWord b) => LargeWord (LargeKey a b) where largeWordToInteger (LargeKey lo hi) = largeWordToInteger lo + (2^(bitSize lo)) * largeWordToInteger hi integerToLargeWord x = let (h,l) = x `quotRem` (2^(bitSize lo)) (lo,hi) = (integerToLargeWord l, integerToLargeWord h) in LargeKey lo hi largeWordPlus (LargeKey alo ahi) (LargeKey blo bhi) = LargeKey lo' hi' where lo' = alo + blo hi' = ahi + bhi + if lo' < alo then 1 else 0 largeWordAnd (LargeKey alo ahi) (LargeKey blo bhi) = LargeKey lo' hi' where lo' = alo .&. blo hi' = ahi .&. bhi largeWordOr (LargeKey alo ahi) (LargeKey blo bhi) = LargeKey lo' hi' where lo' = alo .|. blo hi' = ahi .|. bhi largeWordOr (LargeKey alo ahi) (LargeKey blo bhi) = LargeKey lo' hi' where lo' = alo .|. blo hi' = ahi .|. bhi largeWordXor (LargeKey alo ahi) (LargeKey blo bhi) = LargeKey lo' hi' where lo' = alo `xor` blo hi' = ahi `xor` bhi largeWordShift w 0 = w largeWordShift (LargeKey lo hi) x = if bitSize lo < bitSize hi then LargeKey (shift lo x) (shift hi x .|. (shift (conv lo) (x - (bitSize lo else LargeKey (shift lo x) (shift hi x .|. (conv $ shift lo (x - (bitSize lo where conv = integerToLargeWord . largeWordToInteger largeBitSize ~(LargeKey lo hi) = largeBitSize lo + largeBitSize hi instance (Ord a, Bits a, LargeWord a, Bits b, LargeWord b) => Show (LargeKey a b) where showsPrec p = showInt . largeWordToInteger instance (Ord a, Bits a, LargeWord a, Bits b, LargeWord b) => Num (LargeKey a b) where (+) = largeWordPlus fromInteger = integerToLargeWord -- Larger keys are instances of Bits provided their constituents are keys. instance (Ord a, Bits a, LargeWord a, Bits b, LargeWord b) => Bits (LargeKey a b) where (.&.) = largeWordAnd (.|.) = largeWordOr xor = largeWordXor shift = largeWordShift bitSize = largeBitSize instance (Ord a, Bits a, Bounded a, Integral a, LargeWord a, Bits b, Bounded b, Integral b, LargeWord b) => Bounded (LargeKey a b) where minBound = 0 maxBound = fromIntegral $ (1 + fromIntegral (maxBound::b))* (1 + fromIntegral (maxBound::a)) - 1 instance (Ord a, Bits a, LargeWord a, Ord b, Bits b, LargeWord b) => Integral (LargeKey a b) where toInteger = largeWordToInteger instance (Ord a, Bits a, LargeWord a, Ord b, Bits b, LargeWord b) => Real (LargeKey a b) instance Enum (LargeKey a b) type Word96 = LargeKey Word32 Word64 type Word128 = LargeKey Word64 Word64 type Word160 = LargeKey Word32 Word128 type Word192 = LargeKey Word64 Word128 type Word224 = LargeKey Word32 Word192 type Word256 = LargeKey Word64 Word192 ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
[Haskell] ANNOUNCE: Cryptographic Library for Haskell 1.2.1
I would like to annouce a new release of the Haskell Cryptographic Library (1.2.1). See http://www.haskell.org/crypto/ReadMe.html for more details. This library collects together existing Haskell cryptographic functions. This release contains AES but no longer works with Hugs (as Word64 isn't properly supported). It now includes: DES, Blowfish, AES, Cipher Block Chaining (CBC) mode, PKCS#5 and nulls padding, SHA-1, MD5, RSA, OAEP, ASN.1 and PKCS#8. Dominic Steinitz ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
ANNOUNCE: Cryptographic Library for Haskell
I would like to annouce a new release of the Haskell Cryptographic Library (1.1.2). See http://www.haskell.org/crypto/ReadMe.html for more details. This library collects together existing Haskell cryptographic functions. This release contains MD5 and now works with Hugs (November 2003 version). Dominic Steinitz ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
ANNOUNCE: Cryptographic Library for Haskell
I would like to annouce a new release of the Haskell Cryptographic Library (1.0.1). See http://www.haskell.org/crypto/ReadMe.html for more details. This library collects together existing Haskell cryptographic functions and augments them so that they: · Have common type signatures. · Can be used with the standard mode and padding algorithms (in the case of block mode ciphers). This release includes much improved support for public / private key pairs and contains: · DES · Blowfish · Cipher Block Chaining (CBC) mode · PKCS5 and nulls padding · SHA-1 · RSA · OAEP · ASN.1 · PKCS#8 Dominic Steinitz ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Wrapping Code
Does anyone have any views on how to "wrap" code that has been designed to take input from handles but you now want to take input from strings? I want to make minimal changes to a module that already works and to code that uses that module. Here's my thinking below. I'd be interested in other approaches and pros and cons. Dominic. I thought I would only ever have to parse ASN.1 from a socket or a file. So I have ended up with a lot of functions like this: getTagOctets :: Handle -> IO OctetStream getTagOctets h = do x <- hGetChar h let y = fromIntegral (ord x) in if not (testBit y msb) then return [y] else do ys <- getTagOctets h return ((clearBit y msb):ys) It turns out I need to be able to parse ASN.1 from a string. So my first thought was: tagOctets :: String -> (String,OctetStream) tagOctets s = let y = fromIntegral $ ord $ head s in if not $ testBit y $ msb then (tail s,[y]) else let (s',ys) = tagOctets $ tail s in (s',((clearBit y msb):ys)) Now this is very similar and the type signature suggests state monads. So my second thought was this: tagOctets' :: State String OctetStream tagOctets'= do (x:xs) <- get put xs let y = fromIntegral (ord x) in if not (testBit y msb) then return [y] else do ys <- tagOctets' return ((clearBit y msb):ys) Even nearer but still not good enough. So I went for type class: class Monad m => Foo m where get' :: Handle -> m Char instance Foo IO where get' = hGetChar instance Foo (State String) where get' = \_ -> do (x:xs) <- get; put xs; return x And now I can write: tagOctets'' h = do x <- get' h let y = fromIntegral (ord x) in if not (testBit y msb) then return [y] else do ys <- tagOctets'' h return ((clearBit y msb):ys) I can now use this either with a handle or with a string: test'' :: (OctetStream,String) test'' = runState (tagOctets'' stdin) (map (chr . fromIntegral) (encode $ toASN NoTag NULL)) test = do ofh <- openFile "tst.txt" WriteMode hPutStr ofh (map (chr . fromIntegral) (encode (toASN NoTag NULL))) hClose ofh ifh <- openFile "tst.txt" ReadMode (ts::OctetStream) <- tagOctets'' ifh putStrLn $ show ts ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
ANNOUNCE: Cryptographic Library for Haskell
I would like to annouce the second release of the Haskell Cryptographic Library (0.3.3). See http://www.haskell.org/crypto/ReadMe.html for more details. This library collects together existing Haskell cryptographic functions and augments them so that they: ·Have common type signatures. ·Can be used with the standard mode and padding algorithms (in the case of block mode ciphers). This release contains: ·DES ·Blowfish ·Cipher Block Chaining (CBC) mode ·PKCS5 and nulls padding ·SHA-1 ·RSA ·OAEP Dominic Steinitz ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Re: Polymorphic Recursion / Rank-2 Confusion
Ross, Thanks very much. I was going to use coal :: Vector a -> [a] coal = coal_ (\() -> []) (\x -> [x]) but I prefer your definitions. Dominic. - Original Message - From: "Ross Paterson" <[EMAIL PROTECTED]> To: "Dominic Steinitz" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Saturday, September 20, 2003 5:19 PM Subject: Re: Polymorphic Recursion / Rank-2 Confusion > On Sat, Sep 20, 2003 at 12:01:32PM +0100, Dominic Steinitz wrote: > > Can anyone tell me why the following doesn't work (and what I have to do to > > fix it)? I thought by specifying the type of coalw as rank-2 would allow it > > to be used both at a and (a,b). > > Change the signature to > > coal_ :: (v -> [a]) -> (w -> [a]) -> Vector_ v w -> [a] > > Then you can define > > type Vector = Vector_ () > > coal :: Vector a -> [a] > coal = coal_ (const []) (:[]) ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Re: Polymorphic Recursion / Rank-2 Confusion
Brandon, I get the error below without the type signature. My confusion was thinking I needed rank-2 types. In fact I only need polymorphic recursion. Ross Paterson's suggestion fixes the problem. I stole Even and Odd from Chris Okasaki's paper on square matrices. They relate to fast exponentation algorithm. There's something to be said for Zeror and One; as you say they give the structure in binary. My motivation in using this type was to see if, for example, I could restrict addition of a vector to another vector to vectors of the same length. This would be helpful in the crypto library where I end up having to either define new length Words all the time or using lists and losing the capability of ensuring I am manipulating lists of the same length. Dominic. hugs Type checking ERROR "Test1.hs":23 - Type error in function binding *** Term : coal_ *** Type : (a -> b) -> (c -> [d]) -> Vector_ a e -> b *** Does not match : (a -> b) -> ((c,c) -> [d]) -> Vector_ a (e,e) -> b *** Because: unification would give infinite type ghci Test1.hs:25: Occurs check: cannot construct the infinite type: t = (t, t1) Expected type: (t, t1) Inferred type: t In the first argument of `coalw', namely `w1' In the first argument of `(++)', namely `(coalw w1)' Failed, modules loaded: none. - Original Message ----- From: "Brandon Michael Moore" <[EMAIL PROTECTED]> To: "Dominic Steinitz" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Saturday, September 20, 2003 11:19 PM Subject: Re: Polymorphic Recursion / Rank-2 Confusion > Sorry about the empty message. Send /= Cancel > > > Can anyone tell me why the following doesn't work (and what I have to do to > > fix it)? I thought by specifying the type of coalw as rank-2 would allow it > > to be used both at a and (a,b). > > Frank explained why the type you gave wouldn't work. I would like to add > that your function would type check without the type signature. This > suggests something here is actively confusing. Do you have any idea what > caused this problem? > > I hope to help teach Haskell to first year students, so I'm trying to > figure out what parts of the language are hard to get, and how to usefull > explain things. Anything in pure H98 that trips up an experienced > programmer is worth some attention. > > Completely unrelated, I think Zero and One would be better names than Even > and Odd because then the string of constructors writes the size of the > vector in binary, LSB first. I can't see any mnenomic value to Even and > Odd. How do you interpret Even and Odd? > > Thanks > > Brandon > ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Polymorphic Recursion / Rank-2 Confusion
Can anyone tell me why the following doesn't work (and what I have to do to fix it)? I thought by specifying the type of coalw as rank-2 would allow it to be used both at a and (a,b). Dominic. Reading file "Test.hs":tten Type checking ERROR "Test.hs":18 - Inferred type is not general enough *** Expression: \(w1,w2) -> coalw w1 ++ coalw w2 *** Expected type : a -> [b] *** Inferred type : (a,b) -> [c] data Vector_ v w = Zero v | Even (Vector_ v (w,w)) | Odd (Vector_ (v,w) (w,w)) deriving Show vzero = Zero () vone = Odd (Zero ((),'a')) vtwo = Even (Odd (Zero ((),('a','b' vthree = Odd (Odd (Zero (((),'a'),('b','c' vfour = Even (Even (Odd (Zero ((),(('a','b'),('c','d')) coal_ :: (forall a b. a -> [b]) -> (forall c d. c -> [d]) -> Vector_ v w -> [w] coal_ coalv coalw (Zero v) = coalv v coal_ coalv coalw (Even v) = coal_ coalv (\(w1,w2) -> (coalw w1) ++ (coalw w2)) v coal_ coalv coalw (Odd v) = coal_ (\(v,w) -> (coalv v) ++ (coalw w)) (\(w1,w2) -> (coalw w1) ++ (coalw w2)) v ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Re: Haddock Problems
I realise I have to give an explicit type for the functions but this still doesn't get rid of the warnings. Dominic. - Original Message - From: "Dominic Steinitz" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, August 18, 2003 6:06 PM Subject: Haddock Problems > Can someone tell me why I get the following warnings and also why the > generated documentation is blank? > > Many thanks, Dominic. > > [EMAIL PROTECTED] crypto]$ haddock Codec/Encryption/DES.hs > Warning: module not found: Word > Warning: module not found: Codec.Encryption.DESAux > Warning: module not found: Prelude > Warning: Codec.Encryption.DES: the following names could not be resolved: > encrypt decrypt > > Here's the offending module. > > -- -- > - > -- | > -- Module : Codec.Encryption.DES > -- Copyright : (c) Dominic Steinitz 2003 > -- License : BSD-style (see the file libraries/base/LICENSE) > -- > -- Maintainer : [EMAIL PROTECTED] > -- Stability : experimental > -- Portability : portable > -- > -- Takes the DES module supplied by Ian Lynagh and wraps it so it can > -- used with the standard modes. > -- <http://web.comlab.ox.ac.uk/oucl/work/ian.lynagh/>. > -- > -- -- > - > > module Codec.Encryption.DES ( >-- * Function types >encrypt, decrypt > ) where > > import Codec.Encryption.DESAux > import Word > > -- | Basic DES encryption which takes a key and a block of plaintext > -- and returns the encrypted block of ciphertext according to the standard. > > encrypt = flip des_enc > > -- | Basic DES decryption which takes a key and a block of ciphertext and > -- returns the decrypted block of plaintext according to the standard. > > decrypt = flip des_dec > > ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Haddock Problems
Can someone tell me why I get the following warnings and also why the generated documentation is blank? Many thanks, Dominic. [EMAIL PROTECTED] crypto]$ haddock Codec/Encryption/DES.hs Warning: module not found: Word Warning: module not found: Codec.Encryption.DESAux Warning: module not found: Prelude Warning: Codec.Encryption.DES: the following names could not be resolved: encrypt decrypt Here's the offending module. - -- | -- Module : Codec.Encryption.DES -- Copyright : (c) Dominic Steinitz 2003 -- License : BSD-style (see the file libraries/base/LICENSE) -- -- Maintainer : [EMAIL PROTECTED] -- Stability : experimental -- Portability : portable -- -- Takes the DES module supplied by Ian Lynagh and wraps it so it can -- used with the standard modes. -- <http://web.comlab.ox.ac.uk/oucl/work/ian.lynagh/>. -- - module Codec.Encryption.DES ( -- * Function types encrypt, decrypt ) where import Codec.Encryption.DESAux import Word -- | Basic DES encryption which takes a key and a block of plaintext -- and returns the encrypted block of ciphertext according to the standard. encrypt = flip des_enc -- | Basic DES decryption which takes a key and a block of ciphertext and -- returns the decrypted block of plaintext according to the standard. decrypt = flip des_dec ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Laziness
Could someone explain to me why this doesn't work test l = hs where hs = map (\x -> [x]) [0..abs(l `div` hLen)] hLen = length $ head hs whereas this does test l = hs where hs = map (\x -> [x]) (0:[1..abs(l `div` hLen)]) hLen = length $ head hs I would have thought laziness would allow the compiler to know that hs would contain at least one element and therefore calculate hLen. Dominic.
ANNOUNCE: Cryptographic Library for Haskell
I would like to annouce the first release of the Haskell Cryptographic Library (0.2.0). See http://www.haskell.org/crypto/ReadMe.html for more details. This library collects together existing Haskell cryptographic functions and augments them so that they: ·Have common type signatures. ·Can be used with the standard mode and padding algorithms (in the case of block mode ciphers). This very initial release contains: ·DES ·Blowfish ·Cipher Block Chaining (CBC) mode ·PKCS#5 and nulls padding Dominic Steinitz ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Re: Bits Problem
Is this a recent change? I've downloaded Ian Lynagh's DES module and it doesn't compile because of this. I assume it used to. I don't see the rationale for this. I can see Bool can be an instance of Bit but why does it need to be an instance of Num? Dominic Steinitz - Original Message - From: "Glynn Clements" <[EMAIL PROTECTED]> To: "Dominic Steinitz" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Sunday, April 06, 2003 2:35 PM Subject: Re: Bits Problem > > Dominic Steinitz wrote: > > > Can anyone explain this? Hugs doesn't complain. > > > > Prelude> :set --version > > The Glorious Glasgow Haskell Compilation System, version 5.04.1 > > > > test.hs:5: > > No instance for (Num Bool) > > arising from the instance declaration at test.hs:5 > > In the instance declaration for `Bits Bool' > > > > module Main(main) where > > > > import Bits > > > > instance Bits Bool where > >complement False = True > >complement True = False > > GHC's definition of Bits requires that instances of Bits are also > instances of Num. > > This constraint is required for the default implementations of bit and > testBit: > > bit i = 1 `shift` i > x `testBit` i = (x .&. bit i) /= 0 > > -- > Glynn Clements <[EMAIL PROTECTED]> ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Bits Problem
Can anyone explain this? Hugs doesn't complain. Prelude> :set --version The Glorious Glasgow Haskell Compilation System, version 5.04.1 test.hs:5: No instance for (Num Bool) arising from the instance declaration at test.hs:5 In the instance declaration for `Bits Bool' module Main(main) where import Bits instance Bits Bool where complement False = True complement True = False Dominic Steinitz ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Database Mailing List
There seems to be a small group of Haskell users who are interested in building and using interfaces to databases. Would it be possible to set up a mailing list for those interested? I'd be happy to administer it if required (although someone would have to show / tell me what needs doing). Dominic Steinitz ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Re: Web Application Development
I have summarised the responses I have received and cross posted this to Haskell-Cafe in case anyone wishes to carry on the conversation. > In a moment of weakness, I offered to help a friend develop a website. It's > a simple database application which carries out very little calculation and > then displays the results via HTML. > > The original code was in PHP and MySQL so rather than re-invent the wheel I > > So my question is: what should I do to re-write this in Haskell? > 1. SQL 1.a. MySQL 1.a.i Use MySQL-HS which requires the use of H/Direct. Available via www.haskell.org. 1.a.ii Use http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/hbase/Source/Foreign/. This is pre-alpha. 1.b Oracle 1.b.i Use C2HS and libsqlora8 (a simple C library for interfacing to Oracle http://www.poitschke.de/libsqlora8/). There is no publicly available code. 1.c Database Independent 1.c.i Use the DBI model as found in Perl and the libpq binding as listed on Haskell.org (http://www.astercity.net/~khaliff/haskell/dbi/dbi.tgz). This currently has a PostgreSQL binding but is not listed on SourceForge. 1.c.ii Use the code at http://sourceforge.net/projects/htoolkit/. This is planning (that is pre pre-alpha). There appear to be bindings for MySQL, ODBC and PostgreSQL. 2. HTML I have tried out Wash/CGI and this seems satisfactory for my purposes at the moment. Many thanks to everyone who replied, Dominic. ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Web Application Development
In a moment of weakness, I offered to help a friend develop a website. It's a simple database application which carries out very little calculation and then displays the results via HTML. The original code was in PHP and MySQL so rather than re-invent the wheel I have been modifying it. However, I am spending a lot of time tracking down errors at run time which a type system would have caught. It's particularly easy to write PHP code which generates SQL calls which look correct (by looking in the MySQL log) but actually put garbage in the database. So my question is: what should I do to re-write this in Haskell? >From the discussion on this mailing list in June and reading through the libraries section of haskell.org, I think there are the following options: HTML 1. Use Wash/CGI but maybe somehow move to mod_haskell if the webserver performance isn't adquate. SQL 2. Use MySQL-HS which requires HaskellDirect or use HSQL. I'd be very grateful for any advice and any progress as a result of the discussion in June. Dominic Steinitz ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
A Bug in Time?
Hugs has a bug in Time. I would expect toUTCTime and toCalendarTime to be inverses of toClockTime (modulo the IO monad). toCalendarTime :: ClockTime-> IO CalendarTime toUTCTime:: ClockTime-> CalendarTime toClockTime :: CalendarTime -> ClockTime module Main(main) where import Time main = putStrLn "Hello" test :: Integer -> IO () test x = (toCalendarTime . toClockTime . f $ x) >>= putStrLn . show f x = CalendarTime{ctYear=2002, ctMonth=May, ctDay=30, ctHour=10, ctMin=27, ctSec=11, ctPicosec=x, ctWDay=Thursday, ctYDay=149, ctTZName="BST", ctTZ=3600, ctIsDST=True} GHC gives: Main> test 1 CalendarTime{ctYear=2002,ctMonth=May,ctDay=30,ctHour=10,ctMin=27,ctSec=11,ct Picose c=1,ctWDay=Thursday,ctYDay=149,ctTZName="BST",ctTZ=3600,ctIsDST=True} Main> test 2 CalendarTime{ctYear=2002,ctMonth=May,ctDay=30,ctHour=10,ctMin=27,ctSec=11,ct Picose c=2,ctWDay=Thursday,ctYDay=149,ctTZName="BST",ctTZ=3600,ctIsDST=True} Hugs gives Main> test 1 CalendarTime{ctYear=2002,ctMonth=May,ctDay=30,ctHour=10,ctMin=27,ctSec=11,ct Picose c=0,ctWDay=Thursday,ctYDay=149,ctTZName="BST",ctTZ=3600,ctIsDST=True} Main> test 2 CalendarTime{ctYear=2002,ctMonth=May,ctDay=30,ctHour=10,ctMin=27,ctSec=11,ct Picose c=0,ctWDay=Thursday,ctYDay=149,ctTZName="BST",ctTZ=3600,ctIsDST=True} Dominic Steinitz ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Dependent Types
I've managed to crack something that always annoyed me when I used to do network programming. However, Hugs and GHC behave differently. I'd be interested in views on this approach and also which implementation behaves correctly. Suppose I want to send an ICMP packet. The first byte is the type and the second byte is the code. Furthermore, the code depends on the type. Now you know at compile time that you can't use codes for one type with a different type. However, in Pascal (which is what I used to use) you only seemed to be able to carry out run time checks. Here's a way I came up with for checking at compile time in Haskell. module Main(main) where -- ICMP has many more values for the type byte but we only need two for the example. data Redirect = Redirect data TimeExceeded = TimeExceeded data ICMPType = MkRedirect Redirect | MkTimeExceeded TimeExceeded -- 5 and 11 are the values that get sent. instance Enum ICMPType where fromEnum (MkRedirect Redirect) = 5 fromEnum (MkTimeExceeded TimeExceeded) = 11 data ICMPCodeRedirect = RedirNet | RedirHost | RedirNetToS | RedirHostToS deriving Enum data ICMPCodeTimeExceeded = ExcTTL | ExcFragTime deriving Enum class Encode a b | a -> b where encode :: a -> b instance Encode ICMPType String where encode = show . fromEnum instance Encode Redirect (ICMPCodeRedirect -> String) where encode a y = encode (MkRedirect a) ++ (show (fromEnum y)) instance Encode TimeExceeded (ICMPCodeTimeExceeded -> String) where encode b z = encode (MkTimeExceeded b) ++ (show (fromEnum z)) Now I can say things like encode Redirect Redir and get the value "50". But if I say encode Redirect ExcTTL then I get a type error. GHC gives Couldn't match `ICMPCodeRedirect' against `ICMPCodeTimeExceeded' Expected type: ICMPCodeRedirect -> String Inferred type: ICMPCodeTimeExceeded -> t and Hugs gives ERROR: Constraints are not consistent with functional dependency *** Constraint : Encode Redirect (ICMPCodeTimeExceeded -> [Char]) *** And constraint : Encode Redirect (ICMPCodeRedirect -> String) *** For class: Encode a b *** Break dependency : a -> b This is just what you want as it picks up errors at compile time not at run time. However, if I now comment out the functional dependency class Encode a b {- | a -> b -} where encode :: a -> b and include the expressions x = encode TimeExceeded ExcTTL main = putStrLn x then Hugs complains ERROR "codes.hs" (line 37): Unresolved top-level overloading *** Binding : x *** Outstanding context : Encode TimeExceeded (ICMPCodeTimeExceeded -> b) whereas GHC doesn't complain. Which is right? Dominic. ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Re: getProtocolByName
Finn, Thanks for this. I thought since I wasn't actually using the socket module I wouldn't have to use withSocketsDo.The documentation for BSD is a little spartan and a few explanatory words about how errors get handled wouldn't go amiss.Anyway, it now works so I'll move on to the next bit.Dominic.Finn Wilcox <[EMAIL PROTECTED]>03/03/2002 09:30Please respond to finnw To: [EMAIL PROTECTED] cc: [EMAIL PROTECTED] bcc: Subject: Re: getProtocolByName On Sun, 3 Mar 2002 [EMAIL PROTECTED] wrote:> Here's my test program. TCP is a valid protocol. But I get the following> when I run it. I'm running under W98 by the way. I have two questions:>> 1) Why do I get an error?You want:> module Main(main) where>> import BSD import Socket (withSocketsDo)>> main = withSocketsDo $> do protocolEntry <- getProtocolByName "TCP" ...>See http://www.haskell.org/ghc/docs/latest/set/socket.html#AEN14601> 2) Even if this is a valid error why doesn't the function tell me so that I> can handle it rather than terminating?>It is a valid error. It is raising an exception which you can catch if youwant. e.g.import IO (catch, isDoesNotExistError)... catch (do protocolEntry <- getProtocolByName "TCP" putStrLn ("Protocol name:" ++ (protoName protocolEntry))) (\e -> if isDoesNotExistError e then putStrLn "Error" else ioError e)Finn.___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell