Re: [Haskell-cafe] Stackage with GHC 7.8 has started
Michael, I see one of my packages is on that list, because of the upper bound on template-haskell. I would love the raise the upper bound, but of course only if it will actually build. Can I download a binary version snapshot GHC 7.8 somewhere so I can test and apply changes accordingly? I actively avoid building GHC from source. Thanks, Sebastiaan On Oct 13, 2013, at 5:50 PM, Michael Snoyman mich...@snoyman.com wrote: Hi everyone, I wanted to announce that FP Complete is now running a Jenkins job to build Stackage with GHC 7.8. You can see the current results in the relevant Github issue[1]. Essentially, we're still trying to get version bounds updated so that a build can commence. I'd like to ask two things from the community: * If you have a package with a restrictive upper bound, now's a good time to start testing that package with GHC 7.8 and relaxing those upper bounds. It would be great if, when GHC 7.8 is released, a large percentage of Hackage already compiled with it. * If you have a package on Hackage that is not yet on Stackage, now's a great time to add it. We're going to be doing daily builds against three versions of GHC (7.4.2, 7.6.3, and 7.8), which will help ensure your packages continue to build consistently. Michael [1] https://github.com/fpco/stackage/issues/128 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Seeking Control.Lens Combinator
Charles, I know you specifically asked for a Control.Lens combinator and I don't have one for you, but I take the opportunity to show you how easy this is using fclabels: tupleUp :: f :- a - f :- b - f :- (a, b) tupleUp a b = point $ (,) $ L.fst - a -- L.fst, L.snd are lenses from Data.Label.Base * L.snd - b In fclabels you can use the Applicative instance (and Alternative for multi-constructor cases) to derive views like this. If you look at the structure it'll become clear how easily this scales up to different types of views. This particular example uses total monomorphic lenses, but also works for partial lenses and polymorphic updates. Maybe there is a similar way in Control.Lens to do this. Sebastiaan On Oct 5, 2013, at 1:23 AM, Charlie Paul charli...@gmail.com wrote: Hello, I'm looking for a combinator along the lines of () :: Lens' a b - Lens' a b' - Lens' a (b,b') I can see how it could lead to lenses that don't follow the laws, but for Lenses which are somehow independent (like _1 and _2), it works perfectly well. Is there a way in lens to specify this independence? Thank you, Charles Paul ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Using lenses
Simon, I've used lenses to manipulate URIs represented as strings in a structured way, like: modify (port . iso parsePrintUri) (+10) http://localhost:8070/index.html; Of course using fclabels and not lens ;-) Sebastiaan On Oct 3, 2013, at 10:07 AM, Simon Peyton-Jones simo...@microsoft.com wrote: (I sent this to ‘libraries’ but Kim-Ee suggested adding Café, where so many smart people hang out.) Friends Some of you will know that I’ve promised to give a talk about Edward’s lens library at the Haskell Exchange in London next Wednesday (9th). I did this to give everyone (including me) a break from GHC hackery, and also to force me to learn about this lens voodoo that everyone is twittering about. Edward generously gave me quite a bit of one-to-one attention last week (my hair is still standing on end), but this message is to ask your help too. Specifically, I’d like to give some compelling use-cases. If you are using the lens library yourself, could you spare a few minutes to tell me how you are using it? I expect to cover Lens and Traversal but not Prism. The use-case everyone starts with is nested records, but I’d like to go beyond that. The next levels seem to be: · Lenses as views of data that isn’t “really there” e.g. regarding a record with rectangular coordinates as having polar coordinates too. · Lenses and Traversals that focus on elements of finite maps (Control.Lens.At) What else? I’m sure you are using them in all sorts of cool ways that I would never think of, and I’d love to know. Please don’t tell me anything secret! To give everyone the benefit I may just concatenate all the replies and send to you all, so please say if you don’t want me to do that with yours. And don’t burn too many cycles on this...I don’t want to waste your time, and I can always get back to you if I can’t understand what you say. Sooner is better than later...Weds is coming. Simon “Edward’s prophet” PJ ___ Libraries mailing list librar...@haskell.org http://www.haskell.org/mailman/listinfo/libraries ___ 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] [ANN] fclabels 2.0
Hello everyone, I’m excited to announce a brand new major version of fclabels. This library provides first class labels that can act as bidirectional record fields. The labels are implemented as lenses. This new version contains some interesting new features like support for polymorphic updates and lens derivation for GADTs. Furthermore the API has been cleanup significantly and should be easier to work with. You can read everything about this release at: http://fvisser.nl/post/2013/okt/1/fclabels-2.0.html All feedback more than welcome! -Sebastiaan -- On Hackage: http://hackage.haskell.org/package/fclabels-2.0 Source on github: https://github.com/sebastiaanvisser/fclabels Full changelog: https://github.com/sebastiaanvisser/fclabels/blob/master/CHANGELOG ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Using MonadFix to tie the knot with STM
On Feb 12, 2011, at 6:08 PM, Antoine Latter wrote: On Sat, Feb 12, 2011 at 8:47 AM, Sebastiaan Visser hask...@fvisser.nl wrote: Hi all, During a little experiment I discovered there is no MonadFix instance available for the STM monad. Is this absence the consequence of some deep restriction of how STM works or 'just accidental'? Is there some way I could derive this instance? If you port `fixST` to the STM monad, it seems to work fine at first glance: http://hpaste.org/43915/fixstm But I would want someone else's opinion on it to make sure I'm not doing something like introducing lazy STM values that violate atomicity, or something. The strict `case` on the return value makes me feel pretty good about it. Antoine Interesting! This approach seems to work for my examples as well. Unfortunately I do not have enough insides into STM to be able to tell if the code is correct. Does someone else have an opinion on this? When not I might propose adding the instance to the STM package. Sebastiaan For those who are interested and may know other ways to solve my problem, I'm trying to tie the knot in a graph by using transactional variables as the edges between nodes. I'm trying to do this in a rather generic way: {-# LANGUAGE DeriveFunctor, DeriveFoldable, DeriveTraversable, StandaloneDeriving, DoRec #-} module Graph where import Control.Applicative import Control.Concurrent.STM import Control.Monad.Fix import Data.Maybe import Data.Foldable import Data.Traversable import Prelude hiding (mapM) import qualified Data.Map as M instance MonadFix STM where mfix = error I need this instance! -- What to do? -- A single node is a graph, has a list of both incoming and outgoing edges. data Node edge = Node { nodeId :: NodeId , payload :: String , incoming :: [edge] , ougoing :: [edge] } deriving (Functor, Foldable, Traversable) type NodeId = String -- A graph with an index on the nodes by NodeId, parametrized with the type we -- want to used as the edge pointer. type Graph edge = M.Map NodeId (Node edge) -- Type level fixed point combinator with a TVar annotation. newtype TFix f = TIn { tout :: TVar (f (TFix f)) } -- Take a graph that uses NodeIds as edges and recursively transform it into a -- graph with TVars to the neighbouring nodes in the edges. tieTheKnot :: Graph NodeId - STM (Graph (TFix Node)) tieTheKnot untied = do rec tied - (mapM . mapM) (\nodeid - TIn $ newTVar (tryLookup nodeid tied)) untied return tied -- Helper function to lookup a pre-tied node from a graph, throws an error when -- the edge could not be resolved. This should, of course, not happen! tryLookup :: NodeId - Graph (TFix Node) - Node (TFix Node) tryLookup i = fromJust (error msg) . M.lookup i where msg = tieTheKnot: Lookup error, input is an incomplete graph. Thanks in advance, -- Sebastiaan Visser http://www.silkapp.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] Using MonadFix to tie the knot with STM
Hi all, During a little experiment I discovered there is no MonadFix instance available for the STM monad. Is this absence the consequence of some deep restriction of how STM works or 'just accidental'? Is there some way I could derive this instance? For those who are interested and may know other ways to solve my problem, I'm trying to tie the knot in a graph by using transactional variables as the edges between nodes. I'm trying to do this in a rather generic way: {-# LANGUAGE DeriveFunctor, DeriveFoldable, DeriveTraversable, StandaloneDeriving, DoRec #-} module Graph where import Control.Applicative import Control.Concurrent.STM import Control.Monad.Fix import Data.Maybe import Data.Foldable import Data.Traversable import Prelude hiding (mapM) import qualified Data.Map as M instance MonadFix STM where mfix = error I need this instance! -- What to do? -- A single node is a graph, has a list of both incoming and outgoing edges. data Node edge = Node { nodeId :: NodeId , payload :: String , incoming :: [edge] , ougoing :: [edge] } deriving (Functor, Foldable, Traversable) type NodeId = String -- A graph with an index on the nodes by NodeId, parametrized with the type we -- want to used as the edge pointer. type Graph edge = M.Map NodeId (Node edge) -- Type level fixed point combinator with a TVar annotation. newtype TFix f = TIn { tout :: TVar (f (TFix f)) } -- Take a graph that uses NodeIds as edges and recursively transform it into a -- graph with TVars to the neighbouring nodes in the edges. tieTheKnot :: Graph NodeId - STM (Graph (TFix Node)) tieTheKnot untied = do rec tied - (mapM . mapM) (\nodeid - TIn $ newTVar (tryLookup nodeid tied)) untied return tied -- Helper function to lookup a pre-tied node from a graph, throws an error when -- the edge could not be resolved. This should, of course, not happen! tryLookup :: NodeId - Graph (TFix Node) - Node (TFix Node) tryLookup i = fromJust (error msg) . M.lookup i where msg = tieTheKnot: Lookup error, input is an incomplete graph. Thanks in advance, -- Sebastiaan Visser http://www.silkapp.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Strong version of 'local' for reader monad
Hey Brent, Of course, because your type signature has no valid implementation, the expected semantics are hard to guess. Why should strongLocal bother about the MonadReader constraint on m1 anyway? Are you internally combining it with 'ask' or another 'local'? The monads are potentially different, so m1 has to be run inside m2. A more specific version of strongLocal could be: strongLocalReader :: MonadReader r2 m2 = (r2 - r1) - Reader r1 a - m2 a strongLocalReader f m = do r - asks f return (runReader m r) Or you can generalize it to every 'Runnable' monad: class Monad m = Runnable m where run :: m a - a strongLocalRunnable :: (MonadReader r2 m2, Runnable m1) = (r2 - r1) - (r1 - m1 a) - m2 a strongLocalRunnable f m = do r - asks f return (run (m r)) Is this what you want to express? Cheers, Sebastiaan On Dec 13, 2010, at 9:30 PM, Brent Yorgey wrote: Hi all, Today I wanted this function strongLocal :: (MonadReader r1 m1, MonadReader r2 m2) = (r2 - r1) - m1 a - m2 a Of course, after staring at this type for ten seconds I realized that it cannot be implemented. But I wondered whether anyone has any pointers to anything related, or if anyone has good ideas for a reasonable interface that would allow this. -Brent ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANNOUNCE: arrow-list. List arrows for Haskell.
On Nov 7, 2010, at 1:40 AM, Sebastian Fischer wrote: On Nov 6, 2010, at 10:00 PM, Sebastiaan Visser wrote: List arrows are a powerful tool when processing XML, building query languages and lots of other domains that build on functions that might return more than one value as their output. Interesting. Do you plan to write some examples that show * how to use ListArrows, Yes, I certainly am. Although, time is currently not on my side. I'm planning to write up a blog post about using list arrows for XML processing. * differences to using the list monad, and * when using ListArrow is preferrable? Currently I'm playing with the idea of a translation of XML list arrows in Haskell to DOM operations in JavaScript. The lack of ArrowApply (the full power of monads) allows you to inspect your computations, this makes translations to other languages possible. I'm interested to see something like this worked out although I have some rough ideas like monads are more powerful and arrows may allow stronger reasoning and more efficient implementations. Can you substantiate these general points for the concrete case of ListArrow vs list monad? Beside the fact that, after playing with them for while, I find arrows more convenient to use than monads, the ability to inspect their structure can help you to optimize them. Maybe this sounds weird on the Haskell mailing list, but at Silk[1] we have a full implementation of (functional reactive) list arrows in JavaScript. The arrows build up an AST of operations that we statically optimize to a more efficient form. This is needed because JavaScript itself is not going to fuse intermediate list for you. I'm reinventing all of this in Haskell now to gain more insight in what we've actually done in JavaScript. :-) I assume your implementation is *not* more efficient than the list monad as it builds on ListT. That is entirely true. But this is only implementation, different implementations may be possible that are more efficient. As long as ArrowApply is not involved static optimization might be possible that fuses intermediate lists, as far as the compiler is not already doing so. I'm also planning to investigate whether it is possible (useful) to perform the list computations (the map in concatMap) in parallel. I'm not sure if someone has already tried this for list monads. Sebastian Sebastiaan [1] https://blog.silkapp.com/2009/12/reinventing-xslt-in-pure-javascript/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] ANNOUNCE: arrow-list. List arrows for Haskell.
Hi all, Live from the Hackaton in Ghent, Belgium, I present the first release of the arrow-list[1,2] package. List arrows are a powerful tool when processing XML, building query languages and lots of other domains that build on functions that might return more than one value as their output. This package is inspired by the arrow combinators provided by the HXT package, but in my opinion list arrows deserve to be on Hackage on their own. Cheers, Sebastiaan [1] http://hackage.haskell.org/package/arrow-list [2] https://github.com/sebastiaanvisser/arrow-list (package description) List arrows for Haskell. This small Haskell library provides some type class, types and functions to work with list arrows. List arrows represent computations that may return multiple outputs. Making functions that return lists an instance of both the `Category` and `Arrow` type classes allow you to easily compose multiple computations into one with standard building blocks. This package provides: - A type class `ArrowList` for embedding functions that produce a list of outputs into _some_ list arrow. - A list of utility functions for working with list-arrows, these functions are based on the `ArrowList` type class so they are not tied one specific instance. - A concrete list arrow type that is implemented as a `Kleisli` arrow over the `ListT` list monad transformer. In short, you can both build pure list arrows and list arrows that produce tributary effects. - Not list arrow specific: A type class `ArrowKleisli` for embedding monadic computations into an arrow. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] DSL libraries
Dupont, The `AwesomePrelude' (we apologize for this name) is a very experimental project that is not a workable library or executable at all. You can better consider it to be a `bunch of code' with some interesting ideas and some interesting potential. At least my branch[1] runs on my machine and I'm still able to produce javascript code. But don't expect it to solve any of your problems. ;-) We (at least I) still have some ideas for this project and hope we can someday revive it. Cheers, Sebastiaan [1] https://github.com/sebastiaanvisser/AwesomePrelude On Nov 4, 2010, at 6:51 PM, Dupont Corentin wrote: Nobody had the compilation messages I had? -- Forwarded message -- From: Dupont Corentin corentin.dup...@gmail.com Date: Tue, Nov 2, 2010 at 2:30 PM Subject: [Haskell-cafe] DSL libraries (Was: Map constructor in a DSL) To: steffen steffen.sier...@googlemail.com, haskell-cafe@haskell.org Hello Steffen, can you compile AwesomePrelude? I've got error messages (see below). By the way, I've looked at some DSLs made in Haskell, if I don't mistake there are lots of similarities between them. There similarities could be put in a library to help the implementors of a DSL, more or less like AwesomePrelude. Is there already packages on Hackage dealing with that? Cheers, Corentin AwesomePrelude compilation error: I'm using GHC 6.12.1. cd tomlokhorst-AwesomePrelude-9819315 cabal install (...) Warning: Lang.Haskell: Instances of type and data families are not yet supported. Instances of the following families will be filtered out: H Then, when trying with a very simple GATD in GHCI, I've got: interactive: HSAwesomePrelude-0.1.0.o: unknown symbol `AwesomePreludezm0zi1zi0_ CompilerziLiftDefinitions_inline_closure' ghc: unable to load package `AwesomePrelude-0.1.0' On Thu, Oct 28, 2010 at 2:02 PM, steffen steffen.sier...@googlemail.com wrote: I think you would love to have a look at AwesomePrelude[1] or a fork of AwesomePrelude using associated types[2] Some more background information by Tom Lokhorst [3][4]. [1] http://github.com/tomlokhorst/AwesomePrelude [2] http://github.com/urso/AwesomePrelude [3] http://tom.lokhorst.eu/2009/09/deeply-embedded-dsls [4] http://tom.lokhorst.eu/2010/02/awesomeprelude-presentation-video On 28 Okt., 12:09, Dupont Corentin corentin.dup...@gmail.com wrote: Thank you for your rich responses. Indeed I think I miss some thinks in my DSL, that would make things easier to deal with lists and first class functions. I don't really know what for now. Perhaps a List Constructor? Or a constructor on functions like yours Ryan? EAp :: Exp ref (a - b) - Exp ref a - Exp ref b It's from which DSL? It is accessible on the net? Chris suggested me that I can only define the Foldr constructor and deduce Map from it. But maybe I have to add a List constructor for that. But in the suggestions from Ryan and Brandon I don't understand why I should add an extra type parameter and what it is! Steffen: Wow nice. I'll integrate that ;) I'm also looking at the Atom's DSL to get inspiration. Something I don't understand in it is that it has two languages, on typed: data E a where VRef:: V a - E a Const :: a - E a Cast:: (NumE a, NumE b) = E a - E b Add :: NumE a = E a - E a - E a etc. And, along with it, an untyped counterpart: -- | An untyped term. data UE = UVRef UV | UConst Const | UCast Type UE | UAdd UE UE etc. What that for? What's the use of having beautiful GADT if you have to maintain an untyped ADT aside?? Corentin ___ Haskell-Cafe mailing list haskell-c...@haskell.orghttp://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: Who is afraid of arrows, was Re: [Haskell-cafe] ANNOUNCE: Haskell XML Toolbox Version 9.0.0
Gregory, I use arrows (especially list arrows) in a lot of my projects and find them (after some training) easier to work with than monands. Code that I write point-free using arrows generally contains fewer bugs than code I write in monadic style. On Oct 11, 2010, at 8:48 PM, Gregory Crosswhite wrote: Uwe, Thank you for your reply. On 10/11/10 6:20 AM, Uwe Schmidt wrote: I thing, this is not a question of functionality, it's a question of style. Of course everything in hxt could have been done with monads, but does this also mean: Everything must have been done with monads? No, but there is no point in using a formalism that adds complexity without adding functionality. Arrows are more awkward to use than monads because they were intentionally designed to be less powerful than monads in order to cover situations in which one could not use a monad. When your problem is solved by a monad there is no point in using arrows since an arrow require you to jump through extra hoops to accomplish the same goal. I think it is unfair to say that arrows add complexity over monads. This statement can only be true to people who actually know monads and do not know arrows. This has more to do with the direction of one's knowledge than the 'complexity' (whatever this means) of a programming abstraction. Don't see arrows a less restricted monads, see them as a generalization of functions, than it will all make sense. Use them in situations that need generalization of functions, not in cases that require the power of monads. Arrows are a generalisation of functions, so if you know all about working with functions you know (almost) all about working with arrows. When generalizing a pure algorithm, something like f3 . f2 . f1, or in Unix pipe style f1 f2 f3, you don't have to rewrite the code, you just generalize function composition. Yes, but the = operator lets you do the same thing with monads, and in fact I use it all the time to do point-free programming with monads, so this isn't at all an advantage that arrows have over monads. I'd rather use (.) for composition of expressions than (=) and I'd rather use the 'id' for identity than return. Writing my arrow computations point-free as if they were functions feels far less clumsy and a far more readable than monadic style. When constructing code, it is of course sometimes simpler to start with a point wise version and then refactor and rewrite it into a more compact point free version. The problem with arrows seems, that the arrow style forces to start with the point free style. And that may be the main hurdle in mind. No, that is not at all the problem with arrows. The problem with arrows is that they are more restrictive than monads in two respects. First, unlike monads, in general they do not let you perform an arbitrary action in response to an input. Second, they place restrictions on how you define the input arguments of the arrow because you can't feed the output of one arrow into to input of the next unless said input is captured in the arrows type. This restriction, though not always, can be very useful. This restriction allows you to do full inspection of the arrow expression. This inspection can in some cases be used to serialize an arrow computation of statically optimize it to a more efficient form. When you don't need the power of Monads (or ArrowApply) why use a formalism that does provide this power? That will only make it harder to reason about your program, which isn't quite the Haskell way. To be more concrete about my second point, suppose you have some monadic action f :: a - b - m c How would you structure this same action as an arrow? One thing that you could do is take one of the arguments and turn it into the input of the arrow: f' :: a - Arrow b c But now you can't feed the output of an arrow into the first argument. Alternatively, you could pack both arguments into the input of the arrow: f'' :: Arrow (a,b) c Great, but now you have made it more awkward to use f'' because you have to always pack the arguments into a tuple, so that for example if one of the arguments is a constant then you can no longer easily use currying. The advantage of f over both alternatives is that you don't have to waste any of your time fitting multiple input arguments into the input type of an arrow. In fact, if the first argument to f'' is usually a constant, then f'' is arguably more awkward to use in a point-free setting than f, because instead of being able to write a = f 42 = b You have to write something like a (const 42 id) f'' b Of course, if the first argument were *always* a constant then you could use f', but then you lose the ability to ever feed in the output of an arrow into the first argument. So in short, arrows force you to make choices and trade-offs that never come up when using monads.
Re: [Haskell-cafe] Removing alternate items from a list
Or, when lists had a decent eliminator defined in the Prelude (just like maybe for Maybe and either for Either): list :: b - (a - [a] - b) - [a] - b list d _ [] = d list _ f (x:xs) = f x xs fromList = list [] we could write the alternate function like this: alt :: [a] - [a] alt = list [] $ \a - (a:) . list [] (const alt) -- Sebastiaan On Jun 6, 2010, at 4:46 PM, R J wrote: What's the cleanest definition for a function f :: [a] - [a] that takes a list and returns the same list, with alternate items removed? e.g., f [0, 1, 2, 3, 4, 5] = [1,3,5]? The New Busy is not the old busy. Search, chat and e-mail from your inbox. Get started.___ 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] ANNOUNCE: Agata-0.2.0
Jonas, You can also derive (Co)Arbitrary instances automatically using the regular-extras package based on the Regular generic programming library. The advantage of using a library like Regular is that you do not have to write any Template Haskell code. The library generates a nice algebraic generic view on your datatype that you can use to write your generic functions. The Regular library itself of course uses TH internally, but this is done once and all datatype generic functions can piggy bag on the same TH derivation. For example, look at Generics.Regular.Functions.Arbitrary, this module is really concise. Nice work though! Gr, Sebastiaan On Apr 18, 2010, at 1:43 AM, Jonas Almström Duregård wrote: I'm pleased to announce Agata (Agata Generates Algebraic Types Automatically)! Avoiding excessive details, usage is best described by a small example: {-#LANGUAGE TemplateHaskell #-} import Test.QuickCheck import Test.AgataTH data X a b = X [Either a b] deriving Show data Y = Y deriving Show data Z = Z deriving Show $(agatath $ deriveall [''X,''Y,''Z]) main = sample (arbitrary :: Gen (X Y Z)) This code derives instances of Test.QuickCheck.Arbitrary for the data types X, Y and Z. http://hackage.haskell.org/package/Agata Regards Jonas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell.org re-design
On Mar 28, 2010, at 10:44 PM, Christopher Done wrote: This is a post about re-designing the whole Haskell web site. We got a new logo but didn't really take it any further. For a while there's been talk about a new design for the Haskell web site, and there are loads of web pages about Haskell that don't follow a theme consistent with Haskell.org's, probably because it doesn't really have a proper theme. I'm not a designer so take my suggestion with a grain of salt, but something that showed pictures of the latest events and the feeds we currently have would be nice. The feeds let you know that the community is busy, and pictures tell you that we are human and friendly. Anyway, I came up with something to kick off a discussion: http://haskell.org/haskellwiki/Image:Haskell-homepage-idea.png It answers the basic questions: • What's Haskell? • Where am I on the site? (Answered by a universally recognised tab menu) • What's it like? • How do I learn it? • Does it have an active community? • What's going on in the community? What are they making? • This language is weird. Are they human? -- Yes. The picture of a recent event can fade from one to another with jQuery. The colours aren't the most exciting, but someone who's a professional designer could do a proper design. But I like the idea of the site being like this; really busy but not scarily busy. Subsections of the site could use the header and footer and heading theme, but have a completely different primary-content layout. Probably sub-sections would need a left-nav. Keeping the design simple like this also makes it easy to theme the current Wiki to fit in with it seamlessly. Personally I don't have a problem with the existing site, functionally. It has all the stuff I want to look at. The only stuff that I had issue with as a newbie was finding The One Book I Should Read and The One Download I Should Get. The current site is starting to address this with a Download Haskell button. However, looking at it as a marketing site, it does look pretty lame and messy, and it gives you that impression of Haskell. So if people who own the site are going to redesign it, I thought I'd contribute a bit. Anyway, please contribute your ideas. (Again, I'm not a designer, so you don't need to pick at the aesthetics, a real designer can sort that out.) Cheers! Nice work, definitely beats the current version! A few remarks: - Please throw in a bit more color somehow. Like said before, this shade of gray is a bit depressive. - The more links are far to prominent. These links are not that important and form a very distractive part of the design. Maybe you can right-align them and make them less button-like. - I would recommend to use a bit more conservative font for the headers and the headlines. Why not stick with Helvetica, Gill Sans or Myriad Pro? - Don't use a bold font-face in running text. - Align the bottom of the tabs headers with the content frame? - Maybe you can make the right column less wide, making is more easy to focus on the main content? These remarks might help to make the overall appearance a bit less heavy. Your design is quite lean and quiet, which is good, but some of the details make it a bit messy. Gr, -- Sebastiaan Visser ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANN: Salvia-1.0.0
Nice! This is certainly worth it. I really liked the simplicity of the threadmanager package, it certainly was better than managing threads manually. But your concurrent-extra package seems to do a way better job, I'm certainly going to apply this patch. Thanks a lot guys! Groet, Sebastiaan On Mar 23, 2010, at 12:36 PM, Bas van Dijk wrote: On Sun, Mar 21, 2010 at 5:05 PM, Sebastiaan Visser sfvis...@cs.uu.nl wrote: Straight from Zurihac: I'm very pleased to announce the 1.0.0 release of the Salvia web server. Hoi Sebastiaan, (switching to English) I discovered a major space-leak in Network.Salvia.Impl.Server.start due to the use of threadmanager: When a request handler is forked the threadmanager internally maps the threadId to a status MVar. However when the request handler terminates this association is not deleted from the internal Map. This results in a major O(n) space-leak where n = the number of requests accepted. This space-leak can be visualized when you heap-profile the salvia-helloworld demo: salvia-helloworld +RTS -hy and perform some requests: $ for ((a=0; a1; a++)); do curl -s -o /dev/null localhost:8080; done You will then get the following heap profile which will clearly highlight the linear space-leak: http://bifunctor.homelinux.net/~bas/salvia-helloworld_ORIGINAL_1_requests.ps I fixed it by replacing threadmanager by Control.Concurrent.Thread[1] from Roel's and mines concurrent-extra. This module has the following advantages over threadmanager: * Simpler: We don't have the concept of a ThreadManager. So you don't need to make one and pass it to fork and wait. * More efficient: We don't keep an internal mapping from ThreadIds to status MVars. * Correct: threadmanager has a bug where it can potentially miss the termination of a thread. It doesn't block asynchronous exceptions before it forks the computation that will install the necessary exception handler before executing the given action. We correctly block asynchronous exceptions. Besides these advantages we have the ability to get the return value of the forked thread so you don't need a mutable variable. Besides replacing threadmanager I now manually delete the threadId of the request handler when it terminates. When I repeat the heap-profile you will now see a nice constant heap-usage: http://bifunctor.homelinux.net/~bas/salvia-helloworld_NEW_1_requests.ps I don't know how to attach my git patch to this email so I just copied my git repository to: http://bifunctor.homelinux.net/~bas/salvia/ I think you can just pull from there. Groeten, Bas [1] http://hackage.haskell.org/packages/archive/concurrent-extra/0.4/doc/html/Control-Concurrent-Thread.html ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] ANN: Salvia-1.0.0
Hi all, Straight from Zurihac: I'm very pleased to announce the 1.0.0 release of the Salvia web server. Salvia is a feature rich web server and web application framework that can be used to write dynamic websites in Haskell. From the lower level protocol code up to the high level application code, everything is written as a Salvia handler. This approach makes the framework extremely modular and extensible. This release include the following stack of packages: * salvia-protocol: Protocol stack containing URI, HTTP, Cookie and Mime. * salvia: Basic server interface and implementation. * salvia-extras: Additional server handlers and back end implementation. * salvia-sessions: Session and user management support. * salvia-websocket: Cutting edge HTML5 web socket support. * salvia-demo: Demo servers showing how to use Salvia. All the code is on Hackage[1] and the source repositories can be found on GitHub[2]. Most of the basic ideas of the previous Salvia release are still in these package, but all the code has been cleaned up considerably. There is now a very strong separation between interface and implementation making it more easy to plug-in new back-ends for your web application. To do a full install first run `cabal update' followed by `cabal install salvia-demo'. Now you can run the salvia-demo command and point your browser to http://localhost:8080/ . Thanks to the people that helped me with coding, suggestions and bug-reports. Any comments/suggestions are welcome! Have fun, -- Sebatiaan Visser [1] http://hackage.haskell.org/package/salvia (-protocol, -demo, etc) [2] http://github.com/sebastiaanvisser/salvia (-protocol, -demo, etc) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Hackage down
On Oct 19, 2009, at 12:18 PM, Ross Paterson wrote: On Mon, Oct 19, 2009 at 09:30:55AM +0100, Dougal Stanton wrote: Has not been responding for at least the last 12 hours. Is there somewhere to look for status reports on sysadmin details like this, so we can tell if - it's a scheduled down time - it's a problem but the admins know about it - etc etc. {hackage,darcs,cvs}.haskell.org has been up continuously for 6 days and is still working via ssh, but Apache isn't responding. Anyone any clue how to get the thing running again? We're trying to install a new Haskell-development machine here which is near impossible without the wonderful Hackage. Thanks, -- Sebastiaan Visser ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANN: fclabels-0.4.0 - First class accessor labels.
On Sep 8, 2009, at 11:54 PM, Henning Thielemann wrote: On Fri, 4 Sep 2009, Sebastiaan Visser wrote: Hello all, There are more package around that serve the same purpose (like the Lenses package which was uploaded a few days ago), but I'm convinced the simplicity and elegance of fclabels will strike you all. ;-) How does it compare to data-accessor and data-accessor-template? Please see this reddit thread for more info on this subject: http://www.reddit.com/r/haskell/comments/9hors/fclabels_first_class_labels_that_act_as/ -- Sebastiaan Visser ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] ANN: fclabels-0.4.0 - First class accessor labels.
Hello all, IFCP is a really inspiring place to hang/hack around with your fellow Haskell hackers. So, straight from Edinburgh, I proudly present a new release of fclabels[1,2], your favourite record selector package. This version is joint work with Chris Eidhof and Sjoerd Visscher. This package has been around for a while but has been changed almost entirely now. Naming is different and has a far more consistent usage. This library might look cryptic at first sight, but give it a try it is not that hard. There are more package around that serve the same purpose (like the Lenses package which was uploaded a few days ago), but I'm convinced the simplicity and elegance of fclabels will strike you all. ;-) The package description is included below. Documentation can be found in the package itself or on Hackage. Gr, -- Sebastiaan Visser [1] Hackage: http://hackage.haskell.org/package/fclabels [2] Github: http://github.com/sebastiaanvisser/fclabels/tree/master * package description * First class labels that act as bidirectional records fields. The labels are fully composable and can be used to get, set and modify part of datatypes in a consistent way. The label datatype, conveniently called `:-', is an instance of the `Category' type class meaning it has a proper identity and composition. The library has support for automatically deriving labels from record selectors that start with an underscore. Labels can be used in a pure functional setting or be applied to mutable state in some state monad. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Mapping over multiple values of a list at once?
Or, when the list is infinite, turn it into a some neat but cryptic State computation: avgs = (:) $ ((\d - sum d `div` 3) $ StateT (pure . splitAt 3)) * avgs test = evalState avgs [1,2..] -- Sebastiaan Visser On Aug 27, 2009, at 11:19 AM, Eugene Kirpichov wrote: How about this one? Should be pretty efficient. let mavg n xs = let (sum - seed,rest) = splitAt n xs in map (%n) . scanl (\a (p,n) - a+n-p) seed $ xs `zip` rest 2009/8/27 Patai Gergely patai_gerg...@fastmail.fm: For example, starting from [4,3,2,6,7] you need to find the averages of 4,3,2 and 3,2,6 and 2,6,7 resulting in [3,4,5] What is the most elegant way to do that? It's probably less elegant than tails, but very likely more efficient to keep track of running sums instead of summing the sublists over and over again. import Data.Ratio nsums n xs = map (% n) $ scanl (+) (sum (take n xs)) $ zipWith (-) (drop n xs) xs Gergely ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] ANN: jail-0.0.1 - Jailed IO monad
Hi all, I am very pleased to announce the first release of the jail[1,2] package. A jailed IO monad that can restrict filesystem access for your code. This package will soon be an integral part of the Salvia web server. (a new and improved Salvia will be released soon) Basic documentation of the jail package is included below. Any comments, suggestions, audits, etc. are welcome! Gr, -- Sebastiaan Visser [1] Source repo: http://github.com/sebastiaanvisser/jail/ [2] Hackage: http://hackage.haskell.org/package/jail Like all of us know, the IO monad from the System.IO module is a wild beast allowing all forms of insecure computations that can read, or even worse, alter the real world. Writing to sockets, deleting files or even launching missiles, its possibilities are endless. This library provides a special IO module that wraps all file and handle based IO operations from the System.IO module, but provides a possibility to run them in an restricted environment. When running a jailed IO computation a file path can be specified all IO operations will be checked against. Accessing files outside this directory is not allowed and results in a runtime error. Additionally, when running a jailed IO computation a whitelist of file handles can be specified that are accessible as well. For example, running some code with the permission to access all files within (and only within) my home directory and allowing to access the standard output and standard error can be enforced like this: Jail.run (Just /home/sebas) [stdout, stderr] yourUntrustworthyComputation Only allowing the code to access the standard input and nothing else can be enforced like this: Jail.run Nothing [stdin] yourEvenMoreUntrustworthyComputation Because the jailed IO environment keeps track of all file handles and checks that are opened by its own operations, smuggling in evil file handles from the fierce and dangerous outside world will be punished by border patrol. Only handles from the whitelist or handles securely opened by functions like openFile will be accepted. Because of the opaque IO constructor and the restricted set of exported operations this module is not easily fooled. I would almost dare to say this module is conceptually safe and code with the jailed IO type can blindly be trusted. Except, yes unfortunately except, unsafePerformIO ruins it all. I would almost suggest adding a flag to the compiler to enforce the absence ofunsafeRuinMyTypeSafety-alike functions in order to be able to create systems in which code can be trusted by its type alone. Nonetheless, this module is one step forward in trusting your own programs. Some real http://tinyurl.com/paranoidpeople prefer writing there software in one of the most insecure programming languages and perform security audits by hand, I'd rather have my compiler do the job. (Anyone who wants to audit this library is more than welcome!) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANN: jail-0.0.1 - Jailed IO monad
On Aug 27, 2009, at 4:16 PM, Eugene Kirpichov wrote: Cool! However, it does not protect me from doing System.IO.Unsafe.unsafePerformIO in whatever fashion I like, does it? Unfortunately not, hence my disclaimer: I would almost dare to say this module is conceptually safe and code with the jailed IO type can blindly be trusted. Except, yes unfortunately except, unsafePerformIO ruins it all. I would almost suggest adding a flag to the compiler to enforce the absence ofunsafeRuinMyTypeSafety-alike functions in order to be able to create systems in which code can be trusted by its type alone. Hope there will once be a nice solution to this... -- Sebastiaan Visser 2009/8/27 Sebastiaan Visser sfvis...@cs.uu.nl: Hi all, I am very pleased to announce the first release of the jail[1,2] package. A jailed IO monad that can restrict filesystem access for your code. This package will soon be an integral part of the Salvia web server. (a new and improved Salvia will be released soon) Basic documentation of the jail package is included below. Any comments, suggestions, audits, etc. are welcome! Gr, -- Sebastiaan Visser [1] Source repo: http://github.com/sebastiaanvisser/jail/ [2] Hackage: http://hackage.haskell.org/package/jail ... ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANN: package Boolean: Generalized booleans
On Jun 30, 2009, at 2:44 AM, Conal Elliott wrote: I just uploaded a new package [1] for generalized booleans, which provides type classes with generalizations of boolean values operations, if-then-else, Eq and Ord. These values types come up for me with every new deep DSEL, and I think they do for others as well. The design space has some tricky trade-offs, and I'm not positive I've found the optimum yet. Users comments are very welcome. Please direct discussion to the haskell-cafe list (rather than haskell list). Conal, Good work! Together with Tom Lokhorst I've been working on something very similar. We've been using a rather consistent way of eliminating data structures that scales well to other data types. Although we are also using functional dependencies I think we might want to change them to type families. Examples: class Bool f r | f - r where bool :: r - r - f - r false :: f true :: f class Maybe f a r | f - a, f - r where maybe :: r - (a - r) - f a - r nothing :: f a just:: a - f a class Either f a b r | f - a, f - b, f - r where either :: (a - r) - (b - r) - f a b - r left :: a - f a b right :: b - f a b Currently we have a very limited and somewhat messy code base on github[1] which shows how to instantiate these types to get back the original Haskell functionality and how to produce JavaScript code that runs in a browser. The the JavaScript instance is very much the same as I used in my FRP to JS EDSL[4]. Next target will, off course, be Objective C. :-) Our code is not yet release worthy and probably never will be in this form. But is would be very nice to see some kind of generalized prelude evolving. [1]: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/ Boolean - Conal -- Sebastiaan Visser [1] http://github.com/tomlokhorst/AwesomePrelude/tree/master [2] http://github.com/sebastiaanvisser/frp-js ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: BerkeleyDBXML linking problems.
(crosspost from haskell-libraries) Hello all, again. Meanwhile I've been able to install this package without too much trouble on a Linux system. Unfortunately MacOSX is still a problem. Both on Linux and Mac I installed the Berkeley DB and DBXML packages with `--prefix=/usr' so all include files and libraries end up in a standard place. Also both on Linux and Mac I installed the Haskell BerkeleyDB bindings just with: cabal install BerkeleyDB Because the DBXML include files are installed under /usr/include/dbxml/ *.hpp and the BerkeleyDBXML binding accesses them without this prefix I did: cabal install BerkeleyDBXML --extra-include-dirs=/usr/include/dbxml On both system installation is not a problem. Compiling the demo `adventure' included in de bindings distribution works fine on Linux but fails on MacOSX. The errors are the ones in my previous mail below. A full hpaste of it can be found here[1]. Any idea where the difference in behaviour comes from on these platforms and how to fix this? Unfortunately, my knowledge of the c++ toolchain and Haskell FFI bindings using these is _very_ limited. Thanks, Sebastiaan [1] http://www.hpaste.org/fastcgi/hpaste.fcgi/view?id=6389#a6389 On Jun 26, 2009, at 12:56 PM, Sebastiaan Visser wrote: Hello all, After manually specifying where to find the appropriate include and library directories for the dbxml distribution, I succeeded to install both the BerkeleyDB and the BerkeleyDBXML Haskell bindings. They both nicely show up in `ghc-pkg list'. But when I try to compile my own test or the demo program included in the BerkeleyDBXML package it will kindly present me a dozen or so pages of linking errors. The top lines are: Undefined symbols: std::basic_stringchar, std::char_traitschar, std::allocatorchar ::_Rep::_M_destroy(std::allocatorchar const), referenced from: __xmlDocument_setContent in libHSBerkeleyDBXML-0.6.2.a(dbxml_helper.o) ... Do I have to tell GHC where to find the original dbxml libraries when compiling my BerkeleyDBXML aware Haskell programs? Small system overview: - Mac OS X 10.5.7 - GHC 6.10.3 - BerkeleyDB 0.7.1 - BerkeleyDBXML 0.6.2 - gcc/g++ 4.0.1 Any clue on how to fix this? Thanks, -- Sebastiaan Visser ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANN: package Boolean: Generalized booleans
On Jun 30, 2009, at 5:24 PM, Conal Elliott wrote: Hi Sebastiaan, I like your extensions of generalized booleans to other common Haskell types! I also prefer using type families to fundeps. In this case I didn't because of some awkwardness with vector operations, but I'm going to try again. I'm confused about your particular fundep choice. For instance, class Bool f r | f - r where bool :: r - r - f - r false :: f true :: f Do you *really* mean that the boolean type f determines the value type r? Yes, that is really what I mean. This can be used to enforce that the return value of elimination can be restricted by the boolean type. This is especially useful when using GADTs to encode your domain language. For example, take this simple JavaScript language: data Js a where Prim :: String - Js a-- Primitive embedding. App :: Js (a - b) - Js a - Js b-- Function application. data JsBool Now the functional dependencies can be used to enforce that eliminating booleans in the Js domain always returns a value in the Js domain: instance Bool (Js JsBool) (Js r) where bool f t c = Prim (function ifthenelse (f, t, c) c ? t : f) `App` f `App` t `App` c true = Prim true false = Prim false Getting rid of this fundep and using type families will probably be a lot more intuitive. Any suggestions on how to enforce elimination to be able to go from `Js JsBool - Js r' using other techniques? Regards, - Conal ... -- Sebastiaan Visser ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Nested tests [Code walking off the right edge of the screen]
On Jun 21, 2009, at 2:36 PM, Sebastian Fischer wrote: On Jun 21, 2009, at 11:52 AM, Andrew Coppin wrote: ... When using failUnless boolAction message = lift boolAction = (`unless`fail message) the code becomes either (hPutStrLn stderr) return = runErrorT $ do failUnless (doesDirectoryExist d1) $ Directory ++ d1 ++ not found. failUnless (doesFileExist (d1 / f1)) $ File ++ f1 ++ not found. failUnless (doesDirectoryExist d2) $ Directory ++ d2 ++ not found. failUnless (doesFileExist (d2 / f2)) $ File ++ f2 ++ not found. lift $ doStuff d1 d2 f1 f2 Or make is somewhat prettier (imho) using infix: orError boolAction message = lift boolAction = (`unless`fail message) either (hPutStrLn stderr) return = runErrorT $ do doesDirectoryExist d1 `orError` (Directory ++ d1 ++ not found.) doesFileExist (d1 / f1) `orError` (File ++ f1 ++ not found.) doesDirectoryExist d2 `orError` (Directory ++ d2 ++ not found.) doesFileExist (d2 / f2) `orError` (File ++ f2 ++ not found.) lift $ doStuff d1 d2 f1 f2 It's similar to Claus's proposal to use MaybeT with additional support for error messages. Sebastian -- Underestimating the novelty of the future is a time-honored tradition. (D.G.) -- Sebastiaan Visser ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] [ANN] Data.Reify.CSE
Hi all, This module[1] implements common sub-expression elimination for graphs generated by the Data.Reify package. (Which is a really neat tool!) The algorithm performs a simple fixed point iteration and is not (consciously) optimized for speed. This package might especially be useful for optimizing simple compilers for referential transparent domain specific languages. Which is exactly the reason I've written this code. An example of the usage is included in the Haddock documentation. Gr, -- Sebastiaan Visser [1] http://hackage.haskell.org/package/data-reify-cse ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] A small puzzle: inTwain as function of foldr
On Jun 4, 2009, at 4:32 PM, Sittampalam, Ganesh wrote: Martijn van Steenbergen wrote: Consider the function inTwain that splits a list of even length evenly into two sublists: inTwain Hello world! (Hello ,world!) Is it possible to implement inTwain such that the recursion is done by one of the standard list folds? Does this help? http://www.brics.dk/RS/02/12/BRICS-RS-02-12.pdf Ganesh And maybe this helps: http://www.springerlink.com/content/h1547h551422462u/ -- Sebastiaan Visser ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Bool as type class to serve EDSLs.
Or overloading the `whitespace operator' for several kinds of application. On May 28, 2009, at 9:50 AM, Augustsson, Lennart wrote: And explicit desugaring of list syntax. -Original Message- From: Sittampalam, Ganesh [mailto:ganesh.sittampa...@credit- suisse.com] Sent: 28 May 2009 08:46 To: Simon Peyton-Jones; Sebastiaan Visser; Haskell Cafe Cc: Augustsson, Lennart Subject: RE: [Haskell-cafe] Bool as type class to serve EDSLs. There are multiple possible classes that you might want under different circumstances (I think the most interesting issue is whether the class (==), () etc is in has a fundep from the type of the thing being compared to the type of the boolean), but if NoImplicitPrelude (or some other extension) just desugars if-then-else into ifthenelse (with a default implementation of ifthenelse somewhere) I think that would be enough. Of course once you've got ifthenelse you find yourself wanting explicit desugaring of pattern matching (could view patterns help here?), recursion (into an explicit use of fix), etc... Cheers, Ganesh Simon Peyton-Jones wrote: You are absolutely right about the tantalising opportunity. ... ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] I love purity, but it's killing me.
On May 27, 2009, at 1:49 AM, Conal Elliott wrote: Hi Tom, I've been working on another code-generating graphics compiler, generating GPU code. As always, I run into the problem of efficient common subexpression elimination. In Pan, Vertigo Pajama, I used lazy memoization, using stable pointers and weak references, to avoid the worst-case-exponential behavior you mention below. I'm now using a bottom-up CSE method that's slower and more complicated than I'm going for. What do you mean with `exponential behavior'? Exponential related to what? For my FRP EDSL to JavaScript (toy) compiler[1] I've been implementing CSE as well. I traverses the expression tree recursively and creates an small intermediate language containing id's (pointers) to expressions instead of real sub-expressions. Maybe (probably) I am very naive, but I think this trick takes time linear to the amount of sub-expressions in my script. When using a trie instead of a binary tree for the comparisons there should be no more character (or atomic expression) comparisons that the amount of characters in the script. So the problem seems not to be CSE algorithm, but the fact that EDSL itself tends to blow up because it is hosted in Haskell. Like Tom's example: let d = Add c c e = Add d d-- e now as 16 leaf nodes. But again, I might be missing some important point here. What's your latest wisdom about CSE in DSELs? Thanks, - Conal On Thu, Feb 7, 2008 at 11:33 PM, Tom Hawkins tomahawk...@gmail.com wrote: ... -- Sebastiaan Visser (warning: messy code) [1] http://github.com/sebastiaanvisser/frp-js/blob/b4f37d3b564c4932a3019b9b580e6da9449768a8/src/Core/Compiler.hs ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] I love purity, but it's killing me.
On May 27, 2009, at 12:51 PM, Sittampalam, Ganesh wrote: Sebastiaan Visser wrote: ... But again, I might be missing some important point here. That's exactly right. But it's pretty inconvenient to have your expression tree to blow up exponentially in relation to the code the user actually wrote! You can indeed construct an intermediate language that collapses this blowup, but the pass to create it must take exponential time if written completely purely, since it has to visit everything at least once. In my experience [1], observable sharing using GHC's stable names is a pretty effective solution to this problem. Ganesh [1] http://www.earth.li/~ganesh/research/paradise-icfp08/ Thanks, I just pushed your paper on top of my stack. -- Sebastiaan Visser ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Bool as type class to serve EDSLs.
Hello, While playing with embedded domain specific languages in Haskell I discovered the Num type class is a really neat tool. Take this simple example embedded language that can embed primitives from the output language and can do function application. data Expr :: * - * where Prim :: String - Expr a App :: Expr (a - b) - Expr a - Expr b Take these two dummy types to represent things in the output language. data MyNum data MyBool Now it is very easy to create an Num instance for this language: primPlus :: Expr (MyNum - MyNum - MyNum) primPlus = Prim prim+ instance Num (Epxr MyNum) where a + b = primPlus `App` a `App` b fromInteger = Prim . show ... Which allows you to create very beautiful expression for your language embedded inside Haskell. The Haskell expression `10 * 5 + 2' produces a nice and well typed expression in your embedded domain. But unfortunately, not everyone in the Prelude is as tolerant as the Num instance. Take the Eq and the Ord type classes for example, they require you to deliver real Haskell `Bool's. This makes it impossible make your DSL an instance of these two, because there are no `Bool's only `Expr Bool's. Which brings me to the point that, for the sake of embedding other languages, Haskell's Prelude (or an alternative) can greatly benefit from (at least) a Boolean type class like this: class Boolean a where ifthenelse :: a - b - b - b -- Not sure about this representation. ... And one instance: instance Boolean (Expr MyBool) where ifthenelse c a b = Prim if-then-else `App` c `App` a `App` b Now we can change (for example) the Eq type class to this: class Eq a where (==) :: Boolean b = a - a - b (/=) :: Boolean b = a - a - b For which we can give an implementation for our domain: primEq :: Epxr (a - a - MyBool) primEq = Prim == instance Eq (Expr a) where a == b = primEq `App` a `App` b And now we get all functionality from the Prelude that is based on Eq (like not, , ||, etc) for free in our domain specific language! Off course there are many, many more examples of things from the standard libraries that can be generalised in order to serve reuse in EDSLs. Anyone already working on such a generalized Prelude? I can imagine much more domains can benefit from this than my example above. Any interesting thoughts or pointers related to this subject? Gr, -- Sebastiaan Visser ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] [ANN] multirec-binary
Hello all, MultiRec[1,2] is a great library for generic programming for families of possibly mutual recursive data types. Creating new generic functions might take some effort but the use of these functions is very straightforward. The multirec-binary[3] packages allows generic derivation of Data.Binary instances using the MultiRec library. Just try something like this: import Data.Binary import Generics.MultiRec.Base import Generics.MultiRec.Binary instance Binary MyType where put = gput MyFamily get = gget MyFamily Have fun, -- Sebastiaan Visser [1] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/multirec-0.3 [2] http://www.cs.uu.nl/research/techreps/repo/CS-2008/2008-019.pdf [3] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/multirec-binary ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Writing a compiler in Hakell
On May 6, 2009, at 8:07 AM, Rouan van Dalen wrote: Hi everyone. I am designing my own programming language. I would like to know what is the best way to go about writing my compiler in haskell. What are the tools available in haskell that can help with compiler construction? I know about Happy. Is that a good tool to use? The compiler is intended for serious use and I would like it to be very efficient, maybe competing with compilers written in C. It should also be very easy to extend as the languoge grows. Are there any good books that you can recommend on compiler construction in general and specific to haskell? What is your goal? Writing a compiler, for fun and educational purposes, or to implement a new language? When the actual language is the main purpose and your language will be a functional one you can try to piggyback on existing compilers. For example, translate your language to the GHC core or UHC[1] core and you get a cross platform highly optimizing compiler for free. You can now freely focus on the semantics of your language and let an existing code generator do the dirty work for you. When, in the end when your languages is finished, the existing compiler is not fast enough, improve it and everyone benefits! On another note, how is the operator + implemented in haskell? is there a primitve (say #+) that is wrapped by the haskell operator +? Maybe something like: (+) :: a - a - a v1 + v2 = #+ v1 v2 Thanks in advance Rouan. [1] https://svn.cs.uu.nl:12443/repos/EHC/trunk/EHC/src/ehc/Core/AbsSyn.cag -- Sebastiaan Visser ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] default values in a record structure
On Apr 29, 2009, at 12:18 AM, Luke Palmer wrote: On Tue, Apr 28, 2009 at 4:09 PM, Vasili I. Galchin vigalc...@gmail.com wrote: Hello, Is there anyway when defining a dat type record struct to indicate default values for some of the fields? The usual pattern is to use a default record, and specialize it: data Foo = Foo { bar :: Int, baz :: Int, quux :: Int } fooDefault = Foo { bar = 1, baz = 2, quux = 3 } newRecord = fooDefault { quux = 42 } If you only want some of the fields to be defaulted, you can make them undefined in the default record... unfortunately this won't be checked by the compiler. Luke Additionally, you can choose to not export the constructor Foo and to only export your fooDefault quasi-constructor and your record selectors. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANN: Cute Hack - Hyena handler + Bamboo Blog Engine :)
What kind of port is this? Direct translation from ruby source? I see that you are using the (.) for OO-style reversed function application. Which feels a bit weird at first sight. Snippet from your Hack.Handler.Kibro: handle app = do env - get_env response - app env .liftIO -- set response response.headers.mapM_ (splash setHeader) response.status.show.setHeader Status response.body.output On Apr 25, 2009, at 7:58 AM, Jinjing Wang wrote: Hia, A few interesting progress on Hack: * many middleware ported from Rack, including a lambda! ( just like a pony for wsgi, and a lobster for rack ) * 2 handlers, one for Kibro on fcgi / lighttpd, one for Hyena web server * apps are portable, Bamboo is a port of Panda that runs on Hack, works fine with both handlers * Hyena handler is still experimental A lambda app looks like this -- Main.hs source module Main where import Hack import Hack.Utils import Hack.Handler.Hyena import Hack.Contrib.Lambda main = run $ lambda dummy_app -- compile ghc --make -O2 Main.hs -- run ./Main now go to http://localhost:3000/lambda Cheers, Links: * [Hack] (http://github.com/nfjinjing/hack/tree/master) * [Bamboo] (http://github.com/nfjinjing/bamboo/tree/master) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] CPS and the product function
On Apr 20, 2009, at 4:32 PM, michael rice wrote: Hi Eugene, Clever solution. It didn't come right back so I interrupted it. Guess it would do all those multiplies by zero. Does anyone know how to define it to avoid that? Thanks. Michael --- On Mon, 4/20/09, Eugene Kirpichov ekirpic...@gmail.com wrote: From: Eugene Kirpichov ekirpic...@gmail.com Subject: Re: [Haskell-cafe] CPS and the product function To: michael rice nowg...@yahoo.com Cc: haskell-cafe@haskell.org Date: Monday, April 20, 2009, 9:40 AM Check that by experiment in ghci or by looking at the source: Prelude* product [0..] Or search product at http://holumbus.fh-wedel.de/hayoo/hayoo.html and click on one of the Source links. 2009/4/20 michael rice nowg...@yahoo.com: I've been looking at CPS in Haskell and wondering how many multiplications the product function performs if it encounters a zero somewhere in the input list. Zero? Does anyone know the definition of the product function? Michael Eugene Kirpichov Making multiplication non-strict? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: ANNOUNCE: Utrecht Haskell Compiler (UHC) -- first release
On Apr 20, 2009, at 5:44 PM, David Leimbach wrote: On Mon, Apr 20, 2009 at 8:38 AM, Malcolm Wallace malcolm.wall...@cs.york.ac.uk wrote: Just refuse to use UHC until it conforms. Do you not use Hugs for the same reason? Not to mention that GHC does not comply with the H'98 standard either: http://www.haskell.org/ghc/docs/latest/html/users_guide/bugs-and-infelicities.html#vs-Haskell-defn Regards, Malcolm It's still a matter of choice. So we're saying there are no implementations of Haskell 98? Sounds like the same problem C++ and C99 have. Dave Why is this such a problem? You can still write and compile very beautiful programs with both GHC and UHC. And keep in mind that the UHC compiler is probably not designed to replace GHC and to be fully compliant with the Haskell 98 standard. It still has a very useful place in education and is certainly worth looking at. It is intensively making use of the attribute grammar system to perform traversals over the different internally used languages. This is a very different approach from what GHC does which makes it very interesting from an educational and scientific point of view. I encourage you to take a look inside, it is reasonably easy to grasp what going on inside of UHC. -- Sebastiaan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [ANN] salvia-0.1, salvia-extras-0.1
There is now. Not much new in Orchid itself, but builds against the updated Salvia. Because of the use of keep-alive the performance of orchid should be a lot better now (at some places). -- Sebastiaan On Mar 28, 2009, at 10:26 PM, Paul L wrote: Thanks for the massive update! Is there a new version of Orchid coming along? On 3/22/09, Sebastiaan Visser sfvis...@cs.uu.nl wrote: Hi all, I am pleased to announce a new version of Salvia, the lightweight Haskell Web Server Framework with modular support for serving static files, directories indices, default error responses, connection counting and logging, HEAD and PUT requests, keep-alives, custom banner printing, default handler environments for parsing request and printing responses, dispatching based on request methods, URI, paths and filename extension, URI rewriting and redirection, virtual hosting, cookie, session and user management and more... Changes since previous version: - Some more advanced, non-fundamental handlers have been moved to their own package salvia-extras. This helps pruning the dependencies a bit. - The package now has some default handler environments that simplify setting up a server application. - The server now has support for keep-alive, significantly increasing the performance. - The library functions are now almost fully documented instead of no- documentation-at-all in the previous versions. - Salvia now also works on windows (I heard). - Lots of code cleanups throughout the code. - Lots of minor bug fixes. To install: use cabal. Thanks to the people that helped me with suggestions and bug-reports! -- Sebastiaan. -- Regards, Paul Liu ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [SoC] XML Schema Implementation
Vlad, Some time ago I wrote a generic Haskell data type to XML/XSD library[1]. It was based on an old singleton version of the multirec[2] generic programming library. I never released any of it because it is not really usable in a serious setting but you might want to look at it for some inspiration. Generic programming is *really* useful when it comes to managing XML from Haskell. -- Sebastiaan. [1] http://funct.org/code/gxml/ [2] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/multirec On Mar 31, 2009, at 12:16 AM, Vlad Dogaru wrote: Hello everyone, I am writing to judge interest in a Summer of Code proposition: an XML Schema[1] implementation, described as a possbile application here[2]. As both a tool and an inspiration, I intend to use HaXML[3]. More specifically, I would be interested in the degree the Haskell community uses XML Schema, and if you were tempted to use it if we had an implementation. To further expand the question, how useful do you consider each of these components: * a validator * a pretty-printer * a translator from XML Schema to Haskell, similar to DtdToHaskell[4] For the latter item, some runtime checking will definitely be required: restrictions such as value ranges for integers or minimum and maximum occurences of an element cannot, to my knowledge, be enforced through type definitions. Finally, I kindly ask anyone with relevant experience to point out other possible pitfalls. Vlad Dogaru [1] http://www.w3schools.com/Schema/ [2] http://hackage.haskell.org/trac/summer-of-code/ticket/1120 [3] http://www.cs.york.ac.uk/fp/HaXml/ [4] http://www.cs.york.ac.uk/fp/HaXml/Xml2Haskell.html ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANN: cmonad 0.1.1
On Mar 30, 2009, at 3:30 PM, Bas van Dijk wrote: On Sun, Mar 29, 2009 at 11:16 AM, Lennart Augustsson lenn...@augustsson.net wrote: I've uploaded my CMonad package to Hackage. It allows you to write Haskell code in a C style. Nice! A nice addition would be to output a C AST from language-c: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/language-c regards, Bas And compile and link that back into your program! Nice toys indeed. Lennart, what is the next language DSL you are going to build? Prolog? XSLT? -- Sebastiaan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] The votes are in!
Well done! Although I am quite happy with the result, this was definitely my favorite, this logo is not really 'finished'. Is there going to be some kind of second round in which we can vote for/suggest variations of this logo? With different texts/fonts/colors/ etc? Gr, Sebastiaan On Mar 24, 2009, at 1:20 PM, Eelco Lempsink wrote: The results of the Haskell logo competition are in! You can view them at http://www.cs.cornell.edu/w8/~andru/cgi-perl/ civs/results.pl?num_winners=1id=E_d21b0256a4fd5ed7algorithm=beatpath Congratulations Jeff Wheeler! I'll set up a page with the results visibile. -- Regards, Eelco Lempsink ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Hackage upload problems?
Hello, Currently I'm trying to upload a minor update of Salvia to Hackage to fix some dependency issues but Hackage times out all the time? Both the CLI tool and the web-interface do not react to my upload request. Any known problems here? Gr, Sebastiaan. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] [ANN] salvia-0.1, salvia-extras-0.1
Hi all, I am pleased to announce a new version of Salvia, the lightweight Haskell Web Server Framework with modular support for serving static files, directories indices, default error responses, connection counting and logging, HEAD and PUT requests, keep-alives, custom banner printing, default handler environments for parsing request and printing responses, dispatching based on request methods, URI, paths and filename extension, URI rewriting and redirection, virtual hosting, cookie, session and user management and more... Changes since previous version: - Some more advanced, non-fundamental handlers have been moved to their own package salvia-extras. This helps pruning the dependencies a bit. - The package now has some default handler environments that simplify setting up a server application. - The server now has support for keep-alive, significantly increasing the performance. - The library functions are now almost fully documented instead of no- documentation-at-all in the previous versions. - Salvia now also works on windows (I heard). - Lots of code cleanups throughout the code. - Lots of minor bug fixes. To install: use cabal. Thanks to the people that helped me with suggestions and bug-reports! -- Sebastiaan. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Memoizing partially evaluated computations.
Suppose I have a list of IO computations that depends on a few very time consuming pure operations. The pure operations are not dependent on the real world: computation :: [IO Int] computation = [ smallIOfunc timeConsumingPureOperation0 , smallIOfunc timeConsumingPureOperation1 , smallIOfunc timeConsumingPureOperation2 , smallIOfunc timeConsumingPureOperation3 ] where smallIOfunc a = print a return a In my main function I would like to repeatedly print the values main = forever $ sequence_ (map (=print) computation) When I do this, all the time consuming operations will be reevaluated every run of the main loop. Is there a any (simple or smart) way to prevent the garbage collector from cleaning up the fully evaluated thunks inside my computation? As if it were something like this: computation :: [IO Int] computation = [smallIOfunc 42, smallIOfunc 34385, smallIOfunc 3, smallIOfunc 55] Of course I could plugin some kind of Int memoizer inside my computation, but I do not really have the control to change things `deep' inside the code. I want to have some form of snapshot of a list of partially evaluated IO computations... Any suggestions? Tanks, Sebastiaan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Memoizing partially evaluated computations.
On Mar 18, 2009, at 12:06 PM, minh thu wrote: 2009/3/18 Sebastiaan Visser sfvis...@cs.uu.nl: Suppose I have a list of IO computations that depends on a few very time consuming pure operations. The pure operations are not dependent on the real world: computation :: [IO Int] computation = [ smallIOfunc timeConsumingPureOperation0 , smallIOfunc timeConsumingPureOperation1 , smallIOfunc timeConsumingPureOperation2 , smallIOfunc timeConsumingPureOperation3 ] where smallIOfunc a = print a return a In my main function I would like to repeatedly print the values main = forever $ sequence_ (map (=print) computation) When I do this, all the time consuming operations will be reevaluated every run of the main loop. Is there a any (simple or smart) way to prevent the garbage collector from cleaning up the fully evaluated thunks inside my computation? As if it were something like this: computation :: [IO Int] computation = [smallIOfunc 42, smallIOfunc 34385, smallIOfunc 3, smallIOfunc 55] Of course I could plugin some kind of Int memoizer inside my computation, but I do not really have the control to change things `deep' inside the code. I want to have some form of snapshot of a list of partially evaluated IO computations... Any suggestions? Hi, If timeConsumingPureOperation is pure, the problem is thus not related to IO, and your question remains the same : how to memoize timeConsumingPureOperation for some arguments. Since you want to repeatidly call main, it seems a good idea to wrap your pure operation in a memoizing CAF (and give the wrapped version to smalIOFuncf). The problem is that the `timeConsumingPureOperation' is somewhere very deep inside my code at a point I cannot alter. Like this: -- This I can change: myIOCode = forever (deepLibraryCode = print) -- This I cannot change: deepLibraryCode :: IO Int deepLibraryCode = makeIOfunctionFrom timeConsumingPureOperation The separation between the make `makeIOfunctionFrom' and `timeConsumingPureOperation' might not even be that clear as in my example. That is why I am looking for some high level way of memoizing. You can here : http://www.haskell.org/haskellwiki/Memoization HTH, Thu ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] ANNOUNCE: haha-0.1 - Animated ascii lambda
Always wanted to have an full-color rotating vector based ascii art lambda on your terminal? This is your chance, installing `haha' will do the trick! This is very minimal vector based ascii art library written just for fun. There is a sample program called `rotating-lambda' which does exactly what is says. Make sure your terminal window is at least 80x40 and supports the most basic ANSI escape sequences before trying the demo. -- Sebastiaan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] ANN: orchid-0.0.7
I am pleased to announce a new release of Orchid, just another Haskell Wiki. Some new features/fixes: * Attached wiki to FileStore package which means we now also have Git backend. * Orchid-demo now has a flag which allows user to choose Git or Darcs. * Searching document is now possible. * Deleting and renaming documents is now possible. * Better keyboard support in user interface. * Fixed the in-page HTML anchors. * Password are now saved in md5, not plain text. * Use extensible exceptions to be more compatible with older GHC. * Fixed bugs in directory listings. * Users now also have a email. Watch the demo at: http://funct.org/wiki/ Or get the demo from cabal: $ cabal install orchid-demo ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] [ANN] Haskell web server + wiki: salvia-0.0.4 + orchid-0.0.6
Happy new year, you all! I'm pleased to announce three new packages on Hackage: * salvia-0.0.4: A lightweight modular web server framework. * orchid-0.0.6: A(nother) Wiki written in Haskell, currently using Darcs as a versioning back-end and Salvia as the application server. Orchid ships as a library that can be installed as a server module for the Salvia framework. * orchid-demo-0.0.4: A simple demo application using Salvia and Orchid to serve an example darcs repository. An online demo of the wiki can be found at [1]. The front-end is a typical Ajax application and heavily relies on the availability of JavaScript. A more plain (REST like) web interface to system can be found at [2]. You can signup, login and edit/create some pages. Feel free to play around, it's just a demo. Orchid has an abstract notion of a versioning back-end, theoretically allowing for multiple versioning systems. Currently only a Darcs back- end is available, but it shouldn't be too much work to implement a liaison for Git, Subversion, Mercurial etc. The Wiki uses its own experimental document system with printers to HTML, LaTeX, PDF via LaTeX and some others in the making. The system makes us of the UUAGC [3] attribute grammar system, but is not required in order to build the package. The document system is plug-in based allowing easy addition of new structures. There are currently plug-ins for inline LaTeX formulae, HSColour'ed Haskell code snippets and a table of contents. Some others in the making. Be aware, this is an early release to allow people the play around with the packages and enable me to see how this all behaves in the wild. The tools are not yet finished and I cannot guarantee any form of stability. But, in my experience, they seem to `just work'. Most of the time. I had some trouble getting all dependencies right on systems other than my own. Using `cabal install' seems to behave differently from `./ Setup install' in the package directory, but this may vary from system to system. It is known to work at least on Macosx and Linux with GHC 6.8, 6.10 or even 6.11. Pdflatex is needed for PDF generation, dvipng for inline formulas. Have fun and best wishes for this new year! -- Sebastiaan [1] http://funct.org/wiki/ [2] http://funct.org/wiki/data/Index.html [3] http://www.cs.uu.nl/wiki/HUT/AttributeGrammarSystem ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [ANN] Haskell web server + wiki: salvia-0.0.4 + orchid-0.0.6
On Jan 1, 2009, at 7:15 PM, Gwern Branwen wrote: On Thu, Jan 1, 2009 at 9:04 AM, Sebastiaan Visser wrote: Happy new year, you all! I'm pleased to announce three new packages on Hackage: ... Miscellaneous comments: 1) You're right about cabal-install versus runhaskell etc. There seems to be a(nother) Control.Exception issue with cabal-install using base-4: src/Network/Orchid/Backend/DarcsBackend.hs:91:29: Couldn't match expected type `IOException' against inferred type `Exception' Expected type: IO (Either IOException String) Inferred type: IO (Either Exception String) In the second argument of `()', namely `(try (U.readFile (repo /+ file)) :: IO (Either IOException String))' In the expression: eitherToMaybe (try (U.readFile (repo /+ file)) :: IO (Either IOException String)) I tried to enable building against both the old and the new Exception libraries by using some preprocessor statements. It seems this attempt failed. 2) Have you looked into integrating with Pandoc for generating TeX, PDFs, etc. (instead of rolling your own)? Seems to work fairly well for Gitit. Nope haven't really looked into Pandoc, rolling my was just more fun. 3) Is it just me, or is the fancy AJAX interface - as nice as it is - rather slow? No, it's not really the Ajax that is the performance bottleneck here. It is the slow machine the demo is running on currently, the LaTeX tools running in the background and the poor caching. When I would cache all the generated documents (and images) there will probably a big speedup. This is in my todo. 4) In orchid-demo, I notice it by default looks in /tmp for its datafiles. Is there some particular reason why a better default wouldn't be looking in ./? I was wondering how orchid-demo would do for a personal wiki, where it makes most sense to have a ~/wiki directory to keep all the files in. The /tmp directory is just world writable by default, being a good candidate to get the demo running quick. The command line options allow you to have more control. The demo is only one single `Main.hs', so adapting it to your own needs is also possible. 5) Setting up orchid-demo is not all that clear; I figured out that you want to run 'orchid-demo --extract' to set up a stock configuration and repo, and then one can just run 'orchid-demo', but I think a better way would be to look in the default location for files and if orchid-demo doesn't find any, then fall back to --extract and look again. A better way to roll your own wiki is: $ echo show signup user.db $ echo myusername mypassword loginfo show edit create signup user.db $ mkdir repo $ cd repo $ darcs init $ orhid-demo --data-dir=. --user-db=../user.db - -- gwern Thanks for the feedback. Sebastiaan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Verifying a list of properties using QuickCheck
On Oct 22, 2008, at 1:03 PM, Martijn van Steenbergen wrote: Thomas van Noort wrote: However, I would like a single result for the complete list of properties instead of a result for each property. I realize that this restricts the properties to be of the same type, but that isn't a problem for my application. Why not concatenate your properties into one big conjuction? Prelude Test.QuickCheck (quickCheck . and) [1==1,2==2] +++ OK, passed 100 tests. Martijn. What to do when your properties are parametrised by some `arbitrary' value? Sebastiaan. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Is there already an abstraction for this?
This (recent) paper describes a very interesting way to perform generic term rewriting: http://www.cs.uu.nl/research/techreps/repo/CS-2008/2008-020.pdf On Sep 23, 2008, at 3:46 AM, Jeremy Shaw wrote: Hello, I am trying to figure out if there is an existing abstraction I am missing here. I have an expression data-type: data Expr = Quotient Expr Expr | Product Expr Expr | Sum Expr Expr | Difference Expr Expr | Lit Double | Var Char deriving (Eq, Ord, Data, Typeable, Read, Show) And I want to write a function that will take an expression and automatically apply the identity laws to simplify the expression. The basic identity laws are: a + 0 = a a * 1 = a I can implement these with some 'sugar' as: identity (Sum (Lit 0) a)= a identity (Sum a (Lit 0))= a identity (Difference a (Lit 0)) = a identity (Product a (Lit 1))= a identity (Product (Lit 1) a)= a identity (Quotient a (Lit 1)) = a identity a = a This works fine when the identity only needs to be applied to the root of the expression tree: *Main ppExpr $ identity (expr 1 + 0) 1 But for more complicated trees it does not fully apply the identity laws: *Main ppExpr $ identity (expr 0 + (0 + 0) + (0 + 0)) ((0 + 0) + (0 + 0)) What we need to do is first apply the identity function to the children, and then apply them to the parent of the updated children. A first attempt would be to extend the identity function like this: identity (Sum a b) = identity (Sum (identity a) (identity b)) However, that will not terminate because that same case will keep matching over and over. Another approach is to have two mutually recursive functions like: identity' (Sum (Lit 0) a)= identityRec a identity' (Sum a (Lit 0))= identityRec a identity' a = a identityRec (Sum a b) = identity' (Sum (identity' a) (identity' b)) This prevents non-termination, but you have to be careful about calling identity' vs identityRec or you will either re-introduce non-termination, or you may not fully apply the identity laws. Another option to create a helper function like: -- |Deep map of an expression. eMap :: (Expr - Expr) - Expr - Expr eMap f (Sum a b) = f (Sum (eMap f a) (eMap f b)) eMap f (Difference a b) = f (Difference (eMap f a) (eMap f b)) eMap f (Product a b) = f (Product (eMap f a) (eMap f b)) eMap f (Quotient a b) = f (Quotient (eMap f a) (eMap f b)) eMap f (Var v) = f (Var v) eMap f (Lit i) = f (Lit i) Now we can easily apply the identity law recursively like: deepIdentity :: Expr - Expr deepIdentity = eMap identity *Main ppExpr (deepIdentity (expr 0 + (0 + 0) + (0 + 0))) 0 Sweet! But, having to write eMap out by hand like that somehow feels wrong -- as if I am missing some additional abstraction. In some respects eMap is like a Functor, but not quite. I expect there is a way to implement eMap using Data.Generics, which is perhaps better, but I still feel like that is missing something? Anyway, I just thought I would ask in case someone recognized this pattern and could point me in the right direction. I have attached a working example program you can play with. I would also be interested in alternative approaches besides the ones I outlined. thanks! j. ... ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Bit streams
On Jun 17, 2008, at 10:05 PM, Andrew Coppin wrote: OK, so today I tried to write my first program using the Binary library. And I've hit a snag: It appears the library will only handle data that is byte-aligned. So if I try to write three Bool values, it uses three bytes, not three bits. Before I sit down and spend 3 months designing my own library from scratch, does anybody know of an existing library that allows you to do what Binary does, but with single-bit precision? [I presume Binary is byte-aligned for efficiency...] Andrew, Maybe you could look at the generic encode/decode in this paper: people.cs.uu.nl/johanj/publications/ComparingGP.pdf When you look at some more literature about generic programming the (bit-aligned) encode and decode are quite common examples. It shouldn't be that hard to de-generify them, if you even want that. -- Sebastiaan. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Polymorphic QuickCheck arguments
On Jun 17, 2008, at 11:53 AM, Hugo Pacheco wrote: Hi all, There is something about polymorphic tests in QuickCheck that I do not understand. If you write the simplest dummy test function tst :: a - Bool tst _ = True and evaluate it we get verboseCheck tst 0: () 1: () ... How come did the polymorphic value a get instanciated to ()? Is this done via the Testable type class? Could someone please explain this to me? I'm not saying it does not make sense, but I would like to understand how it works. Being possible to change this behavior, this is, assign another default type whenever polymorphic types occur, would be awesome. I think it is GHCi that is instantiating the type with (). Try compiling the program, it will probably be rejected by the compiler when you do not specify a concrete type. You can, for example, try this: verboseCheck (tst :: [Int] - Bool) Cheers, hugo ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Lazy IO.
On Jun 16, 2008, at 2:58 PM, Jules Bean wrote: Sebastiaan Visser wrote: Does anyone know a pattern in which I can do this easily? Don't use hGetContents on a socket. That's asking for trouble. Can you please explain why? What is a more easier method to spool your HTTP post data to a file than: Bs.hGetContens sock = Bs.hPut fd ? Use hGetContents either NEVER (easy option) or only on throwaway handles/files which won't be used again. My sockets will be thrown away eventually. Isn't anything? I can imagine that this can be a problem when using Keep-Alive connections - or alike - but that is a whole different story. Jules Thanks, Sebas. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Lazy IO.
Hi, I've got a question about lazy IO in Haskell. The most well known function to do lazy IO is the `hGetContents', which lazily reads all the contents from a handle and returns this as a regular [Char]. The thing with hGetContents is that is puts the Handle in a semi-closed state, no one can use the handle anymore. This behaviour is understandable from the point of safety; it is not yet determined when the result of hGetContents will actually be computed, using the handle in the meantime is undesirable. The point is, I think I really have a situation in which I want to use the handle again `after' a call to hGetContents. I think I can best explain this using a code example. readHttpMessage :: IO (Headers, Data.ByteString.Lazy.ByteString) readHttpMessage = do myStream - accept http connection from client request - hGetContents myStream header - parseHttpHeader request bs - Data.ByteString.Lazy.hGetContents myStream return (header, body) The Data.ByteString.Lazy.hGetContents in the example above obviously fails because the handle is semi-closed. So, what I am trying to do here is apply a parser (on that consumes Char's) to the input stream until it has succeeded. After this I want to collect the remainings of the stream in a lazy ByteString, or maybe even something else. I tried to open the handler again using some internal handle hackery, but this failed (luckily). In the module GHC.IO there is a function `lazyRead' that more or less seems to do what I want. But I'll guess there is a good reason for not exporting it. Does anyone know a pattern in which I can do this easily? Thanks, -- Sebastiaan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] const is question
On Jun 14, 2008, at 6:14 PM, odtaa48 wrote: hello could someone explain the following differing results const id 0 5 - 5 -- ie. 'takes' the 'last' one const (id 0) 5 - 0 -- ie. 'takes' the 'first' one Thanks You can easily see what is happening by rewriting the equations step by step. Remember that the const function is (\x y - x) and the id function is (\x - x). Example 1: const id 0 5 == (const id 0) 5 == id 5 == 5 Example 2: const (id 0) 5 == const 0 5 == 0 So, in both cases const takes the first. -- Sebastiaan. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Lazy IO.
On Jun 14, 2008, at 6:45 PM, Felipe Lessa wrote: (Sorry, Sebastiaan, I hit send accidentally) On Sat, Jun 14, 2008 at 1:18 PM, Sebastiaan Visser [EMAIL PROTECTED] wrote: readHttpMessage :: IO (Headers, Data.ByteString.Lazy.ByteString) readHttpMessage = do myStream - accept http connection from client request - hGetContents myStream header - parseHttpHeader request bs - Data.ByteString.Lazy.hGetContents myStream return (header, body) Why not readHttpMessage = do myStream - accept http connection from client data - Data.ByteString.Lazy.hGetContents myStream (header, rest) - parseHttpHeader data return (header, rest) i.e. make parseHttpHeader return the rest of the string it didn't parse? Doesn't this imply that the parseHttpHeader must work on ByteStrings instead of regular Strings? Maybe this works for HTTP headers, but sometimes ByteStrings are not appropriate. Especially when you are not using the regular `System.IO.hGetContents' but the `System.IO.UTF8.hGetContents'. In fact, may I ask why parseHttpHeader is not a pure function? This is not a real-life example. It might as well be a pure function. HTH, -- Felipe. -- Sebastiaan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Lazy IO.
On Jun 14, 2008, at 6:49 PM, Isaac Dupree wrote: Sebastiaan Visser wrote: Hi, I've got a question about lazy IO in Haskell. The most well known function to do lazy IO is the `hGetContents', which lazily reads all the contents from a handle and returns this as a regular [Char]. The thing with hGetContents is that is puts the Handle in a semi- closed state, no one can use the handle anymore. This behaviour is understandable from the point of safety; it is not yet determined when the result of hGetContents will actually be computed, using the handle in the meantime is undesirable. The point is, I think I really have a situation in which I want to use the handle again `after' a call to hGetContents. I think I can best explain this using a code example. readHttpMessage :: IO (Headers, Data.ByteString.Lazy.ByteString) readHttpMessage = do myStream - accept http connection from client request - hGetContents myStream header - parseHttpHeader request bs - Data.ByteString.Lazy.hGetContents myStream return (header, body) that's impure because parseHttpHeader doesn't return anything telling you how much of the stream it's looked at. Maybe it looked ahead more than it needed to, thus deleting part of the body. I was going to suggest, if you can't change parseHttpHeader to use ByteStrings, bs - Data.ByteString.Lazy.hGetContents myStream header - parseHttpHeader (Data.ByteString.Lazy.unpack bs) but you still have to get parseHttpHeader (or perhaps if it has similar friends) to tell you how much of the string it consumed! I don't know what parsing functions you have available to work with, so I can't tell you whether it's possible. It is a regular Parsec parser and I am pretty sure it does not consume anything other than the header itself. Maybe I could rewrite my parser to work on Word8's instead of Char's, I don't think HTTP even allows Unicode characters within HTTP headers. Thanks. I think I'll try this. But I'm still curious about how to lazily parse messages with arbitrary size Unicode headers and plain (possibly) binary bodies. -Isaac -- Sebastiaan. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Lazy IO.
On Jun 14, 2008, at 7:16 PM, Felipe Lessa wrote: On Sat, Jun 14, 2008 at 1:50 PM, Sebastiaan Visser [EMAIL PROTECTED] wrote: Doesn't this imply that the parseHttpHeader must work on ByteStrings instead of regular Strings? I made the change because it's easier and faster to go from ByteString to String than the converse. Maybe this works for HTTP headers, but sometimes ByteStrings are not appropriate. Especially when you are not using the regular `System.IO.hGetContents' but the `System.IO.UTF8.hGetContents'. You may use the package encoding instead, take a look at [1]. It will decode a lazy ByteString into a String. In your HTTP parsing example, you could break the ByteString on \r\n\r\n and then decodeLazy only the first part, while returning the second without modifying it. Sounds interesting. This could indeed solve (a part of) my problem. The thing is, when decoding the header - in my web server architecture - it is not yet clear what should be done be the body. Some `handlers' may want to have it as a String, UTF8 String, ByteString or may not even need it at all. [1] http://hackage.haskell.org/packages/archive/encoding/0.4.1/doc/ html/Data-Encoding.html#v%3AdecodeLazy Because HTTP headers are line based and the parser does not need any look ahead - the first \r\n\r\n is the header delimiter - it might be possible to use the hGetLine for the headers. After this I am still `free' to decide what to do for the body: System.IO.hGetContents, System.IO.UTF8.hGetContents, Data.ByteString.Lazy.hGetContents, hClose, etc... -- Felipe. Thanks, Sebastiaan. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe