Re: [Haskell-cafe] How to get a typed (type tagged) AST from GHC's core [Was: Dynamically typing TH.Exp at runtime]
Matthijs Kooijman wrote: I've been working on parsing core in the past few months. For an example, look here: http://git.stderr.nl/gitweb?p=matthijs/projects/fhdl.git;a=blob;f=Translator.hs;h=8072f85925ad1238 The loadModule and findBind functions are interesting. As for iterating the AST, have a look at Flatten.hs. Thanks, Matthijs! This helps a lot and looks very promising! Only to avoid misunderstandings, you only use the ghc-api to get the AST of a CoreModule which you translate into your own data structure (VHDL). At this point, you don't use type information, right? Martin ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Uploading files to the wiki
Wouter Swierstra wrote: I can't manage to upload files to the Haskell wiki. I've tried different browsers, different internet connections, different machines, different operating systems, and different user accounts - all without success. Is this a new anti-spam measure? This is slightly annoying. I was looking to release the next Monad.Reader on the wiki. Thanks for any advice, It turns out that both PHP and Apache have limits on file uploads. The PHP limit was set to 2MiB, and there was also a PHP-specific Apache configuration that limited POSTs to 0.5MiB. So Apache responded to this upload with a 413 error. MediaWiki (perhaps wisely) does not add its own upload limit, though it does issue a warning confirmation for files bigger than 150KiB. I've set both limits to 20MiB, and switched off MediaWiki's warning. I've uploaded Wouter's file to [[Image:TMR-Issue13.pdf]]. -- Ashley Yakeley ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How to get a typed (type tagged) AST from GHC's core [Was: Dynamically typing TH.Exp at runtime]
Hi Martin, Only to avoid misunderstandings, you only use the ghc-api to get the AST of a CoreModule which you translate into your own data structure (VHDL). That's correct. At this point, you don't use type information, right? I use some typing information, but that's mostly hidden away. In particular, when creating Signals using genSignalId I annotate them with the type of the expression the signal models. Later on, I translate this type to a VHDL type. To get at the type of an expression, I use the CoreUtils.exprType function, which gives you the type of any CoreExpr. Gr. Matthijs signature.asc Description: Digital signature ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] examples for error handling in takusen?
2009/3/14 Gü?nther Schmidt gue.schm...@web.de: Hi, can someone please point me to error handling examples with takusen? I try to run a piece of code with takusen but just get the very sparse Database.InternalEnumerator.DBException Hello Günther, We use dynamic exceptions in Takusen, which is why you don't get much useful information when an exception is thrown. We will include the new extensible-exceptions code in the next release, so once that it done perhaps we can change the way we do exceptions so that you get better messages by default. There are some basic exception handling functions in Database.Enumerator which should help. Firstly, you need to add an exception handler with catchDB. Then you can choose to ignore the error, report it, or re-raise it (see basicDBExceptionReporter and reportRethrow). Also, the DBException constructors are exported, so you can pattern match on it to extract more information, like SqlState, error number, and error message. Alistair ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How to get a typed (type tagged) AST from GHC's core [Was: Dynamically typing TH.Exp at runtime]
Okay, many thanks. That's exactly I need (I hope :-) ). Cheers, Martin ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Uploading files to the wiki
I've set both limits to 20MiB, and switched off MediaWiki's warning. I've uploaded Wouter's file to [[Image:TMR-Issue13.pdf]]. Fantastic! Thanks for all your help, Wouter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] ANN: The Monad.Reader (13)
I am pleased to announce that a new issue of The Monad.Reader is now available: http://www.haskell.org/haskellwiki/The_Monad.Reader The Monad.Reader is a quarterly magazine about functional programming. Issue 13 consists of the following four articles: * Stephen Hicks Rapid Prototyping in TEX * Brent Yorgey The Typeclassopedia * Chris Eidhof, Eelco Lempsink Book Review: Real World Haskell * Derek Elkins Calculating Monads with Category Theory Special thanks to Ashley Yakeley for his help with publishing The Monad.Reader on the Haskell wiki. If you'd like to write something for the next issue of The Monad.Reader, please get in touch. I haven't fixed the deadline for the next issue, but it should be mid-May or thereabouts. Wouter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Data.Binary, Data.Text and errors
On Monday 16 March 2009 06:40:12 Alexander Dunlap wrote: Hi all, I have noticed that in both Data.Binary and Data.Text (which is still experimental, but still), the decode functions can be undefined (i.e. bottom) if they encounter malformed input. What is the preferred way to use these functions in a safe way? For example, if one writes data to a disk using Data.Binary and wants to read it back in at a later date, how can one ensure that it is valid so that Data.Binary does not hit an error? Or do you just have to catch the exception in the IO Monad? I've used ErrorT monad transformer for decoding. With that it's possible to work around this problem. As downside one is required to do all checks and throw errors manually. It would be nice to have some kind of error handling in Data.Binary How it was done: import Control.Monad.Error -- | Get monad with applied to it Error monad transformer type Decoder = ErrorT String Get -- | Subequipment data data SubEq = SubEq { subeqID :: Int , subeqData :: ByteString } -- | Abort execution if function evaluates to True dieIf :: (a - Bool) - String - a - Decoder () dieIf f err x = when (f x) (throwError err) readSubEq :: Decoder SubEq readSubEq = do lift remaining = dieIf (4) DATE: Too short subequipment data (4) -- Read header len - liftM (\x - fromIntegral $ 2*x - 4) $ lift getWord16le s_id - liftM fromIntegral $ lift getWord16le lift remaining = dieIf ( len) DATE: Too short subequipment data buf - lift $ getLazyByteString len return $! SubEq s_id buf -- Actual decoding decodeSubEq = runGet (runErrorT readSubEq) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Hashing over equivalence classes
* Ryan Ingram ryani.s...@gmail.com [2009-03-14 11:36:33-0700] For the second case you might be able to come up with a commutative hash-combiner function for and ||. What a beautiful idea! I wish I thought of it myself. For the lambda-term situation, I can think of a couple ways to hash that give what you want. (1) Ignore variable names altogether while hashing; this gives you what you want but has the disadvantage that (\a b. a) and (\a b. b) hash to the same value. (2) Hash the term with de Bruijn indices. But this is the same as hash the canonical element. Thanks for the reference. I don't see that you have much other choice, though. Fortunately, due to laziness, hash . canonicalize should not have much worse space behavior than just hash. Did you have something else in mind? Not yet. -- ryan On Sat, Mar 14, 2009 at 3:51 AM, Roman Cheplyaka r...@ro-che.info wrote: Are there some known ways to define hashing (or any other) functions over equivalence classes? I.e. a ~ b = hash(a) == hash(b) where (~) is some equivalence relation. For example, you might want to hash lambda terms modulo alpha-equivalence or hash logical terms with respect to commutativity of () and (||). Often we can choose 'canonical' element from each class and hash it. But (at least, in theory) it's not necessary. So, are there (practical) ways to define hash function without it? -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Packet analysis framework for Haskell.
Hi all, Is there a packet analysis framework in Haskell? The framework should abstract away the features of packet analysis in the form of a library that people can use and write extensions to perform computation on the packets flowing through the network. What are the features of packet analysis? 1. Support for packet packet selection, matching a particular criteria. Example: (protocol = tcp destination_port = 80). 2. Multi-threaded. Since the process of computation on packets is inherently data-parallel, the framework should abstract away the parallelism and make use of different CPU cores if available. I believe the features in Haskell would be a great boon to easily achieve this. 3. Support for statistics. Packet analysis is usually done for a purpose. Say, I would like to collect statistics about the rate of connections to a webserver. I would want to: (a) Filter packets, using features in (1). (b) Count the number of packets that pass through after applying operation (a). (c) Generate reports if a particular condition is flagged in (b). Example: (a) protocol = tcp SYN set in flags destination_port = 80, (b) count the number of SYN packets, (c) report if d(count)/dt 100. 4. Availability of efficient data structures for achieving real time performance. Example: The user might want to check if ARP spoofing is taking place. In which case, one has to cache the already seen mapping between protocol and hardware addresses learnt from the packets that flowed, and constantly checking new addresses against this structure for duplicates. The above are some of the features which I believe are necessary for packet analysis (or, analytics maybe?). There could be more. I was wondering if Haskell would be a good language to achieve these things. I had a brief idea and started writing an application in C and I realised the need for such a framework. The ease of parallelism offered by Haskell prompted me to think about using it. I would like to hear your comments. Also, would this qualify as a project that someone in the Haskell community would be willing to mentor for GSoC 2009? (Assuming Haskell would be on the list of mentoring organisations, although I have no reason to doubt it wouldn't.) Thanks, Regards, -- Vimal ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Packet analysis framework for Haskell.
Vimal j.vi...@gmail.com wrote: The above are some of the features which I believe are necessary for packet analysis (or, analytics maybe?). There could be more. I was wondering if Haskell would be a good language to achieve these things. I had a brief idea and started writing an application in C and I realised the need for such a framework. The ease of parallelism offered by Haskell prompted me to think about using it. I would like to hear your comments. I think it's a perfect fit, not only because of parallelism. Mentally combining parser combinators and state collectors a la quickcheck makes me wonder why anyone would use atrocities like iptables[1]... Also, would this qualify as a project that someone in the Haskell community would be willing to mentor for GSoC 2009? (Assuming Haskell would be on the list of mentoring organisations, although I have no reason to doubt it wouldn't.) ZOMG! Don't ask, copy and paste your mail to the proposals! [1] says someone who actually likes iptables -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] darcs fundraising drive - THANK-YOU!
Dear darcs users and Haskellers, I wanted to thank you all for your contributions to our first darcs fundraising drive. We've done it! We managed to raise $1000, over two weeks with contributions from 22 donors. This means that we will able to help our programmers travel to the darcs hacking sprint. This fundraising drive is over, but donations will still be gratefully accepted. In the long term, we hope to raise another $5000 to pay for a summer project ($4000) and also to pay for travel (another $1000) to the third hacking sprint this October or November. Again, thank-you! -- Eric Kow http://www.nltg.brighton.ac.uk/home/Eric.Kow PGP Key ID: 08AC04F9 signature.asc Description: Digital signature ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] What unsafeInterleaveIO is unsafe
Hi, On 2009/03/16, at 10:04, wren ng thornton wrote: next r = do n - readIORef r writeIORef r (n+1) return n Now, if I use unsafeInterleaveIO: main = do r - newIORef 0 x - do a - unsafeInterleaveIO (next r) b - unsafeInterleaveIO (next r) return (a,b) ... The values of a and b in x are entirely arbitrary, and are only set at the point when they are first accessed. They're not just arbitrary between which is 0 and which is 1, they could be *any* pair of values (other than equal) since the reference r is still in scope and other code in the ... could affect it before we access a and b, or between the two accesses. OK, the values of a and b depend how to deconstruct x. Moreover, let's have two pure implementations, f and g, of the same mathematical function. Even if f and g are close enough to correctly give the same output for inputs with _|_ in them, we may be able to observe the fact that they arrive at those answers differently by passing in our x. Given that such observations are possible, it is no longer safe to exchange f and g for one another, despite the fact that they are pure and give the same output for all (meaningful) inputs. Hm, Does it means that in optimization, a compiler may replace implementation of a pure function that have different order of evaluation, so order of actions would be different in some environments? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Has anybody replicated =~ s/../../ or even something more basic for doing replacements with pcre haskell regexen?
Thomas Hartman wrote: testPcre = ( subRegex (mkRegex (?!\n)\n(?!\n)) asdf\n \n\n\nadsf ) == asdf \n\n\nadsf quoting from the man page for regcomp: REG_NEWLINE Compile for newline-sensitive matching. By default, newline is a completely ordinary character with no special meaning in either REs or strings. With this flag, `[^' bracket expressions and `.' never match newline, a `^' anchor matches the null string after any newline in the string in addition to its normal function, and the `$' anchor matches the null string before any newline in the string in addition to its normal function. This is the carried over to Text.Regex with mkRegexWithOpts Source :: String The regular expression to compile - Bool True = '^' and '$' match the beginning and end of individual lines respectively, and '.' does not match the newline character. - Bool True = matching is case-sensitive - Regex Returns: the compiled regular expression Makes a regular expression, where the multi-line and case-sensitive options can be changed from the default settings. Or with regex-posix directly the flag is compNewline: http://hackage.haskell.org/packages/archive/regex-posix/0.94.1/doc/html/Text-Regex-Posix-Wrap.html The defaultCompOpt is (compExtended .|. compNewline). You want to match a \n that is not next to any other \n. So you want to turn off REG_NEWLINE. import Text.Regex.Compat r :: Regex r = mkRegexWithOpts (^|[^\n])\n($|[^\n]) False True -- False is important here The ^ and $ take care of matching a lone newline at the start or end of the whole text. In the middle of the text the pattern is equivalent to [^\n]\n[^\n]. When substituting you can use the \1 and \2 captures to restore the matched non-newline character if one was present. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Has anybody replicated =~ s/../../ or even something more basic for doing replacements with pcre haskell regexen?
Thomas Hartman wrote: testPcre = ( subRegex (mkRegex (?!\n)\n(?!\n)) asdf\n \n\n\nadsf ) == asdf \n\n\nadsf quoting from the man page for regcomp: REG_NEWLINE Compile for newline-sensitive matching. By default, newline is a completely ordinary character with no special meaning in either REs or strings. With this flag, `[^' bracket expressions and `.' never match newline, a `^' anchor matches the null string after any newline in the string in addition to its normal function, and the `$' anchor matches the null string before any newline in the string in addition to its normal function. This is the carried over to Text.Regex with mkRegexWithOpts Source :: String The regular expression to compile - Bool True = '^' and '$' match the beginning and end of individual lines respectively, and '.' does not match the newline character. - Bool True = matching is case-sensitive - Regex Returns: the compiled regular expression Makes a regular expression, where the multi-line and case-sensitive options can be changed from the default settings. Or with regex-posix directly the flag is compNewline: http://hackage.haskell.org/packages/archive/regex-posix/0.94.1/doc/html/Text-Regex-Posix-Wrap.html The defaultCompOpt is (compExtended .|. compNewline). You want to match a \n that is not next to any other \n. So you want to turn off REG_NEWLINE. import Text.Regex.Compat r :: Regex r = mkRegexWithOpts (^|[^\n])\n($|[^\n]) False True -- False is important here The ^ and $ take care of matching a lone newline at the start or end of the whole text. In the middle of the text the pattern is equivalent to [^\n]\n[^\n]. When substituting you can use the \1 and \2 captures to restore the matched non-newline character if one was present. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: A non-inductive Haskell proof?
R J wrote: The following theorem is obviously true, but how is it proved (most cleanly and simply) in Haskell? Theorem: (nondecreasing xs) = nondecreasing (insert x xs), where: nondecreasing :: (Ord a) = [a] - Bool nondecreasing []= True nondecreasing xxs@(x : xs) = and [a = b | (a, b) - zip xxs xs] insert :: (Ord a) = a - [a] - [a] insert x xs = takeWhile (= x) xs ++ [x] ++ dropWhile (= x) xs Since insert involves list concatenation at the outermost level, the first step is to prove a lemma along the lines of nondecreasing xs nondecreasing ys (last xs = head ys) = nondecreasing (xs ++ ys) from which the wanted theorem follows immediately. The lemma itself is proved readily by noting/proving and (xs ++ ys) = and xs and ys zip (xs ++ ys) (tail (xs ++ ys)) ~= zip xs (tail xs) ++ [(last xs, head ys)] ++ zip ys (tail ys) Regards, apfelmus -- http://apfelmus.nfshost.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Packet analysis framework for Haskell.
On 2009 Mar 16, at 6:53, Vimal wrote: Is there a packet analysis framework in Haskell? The framework should abstract away the features of packet analysis in the form of a library that people can use and write extensions to perform computation on the packets flowing through the network. The only one I'm aware of is http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Etherbunny but I couldn't tell you how Haskelly it is (it's in my look at in my Copious Spare Time™ list). -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@kf8nh.com system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu electrical and computer engineering, carnegie mellon universityKF8NH PGP.sig Description: This is a digitally signed message part ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] What unsafeInterleaveIO is unsafe
On 2009 Mar 16, at 8:48, Yusaku Hashimoto wrote: On 2009/03/16, at 10:04, wren ng thornton wrote: Moreover, let's have two pure implementations, f and g, of the same mathematical function. Even if f and g are close enough to correctly give the same output for inputs with _|_ in them, we may be able to observe the fact that they arrive at those answers differently by passing in our x. Given that such observations are possible, it is no longer safe to exchange f and g for one another, despite the fact that they are pure and give the same output for all (meaningful) inputs. Hm, Does it means that in optimization, a compiler may replace implementation of a pure function that have different order of evaluation, so order of actions would be different in some environments? order of actions is meaningless in pure functions, so yes. And that's why unsafeInterleaveIO is unsafe: your pure function can have side effects which are observable, so there is an order of actions to worry about. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@kf8nh.com system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu electrical and computer engineering, carnegie mellon universityKF8NH PGP.sig Description: This is a digitally signed message part ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Incompatibility of different (monad transformer) libraries
On Sat, 14 Mar 2009 02:14:53 +0100 (CET), Henning Thielemann lemm...@henning-thielemann.de wrote: I think 'transformers' exports Control.Monad.Trans.State. This should not conflict with MTL. However, MTL's State type is different from transformer's one. Is that your problem? No. The immediate problem is, that a module named Control.Monad.State is exported by both mtl and monads-tf (and my code needs both packages). It is indeed unfortunate that mtl:State is a different type from transformers:State, but that is not biting me right now. Since the 'cabal' tool became better and better, today I use a cabal file even for small programs. Cabal automatically calls GHC with the right package exposing and hiding options. I already use cabal; my own package has mtl, transformers and monads-tf among its dependencies. Regards, Arie ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] What unsafeInterleaveIO is unsafe
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Yusaku Hashimoto wrote: | I was studying about what unsafeInterleaveIO is.I understood | unsafeInterleaveIO takes an IO action, and delays it. But I couldn't | find any reason why unsafeInterleaveIO is unsafe. I think it depends on what we want to take unsafe to mean. In my opinion, the word unsafe should really only be used in cases where using the function can case an otherwise well-typed program to not be well-typed. I'm pretty sure I haven't yet seen a case where this applies to unsafeInterleaveIO. The biggest problem with unsafeInterleaveIO is that it complicates the semantics of the IO monad. - - Jake -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.9 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkm+aH8ACgkQye5hVyvIUKkOygCghyHD90TdvCBR5V815fxmQbIy mKsAnjnAgtZ5jV1p1P2St5NB2li587lU =PzqF -END PGP SIGNATURE- ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Natural Numbers: Best implementation?
Am Samstag, 14. März 2009 23:33 schrieben Sie: On Fri, 13 Mar 2009, Wolfgang Jeltsch wrote: Class instances should satisfy certain laws. (Although these laws are often not stated explicitely, they are assumed to hold by users of the class and they should hold to make the instance sensible.) In the case of Num, I would expect num + negate num to equal num. equal zero ? Exactly. Best wishes, Wolfgang ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Visualising the Hierarchical Namespace
I've just finished a post (and quick tool) for graphing the complete module namespace of Haskell, taken from the core libraries and all of Hackage. It's quite large: http://donsbot.wordpress.com/2009/03/16/visualising-the-haskell-universe/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Visualising the Hierarchical Namespace
How long did the haskell universe graphs take to render? On Mon, Mar 16, 2009 at 11:05 AM, Don Stewart d...@galois.com wrote: I've just finished a post (and quick tool) for graphing the complete module namespace of Haskell, taken from the core libraries and all of Hackage. It's quite large: http://donsbot.wordpress.com/2009/03/16/visualising-the-haskell-universe/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- /jve ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Visualising the Hierarchical Namespace
Oh, barely any time (maybe 30-60 seconds). It's just a 10k node graph with a 50k edges. :) vanenkj: How long did the haskell universe graphs take to render? On Mon, Mar 16, 2009 at 11:05 AM, Don Stewart d...@galois.com wrote: I've just finished a post (and quick tool) for graphing the complete module namespace of Haskell, taken from the core libraries and all of Hackage. It's quite large: http://donsbot.wordpress.com/2009/03/16/visualising-the-haskell-universe / ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- /jve ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Visualising the Hierarchical Namespace
Very impressive looking, Don. -- Jeff On Mon, Mar 16, 2009 at 11:14 AM, Don Stewart d...@galois.com wrote: Oh, barely any time (maybe 30-60 seconds). It's just a 10k node graph with a 50k edges. :) vanenkj: How long did the haskell universe graphs take to render? On Mon, Mar 16, 2009 at 11:05 AM, Don Stewart d...@galois.com wrote: I've just finished a post (and quick tool) for graphing the complete module namespace of Haskell, taken from the core libraries and all of Hackage. It's quite large: http://donsbot.wordpress.com/2009/03/16/visualising-the-haskell-universe / ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- /jve ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Visualising the Hierarchical Namespace
My secret hope is that Jeff will take the .dot files and doing something very cool with them jefferson.r.heard: Very impressive looking, Don. -- Jeff On Mon, Mar 16, 2009 at 11:14 AM, Don Stewart d...@galois.com wrote: Oh, barely any time (maybe 30-60 seconds). It's just a 10k node graph with a 50k edges. :) vanenkj: How long did the haskell universe graphs take to render? On Mon, Mar 16, 2009 at 11:05 AM, Don Stewart d...@galois.com wrote: I've just finished a post (and quick tool) for graphing the complete module namespace of Haskell, taken from the core libraries and all of Hackage. It's quite large: http://donsbot.wordpress.com/2009/03/16/visualising-the-haskell-universe / ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- /jve ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Visualising the Hierarchical Namespace
Beautiful; I especially like the neato rendering. There's just something about the concentric circles radiating out from certain modules that just looks so...well, cool. Nice work! -John On Mon, Mar 16, 2009 at 11:05 AM, Don Stewart d...@galois.com wrote: I've just finished a post (and quick tool) for graphing the complete module namespace of Haskell, taken from the core libraries and all of Hackage. It's quite large: http://donsbot.wordpress.com/2009/03/16/visualising-the-haskell-universe/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Visualising the Hierarchical Namespace
That's why I just asked on IRC for them :-) Also wrote most of a Hieroglyph script last night to replace the graph of daily uploads on Hackage. Will send it out tonight or tomorrow. On Mon, Mar 16, 2009 at 11:17 AM, Don Stewart d...@galois.com wrote: My secret hope is that Jeff will take the .dot files and doing something very cool with them jefferson.r.heard: Very impressive looking, Don. -- Jeff On Mon, Mar 16, 2009 at 11:14 AM, Don Stewart d...@galois.com wrote: Oh, barely any time (maybe 30-60 seconds). It's just a 10k node graph with a 50k edges. :) vanenkj: How long did the haskell universe graphs take to render? On Mon, Mar 16, 2009 at 11:05 AM, Don Stewart d...@galois.com wrote: I've just finished a post (and quick tool) for graphing the complete module namespace of Haskell, taken from the core libraries and all of Hackage. It's quite large: http://donsbot.wordpress.com/2009/03/16/visualising-the-haskell-universe / ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- /jve ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Polynomial and VectorSpace
The DSP package on Hackage seems to contain complex polynomial functions. It seems these functions are completely independent of the other DSP functions, so this package could be split of? Also, polynomials form a vector space, so could be made an instance of VectorSpace class? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Map in Terms of Fold in terms of Map
Hi, I’ve noticed that it’s possible to define map as foldr and foldr as a map. Would this be sensible to define both in terms of each other in the Prelude? i.e mutually recursive? Cheers, Mark No virus found in this outgoing message. Checked by AVG. Version: 7.5.557 / Virus Database: 270.11.15/2003 - Release Date: 15/03/2009 2:07 PM ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Map in Terms of Fold in terms of Map
Hi Mark, What's the definition of foldr in terms of map? As far as I was aware, its not possible. And as it happens, map is (or is sometimes) defined in term of foldr :-) While you can use mutual recursion, you can't define a in terms of b and b in terms of a unless one of them actually does something at the end - so it does depend exactly what the definitions are. Thanks Neil 2009/3/16 Mark Spezzano mark.spezz...@chariot.net.au: Hi, I’ve noticed that it’s possible to define map as foldr and foldr as a map. Would this be sensible to define both in terms of each other in the Prelude? i.e mutually recursive? Cheers, Mark No virus found in this outgoing message. Checked by AVG. Version: 7.5.557 / Virus Database: 270.11.15/2003 - Release Date: 15/03/2009 2:07 PM ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Haskell-Cafe Digest, Vol 67, Issue 41
On Mon, 16 Mar 2009 08:05:37 -0700 Don Stewart d...@galois.com wrote : Subject: [Haskell-cafe] Visualising the Hierarchical Namespace I've just finished a post (and quick tool) for graphing the complete module namespace of Haskell, taken from the core libraries and all of Hackage. It's quite large: http://donsbot.wordpress.com/2009/03/16/visualising-the-haskell-universe/ Hi Don, That was really good. Amazing stuff there. In fact I just (re) joined the haskell and lisp mailing lists. Course work was keeping me at bay from following my passion for functional programming paradigms except that one of my courses was in fact haskell last semester. Well, it seems as if haskell is taking the functional world by storm. Even in the lisp mailing lists I hear of people reading haskell books, Real World Haskell was one of them and in fact they seem to be appreciating the type system offered by haskell. Now, that really means something. You know how hard it is to impress the lisp folks. All in all an impressive run so far. Hats off to all those developers and the Haskell community at large. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Visualising the Hierarchical Namespace
Don Stewart ha scritto: I've just finished a post (and quick tool) for graphing the complete module namespace of Haskell, taken from the core libraries and all of Hackage. It's quite large: http://donsbot.wordpress.com/2009/03/16/visualising-the-haskell-universe/ Just a note: isn't it time to switch to SVG images? All that PNG images are pretty useless, they are too small. Manlio ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Visualising the Hierarchical Namespace
manlio_perillo: Don Stewart ha scritto: I've just finished a post (and quick tool) for graphing the complete module namespace of Haskell, taken from the core libraries and all of Hackage. It's quite large: http://donsbot.wordpress.com/2009/03/16/visualising-the-haskell-universe/ Just a note: isn't it time to switch to SVG images? All that PNG images are pretty useless, they are too small. All the .svg's are linked at the bottom. Note: they will break your browser -- Don ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] What unsafeInterleaveIO is unsafe
On Mon, Mar 16, 2009 at 7:55 AM, Jake McArthur j...@pikewerks.com wrote: I think it depends on what we want to take unsafe to mean. In my opinion, the word unsafe should really only be used in cases where using the function can case an otherwise well-typed program to not be well-typed. I'm pretty sure I haven't yet seen a case where this applies to unsafeInterleaveIO. I don't think unsafeInterleaveIO on its own can do this. However, I disagree with your description of what unsafe should be used for. unsafe calls out the need for the programmer to prove that what they are doing is safe semantically, instead of the compiler providing those proofs for you. Whether that is due to type safety (unsafeCoerce) or breaking the assumptions of the compiler (unsafePerformIO, unsafeInterleaveIO, unsafeIOToST), depends on the situation. For example, unsafePerformIO can make your program not type-safe, but it's convoluted to do so; in fact, at monomorphic types it can't break type safety. That's not what makes it unsafe at all. It's unsafe because it breaks the rule that pure values don't have side effects, so that the effects inside the unsafePerformIO might get executed more than once, or not at all, depending on how the compiler decides to evaluate the pure value returned. And what happens could depend on the optimization settings of the compiler, the timing of the machine you are running on, or the phase of the moon. -- ryan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Visualising the Hierarchical Namespace
Don Stewart ha scritto: manlio_perillo: Don Stewart ha scritto: I've just finished a post (and quick tool) for graphing the complete module namespace of Haskell, taken from the core libraries and all of Hackage. It's quite large: http://donsbot.wordpress.com/2009/03/16/visualising-the-haskell-universe/ Just a note: isn't it time to switch to SVG images? All that PNG images are pretty useless, they are too small. All the .svg's are linked at the bottom. Note: they will break your browser FF handle them quite well. The problem is that there is too much informations :). By the way: in the SVG files there is a lot of redundant informations. Graphviz should realy use CSS instead of SVG presentation attributes. Using CSS to factor out common style should reduce image size a lot. I would like to see a Graphics package for Haskell, based on SVG/libVG/Cairo/PDF imaging model. Manlio ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] What unsafeInterleaveIO is unsafe
On Monday 16 March 2009 2:11:10 pm Ryan Ingram wrote: However, I disagree with your description of what unsafe should be used for. unsafe calls out the need for the programmer to prove that what they are doing is safe semantically, instead of the compiler providing those proofs for you. Whether that is due to type safety (unsafeCoerce) or breaking the assumptions of the compiler (unsafePerformIO, unsafeInterleaveIO, unsafeIOToST), depends on the situation. Of course, unsafeIOToST can also break the type system, because you can write: unsafePerformIO m = runST (unsafeIOToST m) For example, unsafePerformIO can make your program not type-safe, but it's convoluted to do so; in fact, at monomorphic types it can't break type safety. That's not what makes it unsafe at all. It's unsafe because it breaks the rule that pure values don't have side effects, so that the effects inside the unsafePerformIO might get executed more than once, or not at all, depending on how the compiler decides to evaluate the pure value returned. And what happens could depend on the optimization settings of the compiler, the timing of the machine you are running on, or the phase of the moon. In practice, 'unsafe' can mean any number of things depending on the context. unsafeRead/Write on mutable arrays can (attempt to) read/write arbitrary memory locations. An index into a data structure that just calls error instead of returning a Maybe result might be called unsafe. In a similar vein, some people think head and tail should be called unsafeHead and unsafeTail. :) Technically, one can probably lay down a semantics of IO such that unsafeInterleaveIO maintains the purity of the language by the usual definitions. However, such a semantics is necessarily too vague to explain why you might want to use it in the first place, because the only real reason you'd want to do so is to have side effects triggered in response to evaluation of otherwise pure terms. At the very least, using unsafeInterleaveIO adds significant complications to reasoning about the behavior of otherwise ordinary IO, which might well justify its name. -- Dan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Lambda-Cube 3D render engine
Hi! I've created a wiki page for my project. Currently only some text and screenshot are available. Additional documentation and source code are coming soon.. :) http://www.haskell.org/haskellwiki/LambdaCubeEngine Cheers, Csaba Hruska ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Has anybody replicated =~ s/../../ or even something more basic for doing replacements with pcre haskell regexen?
Thanks, that was extremely helpful. My bad for being so sloppy reading the documentation so sloppily -- I somehow glossed over the bit that backreferences worked as one would expect. To atone for this, http://patch-tag.com/repo/haskell-learning/browse/regexStuff/pcreReplace.hs shows successful =~ s/../../ -like behavior for a pcre and a posix-like (but compatible with pcre engine) regex in the same example, which is based on pcre regex. (See testPcre, testPosix). FWIW, I still think that there should be a library subRegex function for all regex flavors, and not just Posix. If there are gotchas about how capture references work in different flavors I might backpedal on this, but Im not aware of any. 2009/3/16 ChrisK hask...@list.mightyreason.com: Thomas Hartman wrote: testPcre = ( subRegex (mkRegex (?!\n)\n(?!\n)) asdf\n \n\n\nadsf ) == asdf \n\n\nadsf quoting from the man page for regcomp: REG_NEWLINE Compile for newline-sensitive matching. By default, newline is a completely ordinary character with no special meaning in either REs or strings. With this flag, `[^' bracket expressions and `.' never match newline, a `^' anchor matches the null string after any newline in the string in addition to its normal function, and the `$' anchor matches the null string before any newline in the string in addition to its normal function. This is the carried over to Text.Regex with mkRegexWithOpts Source :: String The regular expression to compile - Bool True = '^' and '$' match the beginning and end of individual lines respectively, and '.' does not match the newline character. - Bool True = matching is case-sensitive - Regex Returns: the compiled regular expression Makes a regular expression, where the multi-line and case-sensitive options can be changed from the default settings. Or with regex-posix directly the flag is compNewline: http://hackage.haskell.org/packages/archive/regex-posix/0.94.1/doc/html/Text-Regex-Posix-Wrap.html The defaultCompOpt is (compExtended .|. compNewline). You want to match a \n that is not next to any other \n. So you want to turn off REG_NEWLINE. import Text.Regex.Compat r :: Regex r = mkRegexWithOpts (^|[^\n])\n($|[^\n]) False True -- False is important here The ^ and $ take care of matching a lone newline at the start or end of the whole text. In the middle of the text the pattern is equivalent to [^\n]\n[^\n]. When substituting you can use the \1 and \2 captures to restore the matched non-newline character if one was present. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Incompatibility of different (monad transformer) libraries
On Mon, Mar 16, 2009 at 9:26 AM, Arie Peterson ar...@xs4all.nl wrote: It is indeed unfortunate that mtl:State is a different type from transformers:State, but that is not biting me right now. If the type problem does ever become an issue, could the MTL use the types from the transformers package? Antoine ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Has anybody replicated =~ s/../../ or even something more basic for doing replacements with pcre haskell regexen?
Don Stewart wrote: tphyahoo: Is there something like subRegex... something like =~ s/.../.../ in perl... for haskell pcre Regexen? I mean, subRegex from Text.Regex of course: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/regex-compat Thanks for any advice, Basically, we should have it. Let me open the discussion with all the questions I can quickly ask: What should the subRegex function do, exactly? (Single replacement,global replacement,once per line,...) What should the replacement template be able to specify? (Can it refer to all text before a match or all text after?) (Can it access the start/stop offsets as numbers?) Should the replacement template be specified in a String? As an abstract data type or syntax tree? With combinators? What happens if the referenced capture was not made? Empty text? How will syntax errors in the template be handled (e.g. referring to a capture that does not exist in the regular expression)? Will the output text be String? ByteString? ByteString.Lazy? Seq Char? Note: String and Strict Bytestrings are poor with concatenation. Can the output text type differ from the input text type? -- Chris ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Polynomial and VectorSpace
On Mon, 16 Mar 2009, Peter Verswyvelen wrote: The DSP package on Hackage seems to contain complex polynomial functions. It seems these functions are completely independent of the other DSP functions, so this package could be split of? The matrix stuff is also independent. If you split off the polynomial stuff you might also adapt the identifiers to qualified style. Also, polynomials form a vector space, so could be made an instance of VectorSpace class? Polynomial arithmetic is also contained in http://hackage.haskell.org/packages/archive/numeric-prelude/0.0.5/doc/html/MathObj-Polynomial.html http://darcs.haskell.org/htam/src/Polynomial.hs vector-space seems to be a tough dependency, since it relies on type families. NumericPrelude's VectorSpace class is a multi-parameter type class. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] What unsafeInterleaveIO is unsafe
On Sun, 15 Mar 2009, Ryan Ingram wrote: unsafeInterleaveIO allows embedding side effects into a pure computation. This means you can potentially observe if some pure value has been evaluated or not; the result of your code could change depending how lazy/strict it is, which is very hard to predict! For example: -- given f :: Integer - Integer main = do r - newIORef 0 v - unsafeInterleaveIO $ do writeIORef r 1 return 1 x - case f v of 0 - return 0 n - return (n - 1) y - readIORef r print y -- a couple of examples: f x = 0 -- program prints 0 -- f x = x -- program prints 1 Interesting example. I have implemented the lazyio package. It asserts that unsafely interleaved IO actions are performed in order. This should prevent such problems, does it? However, they are only avoided within the LazyIO monad. Running the LazyIO monad in IO allows the same corruptions as shown above. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/lazyio ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] What unsafeInterleaveIO is unsafe
On Sun, 15 Mar 2009, Claus Reinke wrote: import Data.IORef import Control.Exception main = do r - newIORef 0 let v = undefined handle (\(ErrorCall _)-print hireturn 42) $ case f v of 0 - return 0 n - return (n - 1) y - readIORef r print y I don't see what this has to do with strictness. It's just the hacky exception handling which allows to catch programming errors. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] What unsafeInterleaveIO is unsafe
On Mon, 2009-03-16 at 22:12 +0100, Henning Thielemann wrote: On Sun, 15 Mar 2009, Claus Reinke wrote: import Data.IORef import Control.Exception main = do r - newIORef 0 let v = undefined handle (\(ErrorCall _)-print hireturn 42) $ case f v of 0 - return 0 n - return (n - 1) y - readIORef r print y I don't see what this has to do with strictness. It's just the hacky exception handling which allows to catch programming errors. And which I have a sneaking suspicion actually *is* `unsafe'. Or, at least, incapable of being given a compositional, continuous semantics. jcc ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] darcs fundraising drive - THANK-YOU!
I'm just getting to know this community, and I have to say, I am very impressed by this. Congrats to everyone for making the world a better place :) -- Duane Johnson On Mar 16, 2009, at 6:09 AM, Eric Kow wrote: Dear darcs users and Haskellers, I wanted to thank you all for your contributions to our first darcs fundraising drive. We've done it! We managed to raise $1000, over two weeks with contributions from 22 donors. This means that we will able to help our programmers travel to the darcs hacking sprint. This fundraising drive is over, but donations will still be gratefully accepted. In the long term, we hope to raise another $5000 to pay for a summer project ($4000) and also to pay for travel (another $1000) to the third hacking sprint this October or November. Again, thank-you! -- Eric Kow http://www.nltg.brighton.ac.uk/home/Eric.Kow PGP Key ID: 08AC04F9 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Polynomial and VectorSpace
2009/3/16 Peter Verswyvelen bugf...@gmail.com: The DSP package on Hackage seems to contain complex polynomial functions. It seems these functions are completely independent of the other DSP functions, so this package could be split of? I would be interested in a separate package that deals with polynomials. I am working on a library that does various things with numerals and polynomials are a nice way to represent positional notation systems. Perhaps it would allow me to work with Knuth's quater-imaginary base :-) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Lambda-Cube 3D render engine
2009/3/16 Csaba Hruska csaba.hru...@gmail.com: Hi! I've created a wiki page for my project. Currently only some text and screenshot are available. Additional documentation and source code are coming soon.. :) http://www.haskell.org/haskellwiki/LambdaCubeEngine Cheers, Csaba Hruska ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe This is really nice! I will be looking forward to the preview version. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Lambda-Cube 3D render engine
Oh yes, we will :-) On Mon, Mar 16, 2009 at 10:45 PM, Roel van Dijk vandijk.r...@gmail.comwrote: This is really nice! I will be looking forward to the preview version. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] What unsafeInterleaveIO is unsafe
On Mon, 2009-03-16 at 14:17 -0700, Jonathan Cast wrote: On Mon, 2009-03-16 at 22:12 +0100, Henning Thielemann wrote: On Sun, 15 Mar 2009, Claus Reinke wrote: import Data.IORef import Control.Exception main = do r - newIORef 0 let v = undefined handle (\(ErrorCall _)-print hireturn 42) $ case f v of 0 - return 0 n - return (n - 1) y - readIORef r print y I don't see what this has to do with strictness. It's just the hacky exception handling which allows to catch programming errors. And which I have a sneaking suspicion actually *is* `unsafe'. Or, at least, incapable of being given a compositional, continuous semantics. See this paper: A semantics for imprecise exceptions http://research.microsoft.com/en-us/um/people/simonpj/papers/imprecise-exn.htm Basically if we can only catch exceptions in IO then it doesn't matter, it's just a little extra non-determinism and IO has plenty of that already. Duncan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Polynomial and VectorSpace
On Mon, Mar 16, 2009 at 9:50 PM, Henning Thielemann lemm...@henning-thielemann.de wrote: Polynomial arithmetic is also contained in http://hackage.haskell.org/packages/archive/numeric-prelude/0.0.5/doc/html/MathObj-Polynomial.html http://darcs.haskell.org/htam/src/Polynomial.hs Nice. But the above code doen't seem to contain functions to find (or approximate) all complex roots, which is the function I need (maybe with special cases for linear, quadratic, cubic, since these can be done analytically). The DSP package does, albeit only Laguerre's method, which might be good enough, although my old C# code that I wanted to port used Weierstrass method http://darcs.haskell.org/htam/src/Polynomial.hsvector-space seems to be a tough dependency, since it relies on type families. NumericPrelude's VectorSpace class is a multi-parameter type class. NumericPrelude is very impressive, but it scares me a little, since it is so big :-) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Lambda-Cube 3D render engine
2009/3/16 Duane Johnson duane.john...@gmail.com Looks great! By any chance, is the mesh loading functionality separate from the texture loading? Yes, it is completly separated from material, it only refers to material's name. You can define the material writing a nice human readable script: http://www.ogre3d.org/docs/manual/manual_14.html#SEC23 -- Duane Johnson On Mar 16, 2009, at 1:01 PM, Csaba Hruska wrote: Hi! I've created a wiki page for my project. Currently only some text and screenshot are available. Additional documentation and source code are coming soon.. :) http://www.haskell.org/haskellwiki/LambdaCubeEngine Cheers, Csaba Hruska ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] What unsafeInterleaveIO is unsafe
On Mon, 2009-03-16 at 22:01 +, Duncan Coutts wrote: On Mon, 2009-03-16 at 14:17 -0700, Jonathan Cast wrote: On Mon, 2009-03-16 at 22:12 +0100, Henning Thielemann wrote: On Sun, 15 Mar 2009, Claus Reinke wrote: import Data.IORef import Control.Exception main = do r - newIORef 0 let v = undefined handle (\(ErrorCall _)-print hireturn 42) $ case f v of 0 - return 0 n - return (n - 1) y - readIORef r print y I don't see what this has to do with strictness. It's just the hacky exception handling which allows to catch programming errors. And which I have a sneaking suspicion actually *is* `unsafe'. Or, at least, incapable of being given a compositional, continuous semantics. See this paper: A semantics for imprecise exceptions http://research.microsoft.com/en-us/um/people/simonpj/papers/imprecise-exn.htm Basically if we can only catch exceptions in IO then it doesn't matter, it's just a little extra non-determinism and IO has plenty of that already. I'm not sure that helps much. Given the following inequalities (in the domain ordering) and equations: throw urk! = 1 evaluate . throw = throwIO evaluate x = return x -- x total catch (throwIO a) h = h a catch (return x) h = return x we expect to be able to reason as follows: throw urk! = return 1 == evaluate (throw urk!) = evaluate 1 == catch (evaluate (throw urk!)) (const $ return 2) = catch (evaluate 1) (const $ return 2) while catch (evaluate (throw urk!)) (const $ return 2) = catch (throwIO urk!) (const $ return 2) = const (return 2) urk! = return 2 and catch (evaluate 1) (const $ return 2) = catch (return 1) (const $ return 2) = return 1 So return 2 = return 1, in the domain ordering? That doesn't seem right. jcc ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] random shuffle and random list partition
Hi. For my Netflix Prize project I have implemented two reusable modules. The first module implements a random shuffle on immutable lists. It uses http://okmij.org/ftp/Haskell/perfect-shuffle.txt, with an additional wrapper function, having a more friendly interface. The second module implements a function used to partition a list into n sublists of random length. I have pasted the modules here: http://hpaste.org/fastcgi/hpaste.fcgi/view?id=2483 http://hpaste.org/fastcgi/hpaste.fcgi/view?id=2485 If someone is interested (and if Oleg give me permission), I can release them as a package on Hackage. I need to improve documentation, however. In future I can add an implementation of the random shuffle algorithm on mutable arrays in the ST monad. Manlio ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: darcs fundraising drive - THANK-YOU!
Eric Kow ko...@darcs.net writes: We hope to raise another $5000 to pay for a summer project ($4000) Nitpick: summer is hemispherist. -- Trent W. Buck, Pedant ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] using Typeable with STRefs
Hi, I'm having a problem using Typeable with STRefs. Basically, I want to store STRefs (among other things) in a universal type. STRef is an instance of Typeable2, which means that STRef s a is Typeable if s and a are both Typeable. The problem is that the state type s is opaque and I can see no way to make it Typeable (other than making it RealWorld, and I don't want to use IO for this). If this is the case, then AFAICT there is no point in having STRefs be instances of Typeable2. Am I missing something? Here's the code I'd like to write: import Data.Typeable import Data.STRef import Control.Monad.ST data Value = forall a . Typeable a = V a deriving Typeable getValue :: Typeable a = Value - Maybe a getValue (V v) = cast v -- I need the Typeable s constraint for the code to compile, but I'd rather leave it out. test :: Typeable s = ST s Integer test = do ref - newSTRef (10 :: Integer) let refVal = V ref case getValue refVal of Nothing - error BAD Just r - readSTRef r -- This doesn't compile, because s is not Typeable. test2 :: Integer test2 = runST test Thanks in advance, Mike ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] using Typeable with STRefs
Having the state be an instance of Typeable breaks the purity guarantees of runST; a reference could escape runST: let v = runST (V `liftM` newSTRef 0) in runST (readSTRef $ fromJust $ getValue v) Keep in mind that the state actually used by runST is RealWorld; runST is just a pretty name for unsafePerformIO. So the state types are actually the same, and the cast would succeed. -- ryan On Mon, Mar 16, 2009 at 5:48 PM, Michael Vanier mvanie...@gmail.com wrote: Hi, I'm having a problem using Typeable with STRefs. Basically, I want to store STRefs (among other things) in a universal type. STRef is an instance of Typeable2, which means that STRef s a is Typeable if s and a are both Typeable. The problem is that the state type s is opaque and I can see no way to make it Typeable (other than making it RealWorld, and I don't want to use IO for this). If this is the case, then AFAICT there is no point in having STRefs be instances of Typeable2. Am I missing something? Here's the code I'd like to write: import Data.Typeable import Data.STRef import Control.Monad.ST data Value = forall a . Typeable a = V a deriving Typeable getValue :: Typeable a = Value - Maybe a getValue (V v) = cast v -- I need the Typeable s constraint for the code to compile, but I'd rather leave it out. test :: Typeable s = ST s Integer test = do ref - newSTRef (10 :: Integer) let refVal = V ref case getValue refVal of Nothing - error BAD Just r - readSTRef r -- This doesn't compile, because s is not Typeable. test2 :: Integer test2 = runST test Thanks in advance, Mike ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] using Typeable with STRefs
Ryan, So, if I understand you correctly, my only option is to use an IORef instead of an STRef? What I'm trying to do is implement a mutable box type as part of a dynamically-typed language I'm implementing in Haskell (which is mainly an exercise to improve my Haskell programming; mission accomplished). It bothers me that I have to use an IORef for this, since I don't see what this has to do with I/O. Similarly, if I wanted to have a mutable array type, I couldn't use STArray; I'd have to use IOArray. Or, I suppose I could define a richer Value type that had extra constructors for stateful types. Mike Ryan Ingram wrote: Having the state be an instance of Typeable breaks the purity guarantees of runST; a reference could escape runST: let v = runST (V `liftM` newSTRef 0) in runST (readSTRef $ fromJust $ getValue v) Keep in mind that the state actually used by runST is RealWorld; runST is just a pretty name for unsafePerformIO. So the state types are actually the same, and the cast would succeed. -- ryan On Mon, Mar 16, 2009 at 5:48 PM, Michael Vanier mvanie...@gmail.com wrote: Hi, I'm having a problem using Typeable with STRefs. Basically, I want to store STRefs (among other things) in a universal type. STRef is an instance of Typeable2, which means that STRef s a is Typeable if s and a are both Typeable. The problem is that the state type s is opaque and I can see no way to make it Typeable (other than making it RealWorld, and I don't want to use IO for this). If this is the case, then AFAICT there is no point in having STRefs be instances of Typeable2. Am I missing something? Here's the code I'd like to write: import Data.Typeable import Data.STRef import Control.Monad.ST data Value = forall a . Typeable a = V a deriving Typeable getValue :: Typeable a = Value - Maybe a getValue (V v) = cast v -- I need the Typeable s constraint for the code to compile, but I'd rather leave it out. test :: Typeable s = ST s Integer test = do ref - newSTRef (10 :: Integer) let refVal = V ref case getValue refVal of Nothing - error BAD Just r - readSTRef r -- This doesn't compile, because s is not Typeable. test2 :: Integer test2 = runST test Thanks in advance, Mike ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] What unsafeInterleaveIO is unsafe
exception handling which allows to catch programming errors. And which I have a sneaking suspicion actually *is* `unsafe'. Or, at least, incapable of being given a compositional, continuous semantics. A semantics for imprecise exceptions http://research.microsoft.com/en-us/um/people/simonpj/papers/imprecise-exn.htm Basically if we can only catch exceptions in IO then it doesn't matter, it's just a little extra non-determinism and IO has plenty of that already. I'm not sure that helps much. Given the following inequalities (in the domain ordering) and equations: throw urk! = return 1 == evaluate (throw urk!) = evaluate 1 throw (ErrorCall urk) = evaluate (throw (ErrorCall urk)) as demonstrated here *Main throw (ErrorCall urk) `seq` () *** Exception: urk *Main evaluate (throw (ErrorCall urk)) `seq` () () So that first step already relies on IO (where the two are equivalent). This is very delicate territory. For instance, one might think that this 'f' seems to define a negation function of information content f x = Control.Exception.catch (evaluate x let x = x in x) (\(ErrorCall _)-return 0) = print and hence violates monotonicity (_|_ = ()) = (f _|_ = f ()) since *Main f undefined 0 *Main f () Interrupted. But that is really mixing context-free expression evaluation and context-sensitive execution of io operations. Most of our favourite context-free equivalences only hold within the expression evaluation part, while IO operations are subject to additional, context-sensitive rules. For instance, without execution *Main f () `seq` () () *Main f undefined `seq` () () but if we include execution (and the context-sensitive equivalence that implies, lets call it ~), we have f () ~ _|_ = return 0 ~ f _|_ so 'f' shows that wrapping both sides of an inequality in 'catch' need not preserve the ordering (modulo ~) - its whole purpose is to recover from failure, making something more defined (modulo ~) by translating _|_ to something else. Which affects your second implication. If the odd properties of 'f' capture the essence of your concerns, I think the answer is to keep =, =, and ~ clearly separate, ideally without losing any of the context-free equivalences while limiting the amount of context-sensitive reasoning required. If = and ~ are mixed up, however, monotonicity seems lost. The semantics in the imprecise exceptions paper combines a denotational approach for the context-free part with an operational semantics for the context-sensitive part. This tends to use the good properties of both, with a clear separation between them, but a systematic treatment of the resulting identities was left for future work. Claus ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] using Typeable with STRefs
On Mon, Mar 16, 2009 at 8:08 PM, Michael Vanier mvanie...@gmail.com wrote: Ryan, So, if I understand you correctly, my only option is to use an IORef instead of an STRef? What I'm trying to do is implement a mutable box type as part of a dynamically-typed language I'm implementing in Haskell (which is mainly an exercise to improve my Haskell programming; mission accomplished). It bothers me that I have to use an IORef for this, since I don't see what this has to do with I/O. Similarly, if I wanted to have a mutable array type, I couldn't use STArray; I'd have to use IOArray. Or, I suppose I could define a richer Value type that had extra constructors for stateful types. Why not: data Value = forall a . Typeable a = V a type STValue s = STRef Value Then you have a dynamic, mutable box. Also, even if the language you're interpretting is dynamicaly typed, it doesn't mean that you need to use Haskell Dynamics. It should be enough to do something like: data Value = VInt Integer | VStr String | VChar Char and then: -- | Similar to Prelude.Head primOpHead :: Value - Value primOpHead (VStr xs) = VChar $ head xs primOpHead _ = error Type Mismatch! I'm sure other people can point you to much better ways to do this - the point is that you don't need Dynamics to implement a dynamic language. Antoine ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] using Typeable with STRefs
Why not: data Value = forall a . Typeable a = V a type STValue s = STRef Value This should be: type STValue s = STRef s Value Antoine ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] What unsafeInterleaveIO is unsafe
On Tue, 2009-03-17 at 01:16 +, Claus Reinke wrote: exception handling which allows to catch programming errors. And which I have a sneaking suspicion actually *is* `unsafe'. Or, at least, incapable of being given a compositional, continuous semantics. A semantics for imprecise exceptions http://research.microsoft.com/en-us/um/people/simonpj/papers/imprecise-exn.htm Basically if we can only catch exceptions in IO then it doesn't matter, it's just a little extra non-determinism and IO has plenty of that already. I'm not sure that helps much. Given the following inequalities (in the domain ordering) and equations: throw urk! = return 1 Oops, left a superfluous return in there. I meant throw urk! = 1 (The inequality is at Int). == evaluate (throw urk!) = evaluate 1 throw (ErrorCall urk) = evaluate (throw (ErrorCall urk)) Sure enough. But throwIO (ErrorCall urk) /= _|_: Control.Exception throwIO (ErrorCall urk!) `seq` () () So that first step already relies on IO (where the two are equivalent). Come again? This is very delicate territory. For instance, one might think that this 'f' seems to define a negation function of information content f x = Control.Exception.catch (evaluate x let x = x in x) (\(ErrorCall _)-return 0) = print and hence violates monotonicity (_|_ = ()) = (f _|_ = f ()) since *Main f undefined 0 *Main f () Interrupted. But that is really mixing context-free expression evaluation and context-sensitive execution of io operations. Most of our favourite context-free equivalences only hold within the expression evaluation part, while IO operations are subject to additional, context-sensitive rules. Could you elaborate on this? It sounds suspiciously like you're saying Haskell's axiomatic semantics is unsound :: IO. For instance, without execution *Main f () `seq` () () *Main f undefined `seq` () () but if we include execution (and the context-sensitive equivalence that implies, lets call it ~), So a ~ b = `The observable effects of $(x) and $(y) are equal' ? we have f () ~ _|_ = return 0 ~ f _|_ so 'f' shows that wrapping both sides of an inequality in 'catch' need not preserve the ordering (modulo ~) If f _|_ = f (), then it seems that (=) is not a (pre-) order w.r.t. (~). So taking the quotient of IO Int over (~) gives you a set on which (=) is not an ordering (and may not be a relation). - its whole purpose is to recover from failure, making something more defined (modulo ~) by translating _|_ to something else. Which affects your second implication. If the odd properties of 'f' capture the essence of your concerns, I think the answer is to keep =, =, and ~ clearly separate, ideally without losing any of the context-free equivalences while limiting the amount of context-sensitive reasoning required. If = and ~ are mixed up, however, monotonicity seems lost. So catch (throwIO e) h ~ h e but it is not the case that catch (throwIO e) h = h e ? That must be correct, actually: Control.Exception let x = Control.Exception.catch (throwIO (ErrorCall urk!)) (\ (ErrorCall _) - undefined) in x `seq` () () So catch is total (even if one or both arguments is erroneous), but the IO executor (a beast totally distinct from the Haskell interpreter, even if they happen to live in the same body) when executing it feels free to examine bits of the Haskell program's state it's not safe for a normal program to inspect. I'll have to think about what that means a bit more. The semantics in the imprecise exceptions paper combines a denotational approach for the context-free part with an operational semantics [Totally OT tangent: How did operational semantics come to get its noun? The more I think about it, the more it seems like a precís of the implementation, rather than a truly semantic part of a language specification.] for the context-sensitive part. This tends to use the good properties of both, with a clear separation between them, but a systematic treatment of the resulting identities was left for future work. jcc ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Polynomial and VectorSpace
On Mon, 16 Mar 2009, Matthew Donadio wrote: Thy polynomial and matrix libraries weren't really developed to be stand alone libraries. I was developing some DSP libraries that required polynomial and matrix math, so I implemented what I needed so I could test the DSP. Both libraries work for lower orders, but I suspect they are buggy with big inputs. My long term goal was to interface with LAPACK and/or GSL for the numeric heavy lifting, but that never happened. The same goes for the FFT library. That was written in support of the DSP libraries, and also as a learning exercise for me (to better understand how/why the FFT works). FFTW was the long term goal. In the meantime fftw and gsl-matrix interfaces exist on Hackage. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Design Patterns by Gamma or equivalent
a...@spamcop.net wrote: G'day all. Quoting wren ng thornton w...@freegeek.org: Most of the (particular) problems OO design patterns solve are non-issues in Haskell because the language is more expressive. ...and vice versa. Some of the design patterns that we use in Haskell, for example, are to overcome the fact that Haskell doesn't have mutable global state. Oh sure. However, in my experience the most common design patterns of OO are the ones obviated in functional languages. And I haven't tended to need any of the global mutation patterns in Haskell[1]. Not an objective analysis by any means, but I do think it holds more water than it leaks. The whole genre of SYB papers indicates that there's no panacea. [1] The two times I've needed global mutation, one is for arbitrary unique symbol generation (uses a library), and the other is for doing some very tricky memoization with self-compaction when memory is low. The latter I'd think is certainly too special-purpose to be considered a pattern. A number of other patterns can actually be written down once and for all (in higher-order functions like foldr, map,...) instead of needing repetition. This is also true in many OO languages. A lot of the GoF book, for example, can be implemented as libraries in Ada or C++. I think this depends very much on the specific language in question. For dynamic OO languages with lambdas (Smalltalk, Ruby, Python, Perl) it's easy, but then it's basically the same thing. For languages with a way of doing mixins (the aforementioned, C++) it's also pretty easy. But for languages like Java, oftentimes it's a choice between impossible and grossly inefficient. I've been dealing with a lot of Java lately. Certainly it's _possible_ to do in any language (Turing tarpit et al.), but the question is one of how much boilerplate is involved and how efficient it is. I think the latter point is important not only for the projects I've worked on, but also for how widely adopted any given pattern becomes; many people are fastidious about performance. The former is also important to whether it gets spread as a pattern or whether it gets packaged up in a library somewhere. And then there are some things like monoids which fall somewhere between idiom and pearl. Things like monoids are constructions from algebra. Abstract algebra and design patterns have a lot in common. They're based on the same idea, in fact: When a pattern keeps showing up, define it and give it a name so you can talk about it independently of any specific implementation. Or to put it another way, category theory is the pattern language of mathematics. Indeed. Though, IMO, there's a distinction between fairly banal things (e.g. monoids), and the other more interesting bits of category theory and abstract algebra. Monoids often occur by happenstance and so their triviality lends to being more like an idiom. Similarly, functors also tend to just happen. However, once you start getting into applicative functors, natural transformations, and the like, you've made a step from incidentally using a ubiquitous pattern of mathematics, to making a concerted effort at abstraction. -- Live well, ~wren ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe