Re: [GHC] #974: Add unzipEithers, lefts, rights to Data.Either
#974: Add unzipEithers, lefts, rights to Data.Either +--- Reporter: guest | Owner: Type: proposal| Status: new Priority: normal | Milestone: Component: libraries/base |Version: 6.6 Severity: normal | Resolution: Keywords: | Difficulty: Easy (1 hr) Testcase: | Architecture: Unknown Os: Unknown | +--- Comment (by guest): So far the least objectionable name for [Eithers a b] - ([a],[b]) is separateEithers -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/974 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
haddock's image markup doesn't work for me
Hi, I tried to put images into my comments as follows: -- | images/stock-icons/stock_about_24.png but it produces TD CLASS=doc A HREF=images/stock-icons/stock_about_24.png lt;images/stock-icons/stock_about_24.pnggt;/A i.e. there shouldn't be any around the url of the image. Am I missing something here? Axel. ___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
[GHC] #1041: Bang patterns in do notation and lambdas
#1041: Bang patterns in do notation and lambdas --+- Reporter: dons | Owner: Type: bug| Status: new Priority: normal | Milestone: Component: Compiler (Parser) | Version: 6.6 Severity: normal |Keywords: bang patterns Difficulty: Easy (1 hr)|Testcase: Architecture: Unknown| Os: Unknown --+- Bang patterns in do-notation and lambdas need parentheses around them to parse. This isn't the case for ~ patterns, or bang patterns in let bindings. Seems like a wibble. {{{ {-# OPTIONS -fbang-patterns #-} -- doesn't work:A.hs:5:8: Empty 'do' construct main1 = do !c - return () return () -- doesn't work:A.hs:12:24: parse error on input `!' main2 = return () = \ !c - return () -- does main3 = do (!c) - return () return () -- does main4 = return () = \ (!c) - return () -- does main5 = let !x = 1 in return () -- does main6 = do ~c - return () return () -- does main7 = return () = \ ~c - return () }}} -- dons -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/1041 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: GHCi and Windows 98
steven-tinsley: Good day to you. I installed GHC 6.6 on a Windows 98 SE system recently having decided to try to learn this language. Unfortunetley, GHCi causes an This program has performed an illegal operation error at startup and is shut down. This happens just after Loading base packagelinkingdone is shown. Windows produces this error message: [code] GHC caused an invalid page fault in module GHC.EXE at 0167:00c82e26. Registers: EAX=0078 CS=0167 EIP=00c82e26 EFLGS=00010297 EBX=00d963c8 SS=016f ESP=010cdd50 EBP=01c43f3c ECX=0007 DS=016f ESI=01be57e8 FS=1617 EDX= ES=016f EDI=01be57f4 GS= Bytes at CS:EIP: 66 83 3c 50 00 74 19 ff 45 00 83 ef 08 b8 18 2e Stack dump: 0078 0200 0001 00d0fe5c 0002 00cddbb6 0001 00c34b9c 00408442 [/code] Just thought you'd like to know. Thanks. Steven. Thanks, this is fixed, I think: http://hackage.haskell.org/trac/ghc/ticket/976 http://hackage.haskell.org/trac/ghc/ticket/970 is that the same problem? -- Don ___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: haddock's image markup doesn't work for me
Hi -- | images/stock-icons/stock_about_24.png Why not: -- | images/stock-icons/stock_about_24.png I thought that was the syntax. Thanks Neil ___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: GHCi and Windows 98
Hi Steven, If you are just getting started, and GHC is giving you no luck, try Hugs (in particular WinHugs) which does work on Win98. http://www.haskell.org/hugs/ Thanks Neil On 12/7/06, Steven Tinsley [EMAIL PROTECTED] wrote: Good day to you. I installed GHC 6.6 on a Windows 98 SE system recently having decided to try to learn this language. Unfortunetley, GHCi causes an This program has performed an illegal operation error at startup and is shut down. This happens just after Loading base packagelinkingdone is shown. Windows produces this error message: [code] GHC caused an invalid page fault in module GHC.EXE at 0167:00c82e26. Registers: EAX=0078 CS=0167 EIP=00c82e26 EFLGS=00010297 EBX=00d963c8 SS=016f ESP=010cdd50 EBP=01c43f3c ECX=0007 DS=016f ESI=01be57e8 FS=1617 EDX= ES=016f EDI=01be57f4 GS= Bytes at CS:EIP: 66 83 3c 50 00 74 19 ff 45 00 83 ef 08 b8 18 2e Stack dump: 0078 0200 0001 00d0fe5c 0002 00cddbb6 0001 00c34b9c 00408442 [/code] Just thought you'd like to know. Thanks. Steven. ___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs ___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: [GHC] #1013: interpretBCO: unknown or unimplemented opcode 64356
#1013: interpretBCO: unknown or unimplemented opcode 64356 +--- Reporter: dons| Owner: simonmar Type: bug | Status: closed Priority: high| Milestone: 6.6.1 Component: GHCi|Version: 6.6 Severity: normal | Resolution: fixed Keywords: OS X Sockets | Difficulty: Unknown Testcase: ghci002 | Architecture: Unknown Os: Unknown | +--- Changes (by simonmar): * resolution: = fixed * testcase: = ghci002 * status: new = closed Comment: Fixed, thanks. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/1013 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: haddock's image markup doesn't work for me
On Thu, 2006-12-07 at 14:07 +, Neil Mitchell wrote: Hi -- | images/stock-icons/stock_about_24.png Why not: -- | images/stock-icons/stock_about_24.png I thought that was the syntax. I don't want to link to the image, I want to see it on the web-page. The announcement of haddock 0.8 included the line: * New markup url for including images. And I thought this would be really cool for our Gtk2Hs project, but so far it's not cool at all. Axel. ___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: [GHC] #806: hGetBufNonBlocking doesn't work on Windows
#806: hGetBufNonBlocking doesn't work on Windows +--- Reporter: [EMAIL PROTECTED] | Owner: simonmar Type: bug | Status: new Priority: normal | Milestone: 6.8 Component: libraries/base |Version: 6.4.2 Severity: normal | Resolution: Keywords: | Difficulty: Moderate (1 day) Testcase: hGetBuf001 | Architecture: x86 Os: Windows | +--- Changes (by simonmar): * difficulty: Unknown = Moderate (1 day) * milestone: 6.6.1 = 6.8 * testcase: = hGetBuf001 * summary: hGetBufNonBlocking doesn't work with -threaded on Windows = hGetBufNonBlocking doesn't work on Windows Comment: Changing the title of this bug: hGetBufNonBlocking doesn't work at all on Windows, -threaded or not. The problem is that the I/O system doesn't have any non-blocking primitives, unlike on Unix where we use `O_NONBLOCK`. One way to fix this would be to start using overlapped I/O on Widnows, together with the IO manager thread to wait for blocking I/O operations. This would be a good thing, but it probably isn't going to happen for 6.6.1. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/806 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
[GHC] #1042: Floating point exception
#1042: Floating point exception -+-- Reporter: dons | Owner: Type: bug | Status: new Priority: normal| Milestone: Component: Compiler | Version: 6.6 Severity: normal|Keywords: Difficulty: Unknown |Testcase: Architecture: x86 | Os: Unknown -+-- The slightly evil expression: {{{ (-2147483648::Int) `div` (-1::Int) }}} Can produce floating point exceptions in GHCi: {{{ $ ghci-6.6 ___ ___ _ / _ \ /\ /\/ __(_) / /_\// /_/ / / | | GHC Interactive, version 6.6, for Haskell 98. / /_\\/ __ / /___| | http://www.haskell.org/ghc/ \/\/ /_/\/|_| Type :? for help. Loading package base ... linking ... done. Prelude (-2147483648::Int) `div` (-1::Int) zsh: floating point exception (core dumped) ghci-6.6 }}} Compiled: {{{ $ cat A.hs main = print $ (-2147483648::Int) `div` (-1::Int) $ ghc A.hs $ ./a.out zsh: floating point exception (core dumped) ./a.out }}} Compiled -O: {{{ $ ghc -O -no-recomp A.hs $ ./a.out zsh: floating point exception (core dumped) ./a.out }}} In Hugs: {{{ Hugs.Base (-2147483648::Int) `div` (-1::Int) Unexpected signal }}} A C test cases: {{{ $ cat t.c #include stdio.h int main() { printf(%d\n,((int)(-2147483648)) / ((int)(-1))); return 0; } $ gcc t.c t.c: In function `main': t.c:4: warning: this decimal constant is unsigned only in ISO C90 t.c:4: warning: integer overflow in expression $ ./a.out -2147483648 }}} Another: {{{ $ cat t.c #include stdio.h main () { int i = -2147483648; int j = -1; int k = i / j; printf(%d\n, k); } $ gcc t.c t.c: In function `main': t.c:4: warning: this decimal constant is unsigned only in ISO C90 $ ./a.out zsh: floating point exception (core dumped) ./a.out }}} What does H98 say about this? -- Don -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/1042 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
ghc-6.6-src-extralibs.tar.bz2
The archive http://www.haskell.org/ghc/dist/6.6/ghc-6.6-src-extralibs.tar.bz2 does not contain the files ControlPoint.hs and Domain.hs from directory libraries/OpenGL/Graphics/Rendering/OpenGL/GL/ These files are listed by the binary distribution http://www.haskell.org/ghc/dist/6.6/ghc-6.6-i386-unknown-linux.tar.bz2 Personally I don't miss these files, but they are of course missing from distributions I (and possibly others) made. How imported are these files? They are also not listed in libraries/OpenGL/openGL.cabal. Cheers Christian ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: [Haskell] GHC Error question
And why isn't C a b equivalent to C a b1? forall a b . C a b = a - a and forall a b1 . C a b1 = a - a look alpha convertible to me. Or is the inferred type forall a . C a b1 = a - a Btw, this reminds me again that I'd like to be able to use _ in type signatures. With the meaning of _ being, there's a type here, but I can't be bothered to write it out in full. -- Lennart On Dec 6, 2006, at 02:46 , Simon Peyton-Jones wrote: I agree that this is confusing. Here is a cut-down example: class C a b where op :: a - a -- f :: C a b = a - a f x = op x It doesn't get much simpler than that! With the type sig, GHC can't see that the (C a b) provided can satisfy the (C a b1) which arises from the call to op. However, without the constraint, GHC simply abstracts over the constrains arising in the RHS, namely (C a b1), and hence infers the type f :: C a b1 = a - a It is extremely undesirable that the inferred type does not work as a type signature, but I don't see how to fix it Simon | -Original Message- | From: [EMAIL PROTECTED] [mailto:glasgow- haskell-users- | [EMAIL PROTECTED] On Behalf Of Norman Ramsey | Sent: 06 December 2006 01:41 | To: Simon Peyton-Jones | Cc: GHC users | Subject: Re: [Haskell] GHC Error question | | [redirecting to ghc users] | | It looks like a splendid error to me. | | I'm not sure if you meant the error or the message was splendid :-) | I yelled for help because my usual strategy failed. That strategy is | | 1. Remove the type annotation. | 2. Get ghci to tell me what the 'right type' is. | 3. Put the 'right type' in the type annotation. | | I find it a bit depressing that the most general type inferred by ghci | does not work as a type signature. | | I can't say more without seeing the code. can you give a small repo case? | | Yes, here's a case that fits in one screen of emacs :-) | | | {-# OPTIONS -fglasgow-exts #-} | module Ccomp where | | type Name = String | | data Inface = N | W | data Outface = S | E | | data Sink box = Boxin Inface box | Result | data Source box = Boxout Outface box | Arg Inface | | data Command = Send0 | | class (Monad b) = Builder b box where | box :: Command - b box | wire :: Source box - Sink box - b () | | type Env box = Name - Sink box | | empty = \x - error (x ++ not connected or multiply connected in circuit) | | -- either of these explicit signatures causes the compiler to fail | -- although the inferred signature is the second. | --compile1 :: (Builder b box) = Name - Name - ANF - b Name | compile1 :: (Builder t box) = t1 - Name - ANF - t t1 -- generated by ghci | compile1 f x body = do env - compile body empty |wire (Arg W) (env x) |return f | | data ANF = ANF () | | compile :: (Builder b box) = ANF - Env box - b (Env box) | compile (ANF m) out = undefined | | | This program is rejected by GHC with the following message: | | | | Ccomp.hs:54:23: | | Could not deduce (Builder b box1) from the context (Builder b box) | | arising from use of `wire' at Ccomp.hs:54:23-42 | | Possible fix: | | add (Builder b box1) to the type signature(s) for `compile1' | | In the expression: wire (Arg W) (env x) | | In a 'do' expression: wire (Arg W) (env x) | | In the expression: | | do env - compile body empty | |wire (Arg W) (env x) | |return f | | | | Note that compile1 has an explicit type signature much along the lines | | suggested by GHC. If I *remove* this type signature, the function | | compiles successfully, and ghci reporets this type for compile1: | | | | compile1 :: (Builder t box) = t1 - Name - Ir.ANF - t t1 | | | | I believe this signature is isomorphic to the explicit signature I had | | attempted to use. | ___ | Glasgow-haskell-users mailing list | Glasgow-haskell-users@haskell.org | http://www.haskell.org/mailman/listinfo/glasgow-haskell-users ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Type wildcards, was: Re: [Haskell] GHC Error question
Lennart Augustsson wrote: Btw, this reminds me again that I'd like to be able to use _ in type signatures. With the meaning of _ being, there's a type here, but I can't be bothered to write it out in full. you're not alone ... what is the meaning of two _ in one expression? do they necessarily denote the same type? (probably not.) what about type classes? for example, given sort :: Ord a = [a] - [a], would it be ok to write sort :: [ _ ] - [ _ ] (that is, omitting the context) or is it more like sort :: _ = [ _ ] - [ _ ] BTW, this _ for context would be useful on its own! I have several cases where the conxtext for the type decl is longer than the implementation of the function. Well, nearly. With previous ghc versions, I could get this effect by omitting the type decl but writing f ( x :: type1) ( y :: type2 ) = ... I sometimes wish haddock would understand that. (*) Because - if you write a haddoc comment for a type declaration, then you don't have names for the function's arguments. This leads to either awkward prose (random example, from Data.Maybe:) The maybe function takes a default value, a function, and a Maybe value. If the Maybe value is Nothing ... (this only works here because all the argument types are different in this case) or you have to re-invent names, random example: approxRational :: RealFrac a = a - a - Rational approxRational, applied to two real fractional numbers x and epsilon, which looks like duplication of work. (*) of course the full form would include the return type fun (x :: type1 ) (y :: type2) :: type3 = ... I expect strong opposition from those who write functions with pattern matching (then there is a group of declarations and which one should be type-annotated?) but that's bad style anyway since constructors should not be exported :-) Best regards, -- -- Johannes Waldmann -- Tel/Fax (0341) 3076 6479/80 -- http://www.imn.htwk-leipzig.de/~waldmann/ --- ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: Type wildcards, was: Re: [Haskell] GHC Error question
I would treat multiple _ in a type the same way as multiple _ in a pattern. They can all be different. It might be useful to have multiple variables, say _a, in a type too, all standing for the same type. But I'd settle for _ for now. :) And yes, contexts even more so! Contexts are really annoying in Haskell, they can become quite large, but they cannot be named. Speaking of wishlist, I'd also like to see context synonyms, e.g., context C a = (Ord a, Num a) The current situation is quite bad, there's no way to abstract contexts. Well, you can leave out type signatures altogether (but only a few people advocate this (hello John!)). -- Lennart On Dec 7, 2006, at 07:20 , Johannes Waldmann wrote: Lennart Augustsson wrote: Btw, this reminds me again that I'd like to be able to use _ in type signatures. With the meaning of _ being, there's a type here, but I can't be bothered to write it out in full. you're not alone ... what is the meaning of two _ in one expression? do they necessarily denote the same type? (probably not.) what about type classes? for example, given sort :: Ord a = [a] - [a], would it be ok to write sort :: [ _ ] - [ _ ] (that is, omitting the context) or is it more like sort :: _ = [ _ ] - [ _ ] BTW, this _ for context would be useful on its own! I have several cases where the conxtext for the type decl is longer than the implementation of the function. Well, nearly. With previous ghc versions, I could get this effect by omitting the type decl but writing f ( x :: type1) ( y :: type2 ) = ... I sometimes wish haddock would understand that. (*) Because - if you write a haddoc comment for a type declaration, then you don't have names for the function's arguments. This leads to either awkward prose (random example, from Data.Maybe:) The maybe function takes a default value, a function, and a Maybe value. If the Maybe value is Nothing ... (this only works here because all the argument types are different in this case) or you have to re-invent names, random example: approxRational :: RealFrac a = a - a - Rational approxRational, applied to two real fractional numbers x and epsilon, which looks like duplication of work. (*) of course the full form would include the return type fun (x :: type1 ) (y :: type2) :: type3 = ... I expect strong opposition from those who write functions with pattern matching (then there is a group of declarations and which one should be type-annotated?) but that's bad style anyway since constructors should not be exported :-) Best regards, -- -- Johannes Waldmann -- Tel/Fax (0341) 3076 6479/80 -- http://www.imn.htwk-leipzig.de/~waldmann/ --- ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: Type wildcards, was: Re: [Haskell] GHC Error question
Lennart Augustsson wrote: Speaking of wishlist, I'd also like to see context synonyms, e.g., context C a = (Ord a, Num a) The current situation is quite bad, there's no way to abstract contexts. except by writing extra classes that encode the context, see for example class NFAC: http://141.57.11.163/cgi-bin/cvsweb/lib/Autolib/NFA/Data.hs.drift?rev=1.16 but this is of course only a hack, and it duplicates information since you have to repeat the context in the default instance. At least this happens only in one place, so it is useful. -- -- Johannes Waldmann -- Tel/Fax (0341) 3076 6479/80 -- http://www.imn.htwk-leipzig.de/~waldmann/ --- ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: Type wildcards, was: Re: [Haskell] GHC Error question
On 12/7/06, Lennart Augustsson [EMAIL PROTECTED] wrote: Speaking of wishlist, I'd also like to see context synonyms, e.g., context C a = (Ord a, Num a) This is equivalent to John Meacham's class alias proposal, right? (http://repetae.net/john/recent/out/classalias.html) /g -- It is myself I have never met, whose face is pasted on the underside of my mind. ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Unlifted type variables in GHC
What kind of problems could crop up if I try to create type variables with an unlifted kind inside GHC (not in user code, just inside the compiler)? I want to make ByteArray# and MutableByteArray# parameterized over their element types. ByteArray# would have kind # - #, and MutableByteArray#, * - # - # . indexByteArray# would have the type (in pseudo haskell) forall (e::#). ByteArray# e - Int# - e. This would put all the ByteArray# operations (along with tagToEnum#) in that weird class of primops that have a polymorphic type but must be instantiated with a monomorphic type by the time it hits the code generator but that shouldn't be a big deal. Don't get too hung up on the ByteArray# example. I'm not actually proposing we change ByteArray# (I know it'll cause a few problems with the current UArray implementation). I'm just wondering if something like this is possible, and if so, what I should watch out for if I try to do it. Thanks, -Brian ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: Type wildcards, was: Re: [Haskell] GHC Error question
I should have said that the situation in H98 is quite bad. There you can't make default instances. On Dec 7, 2006, at 07:49 , Johannes Waldmann wrote: Lennart Augustsson wrote: Speaking of wishlist, I'd also like to see context synonyms, e.g., context C a = (Ord a, Num a) The current situation is quite bad, there's no way to abstract contexts. except by writing extra classes that encode the context, see for example class NFAC: http://141.57.11.163/cgi-bin/cvsweb/lib/Autolib/NFA/Data.hs.drift? rev=1.16 but this is of course only a hack, and it duplicates information since you have to repeat the context in the default instance. At least this happens only in one place, so it is useful. -- -- Johannes Waldmann -- Tel/Fax (0341) 3076 6479/80 -- http://www.imn.htwk-leipzig.de/~waldmann/ --- ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: Type wildcards, was: Re: [Haskell] GHC Error question
My (off-the-top-of-my-head) suggestion was much more modest. A context synonym would only allow you to shorten contexts, it would not be a new class. On Dec 7, 2006, at 10:53 , J. Garrett Morris wrote: On 12/7/06, Lennart Augustsson [EMAIL PROTECTED] wrote: Speaking of wishlist, I'd also like to see context synonyms, e.g., context C a = (Ord a, Num a) This is equivalent to John Meacham's class alias proposal, right? (http://repetae.net/john/recent/out/classalias.html) /g -- It is myself I have never met, whose face is pasted on the underside of my mind. ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: Type wildcards, was: Re: [Haskell] GHC Error question
On Thu, Dec 07, 2006 at 10:53:38AM -0500, J. Garrett Morris wrote: On 12/7/06, Lennart Augustsson [EMAIL PROTECTED] wrote: Speaking of wishlist, I'd also like to see context synonyms, e.g., context C a = (Ord a, Num a) This is equivalent to John Meacham's class alias proposal, right? (http://repetae.net/john/recent/out/classalias.html) is is a small part of it, the class alias proposal gives both a shorthand form of refering to a set of class constraints, and a 'template language' of sorts for declaring class instances. the instance declarations part is the meat of the proposal, the shorthand form is more of a natural consequence of it. John -- John Meacham - ⑆repetae.net⑆john⑈ ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: ghc-6.6-src-extralibs.tar.bz2
Am Donnerstag, 7. Dezember 2006 11:37 schrieb Christian Maeder: The archive http://www.haskell.org/ghc/dist/6.6/ghc-6.6-src-extralibs.tar.bz2 does not contain the files ControlPoint.hs and Domain.hs from directory libraries/OpenGL/Graphics/Rendering/OpenGL/GL/ If I see things correctly, the 6.6 extralibs contain the version 2.1 of the OpenGL package, i.e. the stuff currently in http://hackage.haskell.org/packages/unstable/OpenGL/, at least I hope so. :-/ These files are listed by the binary distribution http://www.haskell.org/ghc/dist/6.6/ghc-6.6-i386-unknown-linux.tar.bz2 Personally I don't miss these files, but they are of course missing from distributions I (and possibly others) made. How imported are these files? They are also not listed in libraries/OpenGL/openGL.cabal. The current HEAD (i.e. http://darcs.haskell.org/packages/OpenGL/) contains the bleeding edge version of the OpenGL package, and the version number has already been bumped to 2.2 there (although the version is not yet finished) to avoid confusion. Due to some refactorings, this version has the modules you've mentioned, and they are in the .cabal file, too. So if there is something wrong, it must be the packaging of the 6.6 distributions, but not the OpenGL package itself. To be honest, I don't fully understand the workflow for building the official GHC distributions currently. In former times, the whole tree, including libraries, had a CVS tag, so things were crystal-clear. But due to the new flexibility of making packages independent, we suffer from versionits now, it seems... Some comments/explanations from the packagers are highly welcome. Cheers, S. ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
[Haskell] Higher kind type inference paper
Hi, Are there any papers that describe how higher kind type inference (and I really mean higher kind, not higher rank) is done? Thanks, Edsko ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
Re: [Haskell] Higher kind type inference paper
Edsko, Are there any papers that describe how higher kind type inference (and I really mean higher kind, not higher rank) is done? I'm not aware of any specific papers (but maybe someone else can jump in, here?), but as long as your kind language is simple enough, say k, v ::= * | k - v , you can apply the well-known techniques from type inference. Assuming your kind system does not incorporate kind polymorphism, you could just replace generalization by defaulting; so, instead of, for instance gen((a - *) - a - b - *) = forall k v. (k - *) - k - v - * , you get def((a - *) - a - b - *) = (* - *) - * - * - * . HTH, Stefan ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
Re: [Haskell] Network accept loop with graceful shutdown implementation
Cat Dancer wrote: I have a prospective implementation of a network accept loop with graceful shutdown. Could you add info about where to get your code (or the code) itself to the wiki at http://haskell.org/haskellwiki/Concurrency_demos/Graceful_exit ? To avoid the unlock (return ()) issue that Chris discovered, this implementation uses an additional MVar to indicate that a shutdown is in process. Thus (if the implementation is correct) the accept loop will shutdown either because of the MVar flag or by receiving the asynchronous exception inside of the 'accept'. Small clarification: You don't need a safepoint in your code. But unblock yield is the right code for a safepoint; the unblock (return ()) suggested by the published paper *does not work* in my small test, while unblock yield worked every time in a small test. Simon may updated the documentation eventually to reflect this. To address the issue that Chris noticed of a race condition that new threads cannot be started in a 'block' state, yet another MVar is set by the accept thread to indicate that it is now inside of a 'block' and is ready to receive the asynchronous exception. ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
Re: [Haskell] Network accept loop with graceful shutdown implementation
On 12/7/06, Chris Kuklewicz [EMAIL PROTECTED] wrote: Could you add info about where to get your code (or the code) itself to the wiki at http://haskell.org/haskellwiki/Concurrency_demos/Graceful_exit ? OK, I did. unblock yield is the right code for a safepoint Be careful. You are relying on the runtime to wake up the throwing thread, to let it run long enough to raise the asynchronous exception, and to have that complete before the thread doing the unblock yield is resumed. While a particular Haskell implementation might do all that on a single processor system, it's hard to see how such a guarantee could ever be offered on a multiprocessor system. These days it's common to buy a computer with a dual core cpu, before long we'll be getting cpu's with ten cores... and in a few years we'll be seeing hundred core cpu's. yield is meaningless on a multiprocessor system. I'd suggest that if you're using a concurrent language and you find that the only way you can implement an algorithm is by using yield, either A) you're wrong and there is a way to implement it without yield, or B) your concurrent language is deficient and should be fixed! :-) ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
Re: [Haskell] Network accept loop with graceful shutdown implementation
On 12/7/06, Chris Kuklewicz [EMAIL PROTECTED] wrote: Small clarification: You don't need a safepoint in your code. But unblock yield is the right code for a safepoint; the unblock (return ()) suggested by the published paper *does not work* in my small test, while unblock yield worked every time in a small test. Simon may updated the documentation eventually to reflect this. I think people are misunderstanding the nature of a safepoint. The safepoint is a point at which you are prepared to have exceptions delivered. This does not mean that they *will* be delivered, just that they can. If you need to *wait* for an asynchronous exception, then you shouldn't be using them at all. -- Taral [EMAIL PROTECTED] You can't prove anything. -- Gödel's Incompetence Theorem ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
[Haskell] haddock-via-cabal: --prologue option?
Is it possible to get haddock's --prologue flag passed in through cabal? Is there perhaps a way to get arbitrary options passed in?- Conal ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
Re: [Haskell] haddock-via-cabal: --prologue option?
On Thu, 2006-12-07 at 13:22 -0800, Conal Elliott wrote: Is it possible to get haddock's --prologue flag passed in through cabal? Is there perhaps a way to get arbitrary options passed in? If I recall correctly cabal already passes the description in the .cabal file as the haddock prologue. Duncan ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
Re: [Haskell] Higher kind type inference paper
jhc does it via the simple unification type inference algorithm, modified to push explicitly given kinds down into terms. so, pretty much exactly the boxy type inference algorithm, where your kind inference function looks somewhat like data Kind = Star | Fun Kind Kind | Hash | UnboxedTuple -- (#) | KVar Constraints (IORef (Maybe Kind)) data Constraints = AnyKind | SimpleKind -- * or simplekind - simplekind | FunResult -- ? * # or (#) | Argument-- ?? * or # tiKind :: Term - Kind - Ki () tiKind = ... constraints are how the simple kind subtyping is done. like the rule for application would be: tiKind (TArrow a b) Star = do va - newVar FunArg-- ?? vr - newVar FunResult -- ? tiKind a va tiKind b vr note that ?? and ? arn't real kinds, they are just constraints placed on what valid kinds can be infered in a given spot. whenever a KVar is filled in, it is first checked against the constraint, whenever two KVars are unified, the glb of their constraints is used. then once everything is done. I unify all free kind variables with *. The algorithm is heavily influenced by the 'boxy kind inference paper' of SPJs. the code is in FrontEnd.Tc.Kind and FrontEnd.KindInfer, but it is pretty hairy, due to it evolving incrementally from my previous algorithm which envolved from the original hatchet code, which is derived from the THIH paper. John -- John Meacham - ⑆repetae.net⑆john⑈ ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
Re: [Haskell] haddock-via-cabal: --prologue option?
Sure enough -- it does. Thanks, Duncan. - Conal On 12/7/06, Duncan Coutts [EMAIL PROTECTED] wrote: On Thu, 2006-12-07 at 13:22 -0800, Conal Elliott wrote: Is it possible to get haddock's --prologue flag passed in through cabal? Is there perhaps a way to get arbitrary options passed in? If I recall correctly cabal already passes the description in the .cabal file as the haddock prologue. Duncan ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
[Haskell] Re: GHC Error question
Regarding the quantification: in ML (OCaml) we can write let foo (x:'a) y = (x+1,(y:'a)) That does not mean that foo has the type forall 'a. 'a - 'a - ... Type annotations in OCaml are completely broken and always have been. They use 'unifies with' instead of 'is an instance of' and it renders type annotations nearly useless. If you want to ensure that a function is polymorphic, you have to play horrible games with uninhabited types. I am extremely bitter about this. The analogous declaration in *Standard* ML, which gets this right, is fun 'a foo (x:'a) y = (x + 1, (y:'a)) and as might be expected, this declaration is vigorously rejected by the type checker. As it damn well ought to be. Thanks for the pointers to the new GHC rules. Maybe one day I will learn them well enough to know if I should be bitter about them, too :-) Norman ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
Re: [Haskell] Re: GHC Error question
The analogous declaration in *Standard* ML, which gets this right, is fun 'a foo (x:'a) y = (x + 1, (y:'a)) Following up my own post, I thought it might be kind to explain the arcana of the SML syntax. The explicit 'a between 'fun' and 'foo' is SML syntax for an explicit type-lambda (or /\ or \Lambda as you prefer). In my opinion, the syntax is a bit sneaky, but it sure is useful to be able to bind those type variables explicitly. Regrettably, I know of no way to write an explicit forall in an SML type. GHC 6.6 appears to have taken the dual approach, in which the explicit forall in the type signature magically serves also as an explicit type-lambda in the definition of the term. Since I like to keep my type language and term language distinct, I find this design a bit confusing. It would be great if it were possible to write an explicit type-lambda in the term language as well, but because Haskell does not lexically distinguish term variables from type variables, I can't imagine a convenient syntax. Norman ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
Re: [Haskell-cafe] How to get subset of a list?
On 11/30/06, Huazhi (Hank) Gong [EMAIL PROTECTED] wrote: Thanks, it make sense here. However, like I want to choose s[1,3,6,10] or something like this. Are there some straightforward function or operator for doing this job? The !! operator in haskell seems does not support multiple indecies. hI, Hadn't checked my mail in a few days but here goes: helper function: index' :: forall a. [a] - Int - [a] index' xs i = take 1 $ drop (i-1) xs The real deal: index :: forall a. [a] - [Int] - [[a]] index cs xs = map (index' cs) xs simple example of use: Prelude index ABCDEFGHIJKLMNOPQRSTUVWXYZ [2,5..26] [B,E,H,K,N,Q,T,W,Z] happy computing, gene ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Hac 2007 : Haskell Hackathon - extended registration
Hac 2007 The 2007 Haskell Hackathon January 10-12, 2007 Oxford University Computing Laboratory http://haskell.org/haskellwiki/Hac_2007 The deadline for registration for Hac 2007, the Haskell Hackathon, has passed, and some places are still available, on a first-come first-served basis. The current attendee list is up at: http://haskell.org/haskellwiki/Hac_2007/Attendees If you want to attend the hackathon, and hack on Haskell infrastructure, tools, libraries and compilers, please register, and get ready to hack those lambdas! Follow the instructions on the registration page: http://haskell.org/haskellwiki/Hac_2007/Registration Numbers for the hackathon are limited to 20. The organisers, Duncan Coutts Ian Lynagh Don Stewart Attached is the initial announcement: Hac 2007 The 2007 Haskell Hackathon January 10-12, 2007 Oxford University Computing Laboratory http://haskell.org/haskellwiki/Hac_2007 Following the success of the GHC Hackathon at ICFP, we are pleased to announce the inaugural Haskell Hackathon, Hac 2007! The event will be held over 3 days, January 10-12 2007, at the Oxford University Computing Laboratory, in the UK. The plan is to hack on Haskell infrastructure, tools, libraries and compilers. To attend please register, and get ready to hack those lambdas! Code to hack on: * Hackage * Cabal * Porting foreign libraries * Porting compilers * Bug squashing * Performance improvements to compilers * You decide! Registration: We ask that you register you interest. Follow the instructions on the registration page: http://haskell.org/haskellwiki/Hac_2007/Registration Numbers for the hackathon are limited to 20, due to room size constraints. Should space be available after the registration period ends, additional attendees may register on a first-come first-served basis. Important dates: Registration deadline: December 6th, 2006 Confirmation: December 10th, 2006 Hackathon: January 10-12, 2007 Organisers: Duncan Coutts Ian Lynagh Don Stewart ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Designing an object model in Haskell
Hi, I've got an object model that I have a difficult time conceptualising how it might look like in Haskell: class Element { } class Inline : Element { } class ParentInline : Inline { ListInline children; } class Bold : ParentInline { } class Underline : ParentInline { } class Link : ParentInline { String link; } class Text : Inline { String text; } class Block : Element { } class Paragraph : Block { ListInline paragraph; } class Heading : Block { ListInline heading; } class Document : Element { ListBlock blocks; } How best to represent this OO data model in Haskell? Thanks -John ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] computational time always 0.0 in this example...
Hi, with the following code, I want to measure the time being needed to execute the algorithm. But the result is always 0.0. import Char (toLower) import Maybe import List ( delete, sort, intersect ) import System.CPUTime import Control.Exception import Debug.Trace fromInt = fromIntegral wordList2 :: [String] wordList2 = [Sam J Chapman, Samuel Chapman, S Chapman, Samuel John Chapman, John Smith, Richard Smith, mnop , mnop , aa mnop zz, a , aa, bcdefgh stuvwx zz, bcdefgh stuvx yy, a bcdefgh stuvwx zz, a a a zz, a a] time :: IO t - IO t time a = do start - getCPUTime v - a end - getCPUTime let diff = (fromIntegral (end - start)) / (10^12) --let diff = (fromIntegral (end - start)) putStrLn Computation time: print (diff :: Double) return v main = do putStrLn Starting... time $ doTest wordList2 wordList2 `seq` return () putStrLn Done. test3 = let loop = getCPUTime = print loop in loop doTest :: [String] - [String] - [ Double ] doTest [] _ = [] doTest (x:xs) [] = doTest xs xs doTest (x:xs) (y:ys) = result : (doTest (x:xs) (ys)) where result = qGramMetrics2 x y qGramMetrics2:: String - String - Double qGramMetrics2 t1 t2 = let i = intersect (qGramList (map toLower t1) 3) (qGramList (map toLower t2) 3) il = fromInt (length i) ml = fromInt ((max (length t1) (length t2)) - 1 ) in (il / ml ) -- list of chars within list of qgrams qGramList :: String - Int - [[Char]] qGramList [] _= [] qGramList (x:[]) _ = [] qGramList (x:xs) i1= (x: take (i1 - 1) xs):(qGramList xs i1) -- list of chars within list of qgrams numberedQgramListWithStart :: String - Int - [(Int, [Char])] numberedQgramListWithStart x i1 = let prefix = replicate (i1-1) '#' suffix = replicate (i1-1) '$' in numberedQgramList (prefix++(x++suffix)) i1 0 numberedQgramList :: String - Int - Int - [(Int, [Char])] numberedQgramList [] _ _= [] numberedQgramList (x:xs) i1 i2 -- add the dollar-sign | (length xs) i1 x=='$'= [] | otherwise = (i2,(x: take (i1 - 1) xs)):(numberedQgramList xs i1 (i2+1)) Am using ghci 6.6 under a Kubuntu 6.10 Linux. time $ product [1..1000] `seq` return () instead of time $ doTest wordList2 wordList2 `seq` return () works fine. things like time $ print (doTest wordList2 wordList2) `seq` return () or time $ length (doTest wordList2 wordList2) `seq` return () or time $ trace (doTest wordList2 wordList2) `seq` return () didn't work. Am desperated... Lennart ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Designing an object model in Haskell
Have you looked at OOHaskell (http://homepages.cwi.nl/~ralf/OOHaskell/)? -Jeff [EMAIL PROTECTED] wrote on 12/07/2006 07:07:46 AM: Hi, I've got an object model that I have a difficult time conceptualising how it might look like in Haskell: class Element { } class Inline : Element { } class ParentInline : Inline { ListInline children; } class Bold : ParentInline { } class Underline : ParentInline { } class Link : ParentInline { String link; } class Text : Inline { String text; } class Block : Element { } class Paragraph : Block { ListInline paragraph; } class Heading : Block { ListInline heading; } class Document : Element { ListBlock blocks; } How best to represent this OO data model in Haskell? Thanks -John ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe --- This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] computational time always 0.0 in this example...
On Thu, 7 Dec 2006, Lennart wrote: Hi, with the following code, I want to measure the time being needed to execute the algorithm. But the result is always 0.0. You need to do something to force the result of a, or it'll never actually get evaluated. Depending on the type in question, seq may or may not be enough. Printing it'll make you pay the cost of show, too. -- [EMAIL PROTECTED] There is no magic bullet. There are, however, plenty of bullets that magically home in on feet when not used in exactly the right circumstances. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] computational time always 0.0 in this example...
On 12/7/06, Lennart [EMAIL PROTECTED] wrote: Hi, with the following code, I want to measure the time being needed to execute the algorithm. But the result is always 0.0. import Char (toLower) import Maybe import List ( delete, sort, intersect ) import System.CPUTime import Control.Exception import Debug.Trace fromInt = fromIntegral wordList2 :: [String] wordList2 = [Sam J Chapman, Samuel Chapman, S Chapman, Samuel John Chapman, John Smith, Richard Smith, mnop , mnop , aa mnop zz, a , aa, bcdefgh stuvwx zz, bcdefgh stuvx yy, a bcdefgh stuvwx zz, a a a zz, a a] time :: IO t - IO t time a = do start - getCPUTime v - a end - getCPUTime let diff = (fromIntegral (end - start)) / (10^12) --let diff = (fromIntegral (end - start)) putStrLn Computation time: print (diff :: Double) return v main = do putStrLn Starting... time $ doTest wordList2 wordList2 `seq` return () putStrLn Done. test3 = let loop = getCPUTime = print loop in loop doTest :: [String] - [String] - [ Double ] doTest [] _ = [] doTest (x:xs) [] = doTest xs xs doTest (x:xs) (y:ys) = result : (doTest (x:xs) (ys)) where result = qGramMetrics2 x y qGramMetrics2:: String - String - Double qGramMetrics2 t1 t2 = let i = intersect (qGramList (map toLower t1) 3) (qGramList (map toLower t2) 3) il = fromInt (length i) ml = fromInt ((max (length t1) (length t2)) - 1 ) in (il / ml ) -- list of chars within list of qgrams qGramList :: String - Int - [[Char]] qGramList [] _= [] qGramList (x:[]) _ = [] qGramList (x:xs) i1= (x: take (i1 - 1) xs):(qGramList xs i1) -- list of chars within list of qgrams numberedQgramListWithStart :: String - Int - [(Int, [Char])] numberedQgramListWithStart x i1 = let prefix = replicate (i1-1) '#' suffix = replicate (i1-1) '$' in numberedQgramList (prefix++(x++suffix)) i1 0 numberedQgramList :: String - Int - Int - [(Int, [Char])] numberedQgramList [] _ _= [] numberedQgramList (x:xs) i1 i2 -- add the dollar-sign | (length xs) i1 x=='$'= [] | otherwise = (i2,(x: take (i1 - 1) xs)):(numberedQgramList xs i1 (i2+1)) Am using ghci 6.6 under a Kubuntu 6.10 Linux. time $ product [1..1000] `seq` return () instead of time $ doTest wordList2 wordList2 `seq` return () works fine. things like time $ print (doTest wordList2 wordList2) `seq` return () or time $ length (doTest wordList2 wordList2) `seq` return () or time $ trace (doTest wordList2 wordList2) `seq` return () didn't work. Am desperated... Running 'doTest wordList2 wordList2' takes less than 0.00s. Find a more time consuming function and you will be fine. Also, have a look at ':set +s' in ghci (http://www.haskell.org/ghc/docs/latest/html/users_guide/ghci-set.html). -- Cheers, Lemmih ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] computational time always 0.0 in this example...
Hello Lennart, Thursday, December 7, 2006, 4:59:57 PM, you wrote: time $ product [1..1000] `seq` return () instead of time $ doTest wordList2 wordList2 `seq` return () works fine. because 'product' returns just one value. use the following: time $ (return $! last (doTest wordList2 wordList2)) -- Best regards, Bulatmailto:[EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] computational time always 0.0 in this example...
On 12/7/06, Lennart [EMAIL PROTECTED] wrote: Hi, with the following code, I want to measure the time being needed to execute the algorithm. But the result is always 0.0. import Char (toLower) import Maybe import List ( delete, sort, intersect ) import System.CPUTime import Control.Exception import Debug.Trace fromInt = fromIntegral wordList2 :: [String] wordList2 = [Sam J Chapman, Samuel Chapman, S Chapman, Samuel John Chapman, John Smith, Richard Smith, mnop , mnop , aa mnop zz, a , aa, bcdefgh stuvwx zz, bcdefgh stuvx yy, a bcdefgh stuvwx zz, a a a zz, a a] time :: IO t - IO t time a = do start - getCPUTime v - a end - getCPUTime let diff = (fromIntegral (end - start)) / (10^12) --let diff = (fromIntegral (end - start)) putStrLn Computation time: print (diff :: Double) return v main = do putStrLn Starting... time $ doTest wordList2 wordList2 `seq` return () putStrLn Done. test3 = let loop = getCPUTime = print loop in loop doTest :: [String] - [String] - [ Double ] doTest [] _ = [] doTest (x:xs) [] = doTest xs xs doTest (x:xs) (y:ys) = result : (doTest (x:xs) (ys)) where result = qGramMetrics2 x y qGramMetrics2:: String - String - Double qGramMetrics2 t1 t2 = let i = intersect (qGramList (map toLower t1) 3) (qGramList (map toLower t2) 3) il = fromInt (length i) ml = fromInt ((max (length t1) (length t2)) - 1 ) in (il / ml ) -- list of chars within list of qgrams qGramList :: String - Int - [[Char]] qGramList [] _= [] qGramList (x:[]) _ = [] qGramList (x:xs) i1= (x: take (i1 - 1) xs):(qGramList xs i1) -- list of chars within list of qgrams numberedQgramListWithStart :: String - Int - [(Int, [Char])] numberedQgramListWithStart x i1 = let prefix = replicate (i1-1) '#' suffix = replicate (i1-1) '$' in numberedQgramList (prefix++(x++suffix)) i1 0 numberedQgramList :: String - Int - Int - [(Int, [Char])] numberedQgramList [] _ _= [] numberedQgramList (x:xs) i1 i2 -- add the dollar-sign | (length xs) i1 x=='$'= [] | otherwise = (i2,(x: take (i1 - 1) xs)):(numberedQgramList xs i1 (i2+1)) Am using ghci 6.6 under a Kubuntu 6.10 Linux. time $ product [1..1000] `seq` return () instead of time $ doTest wordList2 wordList2 `seq` return () works fine. things like time $ print (doTest wordList2 wordList2) `seq` return () or time $ length (doTest wordList2 wordList2) `seq` return () or time $ trace (doTest wordList2 wordList2) `seq` return () didn't work. Am desperated... Try: time $ evaluate (sum (doTest wordList2 wordList2)) -- Cheers, Lemmih ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] How to combine Error and IO monads?
I've read Jeff Newbern's tutorial on monad transformers (http://www.nomaware.com/monads/html/index.html), but I don't grok it yet and I can't tell how to get started with this particular requirement, or even if I need monad transformers for this. I have a program that performs a series of IO operations, each which can result in an error or a value. If a step returns a value I usually want to pass that value on to the next step, if I get an error I want to do some error handling but usually want to skip the remaining steps. Thus I have a lot of functions with return types like IO (Either String x), where x might be (), Integer, or some other useful value type, and a lot of case statements like a :: Integer - IO (Either String String) (a :: Either String Integer) - some_io_action_returning_integer_or_error case a of -- got to get from (Either String Integer) to (Either String String) Left message - return $ Left message -- continue on Right i - do_more i If I was using just Either I know how to get rid of the case statements: import Control.Monad.Error p :: Integer - Either String Integer q :: Integer - Either String String r :: Either String String r = do a - p 3 b - q a return b which of course is much nicer. But how do I combine the Error and IO monads so that r could have the type IO (Either String String)? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: How to combine Error and IO monads?
Cat Dancer wrote: I have a program that performs a series of IO operations, each which can result in an error or a value. If a step returns a value I usually want to pass that value on to the next step, if I get an error I want to do some error handling but usually want to skip the remaining steps. Thus I have a lot of functions with return types like IO (Either String x), where x might be (), Integer, or some other useful value type, and a lot of case statements like You are on the right track. The point is that (IO (Either String a)) is a Monad, too. This allows you to write the ever repeating case statements once and forall: newtype ErrorIO a = ErrorIO (IO (Either String a)) instance Monad ErrorIO where return x = return (Right x) f = g = do ex - f case ex of e@(Left _) - return e Right x- g x It happens that you can parametrize this on IO: newtype ErrorT m a = ErrorT (m (Either String a)) typeErrorIO a = ErrorT IO a instance Monad m = Monad (ErrorT m) where ... -- same as above And you just rediscovered monad transformers. Regards, apfelmus PS: In the special case of IO, you can also use exceptions. But using ErrorT is better style. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: How to combine Error and IO monads?
And you just rediscovered monad transformers. Can I use an existing monad transformer like ErrorT for this application? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: How to combine Error and IO monads?
On 12/7/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Cat Dancer wrote: I have a program that performs a series of IO operations, each which can result in an error or a value. If a step returns a value I usually want to pass that value on to the next step, if I get an error I want to do some error handling but usually want to skip the remaining steps. Thus I have a lot of functions with return types like IO (Either String x), where x might be (), Integer, or some other useful value type, and a lot of case statements like You are on the right track. The point is that (IO (Either String a)) is a Monad, too. This allows you to write the ever repeating case statements once and forall: newtype ErrorIO a = ErrorIO (IO (Either String a)) instance Monad ErrorIO where return x = return (Right x) f = g = do ex - f case ex of e@(Left _) - return e Right x- g x It happens that you can parametrize this on IO: newtype ErrorT m a = ErrorT (m (Either String a)) typeErrorIO a = ErrorT IO a instance Monad m = Monad (ErrorT m) where ... -- same as above And you just rediscovered monad transformers. I think I need to explain how thoroughly clueless I am :) I'm sure from a single example I could understand what was going on and elaborate from there. Let's say I want to get a line from the user, and either return an integer or an error string using ErrorT. import Control.Monad.Error import Control.Monad.Trans foo :: ?? foo = do -- something like this? a - getLine if length a == 1 then return 123 else throwError not a single character main = do r - ?? foo ?? print r -- prints Left not a single character or Right 123 ? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: How to combine Error and IO monads?
On 12/7/06, Cat Dancer [EMAIL PROTECTED] wrote: On 12/7/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I'm sure from a single example I could understand what was going on and elaborate from there. Let's say I want to get a line from the user, and either return an integer or an error string using ErrorT. import Control.Monad.Error import Control.Monad.Trans foo :: ?? foo :: ErrorT String IO Int if you're going to use this very often, you can use a line like type M = ErrorT String IO and then foo :: M Int foo = do -- something like this? a - getLine Since ErrorT String IO Int is not the same as IO, you can't use IO operations directly. In this case, you want: a - lift getLine if length a == 1 then return 123 else throwError not a single character This is all fine main = do r - ?? foo ?? You want: r - runErrorT foo and then this will behave as expected: print r -- prints Left not a single character or Right 123 ? Your foo operation is in a monad which wraps IO. lift allows IO operations inside that wrapper, and runErrorT removes the wrapper. The same basic pattern works for other wrappers (like StateT or ListT) or combinations of wrappers (like StateT Int (ErrorT String IO)) /g -- It is myself I have never met, whose face is pasted on the underside of my mind. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] STUArray's newArray_ breaks referential transparency
newArray_ allocates an array full of garbage. import Control.Monad.ST import Data.Array.ST import Data.Array tickle :: Int tickle = runST (do { x - newArray_ (0,100) ; (readArray :: STUArray s Int Int - Int - ST s Int) x 3 }) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] interval arithmetic for integers?
I'm looking to not reinvent the wheel. Is there an existing package that supports interval arithmetic on integers (or more)? A possible complication is that I'm hoping to include open intervals such as (GreaterEqThan 3). If there's not a package to go with, any pointers on the appopriate rules for this stuff? I started coding up multiplication and decided it was harder than I first thought... Thanks for your time, Nick ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] interval arithmetic for integers?
nicolas.frisby: I'm looking to not reinvent the wheel. Is there an existing package that supports interval arithmetic on integers (or more)? A possible complication is that I'm hoping to include open intervals such as (GreaterEqThan 3). If there's not a package to go with, any pointers on the appopriate rules for this stuff? I started coding up multiplication and decided it was harder than I first thought... Anything here? http://haskell.org/haskellwiki/Libraries_and_tools/Mathematics -- Don ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] interval arithmetic for integers?
Some of that is in the Ranged Sets library: http://ranged-sets.sourceforge.net/Ranged/ but it doesn't support Num. On 12/8/06, Nicolas Frisby [EMAIL PROTECTED] wrote: I'm looking to not reinvent the wheel. Is there an existing package that supports interval arithmetic on integers (or more)? A possible complication is that I'm hoping to include open intervals such as (GreaterEqThan 3). -- Taral [EMAIL PROTECTED] You can't prove anything. -- Gödel's Incompetence Theorem ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe