Re: [Haskell-cafe] [Haskell] JustHub 'Sherkin' Release
Hi Chris, Where is this functionality provided by Nix? simply run these commands # Haskell Platform 2009.2.0.2 nix-env -p ~/ghc-6.10.4 -iA haskellPackages_ghc6104.haskellPlatform # Haskell Platform 2010.2.0.0 nix-env -p ~/ghc-6.12.3 -iA haskellPackages_ghc6123.haskellPlatform # Haskell Platform 2012.2.0.0' nix-env -p ~/ghc-7.4.1 -iA haskellPackages_ghc741.haskellPlatform and you'll have profiles that contain the appropriate binaries and libraries defined by the corresponding platform. Nix can do this without any superuser privileges on Linux, Darwin, and BSD Unix, although I have to say that BSD support is limited because there seem to be very few people using Nix on BSD. (I reckon the BSD people are happy with their BSD ports and aren't interested in a third-party package manager.) Furthermore, Nix can many different versions of *any* package simultaneously, not just Haskell: nix-env -p ~/python-2.6.7 -iA python26 nix-env -p ~/python-2.7.3 -iA python27 nix-env -p ~/python-3.2.3 -iA python3 Anyone who's interested in Nix can find lots of information on the web site http://nixos.org/. There's also the IRC channel #nixos on irc.freenode.org where some Nix developers hang out. Last but not least, there is the developer mailing list nix-...@cs.uu.nl. I'll be happy to answer any further questions that may arise. Take care, Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [Haskell] JustHub 'Sherkin' Release
Hi Peter and Andres, Where is this functionality provided by Nix? simply run these commands ... # Haskell Platform 2012.2.0.0' nix-env -p ~/ghc-7.4.1 -iA haskellPackages_ghc741.haskellPlatform and you'll have profiles that contain the appropriate binaries and libraries defined by the corresponding platform. What you have here is a mechanism for setting up a user-environment for an appropriate platform. Unfortunately I cannot see how it can address any of the user-level Haskell package database management and sandboxing mechanisms that I mentioned in the announcement and subsequent emails. Also it requires that the user load up a special environment before going to work on a work tree rather than the drivers detecting from the context the correct toolchain and invoking it automatically. It might not sound like much but imagine how it would be if you had to set up a special environment before you could work with a git work tree -- there is quite a difference between the two approaches in practice. Finally the Nix method is of course fundamentally dependent upon Nix. I can appreciate why you may believe that everybody should just get Haskell through Nix but I think there is merit to developing a mechanism that allows Haskell to be better packaged regardless of its distribution channel. If I thought there was any chance at all that Haskell could be universally provided through Nix then it might be different, but I don't. None of which detracts from general excellence of Nix and the Nix Haskell distribution. And I still think the mechanism I am proposing would work well with the Nix distribution. Indeed it may be best placed to make full use of it. Chris ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Installing pandoc / json with ghc 6.12.1
Hello, I recently tried to install the latest version of pandoc on my debian stable box (with ghc 6.12.1) using virthualenv as sandboxing mechanism. But instead of a normal installation, compilation of the json package (more specifically the Text.JSON.Parsec module) hangs and causes ghc to consume around 2GB of RAM (out of 3GB) and the system to swap and hang. For reference ... I just created a plain virthualenv (for sandboxing) and after that ran (tmp) foo@bar:/tmp$ cabal install json I also tried if this has something to do with version 0.5 (the latest version) only, to no avail. Are there other users of pandoc/json or related packages who encountered/solved this issue? Am I doing something wrong here? Best regards, Rico ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] class instances for kinds with finite ty constrs, does this make sense?
2012/6/8 Brent Yorgey byor...@seas.upenn.edu: On Thu, Jun 07, 2012 at 07:32:45PM +0100, ex falso wrote: we always have to put the class restriction (TupleLength l) there, even though all possible type constructors of [*] have a TupleLength instance defined! Yes, and this is a feature, for at least two reasons. First: to the extent that Haskell's type system corresponds to a logic, it corresponds to a constructive one. Types/propositions are inhabited/proved by explicit terms/evidence. But this request (and [1]) essentially boil down to a desire for double negation elimination: if there *can't* *not* be a certain instance, then the compiler should infer that there *is* one. This seems weird to me (though perhaps I've just drunk too much of the constructivism kool-aid). While I more or less agree with that (still not convinced completely)... Second, on a more practical level, the ability to omit class constraints like this would make reasoning about types much more non-local and difficult, since a type like foo :: Bar a - Baz may or may not implicitly expand to something like foo :: SomeClass a = Bar a - Baz ...this argument is irrelevant in my opinion. You will be forced by GHC type checking to specify which promoted type is an argument. So foo will have type foo :: Bar (a :: Doh) - Baz and constraint will be SomeClass (a :: Doh). (which could have important implications for things like inlining, sharing, etc. -- cf the monomorphism restriction), but figuring out whether it does or not requires knowing (a) the definition of Bar and all the instances that are in scope, and (b) whether or not SomeClass's methods ever get called from foo (or anything it calls, recursively). I'd much rather explicitly write the SomeClass constraint if I want it, and be guaranteed that it won't be added if I don't. In summary, these constraints may be superfluous in a strictly logical sense, but (a) not in the kind of logic that Haskell uses, and (b) the pain and suffering caused by removing them would far outweigh the tiny bit of typing that would be saved. I would like to suffer that removal. Bring the pain of it! Because right now there's no incentive to drop usual types and use the promoted ones. At least, in the concrete use case of type-level arithmetic (with variables, of course). -Brent [1] http://haskell.1045720.n5.nabble.com/Data-Kinds-and-superfluous-in-my-opinion-constraints-contexts-td5689436.html ___ 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] event handler
Hi, it works very well! I tried to implement it. Here is my test code. Apparently I need some casts to search the list. The syntax looks good. Only addEvent will be on the interface, so that should be fine. If I understand well, that's this function that enforces the right types to be used. The events are referenced via the type of data they use. It just bothers me a little that I'm not able to enumerate the events, and also that the user is able to create events with wrong types (like New :: Event String), even if they won't be able to register them. I also have several unrelated events that use the same type of data, so this would be a problem. Adding more events like *data Event d = NewPlayer | NewRule deriving (Typeable, Eq)* is not correct because I can add wrong events like: addEvent (NewPlayer :: Event Rule) (H(undefined::(Rule - IO( [] ** Also one question: I don't understand the where clause in your class. If I remove it, it works the same... Here is my code: *newtype Player = P Int deriving Typeable newtype Rule = R Int deriving Typeable data Event d = New deriving (Typeable, Eq) class (Typeable d) = Handled d where data Handler d = H (d - IO ()) data EventHandler = forall d . (Handled d) = EH (Event d) (Handler d) instance Handled Player instance Handled Rule addEvent :: (Handled d) = Event d - Handler d - [EventHandler] - [EventHandler] addEvent e h ehs = (EH e h):ehs triggerEvent :: (Handled d) = Event d - d - [EventHandler] - IO () triggerEvent e d ehs = do let r = find (\(EH myEvent _) - cast e == Just myEvent) ehs case r of Nothing - return () Just (EH _ (H h)) - case cast h of Just castedH - castedH d Nothing - return () h1 :: Player - IO () h1 (P a) = putStrLn $ Welcome Player ++ (show a) ++ ! h2 :: Rule - IO () h2 (R a) = putStrLn $ New Rule ++ (show a) eventList1 = addEvent (New :: Event Player) (H h1) [] eventList2 = addEvent (New :: Event Rule) (H h2) eventList1 trigger1 = triggerEvent (New :: Event Player) (P 1) eventList2 -- yelds Welcome Player 1! trigger2 = triggerEvent (New :: Event Rule) (R 2) eventList2 --yelds New Rule* 2 Best, Corentin On Fri, Jun 15, 2012 at 12:40 AM, Alexander Solla alex.so...@gmail.comwrote: On Thu, Jun 14, 2012 at 2:04 PM, Corentin Dupont corentin.dup...@gmail.com wrote: That look really nice! Unfortunately I need to have an heterogeneous list of all events with their handlers. With this test code it won't compile: test1 = addEvent (New :: Event Player) (H (undefined::(Player - IO ( [] test2 = addEvent (New :: Event Rule) (H (undefined::(Rule - IO ( test1 Right, okay. Heterogenous lists are tricky, but I think we can get away with using ExistentialQuantification, since you seem to only want to dispatch over the heterogenous types. The assumption I made is a big deal! It means you can't extract the d value. You can only apply properly typed functions (your handlers) on it. * {-# LANGUAGE ExistentialQuantification #-} * * type Player = Int * * type Rule = Int * * data Event d = New d * * * *class Handled data where -- Together with EventHandler, corresponds to your Data type* * * *data EventHandler = forall d . (Handled d) = EH (Event d) (d - IO ()) -- EventHandler takes the place of your (Event d, Handler d) pairs without referring to d.* * * *instance Handled Player* *instance Handled Rule* *addEvent :: (Handled d) = Event d - Handler d - [EventHandler] - [EventHandler] -- Every [EventHandler] made using addEvent will be of correct types (i.e., preserve the typing invariants you want), but YOU must ensure that only [EventHandler]s made in this way are used. This can be done statically with another type and an explicit export list. We can talk about that later, if this works in principle.* *triggerEvent :: (Handled d) = Event d - d - [EventHandler] - IO ()* ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] event handler
On Fri, Jun 15, 2012 at 6:38 AM, Corentin Dupont corentin.dup...@gmail.comwrote: It just bothers me a little that I'm not able to enumerate the events, and also that the user is able to create events with wrong types (like New :: Event String), even if they won't be able to register them. This can be solved with an explicit export list/smart constructors. newPlayer :: Event Player newRule:: Event Rule (hide the New constructor) In any case, my thinking was that your original data Event = *NewPlayer | NewRule* * * was basically trying to join the semantics of new things with Player and Rule. But the original approach ran into the problem you mention below -- it is difficult to maintain invariants, since the types want to multiply. So formally, I factored: data Event = NewPlayer | NewRule == data Event = New (Player | Rule)== data Event d = New -- (since the original event didn't want a Player or Rule value. It witnessed the type relation) On the other hand, if you want to make sure that a type must be Handled before you can issue an Event, you can do: data (Handled d) = Evend d = New I'm pretty sure the compiler will complain if you try to make a (New :: Event String). I like this idea better than smart constructors for events, if only because you get to use ScopedTypeVariables. I also have several unrelated events that use the same type of data, so this would be a problem. Can you clarify? Adding more events like *data Event d = NewPlayer | NewRule deriving (Typeable, Eq)* is not correct because I can add wrong events like: addEvent (NewPlayer :: Event Rule) (H(undefined::(Rule - IO( [] ** Also one question: I don't understand the where clause in your class. If I remove it, it works the same... Yes, unnecessary where clauses are optional. Here is my code: *newtype Player = P Int deriving Typeable newtype Rule = R Int deriving Typeable data Event d = New deriving (Typeable, Eq) class (Typeable d) = Handled d where data Handler d = H (d - IO ()) data EventHandler = forall d . (Handled d) = EH (Event d) (Handler d) instance Handled Player instance Handled Rule addEvent :: (Handled d) = Event d - Handler d - [EventHandler] - [EventHandler] addEvent e h ehs = (EH e h):ehs triggerEvent :: (Handled d) = Event d - d - [EventHandler] - IO () triggerEvent e d ehs = do let r = find (\(EH myEvent _) - cast e == Just myEvent) ehs case r of Nothing - return () Just (EH _ (H h)) - case cast h of Just castedH - castedH d Nothing - return () h1 :: Player - IO () h1 (P a) = putStrLn $ Welcome Player ++ (show a) ++ ! h2 :: Rule - IO () h2 (R a) = putStrLn $ New Rule ++ (show a) eventList1 = addEvent (New :: Event Player) (H h1) [] eventList2 = addEvent (New :: Event Rule) (H h2) eventList1 trigger1 = triggerEvent (New :: Event Player) (P 1) eventList2 -- yelds Welcome Player 1! trigger2 = triggerEvent (New :: Event Rule) (R 2) eventList2 --yelds New Rule* 2 Best, Corentin On Fri, Jun 15, 2012 at 12:40 AM, Alexander Solla alex.so...@gmail.comwrote: On Thu, Jun 14, 2012 at 2:04 PM, Corentin Dupont corentin.dup...@gmail.com wrote: That look really nice! Unfortunately I need to have an heterogeneous list of all events with their handlers. With this test code it won't compile: test1 = addEvent (New :: Event Player) (H (undefined::(Player - IO ( [] test2 = addEvent (New :: Event Rule) (H (undefined::(Rule - IO ( test1 Right, okay. Heterogenous lists are tricky, but I think we can get away with using ExistentialQuantification, since you seem to only want to dispatch over the heterogenous types. The assumption I made is a big deal! It means you can't extract the d value. You can only apply properly typed functions (your handlers) on it. * {-# LANGUAGE ExistentialQuantification #-} * * type Player = Int * * type Rule = Int * * data Event d = New d * * * *class Handled data where -- Together with EventHandler, corresponds to your Data type* * * *data EventHandler = forall d . (Handled d) = EH (Event d) (d - IO ()) -- EventHandler takes the place of your (Event d, Handler d) pairs without referring to d.* * * *instance Handled Player* *instance Handled Rule* *addEvent :: (Handled d) = Event d - Handler d - [EventHandler] - [EventHandler] -- Every [EventHandler] made using addEvent will be of correct types (i.e., preserve the typing invariants you want), but YOU must ensure that only [EventHandler]s made in this way are used. This can be done statically with another type and an explicit export list. We can talk about that later, if this works in principle.* *triggerEvent :: (Handled d) = Event d - d - [EventHandler] - IO ()* ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Installing pandoc / json with ghc 6.12.1
Am I doing something wrong here? Well, you're using ghc-6.12 ... :-) The most recent version of pandoc that Hackage claims to have built with ghc 6.12 looks to be 1.6. Rolling back that far eliminates the json dependency entirely, so I think it would solve your issue. Or you could use the Pandoc in Debian stable, which appears to be 1.5.1. A more recent ghc would probably also work, of course, but I imagine you're trying the Debian stable version for a reason. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [Haskell] JustHub 'Sherkin' Release
Hi Chris, I cannot see how it can address any of the user-level Haskell package database management and sandboxing mechanisms that I mentioned in the announcement and subsequent emails. have you ever actually used Nix? Take care, Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [Haskell] JustHub 'Sherkin' Release
I deatiled some of my trials with Nix -- I wasn't making it up! Chris ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [Haskell] JustHub 'Sherkin' Release
To be honest I did try to use Nix for exactly this purpose. For some reason things started to break and since I couldnt find any documentation on how to do stuff with it, I just abandonded the idea. Also tried out NixOS: pretty much the same story. Everything appears to be fine at the start, but then after few upgrades things start to fail. I know its very vague but really this is how I remember this experience. For one thing there was lack of how tos related to Haskell stuff anywhere. Just some general documentation that really have some gaps. You end up digging up some implementation details just because you wanted to install a new package. I'm not trying to spread FUD: only telling my not-so-success story with Nix. I'm sure Nix/NixOS has some potential but clearly it's not there yet for some reason. Best regards, Krzysztof Skrzętnicki On Fri, Jun 15, 2012 at 9:10 PM, Peter Simons sim...@cryp.to wrote: Hi Chris, I cannot see how it can address any of the user-level Haskell package database management and sandboxing mechanisms that I mentioned in the announcement and subsequent emails. have you ever actually used Nix? Take care, Peter ___ 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] [Haskell] JustHub 'Sherkin' Release
Hi Chris, I deatiled some of my trials with Nix -- I wasn't making it up! of course, I didn't mean to imply that you were. My question was phrased poorly, I am sorry. What I meant to ask is: how much time, approximately, did you spend working with Nix? 1 hour? 10 hours? 10 days? 10 months? Take care, Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANN: Portackage - a hackage portal
Now all packages, including those without exposed modules, are included. Also, I've attempted to parse the author lists into JSON arrays. Due to the free format of many fields in the .cabal package descriptions, including author list, there are many exceptional cases where they are ill-parsed, but at least the JSON file is well-formed and validates at jsonlint.com. Once more: JSON Schema: http://www.fremissant.net/portackage/packages.schema.json.txt Hopefully compressed JSON data: http://www.fremissant.net/portackage/packages.php Raw JSON data in case the compressed doesn't work: http://www.fremissant.net/portackage/packages.json The hackage data updated as of yesterday (June 14). Will work on daily incremental updates from Hackage RSS feed soon. -Andrew On Thu, Jun 14, 2012 at 7:05 PM, Andrew Seniuk ras...@gmail.com wrote: I discovered http://jsonlint.com/ and got it to validate. :) On Thu, Jun 14, 2012 at 6:18 PM, Andrew Seniuk ras...@gmail.com wrote: Hi ___, Thank you for your suggestion to provide JSON, which seconds Derek's earlier suggestion. I have anonymised your name since you wrote to me but didn't CC the list. :) As much as I wish the web interface was up to snuff, it is really too slow. While I continue to try to resolve that, there is something like a JSON feed available now. I'm new to these things and may be doing it wrong. Any advice would be appreciated, either in accelerating the web interface or in providing the JSON. I have no idea whether it parses or not. JSON Schema: http://www.fremissant.net/portackage/packages.schema.json.txt Hopefully compressed JSON data: http://www.fremissant.net/portackage/packages.php Raw JSON data in case the compressed doesn't work: http://www.fremissant.net/portackage/packages.json The hackage data updated as of today (June 14). For now this is only the packages which expose modules (i.e. not including binary packages). No particular reason, I just ran out of time this afternoon and thought I'd post what I've got. The fields present in the JSON are those available on the HTML table version. There are several dozen other fields which come up more or less infrequently in the Hackage packages, and they could all be included. The complete list of modules is included (rather than the summary versions used in the HTML table version). A next step would be for the server to incrementally update the JSON data based on the Hackage RSS feed. Kind Regards, Andrew On Wed, Jun 13, 2012 at 7:58 AM, ___ wrote: Hi Andrew Portackage is a great site for browsing packages, but it's really really slow for filtering per column. What about offering an additional non-javascript version of the pages -- searching with plain text in a browser works quite well. On 4/30/12, Andrew Seniuk ras...@gmail.com wrote: Oops, the three links in summary are: module tree: http://fremissant.net/portackage/modules.php library packages: http://fremissant.net/portackage/portackage.php other packages: http://fremissant.net/portackage/binary.php ___ 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] event handler
I made some modifications based on your suggestions (see below). I made a two parameters class: *class (Typeable e, Typeable d) = Handled e d * Because after all what I want is to associate an event with its type parameters. I don't know why I cannot implement you suggestion to restrict the instances of Event: *data **(Handled e d) = **Event e = Event deriving (Typeable, Eq) *gives me a *Not in scope: type variable `d'* But apart from that it works very well! It's quite a nice interface! Also just to know, is there a way of getting ride of all these Typeable? {-# LANGUAGE ExistentialQuantification, DeriveDataTypeable, MultiParamTypeClasses #-} *module Events (addEvent, newPlayer, newRule) where import Control.Monad import Data.List import Data.Typeable newtype Player = P Int deriving Typeable newtype Rule = R Int deriving Typeable data Event e = Event deriving (Typeable, Eq) data NewPlayer deriving Typeable data NewRule deriving Typeable newPlayer :: Event NewPlayer newPlayer = Event newRule :: Event NewRule newRule = Event class (Typeable e, Typeable d) = Handled e d instance Handled NewPlayer Player instance Handled NewRule Rule data EventHandler = forall e d . (Handled e d) = EH (Event e) (d - IO ()) addEvent :: (Handled e d) = Event e - (d - IO ()) - [EventHandler] - [EventHandler] addEvent e h ehs = (EH e h):ehs triggerEvent :: (Handled e d) = Event e - d - [EventHandler] - IO () triggerEvent e d ehs = do let r = find (\(EH myEvent _) - cast e == Just myEvent) ehs case r of Nothing - return () Just (EH _ h) - case cast h of Just castedH - castedH d Nothing - return () -- TESTS h1 :: Player - IO () h1 (P a) = putStrLn $ Welcome Player ++ (show a) ++ ! h2 :: Rule - IO () h2 (R a) = putStrLn $ New Rule ++ (show a) eventList1 = addEvent newPlayer h1 [] eventList2 = addEvent newRule h2 eventList1 trigger1 = triggerEvent newPlayer (P 1) eventList2 --Yelds Welcome Player 1! trigger2 = triggerEvent newRule (R 2) eventList2 --Yelds New Rule 2 * On Fri, Jun 15, 2012 at 4:53 PM, Alexander Solla alex.so...@gmail.comwrote: On Fri, Jun 15, 2012 at 6:38 AM, Corentin Dupont corentin.dup...@gmail.com wrote: It just bothers me a little that I'm not able to enumerate the events, and also that the user is able to create events with wrong types (like New :: Event String), even if they won't be able to register them. This can be solved with an explicit export list/smart constructors. newPlayer :: Event Player newRule:: Event Rule (hide the New constructor) In any case, my thinking was that your original data Event = *NewPlayer | NewRule* * * was basically trying to join the semantics of new things with Player and Rule. But the original approach ran into the problem you mention below -- it is difficult to maintain invariants, since the types want to multiply. So formally, I factored: data Event = NewPlayer | NewRule == data Event = New (Player | Rule)== data Event d = New -- (since the original event didn't want a Player or Rule value. It witnessed the type relation) On the other hand, if you want to make sure that a type must be Handled before you can issue an Event, you can do: data (Handled d) = Evend d = New I'm pretty sure the compiler will complain if you try to make a (New :: Event String). I like this idea better than smart constructors for events, if only because you get to use ScopedTypeVariables. I also have several unrelated events that use the same type of data, so this would be a problem. Can you clarify? I mean that I have events like: Message String UserEvent String That have a data of the same type, but they are not related. Adding more events like *data Event d = NewPlayer | NewRule deriving (Typeable, Eq)* is not correct because I can add wrong events like: addEvent (NewPlayer :: Event Rule) (H(undefined::(Rule - IO( [] ** Also one question: I don't understand the where clause in your class. If I remove it, it works the same... Yes, unnecessary where clauses are optional. Here is my code: *newtype Player = P Int deriving Typeable newtype Rule = R Int deriving Typeable data Event d = New deriving (Typeable, Eq) class (Typeable d) = Handled d where data Handler d = H (d - IO ()) data EventHandler = forall d . (Handled d) = EH (Event d) (Handler d) instance Handled Player instance Handled Rule addEvent :: (Handled d) = Event d - Handler d - [EventHandler] - [EventHandler] addEvent e h ehs = (EH e h):ehs triggerEvent :: (Handled d) = Event d - d - [EventHandler] - IO () triggerEvent e d ehs = do let r = find (\(EH myEvent _) - cast e == Just myEvent) ehs case r of Nothing - return () Just (EH _ (H h)) - case cast h of Just castedH - castedH d Nothing - return () h1 :: Player - IO () h1 (P a) = putStrLn $ Welcome Player ++ (show a) ++ ! h2 :: Rule - IO () h2 (R a) = putStrLn $ New Rule ++ (show a)
Re: [Haskell-cafe] [Haskell] JustHub 'Sherkin' Release
What I meant to ask is: how much time, approximately, did you spend working with Nix? 1 hour? 10 hours? 10 days? 10 months? You know that it is not 10 months, but I do object to your line of questioning. I have invested a considerable good-faith effort into getting to the bottom of what you and Andres have been saying. I am no seasoned expert at Nix but I have been through the process of installing and using multiple distributions, and reading around and I have been paying attention to what you have been saying. But my time is really quite limited. I of course know exactly what I have been doing in putting together the JustHub distribution and while they have some similarities -- mostly around the idea of allowing multiple tool chains to co-exist; the way they go about it is very different. And those details are critical in my mind (please note). I also know that I have been adding things that a generic package manager is most unlikely to be covering -- because a new tool is provided that tangles with the existing tools in a detailed way (e.g., parsing spec files and analysing package databases for example). To take just one example, I provide a mechanism that allows developers to archive the configuration of their Haskell development environment and check it into a source management system. The developer can check it out on a another system and if the build process invokes the recovery mechansim it will automatically rebuild the environment on the first run (reporting an error if the required tool chain is not installed on the system). Subsequent runs of the build process will merely check that nothing has been disturbed and proceed straight to the main build process. Maybe Nix provides such a mechanism -- I don't know. But all attempts to discover this and other mechanisms have failed and any hard information that I come across suggests that this is unlikely. (Hint: it is mostly concerned with the Haskell *user* package DB; I have just expanded on the 'archiving' part of the original announcement by the way.) It is a great shame as I like the Nix philsophy and I would like to see the other distributions adopt more of its functional philosophy. But I am out of time. If you will excuse me I would rather wind up this thread once you have replied (if you would like to) Chris ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Performance with do notation, mwc-random and unboxed vector
On Wed, Jun 13, 2012 at 12:56 AM, Roman Leshchinskiy r...@cse.unsw.edu.auwrote: It doesn't change the semantics of your program but it can make it significantly slower (or faster, as in this case). The various state hack related tickets on trac might give you an idea of what is happening here. I filed a bug: http://hackage.haskell.org/trac/ghc/ticket/6166 (I'd CC myself on an existing bug, but trac's search feature gives me tons of irrelevant hits.) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Odd HDBC connection bug
Hi I'm having issues with HDBC when connecting to a remote MySQL server - certain queries cause the DB connection to be lost. The following program demonstrates this: import Database.HDBC import Database.HDBC.ODBC main = do conn - connectODBC DSN=owlro putStrLn Connected quickQuery' conn SELECT time, power FROM Power LIMIT 100; [] putStrLn Finished query 1 quickQuery' conn SELECT time, power FROM Power ORDER BY time; [] putStrLn Finished query 2 disconnect conn The DSN points to a remote 32-bit Ubuntu 12.04 Server. The connection and queries work using mysql and isql on the command line, and the table in question contains about 1.3 million rows and only the columns id, time, power. When I compile and run this on a 64-bit Ubuntu 12.04 PC using HDBC-2.3.1.1 and HDBC-odbc-2.3.1.0 using GHC, I get the following (unwanted) output: $ ghc Test.hs $ ./Test Connected Finished query 1 Test: SqlError {seState = [\08S01\], seNativeError = -1, seErrorMsg = execute execute: [\2013: [MySQL][ODBC 5.1 Driver][mysqld-5.5.24-0ubuntu0.12.04.1]Lost connection to MySQL server during query\]} This program finishes (and fails) in less than half a second. When I run it using runhaskell however, the slow second query completes: $ runhaskell Test.hs Connected Finished query 1 Finished query 2 I get the same result from ghci; this method takes about 10 seconds as expected. Basically, simple (short) queries complete, yet long ones crash the connection. I also noticed similar results with HDBC-mysql. Any ideas on what is causing this? Thanks, Will Shackleton digitalsquid.co.uk ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] ANNOUNCE: set-monad
I would like to announce the first release of the set-monad library. On Hackage: http://hackage.haskell.org/package/set-monad The set-monad library exports the Set abstract data type and set-manipulating functions. These functions behave exactly as their namesakes from the Data.Set module of the containers library. In addition, the set-monad library extends Data.Set by providing Functor, Applicative, Alternative, Monad, and MonadPlus instances for sets. In other words, you can use the set-monad library as a drop-in replacement for the Data.Set module of the containers library and, in addition, you will also get the aforementioned instances which are not available in the containers package. It is not possible to directly implement instances for the aforementioned standard Haskell type classes for the Set data type from the containers library. This is because the key operations map and union, are constrained with Ord as follows. map :: (Ord a, Ord b) = (a - b) - Set a - Set b union :: (Ord a) = Set a - Set a - Set a The set-monad library provides the type class instances by wrapping the constrained Set type into a data type that has unconstrained constructors corresponding to monadic combinators. The data type constructors that represent monadic combinators are evaluated with a constrained run function. This elevates the need to use the constraints in the instance definitions (this is what prevents a direct definition). The wrapping and unwrapping happens internally in the library and does not affect its interface. For details, see the rather compact definitions of the run function and type class instances. The left identity and associativity monad laws play a crucial role in the definition of the run function. The rest of the code should be self explanatory. The technique is not new. This library was inspired by [1]. To my knowledge, the original, systematic presentation of the idea to represent monadic combinators as data is given in [2]. There is also a Haskell library that provides a generic infrastructure for the aforementioned wrapping and unwrapping [3]. The set-monad library is particularly useful for writing set-oriented code using the do and/or monad comprehension notations. For example, the following definitions now type check. s1 :: Set (Int,Int) s1 = do a - fromList [1 .. 4] b - fromList [1 .. 4] return (a,b) -- with -XMonadComprehensions s2 :: Set (Int,Int) s2 = [ (a,b) | (a,b) - s1, even a, even b ] s3 :: Set Int s3 = fmap (+1) (fromList [1 .. 4]) As noted in [1], the implementation technique can be used for monadic libraries and EDSLs with restricted types (compiled EDSLs often restrict the types that they can handle). Haskell's standard monad type class can be used for restricted monad instances. There is no need to resort to GHC extensions that rebind the standard monadic combinators with the library or EDSL specific ones. [1] CSDL Blog: The home of applied functional programming at KU. Monad Reification in Haskell and the Sunroof Javascript compiler. http://www.ittc.ku.edu/csdlblog/?p=88 [2] Chuan-kai Lin. 2006. Programming monads operationally with Unimo. In Proceedings of the eleventh ACM SIGPLAN International Conference on Functional Programming (ICFP '06). ACM. [3] Heinrich Apfelmus. The operational package. http://hackage.haskell.org/package/operational ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe