Re: [Haskell-cafe] [Haskell] ANNOUNCE: planar-graph-1.0
On 28 April 2012 11:34, Christian Höner zu Siederdissen wrote: > Hi, > > one minor correction: >> This probably won't be of many use to people > for bioinformatics I'd disagree ;-) I'll take a look at your library. > > (for example, RNA /secondary/ structure forms a planar graph) I stand corrected! -- Ivan Lazar Miljenovic ivan.miljeno...@gmail.com http://IvanMiljenovic.wordpress.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANNOUNCE: planar-graph-1.0
On 28 April 2012 11:38, Felipe Almeida Lessa wrote: > Hello! > > I'm sorry if this is a dumb question, I was just reading the API docs, > but: what happens if one by one I add all edges of a non-planar graph > using addEdge? Are there any sanity checks that would tell me "sorry, > but your graph isn't planar", or would it just give me wrong answers? Wrong answers. I'm assuming you have *some* intelligence :p The original plans were to have Maybe variants that would perform such sanity checks, but as I was going for performance (as my supervisor is of the opinion that if it isn't C it isn't worth considering for pure performance reasons) the default versions didn't include them, and it slipped my mind until you just reminded me :) I can add them in if anyone wants them: what it entails is to add the edge and then perform planarity testing [3]; this can get expensive if the graph is large (I did once work out an approach that involved just checking the new face[s], but I don't recall what it was or whether it was correct). [3]: http://en.wikipedia.org/wiki/Planarity_testing (My rationale for this library was to implement a graph-generating algorithm; I knew what the ordering was, so I didn't need any "will adding this keep it planar" checks.) -- Ivan Lazar Miljenovic ivan.miljeno...@gmail.com http://IvanMiljenovic.wordpress.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANNOUNCE: planar-graph-1.0
Hello! I'm sorry if this is a dumb question, I was just reading the API docs, but: what happens if one by one I add all edges of a non-planar graph using addEdge? Are there any sanity checks that would tell me "sorry, but your graph isn't planar", or would it just give me wrong answers? Cheers, =) -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANN: unfoldable-0.4.0
On 4/26/12 3:52 PM, Roman Cheplyaka wrote: * Tillmann Rendel [2012-04-26 21:34:21+0200] Hi, Sjoerd Visscher wrote: Just as there's a Foldable class, there should also be an Unfoldable class. This package provides one: class Unfoldable t where unfold :: Unfolder f => f a -> f (t a) Just to be sure: That's not a generalization of Data.List.unfoldr, or is it somehow? It seems to be -- see https://github.com/sjoerdvisscher/unfoldable/blob/master/src/Data/Unfoldable.hs#L84 (although that is much more complicated than Data.List.unfoldr) I must admit I'm a bit weirded out by the (Bounded a, Enum a) restriction on the Either, tuple, and Constant instances. Why not just use Unfoldable a, or have a class specifically devoted to unfolding * types? -- Live well, ~wren ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANNOUNCE: planar-graph-1.0
Good work, Ivan. Despite your numerous previous pointers, I still haven't look at this API. I'm glad to see this release, it's great motivation and I'll probably look through it this weekend. Thanks for all the graph library work you do, Thomas On Fri, Apr 27, 2012 at 4:07 PM, Ivan Lazar Miljenovic wrote: > I uploaded this [1] yesterday, posted the blog article [2] about it... > but forgot to send a message to the lists! > > [1]: http://hackage.haskell.org/package/planar-graph > [2]: http://ivanmiljenovic.wordpress.com/2012/04/27/announcing-planar-graph/ > > planar-graph is an implementation of, strangely enough, planar graphs > (that is, a graph that contains an embedding on a surface, can be > drawn with no edge crossings and has a specific ordering of edges). > It handles graphs on planes and spheres, but I'm not sure about other > surfaces (and there seems to be little demand for such). > > This probably won't be of many use to people, but as I described in > the blog post, I've been using this as a test bed for graph library > design (specifically usage of abstract node/edge identifiers, using > half-edges and the serialisation/encoding setup). > > -- > Ivan Lazar Miljenovic > ivan.miljeno...@gmail.com > http://IvanMiljenovic.wordpress.com > > ___ > 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] ANNOUNCE: planar-graph-1.0
I uploaded this [1] yesterday, posted the blog article [2] about it... but forgot to send a message to the lists! [1]: http://hackage.haskell.org/package/planar-graph [2]: http://ivanmiljenovic.wordpress.com/2012/04/27/announcing-planar-graph/ planar-graph is an implementation of, strangely enough, planar graphs (that is, a graph that contains an embedding on a surface, can be drawn with no edge crossings and has a specific ordering of edges). It handles graphs on planes and spheres, but I'm not sure about other surfaces (and there seems to be little demand for such). This probably won't be of many use to people, but as I described in the blog post, I've been using this as a test bed for graph library design (specifically usage of abstract node/edge identifiers, using half-edges and the serialisation/encoding setup). -- Ivan Lazar Miljenovic ivan.miljeno...@gmail.com http://IvanMiljenovic.wordpress.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [Haskell] ANN: Portackage - a hackage portal
Hi Derek, Thanks for your comments. Yes, I am probably going to focus on making it work as a web service and stay away from platform-specific mobile apps. Not been thinking mobile much at all, since the quantities of data are taxing even to my laptop, and also I'm inclined to believe people are mostly at a laptop or desktop when coding Haskell. However, I'm planning to try server-side sorting and filtering, and compare performance. No DB is used on the server yet, but it would be simple enough I suppose -- all this is quite new territory for me. Also my shared hosting resource limits may become a problem if this gets a lot of use. On the other hand, was planning to use persistence (cookies i guess?) to save the data on the client, so that patches based on Hackage RSS could be applied incrementally. Also, I think the sorting could be faster by sending per-column lists of indices. But maybe it is just the browser rendering which is taking all the time? I'll take this opportunity to announce a few improvements: - shift-click a row to see the Hackage page (bare click does nothing) - per-column filtering widgets Presently working on getting the "last updated" column, this information is not in a .cabal file but I'm hoping it is in the TAR metadata... The link again: http://www.fremissant.net/portackage A. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Uploading a new hsc2hs
On Wed, Apr 25, 2012 at 06:57:14PM -0700, Thomas DuBuisson wrote: > On Wed, Apr 25, 2012 at 5:27 PM, Antoine Latter wrote: > > On Wed, Apr 25, 2012 at 4:59 PM, Thomas DuBuisson > > wrote: > >> Warning: > >> > >> I, not the maintainer of hsc2hs, will be uploading a trivial fix for > >> hsc2hs to hackage (new build deps). Even after public attempts to > >> contact anyone in charge of hsc2hs (last January) there still has been > >> no word. Speak now or forever hold your peace. > >> > > > > I don't think I've ever installed hsc2hs from Hackage as it ships with GHC. > > Fair point, and Ian has been the one pushing patches to the repo > lately. Ian - any objections to me bumping to version 0.68 and > uploading that to hackage? I have no objections. Thanks Ian ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Annotations in abstract syntax tree
For simple datatypes like this, GHC can derive the Functor implementation for you: {-# LANGUAGE DeriveFunctor #-} data ExprF r = deriving (..., Functor) See http://www.haskell.org/ghc/docs/7.0.4/html/users_guide/deriving.html -- ryan On Fri, Apr 27, 2012 at 5:40 AM, Stefan Holdermans wrote: > Romildo, > > > I could write the (Functor ExprF) instance: > > > > instance Functor ExprF where > >fmap f expr = case expr of > >Num n -> Num n > >Var v -> Var v > >Bin op x y -> Bin op (f x) (f y) > > Yes, excellent. That'll do. > > Cheers, > > Stefan > > ___ > 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] Automatic discovery of tests
Hi, trying to learn haskell and the associated build env. I come from a java/scala world so trying to understand the how to invoke tests. Have a cabal file that invokes a main function to execute a test. But wondering if there is any automatic discovery of tests as per junit. I have seen test-framework-th but to me that implies putting a testGroupGenerator into each module. Am i correct about that and if so is there an example of calling multiple modules tests ? Or is there a better way just to invoke specific functions prefixed with case_ prop_ etc in the entire src/test directory of the cabal build ? Thanks ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [Haskell] ANN: Portackage - a hackage portal
Excuse the delay, I have no home internet. > On Fri, Apr 27, 2012 at 1:16 AM, wrote: > Great idea. Maybe the format can start as compactly as possible, > i.e. 1 entry per line to make it easy to browse as many entries > as possible in one page. > > It looks as though disabling just the dependencies would go a > long way to accomplish that. Yep, and in fact the version I uploaded while reading your message has the deps column elided (and one or two others). Enforcing single-line rows is a but a few tweaks away. The thing is, the module namespace was the main motivator for this project, so I'm also seeing whether I can get away with a single view, package-oriented as presently, and still give good focus to the modules names. Soon I hope to include "accordion" views of the module namespace, with cookie-based (?) persistent state so user's collapse/expand tree state is preserved. > I'd like to vote to make the synopsis to be the second column. > > will each column type have an enable/disable ? I like the idea (although that one wasn't in the upload). Hopefully when I explore the JavaScript UI tools a bit more, the columns (key structure) will be totally configurable by drag-and-drop, with columns sizable, and keys selected from a listbox. (?) stuff like that > it's probably best if a click on a specific target, say the actual > name of the package, sends you to the hackage entry instead of a > click anywhere on the row. I find myself clicking on the page > by accident and it sending me off to some random hackage entry. :) That's a feature! But seriously, you're right, and as a bonus the links can be specific to the columns (package -> hackage, modules -> API pages, homepages -> hps, maintainer -> sendto [1]). (A 2-finger or Mod- click anywhere on a row might still be nice, but a bare tap is admittedly way too accident prone with touch input.) > I really like the idea - makes your hackage surfing > much more enjoyable ! > > Brian And thank-you for sharing your thoughts! I'm committed to improving it, until the ideas run out. > On Fri, Apr 27, 2012 at 4:12 AM, Christoph Breitkopf > wrote: > this already looks great. So here's my wish-list, in case you have > too much time on yours hands ;-) Thanks! Yes I suppose I do have too much time on my hands, but the pain of that is conterbalanced by all the excitement. > Quality/popularity indicators (I'm aware that some of these are > real work and better provided by hackage itself): > - used by how many other packages (number of edges to that package >in the dependency graph of all packages) > - haddock coverage, test coverage, etc. > - like, +1, whatnot button > - link to issue tracker, if there is one If there's interest, this could become integrated with hackage at some point in the future. Next thing is to get a "last upload" field which can replace the version field. The codependency graph :) would be a nice metric to add, I'll look into it. I remember seeing a package that does this someplace on hackage. The +1 button is a good one! In short I'll try to implement all these ideas, thanks to you both for the encouraging comments. -Andrew [1] I omitted the maintainer column, thinking its inclusion might be harmful, making the emails so easy for a bot to collect. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Printing call site for partial functions
On Thu, Apr 26, 2012 at 12:20 AM, Simon Peyton-Jones wrote: > Tristan Allwood got quite a long way with this a couple of years ago. > http://research.microsoft.com/en-us/um/people/simonpj/papers/stack-trace/DebugTraces.pdf While stack traces are undoubtably useful, I think this is a different problem. At least the one I'm thinking of is. It's probably never going to be reasonable to get a whole stack trace on every call to a logger, but all that's actually needed is the direct call site. That's a different (and much simpler!) problem. And at least in my case, the logging and exception functions are all pure, so using currentCallStack under an unsafePerformIO would be sketchy. On Thu, Apr 26, 2012 at 7:05 AM, Joachim Breitner wrote: > using TH (which I only reluctantly advocate for general usage) you can > get good location information behaviour, see Yeah, this is the TH solution I mentioned. It requires boilerplate at every call site and put a TH dependency on every module (which seems to slow down compilation quite a lot!), but on the other hand it *does* provide zero overhead caller information. I still prefer my hacky preprocessor, even though I don't like it much either. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Printing call site for partial functions
On Thu, Apr 26, 2012 at 5:05 PM, Joachim Breitner wrote: > Hi, > > Am Mittwoch, den 25.04.2012, 18:36 +0300 schrieb Michael Snoyman: >> I'm sure there are many better ways to approach the problem, and I >> can't speak to the complexity of implementation within GHC. I *can* >> say, however, that this would have saved me a lot of time in the >> example I gave above, and I'd bet many Haskellers have similar >> stories. This could be a huge debugging win across the board. > > using TH (which I only reluctantly advocate for general usage) you can > get good location information behaviour, see > http://hackage.haskell.org/packages/archive/stm-stats/0.2.0.0/doc/html/Control-Concurrent-STM-Stats.html#v:trackThisSTM > (and its source) for one example. One would use this approach maybe with > http://hackage.haskell.org/packages/archive/safe/0.3.3/doc/html/Safe.html#v:headNote > > Greetings, > Joachim > > > -- > Joachim Breitner > e-Mail: m...@joachim-breitner.de > Homepage: http://www.joachim-breitner.de > Jabber-ID: nome...@joachim-breitner.de > > ___ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > We actually use a similar technique in Yesod for logging[1]. But it requires actively using it in all libraries. In other words, unless the author of the library in question explicitly used $headLoc, this wouldn't help. [1] http://hackage.haskell.org/packages/archive/yesod-core/1.0.1.1/doc/html/Yesod-Core.html#v:logDebug ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Annotations in abstract syntax tree
Romildo, > I could write the (Functor ExprF) instance: > > instance Functor ExprF where >fmap f expr = case expr of >Num n -> Num n >Var v -> Var v >Bin op x y -> Bin op (f x) (f y) Yes, excellent. That'll do. Cheers, Stefan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Annotations in abstract syntax tree
Romildo, > How should an instance of (Functor ExprF) be defined? It is not shown in > the thesis. It's actually quite straigtforward: instance Functor ExprF where fmap _ (Num n) = Num n fmap _ (Var x) = Var x fmap f (Bin op l r) = Bin op (f l) (f r) As expected you get: > cata exprEval (runExpr (1+2*3)) 7.0 HTH, Stefan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Annotations in abstract syntax tree
On Fri, Apr 27, 2012 at 08:39:23AM -0300, romi...@malaquias.dhcp-GERAL wrote: > On Thu, Apr 26, 2012 at 10:21:36AM +0200, José Pedro Magalhães wrote: > > Hi Romildo, > > > > If I understand correctly, you now want to add annotations to > > mutually-recursive datatypes. The annotations package supports that. > > Section 8 of our paper [1] gives an example of how to do that, and also > > Chapter 6 of Martijn's MSc thesis [2]. > > > > Let me know if these references do not answer your question. > > I am reading Martijn's MSc thesis and trying some code he presents. In > secton 5.1 he presents catamorphisms over fixed points. > > The code I am trying is attached. > > When evaluating the expression > > cata exprEval (runExpr (1+2*3)) > > I am getting the following error: > > No instance for (Functor ExprF) > arising from a use of `cata' > Possible fix: add an instance declaration for (Functor ExprF) > In the expression: cata exprEval (runExpr (1 + 2 * 3)) > In an equation for `it': it = cata exprEval (runExpr (1 + 2 * 3)) > > How should an instance of (Functor ExprF) be defined? It is not shown in > the thesis. [...] > type Id = String > > data Op = Add | Sub | Mul | Div > deriving (Show) > > data ExprF r = Num Double > | Var Id > | Bin Op r r >deriving (Show) I could write the (Functor ExprF) instance: instance Functor ExprF where fmap f expr = case expr of Num n -> Num n Var v -> Var v Bin op x y -> Bin op (f x) (f y) Romildo ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Annotations in abstract syntax tree
On Thu, Apr 26, 2012 at 10:21:36AM +0200, José Pedro Magalhães wrote: > Hi Romildo, > > If I understand correctly, you now want to add annotations to > mutually-recursive datatypes. The annotations package supports that. > Section 8 of our paper [1] gives an example of how to do that, and also > Chapter 6 of Martijn's MSc thesis [2]. > > Let me know if these references do not answer your question. I am reading Martijn's MSc thesis and trying some code he presents. In secton 5.1 he presents catamorphisms over fixed points. The code I am trying is attached. When evaluating the expression cata exprEval (runExpr (1+2*3)) I am getting the following error: No instance for (Functor ExprF) arising from a use of `cata' Possible fix: add an instance declaration for (Functor ExprF) In the expression: cata exprEval (runExpr (1 + 2 * 3)) In an equation for `it': it = cata exprEval (runExpr (1 + 2 * 3)) How should an instance of (Functor ExprF) be defined? It is not shown in the thesis. Romildo {-# LANGUAGE StandaloneDeriving #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE UndecidableInstances #-} module Annot where newtype Fix f = In { out :: f (Fix f) } deriving instance Show (f (Fix f)) => Show (Fix f) data Ann x f a = Ann x (f a) deriving (Show) instance Functor f => Functor (Ann x f) where fmap f (Ann x t) = Ann x (fmap f t) type Algebra f a = f a -> a cata :: Functor f => Algebra f a -> Fix f -> a cata f = f . fmap (cata f) . out module Expr where import Annot type Id = String data Op = Add | Sub | Mul | Div deriving (Show) data ExprF r = Num Double | Var Id | Bin Op r r deriving (Show) newtype Expr = Expr { runExpr :: Fix ExprF } deriving (Show) instance Num Expr where Expr x + Expr y = Expr (In (Bin Add x y)) -- (+) = ((Expr . In) .) . (. runExpr) . Bin Add . runExpr Expr x - Expr y = Expr (In (Bin Sub x y)) -- (-) = (Expr . In) .: (Bin Sub `on` runExpr), where infixr 9 .: ; (.:) = (.) . (.) Expr x * Expr y = Expr (In (Bin Mul x y)) abs = undefined signum = undefined fromInteger = Expr . In . Num . fromInteger instance Fractional Expr where Expr x / Expr y = Expr (In (Bin Div x y)) fromRational= Expr . In . Num . fromRational data Bounds = Bounds Int Int deriving (Show) newtype PosExpr = PosExpr { runPosExpr :: Fix (Ann Bounds ExprF) } deriving (Show) exprEval :: Algebra ExprF Double exprEval expr = case expr of Num n -> n Var v -> 0 Bin op x y -> let g = case op of Add -> (+) Sub -> (-) Mul -> (*) Div -> (/) in g x y ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANN: HandsomeSoup-0.3: CSS selectors for HXT
Why do you make your own overlay to download files via HTTP? HXT has backends (hxt-http or hxt-curl) to do that. Le 27 avril 2012 04:16, aditya bhargava a écrit : > *Homepage:* http://egonschiele.github.com/HandsomeSoup > *On Hackage:* http://hackage.haskell.org/package/HandsomeSoup > > *Blurb:* > > HandsomeSoup is the library I wish I had when I started parsing HTML in > Haskell. > It is built on top of HXT and adds a few functions that make is easier to > work with HTML. > Most importantly, it adds CSS selectors to HXT. The goal of HandsomeSoup > is to be a complete CSS2 parser for HXT (it is very close to this right > now). > > > > -- > adit.io > > ___ > 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