From voldermort at hotmail.com Sun Feb 2 21:01:24 2014 From: voldermort at hotmail.com (harry) Date: Sun, 2 Feb 2014 21:01:24 +0000 (UTC) Subject: [Haskell-beginners] Convert numeric IP to Network.Socket.HostAddress Message-ID: I need to convert a numeric IP (such as 1.2.3.4) to a HostAddress for consumption by SockAddrInet. The only function I can find to do this is inet_addr, which is impure (can do DNS lookups). Is there a pure conversion? From tim.v2.0 at gmail.com Sun Feb 2 21:30:45 2014 From: tim.v2.0 at gmail.com (Tim Perry) Date: Sun, 2 Feb 2014 13:30:45 -0800 Subject: [Haskell-beginners] Convert numeric IP to Network.Socket.HostAddress In-Reply-To: References: Message-ID: Can you use the SockAddrUnix constructor of SockAddr? See http://hackage.haskell.org/package/network-2.2.1.3/docs/Network-Socket.html#t%3ASockAddr Tim Perry (916) 505-3634 On Sun, Feb 2, 2014 at 1:01 PM, harry wrote: > I need to convert a numeric IP (such as 1.2.3.4) to a HostAddress for > consumption by SockAddrInet. The only function I can find to do this is > inet_addr, which is impure (can do DNS lookups). Is there a pure > conversion? > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://www.haskell.org/mailman/listinfo/beginners > -------------- next part -------------- An HTML attachment was scrubbed... URL: From michael at snoyman.com Mon Feb 3 05:23:29 2014 From: michael at snoyman.com (Michael Snoyman) Date: Mon, 3 Feb 2014 07:23:29 +0200 Subject: [Haskell-beginners] Convert numeric IP to Network.Socket.HostAddress In-Reply-To: References: Message-ID: You can use the functionality in Data.IP[1] (from iproutes) to accomplish this. You'd first use `read` (or a safer version thereof, like Safe.readMay) to convert a String to an IPv4, and then toHostAddress to convert that to a HostAddress. [1] http://hackage.haskell.org/package/iproute-1.2.11/docs/Data-IP.html On Sun, Feb 2, 2014 at 11:01 PM, harry wrote: > I need to convert a numeric IP (such as 1.2.3.4) to a HostAddress for > consumption by SockAddrInet. The only function I can find to do this is > inet_addr, which is impure (can do DNS lookups). Is there a pure > conversion? > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://www.haskell.org/mailman/listinfo/beginners > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dominikbollmann at gmail.com Mon Feb 3 15:55:12 2014 From: dominikbollmann at gmail.com (Dominik Bollmann) Date: Mon, 03 Feb 2014 10:55:12 -0500 Subject: [Haskell-beginners] foldM with tuple and maybe In-Reply-To: References: Message-ID: <87wqhcur6n.fsf@debox.i-did-not-set--mail-host-address--so-tickle-me> Or maybe what you really want is mapM instead of foldM? In this case, your function f2 will look like this: f2 :: [(String, String)] -> IO [Maybe String] f2 xs = mapM f1 xs And this will first map (=apply) your function f1 over all elements in the given input list xs and then it will sequence this list, thus creating a resulting list of type IO [Maybe String] David McBride writes: > You have a foldM function which takes a " a -> b -> m a " as a first > argument. But you are passing it f1 which has a type (a, b) -> m a. > > Unfortunately I'm not sure what you were trying to do. The function > you have just doesn't fit. :( > > Maybe you intended to have f1 :: String -> (String, String) -> IO > String, and then go > > :t foldM f1 "" x > foldM f1 "" [("a","b"),("c","d")] :: IO String > > > ? > > On Mon, Dec 30, 2013 at 6:42 PM, Miro Karpis wrote: >> Hi, please can you help me with following? >> >> I have a following function: >> f1 :: (String, String) -> IO (Maybe String) >> >> which I would like to apply to a list of tuples.I have defined the function >> like this, but that gives me error (below): >> >> f2 :: [(String, String)] -> IO (Maybe String) >> f2 x = foldM f1 0 x >> >> >> error: >> Couldn't match expected type `IO (Maybe String)' with actual type `[b0] -> >> m0 (String, String)' In the return type of a call of `foldM' >> >> thanks, >> m. >> >> _______________________________________________ >> Beginners mailing list >> Beginners at haskell.org >> http://www.haskell.org/mailman/listinfo/beginners >> > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://www.haskell.org/mailman/listinfo/beginners From tam at hiddenrock.com Wed Feb 5 03:29:56 2014 From: tam at hiddenrock.com (tam at hiddenrock.com) Date: Tue, 4 Feb 2014 22:29:56 -0500 Subject: [Haskell-beginners] coming to grips with hackage Message-ID: <20140205032956.GM7853@vingilot.hiddenrock.com> Hi there -- I've groveled through the Hackage site, I've read a bunch of cabal documentation, and I've read far more blog entries, mailing list posts, and other things turned up by Google than I can count. Please forgive me if my confusions have been addressed elsewhere; if they have, I would appreciate a pointer. I'm having trouble wrapping my head around how to work with Hackage in the context of a Linux distribution that already has its own package management situation. Between distribution-provided packages containing Haskell programs and/or libraries, system-wide cabal installs, user-specific cabal installs, and cabal sandboxes, I can't seem to work out how the hackage/cabal architects intend people (ie, me) to juggle things. Here's a potential scenario: I want to use pandoc, for which my distro provides packages, so I install it along with its various and sundry dependencies using the package manager. Then I want to use another program for which my distro *doesn't* provide a package, so I use cabal-install to install it along with its various and sundry dependencies in ~/.cabal. Then I have a crazy idea I want to play around with in code. Initially, I've got all the libraries I need already installed, but eventually I discover there's a feature in foo-1.1.3.4 that my idea just can't live without. Unfortunately, foo-1.0.5.12 is required by pandoc. At this point, it would seem like cabalizing my little idea and letting it play by itself in a cabal sandbox is the preferred method. This seems reasonable, I say to myself, and proceed to recompile every single library upon which my little idea (recursively) depends. But then pandoc gets updated, as well as many of the libraries upon which it depends, which results in a wholesale upgrade of most of the system-wide libraries and now the stuff I've installed in my home directory has all manner of broken dependencies. There's probably a cabal-install command I can run at this point to clean things up (though presumably I'd have to run it for every source tree that uses a library that has been upgraded) but that's beside the point. My confusion is how this scales. Enough little ideas that depend on non-trivial libraries and I'm going to have eleventy-billion extremely similar copies of Data.Text littered about my home directory. Is this really the intention? Did I miss something? Are there better ``best practices'' than what I've described? Any guidance is most appreciated! Thank you. pete PS. Bonus question, which seems intimately related: if A depends on B and a new version of B appears, why does A necessarily need to be recompiled? Isn't one of the big wins of shared objects avoiding this very necessity? Presumably this is a consequence of how the GHC runtime does its linking, but I couldn't find helpful documentation on this count. From allbery.b at gmail.com Wed Feb 5 04:48:52 2014 From: allbery.b at gmail.com (Brandon Allbery) Date: Tue, 4 Feb 2014 23:48:52 -0500 Subject: [Haskell-beginners] coming to grips with hackage In-Reply-To: <20140205032956.GM7853@vingilot.hiddenrock.com> References: <20140205032956.GM7853@vingilot.hiddenrock.com> Message-ID: On Tue, Feb 4, 2014 at 10:29 PM, wrote: > I'm having trouble wrapping my head around how to work with Hackage in the > context of a Linux distribution that already has its own package management > situation. Between distribution-provided packages containing Haskell > programs > and/or libraries, system-wide cabal installs, user-specific cabal installs, > and cabal sandboxes, I can't seem to work out how the hackage/cabal > architects > intend people (ie, me) to juggle things. > This is not a Hackage-specific issue; you will run into it with any language ecosystem, and every language ecosystem has its own mechanisms for dealing with it (usually involving some form of sandboxing). Indeed, some languages pretty much require those mechanisms: all too often, you need a separate rvm sandbox for multiple Ruby applications.... The general rule is that if you're just looking to install a few things available from OS packages and are not doing development, use the OS packages; otherwise, install just enough to be able to use cabal to install stuff. Although this also may vary: in many cases you will want to install the Platform libraries from your OS because you should really only have one version installed and it should generally be the "blessed" stable version. But if you're [say] intending to work with bleeding edge Yesod, then you probably want to only install ghc and cabal-install from the OS. Anyway, this question is why Haskell has hsenv, cabal-dev, and cabal sandboxes; Ruby has rvm, Python has virtualenv, and Perl has perlbrew, and other languages have their own mechanisms to deal with the same problems. And pkg-config is (de facto and for the moment) the solution C and C++ use, attacking it from a different direction. -- brandon s allbery kf8nh sine nomine associates allbery.b at gmail.com ballbery at sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net -------------- next part -------------- An HTML attachment was scrubbed... URL: From apfelmus at quantentunnel.de Wed Feb 5 09:37:57 2014 From: apfelmus at quantentunnel.de (Heinrich Apfelmus) Date: Wed, 05 Feb 2014 10:37:57 +0100 Subject: [Haskell-beginners] coming to grips with hackage In-Reply-To: References: <20140205032956.GM7853@vingilot.hiddenrock.com> Message-ID: Brandon Allbery wrote: > On Tue, Feb 4, 2014 at 10:29 PM, wrote: > >> I'm having trouble wrapping my head around how to work with Hackage in the >> context of a Linux distribution that already has its own package management >> situation. Between distribution-provided packages containing Haskell >> programs >> and/or libraries, system-wide cabal installs, user-specific cabal installs, >> and cabal sandboxes, I can't seem to work out how the hackage/cabal >> architects >> intend people (ie, me) to juggle things. >> > > This is not a Hackage-specific issue; you will run into it with any > language ecosystem, and every language ecosystem has its own mechanisms for > dealing with it (usually involving some form of sandboxing). Indeed, some > languages pretty much require those mechanisms: all too often, you need a > separate rvm sandbox for multiple Ruby applications.... Pretty much this. Perhaps Nix can offer a more pleasant solution: http://ocharles.org.uk/blog/posts/2014-02-04-how-i-develop-with-nixos.html Best regards, Heinrich Apfelmus -- http://apfelmus.nfshost.com From tam at hiddenrock.com Thu Feb 6 04:10:55 2014 From: tam at hiddenrock.com (tam at hiddenrock.com) Date: Wed, 5 Feb 2014 23:10:55 -0500 Subject: [Haskell-beginners] coming to grips with hackage In-Reply-To: References: <20140205032956.GM7853@vingilot.hiddenrock.com> Message-ID: <20140206041055.GI23739@vingilot.hiddenrock.com> Thanks! pete On Tue, Feb 04, 2014 at 11:48:52PM -0500, Brandon Allbery wrote: > On Tue, Feb 4, 2014 at 10:29 PM, wrote: > > > I'm having trouble wrapping my head around how to work with Hackage in the > > context of a Linux distribution that already has its own package management > > situation. Between distribution-provided packages containing Haskell > > programs > > and/or libraries, system-wide cabal installs, user-specific cabal installs, > > and cabal sandboxes, I can't seem to work out how the hackage/cabal > > architects > > intend people (ie, me) to juggle things. > > > > This is not a Hackage-specific issue; you will run into it with any > language ecosystem, and every language ecosystem has its own mechanisms for > dealing with it (usually involving some form of sandboxing). Indeed, some > languages pretty much require those mechanisms: all too often, you need a > separate rvm sandbox for multiple Ruby applications.... > > The general rule is that if you're just looking to install a few things > available from OS packages and are not doing development, use the OS > packages; otherwise, install just enough to be able to use cabal to install > stuff. Although this also may vary: in many cases you will want to install > the Platform libraries from your OS because you should really only have one > version installed and it should generally be the "blessed" stable version. > But if you're [say] intending to work with bleeding edge Yesod, then you > probably want to only install ghc and cabal-install from the OS. > > Anyway, this question is why Haskell has hsenv, cabal-dev, and cabal > sandboxes; Ruby has rvm, Python has virtualenv, and Perl has perlbrew, and > other languages have their own mechanisms to deal with the same problems. > And pkg-config is (de facto and for the moment) the solution C and C++ use, > attacking it from a different direction. > > -- > brandon s allbery kf8nh sine nomine associates > allbery.b at gmail.com ballbery at sinenomine.net > unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://www.haskell.org/mailman/listinfo/beginners From michael at orlitzky.com Thu Feb 6 05:37:59 2014 From: michael at orlitzky.com (Michael Orlitzky) Date: Thu, 06 Feb 2014 00:37:59 -0500 Subject: [Haskell-beginners] coming to grips with hackage In-Reply-To: <20140205032956.GM7853@vingilot.hiddenrock.com> References: <20140205032956.GM7853@vingilot.hiddenrock.com> Message-ID: <52F31FB7.3060609@orlitzky.com> On 02/04/2014 10:29 PM, tam at hiddenrock.com wrote: > Hi there -- > > I'm having trouble wrapping my head around how to work with Hackage in the > context of a Linux distribution that already has its own package management > situation. Between distribution-provided packages containing Haskell programs > and/or libraries, system-wide cabal installs, user-specific cabal installs, > and cabal sandboxes, I can't seem to work out how the hackage/cabal architects > intend people (ie, me) to juggle things. > The most robust approach is to find or create distro packages for everything you need. I'm biased, but I think Gentoo has it best here because its hackport utility makes it trivial to create ebuilds for anything on hackage. We also gladly accept new ebuilds into our Haskell overlay. Arch and Debian are probably tied for second, but I don't know enough to say. In any case, you should track down the Haskell community for your distro and ask them about the easiest way to make a distro package from hackage. From tam at hiddenrock.com Thu Feb 6 05:59:42 2014 From: tam at hiddenrock.com (tam at hiddenrock.com) Date: Thu, 6 Feb 2014 00:59:42 -0500 Subject: [Haskell-beginners] coming to grips with hackage In-Reply-To: <52F31FB7.3060609@orlitzky.com> References: <20140205032956.GM7853@vingilot.hiddenrock.com> <52F31FB7.3060609@orlitzky.com> Message-ID: <20140206055942.GA4424@vingilot.hiddenrock.com> > The most robust approach is to find or create distro packages for > everything you need. How does this handle the situation where I want both package A and package B installed, but they each want a different version of package C? From voldermort at hotmail.com Thu Feb 6 12:10:57 2014 From: voldermort at hotmail.com (harry) Date: Thu, 6 Feb 2014 12:10:57 +0000 (UTC) Subject: [Haskell-beginners] =?utf-8?q?Convert_numeric_IP_to=09Network=2ES?= =?utf-8?q?ocket=2EHostAddress?= References: Message-ID: Tim Perry gmail.com> writes: > Can you use the SockAddrUnix constructor of SockAddr?? > See?http://hackage.haskell.org/package/network-2.2.1.3/docs/Network-Socket.html#t%3ASockAddr What do I give as the parameter? I can't work out the format (which is just String). From voldermort at hotmail.com Thu Feb 6 10:04:50 2014 From: voldermort at hotmail.com (harry) Date: Thu, 6 Feb 2014 10:04:50 +0000 (UTC) Subject: [Haskell-beginners] =?utf-8?q?Convert_numeric_IP_to=09Network=2ES?= =?utf-8?q?ocket=2EHostAddress?= References: Message-ID: Tim Perry gmail.com> writes: > Can you use the SockAddrUnix constructor of SockAddr?? > See?http://hackage.haskell.org/package/network-2.2.1.3/docs/Network-Socket.html#t%3ASockAddr What's the input format? All it says is String. From allbery.b at gmail.com Thu Feb 6 14:38:46 2014 From: allbery.b at gmail.com (Brandon Allbery) Date: Thu, 6 Feb 2014 09:38:46 -0500 Subject: [Haskell-beginners] Convert numeric IP to Network.Socket.HostAddress In-Reply-To: References: Message-ID: On Thu, Feb 6, 2014 at 5:04 AM, harry wrote: > Tim Perry gmail.com> writes: > > Can you use the SockAddrUnix constructor of SockAddr? > > > See > http://hackage.haskell.org/package/network-2.2.1.3/docs/Network-Socket.html#t%3ASockAddr > > What's the input format? All it says is String. You don't want SockAddrUnix. It's for AF_UNIX / AF_LOCAL sockets, which live in the filesystem, and the parameter is the pathname of the socket. -- brandon s allbery kf8nh sine nomine associates allbery.b at gmail.com ballbery at sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net -------------- next part -------------- An HTML attachment was scrubbed... URL: From michael at orlitzky.com Thu Feb 6 22:47:42 2014 From: michael at orlitzky.com (Michael Orlitzky) Date: Thu, 06 Feb 2014 17:47:42 -0500 Subject: [Haskell-beginners] coming to grips with hackage In-Reply-To: <20140206055942.GA4424@vingilot.hiddenrock.com> References: <20140205032956.GM7853@vingilot.hiddenrock.com> <52F31FB7.3060609@orlitzky.com> <20140206055942.GA4424@vingilot.hiddenrock.com> Message-ID: <52F4110E.90604@orlitzky.com> On 02/06/2014 12:59 AM, tam at hiddenrock.com wrote: >> The most robust approach is to find or create distro packages for >> everything you need. > > How does this handle the situation where I want both package A and package B > installed, but they each want a different version of package C? > How would your distro handle it if those packages were written in C? This isn't too much of a problem in practice. With Haskell it seems worse because everything has conservative dependencies in a *.cabal file and Cabal will refuse to build the thing unless they're met. When we find a package that's too conservative, we mangle the dependencies on the fly and report it upstream. If there's a more serious conflict, sometimes both versions can be installed side-by-side, but in general we have to file a bug and wait just like if it was written in e.g. python. But I see that as a good thing: I've got some 300 haskell packages installed at the moment, and I know that they're all in a consistent state (and up to date). It's pretty nice when people complain about Cabal and you have no idea what they're talking about. I also do development on three different machines, and it's handy to have them running the same packages. From tam at hiddenrock.com Fri Feb 7 02:36:41 2014 From: tam at hiddenrock.com (tam at hiddenrock.com) Date: Thu, 6 Feb 2014 21:36:41 -0500 Subject: [Haskell-beginners] coming to grips with hackage In-Reply-To: <52F4110E.90604@orlitzky.com> References: <20140205032956.GM7853@vingilot.hiddenrock.com> <52F31FB7.3060609@orlitzky.com> <20140206055942.GA4424@vingilot.hiddenrock.com> <52F4110E.90604@orlitzky.com> Message-ID: <20140207023641.GK13515@vingilot.hiddenrock.com> > > How does this handle the situation where I want both package A and package B > > installed, but they each want a different version of package C? > > How would your distro handle it if those packages were written in C? I'd say the C-leaning factions of the open-source community have largely accepted the convention that ABI/API changes that cause incompatibilities are accompanied by bumps in the major version number. There are, of course, exceptions, but my feeling is they are rare, generally well-publicized, and quickly fixed. To be honest, I don't even know if hackage authors tend to follow this convention because... > With Haskell it seems worse because everything has conservative dependencies > in a *.cabal file and Cabal will refuse to build the thing unless they're > met. ... Haskell seems worse to me in that if package foo is updated, every other package depending on foo (recursely) must then be rebuilt, even if they didn't change and even if the interface presented by foo didn't change. C programs do not suffer similarly and my limited experience with ``cabal hell'' would have been a non-event if this recompilation process wasn't necessary. I don't know what technical issues necessitate it and I don't know whether the conventions required to make it feasible are already in place, which is partially what I'm trying to learn here. =) Additionally, it seems that the hackage ecosystem is far more intertwined than that of third-party Python packages (I have no experience with Ruby). That is, many things in hackage depend on other things in hackage whereas far more Python packages depend only on the libraries included in the base install. This is not a knock against Haskell by any means; it is, in fact, a testament to the powerful abstractions it supplies and enables. It does, however, weaken the ``other languages have this problem, too'' argument. Perhaps the solution is a more rigorous effort to keep the Haskell Platform up to date, especially with well-regarded ``building block'' libraries (eg, lens), and possibly even on a fixed schedule. Then hackage authors can be encouraged to make their stuff compatible with particular releases of the Haskell Platform and ``normal'' users would only need to worry about upgrades whenever the Platform is updated. But then we're really edging out on the slippery slope to Haskell becoming a distro unto itself. pete From allbery.b at gmail.com Fri Feb 7 02:53:17 2014 From: allbery.b at gmail.com (Brandon Allbery) Date: Thu, 6 Feb 2014 21:53:17 -0500 Subject: [Haskell-beginners] coming to grips with hackage In-Reply-To: <20140207023641.GK13515@vingilot.hiddenrock.com> References: <20140205032956.GM7853@vingilot.hiddenrock.com> <52F31FB7.3060609@orlitzky.com> <20140206055942.GA4424@vingilot.hiddenrock.com> <52F4110E.90604@orlitzky.com> <20140207023641.GK13515@vingilot.hiddenrock.com> Message-ID: On Thu, Feb 6, 2014 at 9:36 PM, wrote: > ... Haskell seems worse to me in that if package foo is updated, every > other > package depending on foo (recursely) must then be rebuilt, even if they > didn't > change and even if the interface presented by foo didn't change. > This is something of a problem, yes... but it's not really "Haskell"'s fault. It's a specific design decision in GHC, in the name of performance: aggressive cross-module inlining means that specific compilation details of dependencies leak into the ABI of their dependents, necessitating exact ABI matches instead of simply consonant versions as in (normal) C. (For comparison, note that KDE has often had exactly the same problem in C++, through using cpp macros in place of inline functions for performance on "hot paths"; the exact macro and *every* (external or internal) function/method/variable it touches becomes part of the "public" ABI that must be maintained for compatibility.) Other Haskell compilers such do things differently. ajhc is a whole-program compiler, so in fact you *always* compile your dependencies again from source. uhc I don't think does the same amount of cross-module inlining, at a performance cost but maintainability gain. (And "Cabal hell" is shooting the messenger; it's just reporting the mess ghc has made / will make.) I do find myself wondering if anyone has checked to see how important the inlining is these days; perhaps ghc's general performance (and a hat tip to Moore's law) has made it possible to consider compiling more stable libraries. -- brandon s allbery kf8nh sine nomine associates allbery.b at gmail.com ballbery at sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net -------------- next part -------------- An HTML attachment was scrubbed... URL: From apfelmus at quantentunnel.de Sat Feb 8 09:52:31 2014 From: apfelmus at quantentunnel.de (Heinrich Apfelmus) Date: Sat, 08 Feb 2014 10:52:31 +0100 Subject: [Haskell-beginners] coming to grips with hackage In-Reply-To: References: <20140205032956.GM7853@vingilot.hiddenrock.com> <52F31FB7.3060609@orlitzky.com> <20140206055942.GA4424@vingilot.hiddenrock.com> <52F4110E.90604@orlitzky.com> <20140207023641.GK13515@vingilot.hiddenrock.com> Message-ID: Brandon Allbery wrote: > I do find myself wondering if anyone has checked to see how important the > inlining is these days; perhaps ghc's general performance (and a hat tip to > Moore's law) has made it possible to consider compiling more stable > libraries. Lately, I have been looking at GHC Core output for unrelated reasons, and it appears to me that cross-module inlining is essential to GHC performance. For instance, if you don't inline the monadic combinators (>>=) and `return` for the IO monad and perform even more inlining afterwards, performance can easily differ by an order of magnitude. The reason is that the second argument of (>>=) is a closure. Closure creation is very expensive compared to the sequence of primops you get after inlining. Best regards, Heinrich Apfelmus -- http://apfelmus.nfshost.com From mathewrphillips at gmail.com Sat Feb 8 15:21:53 2014 From: mathewrphillips at gmail.com (Mathew Phillips) Date: Sat, 8 Feb 2014 09:21:53 -0600 Subject: [Haskell-beginners] Getting GHC 7.8.1 Message-ID: Is there a recommended way to install a newer version of ghc when you already have the haskell platform installed? I've been reading the documentation and I can't seem to find anything that shows how to actually get it other than compiling from source, and I don't want to brick my current setup if both cant coexist. Matt P. -------------- next part -------------- An HTML attachment was scrubbed... URL: From hjgtuyl at chello.nl Sat Feb 8 17:35:48 2014 From: hjgtuyl at chello.nl (Henk-Jan van Tuyl) Date: Sat, 08 Feb 2014 18:35:48 +0100 Subject: [Haskell-beginners] Getting GHC 7.8.1 In-Reply-To: References: Message-ID: On Sat, 08 Feb 2014 16:21:53 +0100, Mathew Phillips wrote: > Is there a recommended way to install a newer version of ghc when you > already have the haskell platform installed? I've been reading the > documentation and I can't seem to find anything that shows how to > actually > get it other than compiling from source, and I don't want to brick my > current setup if both cant coexist. > > Matt P. Just install GHC; nothing from the platform is overwritten. Make sure that the search path points to the right directories. Regards, Henk-Jan van Tuyl -- Folding at home What if you could share your unused computer power to help find a cure? In just 5 minutes you can join the world's biggest networked computer and get us closer sooner. Watch the video. http://folding.stanford.edu/ http://Van.Tuyl.eu/ http://members.chello.nl/hjgtuyl/tourdemonad.html Haskell programming -- From lortabac at gmx.com Sat Feb 8 19:10:18 2014 From: lortabac at gmx.com (Lorenzo Tabacchini) Date: Sat, 08 Feb 2014 20:10:18 +0100 Subject: [Haskell-beginners] Problem with GADTs and Parsec Message-ID: <20140208191019.27630@gmx.com> Hello, I am developing a very simple programming language for didactic purposes. Expressions can be composed of different types, like Int, Bool, String etc... The AST is compiled to JavaScript and the result is shown in the browser. The code is more or less like this: {-# LANGUAGE GADTs #-} data Expr a where Int :: Int -> Expr Int Bool :: Bool -> Expr Bool Text :: String -> Expr String -- Int operations Add :: Expr Int -> Expr Int -> Expr Int -- Bool operations And :: Expr Bool -> Expr Bool -> Expr Bool -- etc. etc. -- converts to JavaScript compile :: Expr a -> String compile (Int n) = show n compile (Text t) = show t compile (Add x y) = compile x ++ "+" ++ compile y -- etc. etc. The compilation works perfectly, but I am stuck with the parser. Since I don't know the types in advance, I would like to parse the whole expression at once. If I do: exprParser :: Parsec String u (Expr a) exprParser = parens exprParser <|> (reserved "true" >> return (Bool True)) <|> (reserved "false" >> return (Bool False)) <|> (stringLiteral >>= return . Text) The compiler says: "Couldn't match type `Bool' with `[Char]'" Where am I wrong? -------------- next part -------------- An HTML attachment was scrubbed... URL: From allbery.b at gmail.com Sat Feb 8 19:21:36 2014 From: allbery.b at gmail.com (Brandon Allbery) Date: Sat, 8 Feb 2014 14:21:36 -0500 Subject: [Haskell-beginners] Problem with GADTs and Parsec In-Reply-To: <20140208191019.27630@gmx.com> References: <20140208191019.27630@gmx.com> Message-ID: On Sat, Feb 8, 2014 at 2:10 PM, Lorenzo Tabacchini wrote: > If I do: > > exprParser :: Parsec String u (Expr a) > exprParser = parens exprParser > <|> (reserved "true" >> return (Bool True)) > <|> (reserved "false" >> return (Bool False)) > <|> (stringLiteral >>= return . Text) > > The compiler says: "Couldn't match type `Bool' with `[Char]'" > Where am I wrong? > The type of exprParser doesn't do what you intend. Specifically, the `a` in `(Expr a)` is chosen by the *caller* and you have to deal with that choice somehow --- it does not mean you can pick a different `a` in different parts of your code. There are several ways you might redesign your types, but I think I'll have to let someone else address those. -- brandon s allbery kf8nh sine nomine associates allbery.b at gmail.com ballbery at sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net -------------- next part -------------- An HTML attachment was scrubbed... URL: From byorgey at seas.upenn.edu Sat Feb 8 20:15:19 2014 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Sat, 8 Feb 2014 15:15:19 -0500 Subject: [Haskell-beginners] Problem with GADTs and Parsec In-Reply-To: <20140208191019.27630@gmx.com> References: <20140208191019.27630@gmx.com> Message-ID: <20140208201519.GA29161@seas.upenn.edu> On Sat, Feb 08, 2014 at 08:10:18PM +0100, Lorenzo Tabacchini wrote: > > exprParser :: Parsec String u (Expr a) > exprParser = parens exprParser > <|> (reserved "true" >> return (Bool True)) > <|> (reserved "false" >> return (Bool False)) > <|> (stringLiteral >>= return . Text) As Brandon explained, this type does not mean what you want: it promises to be able to return *any* type of Expr, but then it goes and tries to return *particular* types of Exprs. Of course, the type is a lie: you will only be able to return specific types of Exprs, but you can't know which ones in advance. In my opinion, this is one of the few places where existential wrappers are really what you want. If I were you, I would do something like this: data ExprE where ExprE :: Expr a -> ExprE -- existentially hides the expression type Now you can write your parser to return an ExprE, with the type of the expression hidden inside. In order to be able to use the resulting ExprE values, you will also want a function like withExprE :: ExprE -> (Expr a -> r) -> r withExprE (ExprE expr) k = k expr -Brent From lortabac at gmx.com Sun Feb 9 08:21:15 2014 From: lortabac at gmx.com (Lorenzo) Date: Sun, 09 Feb 2014 09:21:15 +0100 Subject: [Haskell-beginners] Problem with GADTs and Parsec In-Reply-To: <20140208201519.GA29161@seas.upenn.edu> Message-ID: <1391934075.3727.15.camel@localhost.localdomain> > In my opinion, this is one of the few places where existential > wrappers are really what you want. If I were you, I would do > something like this: > > data ExprE where > ExprE :: Expr a -> ExprE -- existentially hides the expression > type > > Now you can write your parser to return an ExprE, with the type of the > expression hidden inside. In order to be able to use the resulting > ExprE values, you will also want a function like > > withExprE :: ExprE -> (Expr a -> r) -> r > withExprE (ExprE expr) k = k expr Thanks. This is the kind of solution I was looking for. The problem is, when I try to access the "hidden" Expr type the compiler complains: Couldn't match type `a1' with `a' `a1' is a rigid type variable bound by a pattern with constructor ExprE :: forall a. Expr a -> ExprE, in an equation for `withExprE' `a' is a rigid type variable bound by the type signature for withExprE :: ExprE -> (Expr a -> r) -> r From byorgey at seas.upenn.edu Sun Feb 9 19:03:33 2014 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Sun, 9 Feb 2014 14:03:33 -0500 Subject: [Haskell-beginners] Problem with GADTs and Parsec In-Reply-To: <1391934075.3727.15.camel@localhost.localdomain> References: <20140208201519.GA29161@seas.upenn.edu> <1391934075.3727.15.camel@localhost.localdomain> Message-ID: <20140209190333.GA3443@seas.upenn.edu> On Sun, Feb 09, 2014 at 09:21:15AM +0100, Lorenzo wrote: > > In my opinion, this is one of the few places where existential > > wrappers are really what you want. If I were you, I would do > > something like this: > > > > data ExprE where > > ExprE :: Expr a -> ExprE -- existentially hides the expression > > type > > > > Now you can write your parser to return an ExprE, with the type of the > > expression hidden inside. In order to be able to use the resulting > > ExprE values, you will also want a function like > > > > withExprE :: ExprE -> (Expr a -> r) -> r > > withExprE (ExprE expr) k = k expr > > Thanks. This is the kind of solution I was looking for. > The problem is, when I try to access the "hidden" Expr type the compiler > complains: > Whoops! Sorry, I gave you the wrong type for withExprE. And you can see why it is wrong, based on the earlier explanation: the *caller* of withExprE gets to choose the type a, but there is some particular (unknown) type inside the ExprE, so there is no guarantee they will match up. Instead, we must write withExprE :: ExprE -> (forall a. Expr a -> r) -> r (note you have to enable the Rank2Types extension). This says that the caller of ExprE must provide a function which works *no matter what* the type a is, i.e. the implementation of withExprE gets to choose the type a, rather than the caller. -Brent From fa-ml at ariis.it Mon Feb 10 04:11:49 2014 From: fa-ml at ariis.it (fa-ml) Date: Mon, 10 Feb 2014 05:11:49 +0100 Subject: [Haskell-beginners] problems loading zeromq Message-ID: <20140210041149.GA6031@x60s.casa> Hello list, I am trying to cabal install hbro. After a bit of fiddling I stumbled on this: Resolving dependencies... Configuring hbro-1.1.2.1... Building hbro-1.1.2.1... Preprocessing library hbro-1.1.2.1... [ 1 of 19] Compiling Paths_hbro ( dist/build/autogen/Paths_hbro.hs, dist/build/Paths_hbro.o ) [ 2 of 19] Compiling Hbro.Keys ( Hbro/Keys.hs, dist/build/Hbro/Keys.o ) Loading package ghc-prim ... linking ... done. [omissis] Loading package semigroups-0.12.2 ... linking ... done. Loading package zeromq3-haskell-0.5.1 ... linking ... ghc: /home/user/.cabal/lib/zeromq3-haskell-0.5.1/ghc-7.4.1/HSzeromq3-haskell-0.5.1.o: unknown symbol `zmq_ctx_new' ghc: unable to load package `zeromq3-haskell-0.5.1' cabal: Error: some packages failed to install: hbro-1.1.2.1 failed during the building phase. The exception was: ExitFailure 1 I am puzzled because I cabal installed zeromq3-haskell *and* downloaded/installed 0mq3 (./configure; make; su; make install). 0mq version is 3.2.5 and I am running debian/stable(i386). Any idea on what is happening here? Thanks in advance -F -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: From james at jtoll.com Tue Feb 11 14:54:53 2014 From: james at jtoll.com (James Toll) Date: Tue, 11 Feb 2014 08:54:53 -0600 Subject: [Haskell-beginners] filter by max length a list of lists with equivalent values Message-ID: Hi, I have what?s proving to be a tricky little problem for me to solve. I?m trying to take a list of a list of Int?s and return the longest list for each list with elements of equivalent value. That?s not a great explanation, so let me try to give an example: If I have a list of lists grouped by element value. ghci> group [1,1,1,1,2,2,2,2,3,3,2,2,2,5,6,2,2,7] [[1,1,1,1],[2,2,2,2],[3,3],[2,2,2],[5],[6],[2,2],[7]] I would like to take the subset of the outer list containing only the longest of the inner lists for any particular element. So for this particular example, the desired output would be: [[1,1,1,1],[2,2,2,2],[3,3],[5],[6],[7]] The lists [2,2,2] and [2,2] would be removed because they?re shorter than [2,2,2,2]. Any thoughts on how to do this would be appreciated. Thanks and best regards, James From raabe at froglogic.com Tue Feb 11 15:08:40 2014 From: raabe at froglogic.com (Frerich Raabe) Date: Tue, 11 Feb 2014 16:08:40 +0100 Subject: [Haskell-beginners] filter by max length a list of lists with equivalent values In-Reply-To: References: Message-ID: <0a2c75336776df3c2583df0a18149aad@roundcube.froglogic.com> On 2014-02-11 15:54, James Toll wrote: > If I have a list of lists grouped by element value. > > ghci> group [1,1,1,1,2,2,2,2,3,3,2,2,2,5,6,2,2,7] > [[1,1,1,1],[2,2,2,2],[3,3],[2,2,2],[5],[6],[2,2],[7]] > > I would like to take the subset of the outer list containing only the > longest of the inner lists for any particular element. > > So for this particular example, the desired output would be: > > [[1,1,1,1],[2,2,2,2],[3,3],[5],[6],[7]] > Any thoughts on how to do this would be appreciated. After grouping the given list, so that you have [[1,1,1,1],[2,2,2,2],[3,3],[2,2,2],[5],[6],[2,2],[7]] Sort the list by comparing the first element of each list ghci> sortBy (comparing head) [[1,1,1,1],[2,2,2,2],[3,3],[2,2,2],[5],[6],[2,2],[7]] [[1,1,1,1],[2,2,2,2],[2,2,2],[2,2],[3,3],[5],[6],[7]] Then, group that again such that lists with equal elements get put into one list: ghci> groupBy ((==) `on` head) [[1,1,1,1],[2,2,2,2],[2,2,2],[2,2],[3,3],[5],[6],[7]] [[[1,1,1,1]],[[2,2,2,2],[2,2,2],[2,2]],[[3,3]],[[5]],[[6]],[[7]]] Finally, select the "maximum" of each inner list by comparing the length of the sub-sub-lists: ghci> map (maximumBy (comparing length)) [[[1,1,1,1]],[[2,2,2,2],[2,2,2],[2,2]],[[3,3]],[[5]],[[6]],[[7]]] You'll need "Data.List", "Data.Ord" and "Data.Function" for this. -- Frerich Raabe - raabe at froglogic.com www.froglogic.com - Multi-Platform GUI Testing From james at jtoll.com Tue Feb 11 15:34:31 2014 From: james at jtoll.com (James Toll) Date: Tue, 11 Feb 2014 09:34:31 -0600 Subject: [Haskell-beginners] filter by max length a list of lists with equivalent values In-Reply-To: <0a2c75336776df3c2583df0a18149aad@roundcube.froglogic.com> References: <0a2c75336776df3c2583df0a18149aad@roundcube.froglogic.com> Message-ID: On Feb 11, 2014, at 9:08 AM, Frerich Raabe wrote: > > After grouping the given list, so that you have > > [[1,1,1,1],[2,2,2,2],[3,3],[2,2,2],[5],[6],[2,2],[7]] > > Sort the list by comparing the first element of each list > > ghci> sortBy (comparing head) [[1,1,1,1],[2,2,2,2],[3,3],[2,2,2],[5],[6],[2,2],[7]] > [[1,1,1,1],[2,2,2,2],[2,2,2],[2,2],[3,3],[5],[6],[7]] > > Then, group that again such that lists with equal elements get put into one list: > > ghci> groupBy ((==) `on` head) [[1,1,1,1],[2,2,2,2],[2,2,2],[2,2],[3,3],[5],[6],[7]] > [[[1,1,1,1]],[[2,2,2,2],[2,2,2],[2,2]],[[3,3]],[[5]],[[6]],[[7]]] > > Finally, select the "maximum" of each inner list by comparing the length of the sub-sub-lists: > > ghci> map (maximumBy (comparing length)) [[[1,1,1,1]],[[2,2,2,2],[2,2,2],[2,2]],[[3,3]],[[5]],[[6]],[[7]]] Thank you for the nicely detailed explanation. In my frustration, I was fearing I was going to have to revert to a more imperative approach to solving this, and I was hoping someone would demonstrate a more functional solution. In the various iterations that I unsuccessfully tried, I think the major idea I was lacking was your second step, the groupBy ((==) `on` head). That?s really the part I just wasn?t able to come up with on my own. Again, thanks so much for the help. Best, James From ehamberg at gmail.com Tue Feb 11 16:15:28 2014 From: ehamberg at gmail.com (Erlend Hamberg) Date: Tue, 11 Feb 2014 17:15:28 +0100 Subject: [Haskell-beginners] filter by max length a list of lists with equivalent values In-Reply-To: References: Message-ID: Another way to do this would be to sort the sub lists according to what they contain (the list heads) and then their length (to resolve ties). You could then use nubBy with "(==) `on` head" to remove lists and only be left with the longest lists. Since nub[By] keeps only the first occurrence of each element when there are duplicates, "comparing length" is flipped - meaning that longer lists come first. This gives us the following function: nubBy ((==) `on` head) . sortBy (comparing head <> flip (comparing length)) . group Where (<>) is from Data.Monoid. An explanation of using monoids to build sorting combinators can be found in this reddit post [note that the author uses (++) for (<>)]: http://www.reddit.com/r/programming/comments/7cf4r/monoids_in_my_programming_language/c06adnx -- Erlend Hamberg ehamberg at gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From james at jtoll.com Tue Feb 11 16:43:39 2014 From: james at jtoll.com (James Toll) Date: Tue, 11 Feb 2014 10:43:39 -0600 Subject: [Haskell-beginners] filter by max length a list of lists with equivalent values In-Reply-To: References: Message-ID: On Feb 11, 2014, at 10:15 AM, Erlend Hamberg wrote: > Another way to do this would be to sort the sub lists according to what they contain (the list heads) and then their length (to resolve ties). > You could then use nubBy with ?(==) `on` head? to remove lists and only be left with the longest lists. Since nub[By] keeps only the first occurrence of each element when there are duplicates, ?comparing length? is flipped ? meaning that longer lists come first. This gives us the following function: > > nubBy ((==) `on` head) . sortBy (comparing head <> flip (comparing length)) . group > > Where (<>) is from Data.Monoid. An explanation of using monoids to build sorting combinators can be found in this reddit post [note that the author uses (++) for (<>)]: > http://www.reddit.com/r/programming/comments/7cf4r/monoids_in_my_programming_language/c06adnx Thank you for this example and the link. I have not explored the Data.Monoid module yet, but I will read through the reddit post. Best, James From bryan.brady at gmail.com Wed Feb 12 04:23:05 2014 From: bryan.brady at gmail.com (Bryan Brady) Date: Tue, 11 Feb 2014 23:23:05 -0500 Subject: [Haskell-beginners] Data.Stream interleave implementation question Message-ID: I'm in the process of learning Haskell and am implementing my own Stream type. ( I'm working my way through homework problems I found at http://www.seas.upenn.edu/~cis194/hw/06-laziness.pdf ) One of the questions is: "De?ne the stream ruler :: Stream Integer which corresponds to the ruler function 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, . . . where the nth element in the stream (assuming the ?rst element corresponds to n = 1) is the largest power of 2 which evenly divides n. " I got pretty close, but ended up looking at Data.Stream to nail down my mistake. My original solution was: ----- data Stream a = Cons a (Stream a) deriving (Eq, Ord) streamRepeat :: a -> Stream a streamRepeat a = Cons a (streamRepeat a) interleaveStreams :: Stream a -> Stream a -> Stream a interleaveStreams (Cons a as) (Cons b bs) = Cons a (Cons b (interleaveStreams as bs)) ruler :: Stream Integer ruler = foldr1 interleaveStreams (map streamRepeat [0..]) ----- Attempting to evaluate 'ruler' in ghci does not finish. I knew something was wrong with my implementation of interleaveStreams because it worked when I expanded it out manually for a few steps. The way Data.Stream implements interleave is: interleaveStreams (Cons a as) bs = Cons a (interleaveStreams bs as) I don't understand why this works and why my original implementation doesn't. I figure if the latter works, the former should as well. Here is my reasoning: In the latter definition, Cons a (interleaveStreams bs as), (interleaveStreams bs as) is a thunk. The thunk should only be evaluated when it is needed. In my original definition, (interleaveStreams as bs) is a thunk. The difference is an extra Cons (e.g., Cons b). It seems like the additional Cons is causing problems, I just don't understand why. Can anyone point out what I'm missing? thanks, bb -------------- next part -------------- An HTML attachment was scrubbed... URL: From ky3 at atamo.com Wed Feb 12 08:10:21 2014 From: ky3 at atamo.com (Kim-Ee Yeoh) Date: Wed, 12 Feb 2014 15:10:21 +0700 Subject: [Haskell-beginners] Data.Stream interleave implementation question In-Reply-To: References: Message-ID: On Wed, Feb 12, 2014 at 11:23 AM, Bryan Brady wrote: > ruler :: Stream Integer > ruler = foldr1 interleaveStreams (map streamRepeat [0..]) > This is an interesting solution. I'd hazard to say that it's probably not the solution the author had in mind, so bonus points for novelty! How would you prove it correct though? -- Kim-Ee -------------- next part -------------- An HTML attachment was scrubbed... URL: From ml at isaac.cedarswampstudios.org Wed Feb 12 08:36:41 2014 From: ml at isaac.cedarswampstudios.org (Isaac Dupree) Date: Wed, 12 Feb 2014 03:36:41 -0500 Subject: [Haskell-beginners] Data.Stream interleave implementation question In-Reply-To: References: Message-ID: <52FB3299.7090201@isaac.cedarswampstudios.org> On 02/11/2014 11:23 PM, Bryan Brady wrote: > [...] > interleaveStreams :: Stream a -> Stream a -> Stream a > interleaveStreams (Cons a as) (Cons b bs) = Cons a (Cons b > (interleaveStreams as bs)) > > ruler :: Stream Integer > ruler = foldr1 interleaveStreams (map streamRepeat [0..]) > [...] > In the latter definition, Cons a (interleaveStreams bs as), > (interleaveStreams bs as) is a thunk. The thunk should only be evaluated > when it is needed. In my original definition, (interleaveStreams as bs) > is a thunk. The difference is an extra Cons (e.g., Cons b). It seems > like the additional Cons is causing problems, I just don't understand > why. Can anyone point out what I'm missing? The issue is on the left-hand-side of interleaveStreams. It is strict in both its arguments. Look at foldr1; you're evaluating interleaveStreams (streamRepeat 0) (interleaveStreams (streamRepeat 1) (interleaveStreams (streamRepeat 2) (interleaveStreams (streamRepeat 3) ... In this situation, if interleaveStreams evaluates its second argument before returning any work, it will never be able to return. Happily, the outer Cons of the result does not depend on the second argument. I can fix the issue just by making the second argument be pattern-matched lazily (with ~, i.e. only as soon as any uses of the argument in the function are evaluated): interleaveStreams (Cons a as) ~(Cons b bs) = Cons a (Cons b (interleaveStreams as bs)) You can also write this without ~ by explicitly pattern matching later, e.g. interleaveStreams (Cons a as) bs = Cons a (case bs of Cons b bs' -> Cons b (interleaveStreams as bs')) I'm not sure whether there's a practical difference between these and Data.Stream's definition. Actually, I think they turn out to do exactly the same thing... (I tested by deriving Show for Stream, and typing 'ruler' in `ghci file.hs`, or 'take 80 (show ruler)'.) -Isaac From ky3 at atamo.com Wed Feb 12 09:11:08 2014 From: ky3 at atamo.com (Kim-Ee Yeoh) Date: Wed, 12 Feb 2014 16:11:08 +0700 Subject: [Haskell-beginners] Data.Stream interleave implementation question In-Reply-To: References: Message-ID: On Wed, Feb 12, 2014 at 11:23 AM, Bryan Brady wrote: > In the latter definition, Cons a (interleaveStreams bs as), > (interleaveStreams bs as) is a thunk. The thunk should only be evaluated > when it is needed. In my original definition, (interleaveStreams as bs) is > a thunk. The difference is an extra Cons (e.g., Cons b). It seems like the > additional Cons is causing problems, I just don't understand why. Can > anyone point out what I'm missing? As Isaac wrote, you want to look at the _left_ hand side, not the right. It's pattern matching that impacts operational semantics. -- Kim-Ee -------------- next part -------------- An HTML attachment was scrubbed... URL: From bryan.brady at gmail.com Wed Feb 12 12:49:04 2014 From: bryan.brady at gmail.com (Bryan Brady) Date: Wed, 12 Feb 2014 07:49:04 -0500 Subject: [Haskell-beginners] Data.Stream interleave implementation question In-Reply-To: <52FB3299.7090201@isaac.cedarswampstudios.org> References: <52FB3299.7090201@isaac.cedarswampstudios.org> Message-ID: Thanks Isaac! It never crossed my mind that the problem was on the left hand side. On Wed, Feb 12, 2014 at 3:36 AM, Isaac Dupree < ml at isaac.cedarswampstudios.org> wrote: > [...] > In this situation, if interleaveStreams evaluates its second argument > before returning any work, it will never be able to return. Happily, the > outer Cons of the result does not depend on the second argument. I can fix > the issue just by making the second argument be pattern-matched lazily > (with ~, i.e. only as soon as any uses of the argument in the function are > evaluated): > interleaveStreams (Cons a as) ~(Cons b bs) = Cons a (Cons b > (interleaveStreams as bs)) > > > So that's what the ~ does... :) I'm not sure whether there's a practical difference between these and > Data.Stream's definition. Actually, I think they turn out to do exactly > the same thing... > Yes, they do. I used the solution in Data.Stream to fix mine, though I didn't recognize the true source of the problem until you pointed it out. Thanks again! -------------- next part -------------- An HTML attachment was scrubbed... URL: From bryan.brady at gmail.com Wed Feb 12 13:05:55 2014 From: bryan.brady at gmail.com (Bryan Brady) Date: Wed, 12 Feb 2014 08:05:55 -0500 Subject: [Haskell-beginners] Data.Stream interleave implementation question In-Reply-To: References: Message-ID: On Wed, Feb 12, 2014 at 3:10 AM, Kim-Ee Yeoh wrote: > I'd hazard to say that it's probably not the solution the author had in > mind, so bonus points for novelty! > What solution do you think the author had in mind? He did hint to use define and use interleaveStreams and to avoid checking divisibility testing. > How would you prove it correct though? > I haven't attempted this yet, but if I were to, I'd go for an inductive proof. If you list the solution along with the numbers they correspond to (divide), you get: 1 2 3 4 5 6 7 8 9 10... 0 1 0 2 0 1 0 3 0 1... If you drop all the numbers corresponding to a 0 in the ruler function: 2 4 6 8 10... 1 2 1 3 1 ... then drop the numbers corresponding to a 1 in the ruler function: 4 6 ... 2 3 ... At each level, you drop every other number, and the first number of each successive level is 1 greater than the previous level. Formalize that a bit and you got a proof. -------------- next part -------------- An HTML attachment was scrubbed... URL: From ky3 at atamo.com Wed Feb 12 14:03:52 2014 From: ky3 at atamo.com (Kim-Ee Yeoh) Date: Wed, 12 Feb 2014 21:03:52 +0700 Subject: [Haskell-beginners] Data.Stream interleave implementation question In-Reply-To: References: Message-ID: On Wed, Feb 12, 2014 at 8:05 PM, Bryan Brady wrote: > What solution do you think the author had in mind? He did hint to use > define and use interleaveStreams and to avoid checking divisibility > testing. Recall the famous haskell fibonacci: fib = 0 : 1 : some_function_of fib Mathematically speaking, what fractal property does the ruler sequence observe that you could similarly exploit? As for your solution, I don't doubt for a minute it's correct (I probably could have worded what I said better). The hope is that a proof would be interesting/delightful in that ineffable math-y way. -- Kim-Ee -------------- next part -------------- An HTML attachment was scrubbed... URL: From byorgey at seas.upenn.edu Wed Feb 12 17:19:39 2014 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Wed, 12 Feb 2014 12:19:39 -0500 Subject: [Haskell-beginners] Data.Stream interleave implementation question In-Reply-To: References: Message-ID: <20140212171939.GA18721@seas.upenn.edu> On Wed, Feb 12, 2014 at 03:10:21PM +0700, Kim-Ee Yeoh wrote: > On Wed, Feb 12, 2014 at 11:23 AM, Bryan Brady wrote: > > > ruler :: Stream Integer > > ruler = foldr1 interleaveStreams (map streamRepeat [0..]) > > > > This is an interesting solution. > > I'd hazard to say that it's probably not the solution the author had in > mind, so bonus points for novelty! You're right that it's not the exact solution I had in mind, but I like it! I had in mind a more directly recursive version of ruler; I think proving the two solutions equivalent should not be too hard. -Brent From james at jtoll.com Sat Feb 15 19:42:15 2014 From: james at jtoll.com (James Toll) Date: Sat, 15 Feb 2014 13:42:15 -0600 Subject: [Haskell-beginners] type error in sub-function Message-ID: Hi, I am trying to write a simple function to determine the divisors of an integer. In its simplest form the type signature should be something like: divisors :: Int -> [Int] divisors x = 1 : lower ++ upper ++ x : [] where lower = filter (\y -> mod x y == 0) [2..(ceiling . sqrt) x] upper = sort $ map (div x) lower Although, I think my type signature isn?t complete as it ignores a lot of what?s going on in the function. Regardless, the function throws an error when evaluated. I don?t know if I just need a more accurate type signature, or if there is a bigger problem. From what I can tell, my problem is in the lower function, but when I deconstruct it into its parts, they work individually and as a whole, but not as a stand-alone function. For example, using x = 36: Prelude> [2..(ceiling . sqrt) 36] [2,3,4,5,6] Prelude> filter (\y -> mod 36 y == 0) it [2,3,4,6] Or as a whole: Prelude> filter (\y -> mod 36 y == 0) [2..(ceiling . sqrt) 36] [2,3,4,6] But when I define this as a function, it throws an error when evaluated. Prelude> let lower x = filter (\y -> mod x y == 0) [2..(ceiling . sqrt) x] Prelude> lower 36 :6:1: No instance for (RealFrac b0) arising from a use of `lower' The type variable `b0' is ambiguous Possible fix: add a type signature that fixes these type variable(s) Note: there are several potential instances: instance RealFrac Double -- Defined in `GHC.Float' instance RealFrac Float -- Defined in `GHC.Float' instance Integral a => RealFrac (GHC.Real.Ratio a) -- Defined in `GHC.Real' In the expression: lower 36 In an equation for `it': it = lower 36 :6:7: No instance for (Num b0) arising from the literal `36' The type variable `b0' is ambiguous Possible fix: add a type signature that fixes these type variable(s) Note: there are several potential instances: instance Num Double -- Defined in `GHC.Float' instance Num Float -- Defined in `GHC.Float' instance Integral a => Num (GHC.Real.Ratio a) -- Defined in `GHC.Real' ...plus three others In the first argument of `lower', namely `36' In the expression: lower 36 In an equation for `it': it = lower 36 At this point, I?m not sure what I need to do to get his working properly. It appears to be a type error, but I?m apparently not understanding the error message enough to fix the problem. Any suggestions would be appreciated. Thanks, James From alegomez544 at gmail.com Sat Feb 15 20:15:06 2014 From: alegomez544 at gmail.com (Alejandro Gomez) Date: Sat, 15 Feb 2014 15:15:06 -0500 Subject: [Haskell-beginners] type error in sub-function In-Reply-To: References: Message-ID: 2014-02-15 14:42 GMT-05:00 James Toll : I will suggest you to take a look at the type of all the things you are using: > Hi, > > I am trying to write a simple function to determine the divisors of an integer. In its simplest form the type signature should be something like: > > divisors :: Int -> [Int] > divisors x = 1 : lower ++ upper ++ x : [] > where lower = filter (\y -> mod x y == 0) [2..(ceiling . sqrt) x] > upper = sort $ map (div x) lower > > Although, I think my type signature isn't complete as it ignores a lot of what's going on in the function. Regardless, the function throws an error when evaluated. I don't know if I just need a more accurate type signature, or if there is a bigger problem. > > From what I can tell, my problem is in the lower function, but when I deconstruct it into its parts, they work individually and as a whole, but not as a stand-alone function. For example, using x = 36: > > Prelude> [2..(ceiling . sqrt) 36] > [2,3,4,5,6] :t [2..(ceiling . sqrt) 36] [2..(ceiling . sqrt) 36] :: Integral t => [t] > Prelude> filter (\y -> mod 36 y == 0) it > [2,3,4,6] :t filter (\y -> mod 36 y == 0) filter (\y -> mod 36 y == 0) :: Integral a => [a] -> [a] > Or as a whole: > > Prelude> filter (\y -> mod 36 y == 0) [2..(ceiling . sqrt) 36] > [2,3,4,6] :t filter (\y -> mod 36 y == 0) [2..(ceiling . sqrt) 36] filter (\y -> mod 36 y == 0) [2..(ceiling . sqrt) 36] :: Integral a => [a] > But when I define this as a function, it throws an error when evaluated. > > Prelude> let lower x = filter (\y -> mod x y == 0) [2..(ceiling . sqrt) x] :t lower lower :: (Floating b, Integral b, RealFrac b) => b -> [b] :t 36 36 :: Num a => a > Prelude> lower 36 Take a look to all the thing your function request, and what are you giving to it, the 36 satisfy those requirements? (Class constraints). furthermore, the Int type you are using satisfies that too? The most messy part is: (ceiling . sqrt) , that's the root of all the problem. Remember there is no implicit conversion between data types -- Alejandro G?mez Londo?o From eual.jp at gmail.com Sat Feb 15 20:38:38 2014 From: eual.jp at gmail.com (Alexander Batischev) Date: Sat, 15 Feb 2014 22:38:38 +0200 Subject: [Haskell-beginners] type error in sub-function In-Reply-To: References: Message-ID: <20140215203838.GA30857@antaeus> Hi, Alejandro Gomez already posted an answer that should be enough for you to figure out the solution by yourself, but I decided to post mine anyway, in case you have trouble understanding how to proceed. On Sat, Feb 15, 2014 at 01:42:15PM -0600, James Toll wrote: > Prelude> let lower x = filter (\y -> mod x y == 0) [2..(ceiling . sqrt) x] > Prelude> lower 36 > > :6:1: > No instance for (RealFrac b0) arising from a use of `lower' > The type variable `b0' is ambiguous > Possible fix: add a type signature that fixes these type variable(s) > Note: there are several potential instances: > instance RealFrac Double -- Defined in `GHC.Float' > instance RealFrac Float -- Defined in `GHC.Float' > instance Integral a => RealFrac (GHC.Real.Ratio a) > -- Defined in `GHC.Real' > In the expression: lower 36 > In an equation for `it': it = lower 36 > > :6:7: > No instance for (Num b0) arising from the literal `36' > The type variable `b0' is ambiguous > Possible fix: add a type signature that fixes these type variable(s) > Note: there are several potential instances: > instance Num Double -- Defined in `GHC.Float' > instance Num Float -- Defined in `GHC.Float' > instance Integral a => Num (GHC.Real.Ratio a) > -- Defined in `GHC.Real' > ...plus three others > In the first argument of `lower', namely `36' > In the expression: lower 36 > In an equation for `it': it = lower 36 > > > At this point, I?m not sure what I need to do to get his working > properly. It appears to be a type error, but I?m apparently not > understanding the error message enough to fix the problem. Any > suggestions would be appreciated. Your first instinct should be to look at the type signature of the function you just wrote, so you can figure out what `b0` means: ?: :t lower lower :: (Floating b, Integral b, RealFrac b) => b -> [b] See? It expects to be given something that belongs to Floating, Integral and RealFrac typeclasses. The Haskell Report contains a nice image of the dependencies between typeclasses along with the actual types that instantiate them[1] From looking at it, you can deduce that there is no type that belongs to all three typeclasses. Thus the type error. 1. https://www.haskell.org/onlinereport/classes.gif To fix this, let's take a step back and deconstruct your function to see where each of the constraints (the thing in the parentheses that goes before the type) comes from. It all starts with `sqrt`, which has the following type: ?: :t sqrt sqrt :: Floating a => a -> a By looking at the aforementioned diagram again, you can conclude that `a` here is either Float or Double. Next, you compose `sqrt` with `ceiling`, which has the following type: ?: :t ceiling ceiling :: (Integral b, RealFrac a) => a -> b Here, `a` can be Float or Double, and `b` is either Int or Integer. After the composition you have a function with the following type: ?: :t (ceiling . sqrt) (ceiling . sqrt) :: (Floating b, Integral c, RealFrac b) => b -> c It accepts Float or Double (which both belong to Floating and RealFrac typeclasses) and returns Int or Integer. But you want to feed it an Int! Unlike many other languages, Haskell never casts (converts) types unless you order to do so. So you need some function to convert an instance of Integral typeclass (Int or Integer) into instance of both Floating and RealFrac, i.e. a function with the following type: (Integral a, Floating b, RealFrac b) => a -> b For that, we have Hoogle[2] Type in the signature, hit Search and you will be presented with a list of matching functions. `fromIntegral`, which is the second result I've been given, is *exactly* what you need. Let's use it, rewriting `lower` as ?: let lower x = filter (\y -> mod x y == 0) [2..(ceiling . sqrt) (fromIntegral x)] ?: :t lower lower :: Integral a => a -> [a] 2. https://www.haskell.org/hoogle/ As you can see, you've got a function that accepts any instance of Integral typeclass, i.e. Int and Integer types. Precisely what was required. Hope that makes sense. -- Regards, Alexander Batischev -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: From psismondi at arqux.com Sat Feb 15 21:25:31 2014 From: psismondi at arqux.com (Philippe Sismondi) Date: Sat, 15 Feb 2014 16:25:31 -0500 Subject: [Haskell-beginners] Need help with HXT Message-ID: <0FA49095-7484-4BA5-B18A-F2CADFE85B8D@arqux.com> Greetings. I am trying to move some very old code from using HaXml to HXT. This is experimental; I have reasons which I think are not relevant to this post. The website that purports to document HXT has broken links. This is Uwe Schmidt's website. I have emailed Dr. Schmidt. Meanwhile, can anyone elucidate the use of readDocument with its withCurl and withHTTP options? What may be passed in the list to e.g. withHTTP? - Phil - From james at jtoll.com Sat Feb 15 21:52:25 2014 From: james at jtoll.com (James Toll) Date: Sat, 15 Feb 2014 15:52:25 -0600 Subject: [Haskell-beginners] type error in sub-function In-Reply-To: <20140215203838.GA30857@antaeus> References: <20140215203838.GA30857@antaeus> Message-ID: On Feb 15, 2014, at 2:38 PM, Alexander Batischev wrote: > Hi, > > Alejandro Gomez already posted an answer that should be enough for you > to figure out the solution by yourself, but I decided to post mine > anyway, in case you have trouble understanding how to proceed. Yes, thank you. I really appreciate both of you taking the time to respond to my question, but that?s exactly the problem I was having. I had broken down and inspected the type signature of the subsections of my ?lower? function. Each subsection on its own seemed fine, but what was confusing me was the type signature for the whole thing. And I wasn?t sure how to fix it. I really appreciate you walking me through the process. Beforehand, I kind of guessed that I probably needed to use fromIntegral somewhere, but I wasn?t sure where, and even if I got lucky and guessed, I don?t think I would have understood why. > After the composition you have a function with the following type: > > ?: :t (ceiling . sqrt) > (ceiling . sqrt) :: (Floating b, Integral c, RealFrac b) => b -> c > > It accepts Float or Double (which both belong to Floating and RealFrac > typeclasses) and returns Int or Integer. > > But you want to feed it an Int! Unlike many other languages, Haskell > never casts (converts) types unless you order to do so. Again, thank you for this very helpful explanation of the problem, and I understand that Haskell doesn?t cast types automatically. In fact I was relying on that as I built up my function. What I guess really confused me was that this worked: Prelude> filter (\y -> mod 36 y == 0) [2..(ceiling . sqrt) 36] [2,3,4,6] while this didn?t. Prelude> let lower x = filter (\y -> mod x y == 0) [2..(ceiling . sqrt) x] Prelude> lower 36 Since the former worked, I really expected the latter to work as well. > :t 36 > 36 :: Num a => a I am still slightly confused about the type that I passed into the function. If the type of 36 is Numeric, that doesn?t seem to necessarily tell me that it is an Int. Float and Double are listed under Numeric in the chart (https://www.haskell.org/onlinereport/classes.gif). This seems like a really stupid question, but how do I know that I can?t pass a Numeric into a function like sqrt that is expecting a Float? ghci> :t sqrt sqrt :: Floating a => a -> a And again, why does it work in the former case when it?s not a function, but not in the latter as a function? If there is no casting going on, it seems like it should fail every single time. Why does it work at all? > As you can see, you've got a function that accepts any instance of > Integral typeclass, i.e. Int and Integer types. Precisely what was > required. > > Hope that makes sense. Yes, thank you. I do think I have a better understanding now. Best regards, James From fuuzetsu at fuuzetsu.co.uk Sat Feb 15 22:17:23 2014 From: fuuzetsu at fuuzetsu.co.uk (Mateusz Kowalczyk) Date: Sat, 15 Feb 2014 22:17:23 +0000 Subject: [Haskell-beginners] Need help with HXT In-Reply-To: <0FA49095-7484-4BA5-B18A-F2CADFE85B8D@arqux.com> References: <0FA49095-7484-4BA5-B18A-F2CADFE85B8D@arqux.com> Message-ID: <52FFE773.7010904@fuuzetsu.co.uk> On 15/02/14 21:25, Philippe Sismondi wrote: > Greetings. I am trying to move some very old code from using HaXml to HXT. This is experimental; I have reasons which I think are not relevant to this post. > > The website that purports to document HXT has broken links. This is Uwe Schmidt's website. I have emailed Dr. Schmidt. Meanwhile, can anyone elucidate the use of readDocument with its withCurl and withHTTP options? What may be passed in the list to e.g. withHTTP? > > - Phil - > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://www.haskell.org/mailman/listinfo/beginners > Why don't you use the documentation on Hackage? Here[1] is your readDocument. It mentions the withCurl option and how to use it. As it points out, the withCurl comes from hxt-curl and the relevant page is at [2]. As you can see, it takes Attributes which is just a list of key-value pairs. I'm sure you can keep clicking on the links and find out what it is you need to pass to it. It's the same case when looking at withHTTP. Word of warning about HXT, it will blow up in your face if you give it bigger XML files: I found ~30MB to be the limit for a 4GB machine. It's great for smaller files however. See [3] for that issue and [4] for other issues that you might want to view. [1]: http://hackage.haskell.org/package/hxt-9.3.1.3/docs/Text-XML-HXT-Arrow-ReadDocument.html [2]: http://hackage.haskell.org/package/hxt-curl-9.1.1/docs/Text-XML-HXT-Curl.html [3]: https://github.com/UweSchmidt/hxt/issues/9 [4]: https://github.com/UweSchmidt/hxt/issues -- Mateusz K. From byorgey at seas.upenn.edu Sat Feb 15 22:40:21 2014 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Sat, 15 Feb 2014 17:40:21 -0500 Subject: [Haskell-beginners] type error in sub-function In-Reply-To: References: <20140215203838.GA30857@antaeus> Message-ID: <20140215224021.GA23559@seas.upenn.edu> On Sat, Feb 15, 2014 at 03:52:25PM -0600, James Toll wrote: > > Again, thank you for this very helpful explanation of the problem, and I understand that Haskell doesn?t cast types automatically. In fact I was relying on that as I built up my function. What I guess really confused me was that this worked: > > Prelude> filter (\y -> mod 36 y == 0) [2..(ceiling . sqrt) 36] > [2,3,4,6] > > while this didn?t. > > Prelude> let lower x = filter (\y -> mod x y == 0) [2..(ceiling . sqrt) x] > Prelude> lower 36 This is sneaky: in the first example, there are two occurrences of the number 36, and they have different types! Number literals are polymorphic, that is, they can be any type which is an instance of the Num class. The first 36 has type Integer, since it's constrained by 'mod' to be an instance of Integral, and GHC will pick the Integer type by default. The second 36, on the other hand, has type Double, since sqrt requires a type which is an instance of Floating. When you abstract this out into the function 'lower', however, the argument x can only have one type, i.e. the two occurrences of x are required to be the *same* type. > > Since the former worked, I really expected the latter to work as well. > > > :t 36 > > 36 :: Num a => a > > > I am still slightly confused about the type that I passed into the function. If the type of 36 is Numeric, that doesn?t seem to necessarily tell me that it is an Int. Float and Double are listed under Numeric in the chart (https://www.haskell.org/onlinereport/classes.gif). This seems like a really stupid question, but how do I know that I can?t pass a Numeric into a function like sqrt that is expecting a Float? Note that Num (Numeric) is not a type, it is a type class. It does not make sense to say "the type of 36 is Numeric". A better way to say it is that "36 can have any type, as long as it is an instance of the Num type class". You *can* pass 36 into a function like sqrt, since anything which is an instance of Floating is required to also be an instance of Num. -Brent From eual.jp at gmail.com Sat Feb 15 22:53:42 2014 From: eual.jp at gmail.com (Alexander Batischev) Date: Sun, 16 Feb 2014 00:53:42 +0200 Subject: [Haskell-beginners] type error in sub-function In-Reply-To: References: <20140215203838.GA30857@antaeus> Message-ID: <20140215225342.GB30857@antaeus> Hi, On Sat, Feb 15, 2014 at 03:52:25PM -0600, James Toll wrote: > What I guess really > confused me was that this worked: > > Prelude> filter (\y -> mod 36 y == 0) [2..(ceiling . sqrt) 36] > [2,3,4,6] > > while this didn?t. > > Prelude> let lower x = filter (\y -> mod x y == 0) [2..(ceiling . sqrt) x] > Prelude> lower 36 > > Since the former worked, I really expected the latter to work as well. Because in the first case, you have 36 in two places, and they have different types. In the second case, though, both numbers are replaced by `x`, that has one type. Something should have just clicked in your brain, and every piece fell in place, but if not, read on. In my previous email, I showed you what constraints a composition of ceiling and sqrt places on `x`: ?: :t (ceiling . sqrt) (ceiling . sqrt) :: (Floating b, Integral c, RealFrac b) => b -> c From here, you can see that `x` is only constrained by typeclasses Floating and RealFrac. But `lower` has one more constraint, Integral: ?: :t lower lower :: (Floating b, Integral b, RealFrac b) => b -> [b] Why is that? Because you do `mod`: ?: :t mod mod :: Integral a => a -> a -> a When you filter the list, `x` gets constrained by the Integral typeclass, which leads to the situation you observe - too many constraints, typechecker can't pick a type to satisfy them all. And what do we do? We help the compiler using `fromIntegral`, thus removing the Floating and RealFrac constraints from `x` (they're now placed on a result of `fromIntegral`). > > :t 36 > > 36 :: Num a => a > > > I am still slightly confused about the type that I passed into the > function. If the type of 36 is Numeric, that doesn?t seem to > necessarily tell me that it is an Int. Float and Double are listed > under Numeric in the chart > (https://www.haskell.org/onlinereport/classes.gif). It's incorrect to say that "the type of 36 is Numeric", but I guess it's just bad wording - you get the idea right, 36 isn't necessary Int. There's a thing called "type defaulting". It's a set of rules that GHC follows in order to pick a type for a thing whose type is not specified, like 36. (Note that GHCi has slightly different, more relaxed rules.) So when you run `filter`, GHCi has to pick some type for the results, and it settles for Integer. But type defaulting doesn't kick in until the very last moment. Up until binding the result, it stays as polimorphic as possible: ?: :t 36 36 :: Num a => a The moment you bind the result, though, it gets concrete type: ?: let x = 36 ?: :t x x :: Integer > This seems like > a really stupid question, but how do I know that I can?t pass > a Numeric into a function like sqrt that is expecting a Float? > > ghci> :t sqrt > sqrt :: Floating a => a -> a I don't know how well you understand typeclasses, so pardon me if I explain something you already know. The thing is, each typeclass adds some new restrictions (functions to implement) that narrow the choice of possible instances of that typeclass. Almost every type instantiates Eq, but only four standard ones instantiate Num. Furthermore, only two standard types instantiate Floating. That's why you can't pass every Num instance into sqrt - not every one of them implements all the necessary methods. Is that clear enough? -- Regards, Alexander Batischev PGP key 356961A20C8BFD03 Fingerprint: CE6C 4307 9348 58E3 FD94 A00F 3569 61A2 0C8B FD03 -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: From byorgey at seas.upenn.edu Sat Feb 15 23:00:14 2014 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Sat, 15 Feb 2014 18:00:14 -0500 Subject: [Haskell-beginners] type error in sub-function In-Reply-To: <20140215225342.GB30857@antaeus> References: <20140215203838.GA30857@antaeus> <20140215225342.GB30857@antaeus> Message-ID: <20140215230014.GA5525@seas.upenn.edu> On Sun, Feb 16, 2014 at 12:53:42AM +0200, Alexander Batischev wrote: > But type defaulting doesn't kick in until the very last moment. Up until > binding the result, it stays as polimorphic as possible: > > ?: :t 36 > 36 :: Num a => a > > The moment you bind the result, though, it gets concrete type: > > ?: let x = 36 > ?: :t x > x :: Integer It has nothing to do with binding, actually. The above is just due to the monomorphism restriction. If you turn it off (highly recommended!): > :set -XNoMonomorphismRestriction > let x = 36 > :t x Num a => a -Brent From eual.jp at gmail.com Sat Feb 15 23:06:54 2014 From: eual.jp at gmail.com (Alexander Batischev) Date: Sun, 16 Feb 2014 01:06:54 +0200 Subject: [Haskell-beginners] type error in sub-function In-Reply-To: <20140215230014.GA5525@seas.upenn.edu> References: <20140215203838.GA30857@antaeus> <20140215225342.GB30857@antaeus> <20140215230014.GA5525@seas.upenn.edu> Message-ID: <20140215230654.GC30857@antaeus> On Sat, Feb 15, 2014 at 06:00:14PM -0500, Brent Yorgey wrote: > It has nothing to do with binding, actually. The above is just due to > the monomorphism restriction. If you turn it off (highly > recommended!): I stand corrected. Been thinking about it, actually, but somehow managed to miss it when tried things out in GHCi. Thanks! -- Regards, Alexander Batischev -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: From james at jtoll.com Sat Feb 15 23:11:39 2014 From: james at jtoll.com (James Toll) Date: Sat, 15 Feb 2014 17:11:39 -0600 Subject: [Haskell-beginners] type error in sub-function In-Reply-To: <20140215225342.GB30857@antaeus> References: <20140215203838.GA30857@antaeus> <20140215225342.GB30857@antaeus> Message-ID: <35CADB2A-204C-4B0F-A63F-98AD28B17B60@jtoll.com> On Feb 15, 2014, at 4:53 PM, Alexander Batischev wrote: > Something should have just clicked in your > brain, and every piece fell in place, but if not, read on. Yes, the light bulb has gone on. Thanks to you and Brent. I really appreciate both of your explanations to my follow-up question. It?s almost a bit difficult to keep up with responding while reading your excellent and very helpful responses. I do think I now understand what was going on in this particular instance and why I was tricking myself. It always seems so simple in hindsight. I?m sure this won?t be the last time I get tripped up on this though. But I?m hopeful I can better reason it out going forward. Thanks again for all the extremely helpful responses. Best, James From byorgey at seas.upenn.edu Sun Feb 16 03:15:49 2014 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Sat, 15 Feb 2014 22:15:49 -0500 Subject: [Haskell-beginners] type error in sub-function In-Reply-To: <35CADB2A-204C-4B0F-A63F-98AD28B17B60@jtoll.com> References: <20140215203838.GA30857@antaeus> <20140215225342.GB30857@antaeus> <35CADB2A-204C-4B0F-A63F-98AD28B17B60@jtoll.com> Message-ID: <20140216031549.GA5667@seas.upenn.edu> On Sat, Feb 15, 2014 at 05:11:39PM -0600, James Toll wrote: > > On Feb 15, 2014, at 4:53 PM, Alexander Batischev wrote: > > > Something should have just clicked in your > > brain, and every piece fell in place, but if not, read on. > > Yes, the light bulb has gone on. Thanks to you and Brent. I really appreciate both of your explanations to my follow-up question. It?s almost a bit difficult to keep up with responding while reading your excellent and very helpful responses. I do think I now understand what was going on in this particular instance and why I was tricking myself. It always seems so simple in hindsight. I?m sure this won?t be the last time I get tripped up on this though. But I?m hopeful I can better reason it out going forward. > > Thanks again for all the extremely helpful responses. Glad to be of help! For what it's worth, the whole numeric-types-and-type-classes thing is definitely one of the trickiest corners of Haskell, at least when starting out. I remember spending a good deal of time struggling through it at first too. -Brent From roman at czyborra.com Sun Feb 16 07:33:23 2014 From: roman at czyborra.com (roman at czyborra.com) Date: Sun, 16 Feb 2014 08:33:23 +0100 (CET) Subject: [Haskell-beginners] type error in sub-function In-Reply-To: References: Message-ID: > write a simple function to determine the divisors of an integer. straight simple first, let { divides n x = (mod n) x == 0 ; divisors n = filter (divides n) [1..n] } in map divisors [255,256,257] > divisors x = 1 : lower ++ upper ++ x : [] > where lower = filter (\y -> mod x y == 0) [2..(ceiling . sqrt) x] > upper = sort $ map (div x) lower time-critical millions: let { divides n x = (mod n) x == 0; divisors n = let { firsthalf = filter (divides n) [ 1 .. ceiling$sqrt$fromInteger n ] } in nub ( firsthalf ++ map (div n) (reverse firsthalf) ) } in divisors 256 From thbach at students.uni-mainz.de Sun Feb 16 09:45:21 2014 From: thbach at students.uni-mainz.de (Thomas Bach) Date: Sun, 16 Feb 2014 10:45:21 +0100 Subject: [Haskell-beginners] QuickCheck for testing a parsing function Message-ID: <87fvnjpf0u.fsf@ilxwinb01.fritz.box> Hi there, I have the following snippet: data Volume = Volume { name :: String , mount :: String , size :: String , fs :: String , mbr :: Bool } deriving (Show, Eq) defaultVolume :: Volume defaultVolume = Volume { name = "" , mount = "" , size = "" , fs = "ext4" , mbr = False } parseOptVols :: String -> Volume parseOptVols s = parseChain (defaultVolume, s) where parseChain = parseMBR . parseFS . parseSize . parseMount . parseName parseName (vol, s) = (vol {name = getThis s}, getNext s) parseMount (vol, s) = (vol {mount = getThis s}, getNext s) parseSize (vol, s) = (vol {size = getThis s}, getNext s) -- fs and mbr are optional parseFS (vol, "") = (vol, "") parseFS (vol, ',':s) = (vol, s) parseFS (vol, s) = (vol {fs = getThis s}, getNext s) parseMBR (vol, "t") = vol {mbr = True} parseMBR (vol, _ ) = vol getThis = takeWhile (',' /=) getNext = saveTail . dropWhile (',' /=) saveTail :: [a] -> [a] saveTail [] = [] saveTail (_:xs) = xs What it basically does is parse a string (handed over from the command line) like "boot,/boot,256M,ext3,t" and populates a Volume instance with this. The last two fields are optional. I like testing and coming from an object-oriented background unit testing is the most comfortable to me. But I wonder if there is some smart way to make QuickCheck produce test cases. I would need some generator for this which produces a pattern like "name,mount,size,fs,mbr" eventually leaving "fs" and/or "mbr" empty and sometimes omitting both commas or just one of them. And I also need access to these fields in order to be able to compare them with the resulting Volume instance. I can see how to achieve the former somehow, but I don't have any clue how to achieve the latter. Any hints? Or is this simply not a nail for the QuickCheck-hammer? Regards, Thomas Bach. PS: Any advice on how to improve the code above is highly appreciated as well. From stf at eisenbits.com Sun Feb 16 11:12:51 2014 From: stf at eisenbits.com (=?UTF-8?B?U3RhbmlzxYJhdyBGaW5kZWlzZW4=?=) Date: Sun, 16 Feb 2014 12:12:51 +0100 Subject: [Haskell-beginners] make https request with client certificate Message-ID: <53009D33.1080608@eisenbits.com> Hi How can you issue a HTTPS request using client X.509 certificate for authentication? Is it supported? -- http://people.eisenbits.com/~stf/ http://www.eisenbits.com/ OpenPGP: 80FC 1824 2EA4 9223 A986 DB4E 934E FEA0 F492 A63B -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 897 bytes Desc: OpenPGP digital signature URL: From psismondi at arqux.com Sun Feb 16 14:34:31 2014 From: psismondi at arqux.com (Philippe Sismondi) Date: Sun, 16 Feb 2014 09:34:31 -0500 Subject: [Haskell-beginners] Need help with HXT In-Reply-To: <52FFE773.7010904@fuuzetsu.co.uk> References: <0FA49095-7484-4BA5-B18A-F2CADFE85B8D@arqux.com> <52FFE773.7010904@fuuzetsu.co.uk> Message-ID: <06CE1226-D891-4A27-A87C-ED779ED2E6D3@arqux.com> On 2014-02-15, at 5:17 PM, Mateusz Kowalczyk wrote: > On 15/02/14 21:25, Philippe Sismondi wrote: >> Greetings. I am trying to move some very old code from using HaXml to HXT. This is experimental; I have reasons which I think are not relevant to this post. >> >> The website that purports to document HXT has broken links. This is Uwe Schmidt's website. I have emailed Dr. Schmidt. Meanwhile, can anyone elucidate the use of readDocument with its withCurl and withHTTP options? What may be passed in the list to e.g. withHTTP? >> >> - Phil - >> _______________________________________________ >> Beginners mailing list >> Beginners at haskell.org >> http://www.haskell.org/mailman/listinfo/beginners >> > > Why don't you use the documentation on Hackage? Here[1] is your I tried to do that. > readDocument. It mentions the withCurl option and how to use it. As it > points out, the withCurl comes from hxt-curl and the relevant page is > at [2]. As you can see, it takes Attributes which is just a list of Yes. The "relevant page is at [2]". Clicking on that link takes me to a page that tells me this: withCurl :: Attributes -> SysConfig So now I want to know what about "Attributes" (above). If I click on the link to "Attributes" in the hackage documentation I discover this: Attribute list used for storing option lists and features of DTD parts So, I am clearly missing something - which, as usual, is probably my fault. What I am missing is: what goes in the attribute list for e.g. withCurl? -------------- next part -------------- An HTML attachment was scrubbed... URL: From renahs at suite-sol.com Mon Feb 17 10:38:47 2014 From: renahs at suite-sol.com (Renah Scarowsky) Date: Mon, 17 Feb 2014 10:38:47 +0000 Subject: [Haskell-beginners] combine concatMap and mapM Message-ID: Hi, How would I combine the functionalities of concatMap and mapM to define a function like: Monad m => (a -> m [b]) -> [a] -> m [b] I need to create a recursive function within the IO monad which results in a list of the original type. So something like: goX :: MonadIO m => x -> m [x] goX = do .... x includes within it a list of xs, let's call it (children x) I need to call goX on each of the children and get a modified list of children as result ys <- ? return $ x { children = ys } : zs Thanks, Renah Scarowsky Suite Solutions Create>Manage>Deploy http://www.suite-sol.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From vlatko.basic at gmail.com Mon Feb 17 12:42:38 2014 From: vlatko.basic at gmail.com (Vlatko Basic) Date: Mon, 17 Feb 2014 13:42:38 +0100 Subject: [Haskell-beginners] combine concatMap and mapM In-Reply-To: References: Message-ID: <530203BE.7090808@gmail.com> An HTML attachment was scrubbed... URL: From psismondi at arqux.com Tue Feb 18 16:26:23 2014 From: psismondi at arqux.com (Philippe Sismondi) Date: Tue, 18 Feb 2014 11:26:23 -0500 Subject: [Haskell-beginners] Is a ghc package the same as a cabal package? Message-ID: <29D101B3-2E39-47DE-BC24-2B9BE785B7C1@arqux.com> Is a ghc package the same as a cabal package? As far as I can tell they are not. I mean "package" as defined by the documentation for each. In the ghc documentation it states that "A package specification is a Haskell record". A Cabal package seems to be a collection of stuff including the .cabal file etc. Finally, does Hackage use the term "package" differently again? Rant: package and/or build systems are the bane of my existence in any non-commercial language that I use. Sigh. I have been using Cabal and cabal-install naively (read "blindly") for long enough; time to come to grips with it. Thanks, if anyone has time to help. - P - From ky3 at atamo.com Tue Feb 18 17:35:27 2014 From: ky3 at atamo.com (Kim-Ee Yeoh) Date: Wed, 19 Feb 2014 00:35:27 +0700 Subject: [Haskell-beginners] Is a ghc package the same as a cabal package? In-Reply-To: <29D101B3-2E39-47DE-BC24-2B9BE785B7C1@arqux.com> References: <29D101B3-2E39-47DE-BC24-2B9BE785B7C1@arqux.com> Message-ID: On Tue, Feb 18, 2014 at 11:26 PM, Philippe Sismondi wrote: > Rant: package and/or build systems are the bane of my existence in any > non-commercial language that I use. Sigh. I have been using Cabal and > cabal-install naively (read "blindly") for long enough; time to come to > grips with it. You are not alone. It's true that cabal works smoothly for lots of users lots of the time. But when it doesn't, it's murder. -- Kim-Ee -------------- next part -------------- An HTML attachment was scrubbed... URL: From allbery.b at gmail.com Tue Feb 18 17:46:54 2014 From: allbery.b at gmail.com (Brandon Allbery) Date: Tue, 18 Feb 2014 12:46:54 -0500 Subject: [Haskell-beginners] Is a ghc package the same as a cabal package? In-Reply-To: <29D101B3-2E39-47DE-BC24-2B9BE785B7C1@arqux.com> References: <29D101B3-2E39-47DE-BC24-2B9BE785B7C1@arqux.com> Message-ID: On Tue, Feb 18, 2014 at 11:26 AM, Philippe Sismondi wrote: > Is a ghc package the same as a cabal package? As far as I can tell they > are not. I mean "package" as defined by the documentation for each. > Start here: http://www.vex.net/~trebla/haskell/sicp.xhtml Briefly: a cabal package is a collection of source code, metadata, and build instructions to create a ghc package. Hackage is a collection of cabal packages. -- brandon s allbery kf8nh sine nomine associates allbery.b at gmail.com ballbery at sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net -------------- next part -------------- An HTML attachment was scrubbed... URL: From psismondi at arqux.com Tue Feb 18 17:56:20 2014 From: psismondi at arqux.com (Philippe Sismondi) Date: Tue, 18 Feb 2014 12:56:20 -0500 Subject: [Haskell-beginners] Is a ghc package the same as a cabal package? In-Reply-To: References: <29D101B3-2E39-47DE-BC24-2B9BE785B7C1@arqux.com> Message-ID: <607D4B49-001D-4DA4-B1CF-EE081706B758@arqux.com> Thanks, all. That helps. The ambiguous use of the term "package" was tripping me up. Kind of like when I didn't know that "cabal" invokes "cabal-install", and (more recently) that I invoke "cabal-repl" by typing "cabal repl". Funny that understanding the problems created by ambiguity in source code does not seem to prevent us as a community from f**king up our use of natural language, naming, documentation etc. Back to work. Best, - P - On 2014-02-18, at 12:46 PM, Brandon Allbery wrote: > On Tue, Feb 18, 2014 at 11:26 AM, Philippe Sismondi wrote: > Is a ghc package the same as a cabal package? As far as I can tell they are not. I mean "package" as defined by the documentation for each. > > Start here: http://www.vex.net/~trebla/haskell/sicp.xhtml > > Briefly: a cabal package is a collection of source code, metadata, and build instructions to create a ghc package. Hackage is a collection of cabal packages. > > -- > brandon s allbery kf8nh sine nomine associates > allbery.b at gmail.com ballbery at sinenomine.net > unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://www.haskell.org/mailman/listinfo/beginners -------------- next part -------------- An HTML attachment was scrubbed... URL: From psismondi at arqux.com Tue Feb 18 18:32:21 2014 From: psismondi at arqux.com (Philippe Sismondi) Date: Tue, 18 Feb 2014 13:32:21 -0500 Subject: [Haskell-beginners] Is a ghc package the same as a cabal package? In-Reply-To: <29D101B3-2E39-47DE-BC24-2B9BE785B7C1@arqux.com> References: <29D101B3-2E39-47DE-BC24-2B9BE785B7C1@arqux.com> Message-ID: <89F7DB54-63E0-40C2-8A23-75D6F464D65C@arqux.com> Actually - feeling a bit guilty here. I just found the passage in the Cabal documentation that treats the issue of ghc versus cabal packages. That's probably not the last time I'll post before the RTFM step, but my apologies anyway. - P - On 2014-02-18, at 11:26 AM, Philippe Sismondi wrote: > Is a ghc package the same as a cabal package? As far as I can tell they are not. I mean "package" as defined by the documentation for each. > > In the ghc documentation it states that "A package specification is a Haskell record". A Cabal package seems to be a collection of stuff including the .cabal file etc. > > Finally, does Hackage use the term "package" differently again? > > Rant: package and/or build systems are the bane of my existence in any non-commercial language that I use. Sigh. I have been using Cabal and cabal-install naively (read "blindly") for long enough; time to come to grips with it. > > Thanks, if anyone has time to help. > > - P - > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://www.haskell.org/mailman/listinfo/beginners From hjgtuyl at chello.nl Thu Feb 20 13:39:33 2014 From: hjgtuyl at chello.nl (Henk-Jan van Tuyl) Date: Thu, 20 Feb 2014 14:39:33 +0100 Subject: [Haskell-beginners] QuickCheck for testing a parsing function In-Reply-To: <87fvnjpf0u.fsf@ilxwinb01.fritz.box> References: <87fvnjpf0u.fsf@ilxwinb01.fritz.box> Message-ID: On Sun, 16 Feb 2014 10:45:21 +0100, Thomas Bach wrote: > Hi there, > > I have the following snippet: : > Any hints? Or is this simply not a nail for the QuickCheck-hammer? I am not a QuickCheck expert, but I think you need to generate the parts that you expect as output, than compose these parts into the string to be parsed. That way, you can check the result. Regards, Henk-Jan van Tuyl -- Folding at home What if you could share your unused computer power to help find a cure? In just 5 minutes you can join the world's biggest networked computer and get us closer sooner. Watch the video. http://folding.stanford.edu/ http://Van.Tuyl.eu/ http://members.chello.nl/hjgtuyl/tourdemonad.html Haskell programming -- From michael at orlitzky.com Thu Feb 20 18:49:18 2014 From: michael at orlitzky.com (Michael Orlitzky) Date: Thu, 20 Feb 2014 13:49:18 -0500 Subject: [Haskell-beginners] Need help with HXT In-Reply-To: <06CE1226-D891-4A27-A87C-ED779ED2E6D3@arqux.com> References: <0FA49095-7484-4BA5-B18A-F2CADFE85B8D@arqux.com> <52FFE773.7010904@fuuzetsu.co.uk> <06CE1226-D891-4A27-A87C-ED779ED2E6D3@arqux.com> Message-ID: <53064E2E.4020307@orlitzky.com> On 02/16/2014 09:34 AM, Philippe Sismondi wrote: > > Attribute list > used for storing option lists and features of DTD parts > > So, I am clearly missing something - which, as usual, is probably my > fault. What I am missing is: what goes in the attribute list for e.g. > withCurl? > I can't be sure, but the 'Attributes' type is a list of 2-tuples that contain... something. I would try the empty list and see what happens. For example, readDocument [ withCurl [] ] "http://example.com/some.xml" From psismondi at arqux.com Thu Feb 20 21:48:57 2014 From: psismondi at arqux.com (Philippe Sismondi) Date: Thu, 20 Feb 2014 16:48:57 -0500 Subject: [Haskell-beginners] Need help with HXT In-Reply-To: <53064E2E.4020307@orlitzky.com> References: <0FA49095-7484-4BA5-B18A-F2CADFE85B8D@arqux.com> <52FFE773.7010904@fuuzetsu.co.uk> <06CE1226-D891-4A27-A87C-ED779ED2E6D3@arqux.com> <53064E2E.4020307@orlitzky.com> Message-ID: On 2014-02-20, at 1:49 PM, Michael Orlitzky wrote: > On 02/16/2014 09:34 AM, Philippe Sismondi wrote: > > I can't be sure, but the 'Attributes' type is a list of 2-tuples that > contain... something. I would try the empty list and see what happens. > For example, > Thanks, Michael. I can get withCurl to work when I supple an empty list, but I am guessing that the curl options allow more control. There is a link that purports to document curl and http options, but the links are broken. I contacted Uwe Schmidt (a prof who spearheaded development of HXT, I think). He replied to say that he would check into it when he has time. I may have to plunge into the source code to see how curl and/or http actually get called if nobody restores the broken links. Meanwhile thanks for the reply. - P - > readDocument [ withCurl [] ] "http://example.com/some.xml" > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://www.haskell.org/mailman/listinfo/beginners From mathewrphillips at gmail.com Fri Feb 21 00:19:34 2014 From: mathewrphillips at gmail.com (Mathew Phillips) Date: Thu, 20 Feb 2014 18:19:34 -0600 Subject: [Haskell-beginners] Print values stored in an "Either" in the main method Message-ID: I have a module that looks like this runEval :: (Show a) => Env -> Eval a -> Either String a runEval = ... data Value = IntVal Integer main :: IO () main = do let env = Map.fromList [("x",IntVal 3)] result <- runEval env (eval (Plus (Var "x") (Lit 2))) case result of Left err -> putStrLn "Error: "++err Right (IntVal i) -> print i when I call runEval from ghci I get back a result just fine let env = Map.fromList [("x",IntVal 3)] runEval env (eval (Plus (Var "x") (Lit 2))) This outputs "Right (IntVal 5)" as I would expect. But when I try and compile my main method I get the following error. Couldn't match expected type `Value' with actual type `Either t1 Value' In the pattern: Right (IntVal i) In a case alternative: Right (IntVal i) -> print i In a stmt of a 'do' block: case result of { Left err -> print err Right (IntVal i) -> print i } I also tried using (putStrLn . either show show) result, but this gave me the following error. Couldn't match expected type `Either a0 b0' with actual type `Value' In the first argument of `putStrLn . either show show', namely `result' In a stmt of a 'do' block: (putStrLn . either show show) result In the expression: do { let env = Map.fromList ...; result <- runEval3 env (eval3 (Plus (Var "x") (Lit 2))); (putStrLn . either show show) result } Why is it when I try and pattern match on Either String Value it says result is of type "Value", but when I try and use either it says result is of type "Either String Value"? Matt P. -------------- next part -------------- An HTML attachment was scrubbed... URL: From toad3k at gmail.com Fri Feb 21 01:01:33 2014 From: toad3k at gmail.com (David McBride) Date: Thu, 20 Feb 2014 20:01:33 -0500 Subject: [Haskell-beginners] Print values stored in an "Either" in the main method In-Reply-To: References: Message-ID: Because you didn't put all your code, I'm not sure if this is correct, but my best guess is that you expect runEval to return Either String a, but the way you are using it I suspect you actually want its type to be IO (Either String a). Alternatively change result <- runEval env (eval (Plus (Var "x") (Lit 2))) to let result = runEval env (eval (Plus (Var "x") (Lit 2))) On Thu, Feb 20, 2014 at 7:19 PM, Mathew Phillips wrote: > I have a module that looks like this > > runEval :: (Show a) => Env -> Eval a -> Either String a > runEval = ... > > data Value = IntVal Integer > > main :: IO () > main = do > let env = Map.fromList [("x",IntVal 3)] > result <- runEval env (eval (Plus (Var "x") (Lit 2))) > case result of > Left err -> putStrLn "Error: "++err > Right (IntVal i) -> print i > > when I call runEval from ghci I get back a result just fine > > let env = Map.fromList [("x",IntVal 3)] > runEval env (eval (Plus (Var "x") (Lit 2))) > > This outputs "Right (IntVal 5)" as I would expect. But when I try and > compile my main method I get the following error. > > Couldn't match expected type `Value' > with actual type `Either t1 Value' > In the pattern: Right (IntVal i) > In a case alternative: Right (IntVal i) -> print i > In a stmt of a 'do' block: > case result of { > Left err -> print err > Right (IntVal i) -> print i } > > I also tried using (putStrLn . either show show) result, but this gave me > the following error. > > Couldn't match expected type `Either a0 b0' > with actual type `Value' > In the first argument of `putStrLn . either show show', namely > `result' > In a stmt of a 'do' block: (putStrLn . either show show) result > In the expression: > do { let env = Map.fromList ...; > result <- runEval3 env (eval3 (Plus (Var "x") (Lit 2))); > (putStrLn . either show show) result } > > Why is it when I try and pattern match on Either String Value it says > result is of type "Value", but when I try and use either it says result is > of type "Either String Value"? > > Matt P. > > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://www.haskell.org/mailman/listinfo/beginners > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mathewrphillips at gmail.com Fri Feb 21 01:05:51 2014 From: mathewrphillips at gmail.com (Mathew Phillips) Date: Thu, 20 Feb 2014 19:05:51 -0600 Subject: [Haskell-beginners] Print values stored in an "Either" in the main method In-Reply-To: References: Message-ID: Ok now I'm even more confused! That works, but I thought that "let" was for when the value inside the do block was pure, and the <- notation when it's inside another monad? On Thu, Feb 20, 2014 at 7:01 PM, David McBride wrote: > Because you didn't put all your code, I'm not sure if this is correct, but > my best guess is that you expect runEval to return Either String a, but the > way you are using it I suspect you actually want its type to be IO (Either > String a). > > Alternatively change > > > result <- runEval env (eval (Plus (Var "x") (Lit 2))) > > to > > let result = runEval env (eval (Plus (Var "x") (Lit 2))) > > > On Thu, Feb 20, 2014 at 7:19 PM, Mathew Phillips < > mathewrphillips at gmail.com> wrote: > >> I have a module that looks like this >> >> runEval :: (Show a) => Env -> Eval a -> Either String a >> runEval = ... >> >> data Value = IntVal Integer >> >> main :: IO () >> main = do >> let env = Map.fromList [("x",IntVal 3)] >> result <- runEval env (eval (Plus (Var "x") (Lit 2))) >> case result of >> Left err -> putStrLn "Error: "++err >> Right (IntVal i) -> print i >> >> when I call runEval from ghci I get back a result just fine >> >> let env = Map.fromList [("x",IntVal 3)] >> runEval env (eval (Plus (Var "x") (Lit 2))) >> >> This outputs "Right (IntVal 5)" as I would expect. But when I try and >> compile my main method I get the following error. >> >> Couldn't match expected type `Value' >> with actual type `Either t1 Value' >> In the pattern: Right (IntVal i) >> In a case alternative: Right (IntVal i) -> print i >> In a stmt of a 'do' block: >> case result of { >> Left err -> print err >> Right (IntVal i) -> print i } >> >> I also tried using (putStrLn . either show show) result, but this gave me >> the following error. >> >> Couldn't match expected type `Either a0 b0' >> with actual type `Value' >> In the first argument of `putStrLn . either show show', namely >> `result' >> In a stmt of a 'do' block: (putStrLn . either show show) result >> In the expression: >> do { let env = Map.fromList ...; >> result <- runEval3 env (eval3 (Plus (Var "x") (Lit 2))); >> (putStrLn . either show show) result } >> >> Why is it when I try and pattern match on Either String Value it says >> result is of type "Value", but when I try and use either it says result is >> of type "Either String Value"? >> >> Matt P. >> >> >> _______________________________________________ >> Beginners mailing list >> Beginners at haskell.org >> http://www.haskell.org/mailman/listinfo/beginners >> >> > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://www.haskell.org/mailman/listinfo/beginners > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From allbery.b at gmail.com Fri Feb 21 01:10:18 2014 From: allbery.b at gmail.com (Brandon Allbery) Date: Thu, 20 Feb 2014 20:10:18 -0500 Subject: [Haskell-beginners] Print values stored in an "Either" in the main method In-Reply-To: References: Message-ID: On Thu, Feb 20, 2014 at 8:05 PM, Mathew Phillips wrote: > Ok now I'm even more confused! That works, but I thought that "let" was > for when the value inside the do block was pure, and the <- notation when > it's inside another monad? > Are you referring to the fact that Either has a Monad instance? Because you're not *using* it monadically, but purely, so its Monad instance is not relevant. Likewise lists have a Monad instance, but most of the time you don't use it, you treat them as pure values. (You also can't mix monads; if you're using <- in a do block in IO, it must be working with a value in IO, not merely one in some monad. This is clearer when you learn how do blocks desugar into functions.) -- brandon s allbery kf8nh sine nomine associates allbery.b at gmail.com ballbery at sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net -------------- next part -------------- An HTML attachment was scrubbed... URL: From mathewrphillips at gmail.com Fri Feb 21 01:16:27 2014 From: mathewrphillips at gmail.com (Mathew Phillips) Date: Thu, 20 Feb 2014 19:16:27 -0600 Subject: [Haskell-beginners] Print values stored in an "Either" in the main method In-Reply-To: References: Message-ID: Actually your comment in parenthesis is what made it click. If i do "result <- return $ runEval ..." it works too. The fact that the first error was complaining that it expected something of type IO should have tipped me off. Thank you, Matt P. On Thu, Feb 20, 2014 at 7:10 PM, Brandon Allbery wrote: > On Thu, Feb 20, 2014 at 8:05 PM, Mathew Phillips < > mathewrphillips at gmail.com> wrote: > >> Ok now I'm even more confused! That works, but I thought that "let" was >> for when the value inside the do block was pure, and the <- notation when >> it's inside another monad? >> > > Are you referring to the fact that Either has a Monad instance? Because > you're not *using* it monadically, but purely, so its Monad instance is not > relevant. Likewise lists have a Monad instance, but most of the time you > don't use it, you treat them as pure values. > > (You also can't mix monads; if you're using <- in a do block in IO, it > must be working with a value in IO, not merely one in some monad. This is > clearer when you learn how do blocks desugar into functions.) > > -- > brandon s allbery kf8nh sine nomine > associates > allbery.b at gmail.com > ballbery at sinenomine.net > unix, openafs, kerberos, infrastructure, xmonad > http://sinenomine.net > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://www.haskell.org/mailman/listinfo/beginners > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From allbery.b at gmail.com Fri Feb 21 01:32:32 2014 From: allbery.b at gmail.com (Brandon Allbery) Date: Thu, 20 Feb 2014 20:32:32 -0500 Subject: [Haskell-beginners] Print values stored in an "Either" in the main method In-Reply-To: References: Message-ID: On Thu, Feb 20, 2014 at 8:16 PM, Mathew Phillips wrote: > Actually your comment in parenthesis is what made it click. If i do > "result <- return $ runEval ..." it works too. The fact that the first > error was complaining that it expected something of type IO should have > tipped me off. > Note also that, while using <- that way "should" have the same effect as using let, it forces the value to be sequenced with I/O actions, which you may not want. It may disable optimizations, for one thing, and changes laziness since it is now constrained by sequencing with I/O when I/O isn't actually involved with it. -- brandon s allbery kf8nh sine nomine associates allbery.b at gmail.com ballbery at sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net -------------- next part -------------- An HTML attachment was scrubbed... URL: From psismondi at arqux.com Fri Feb 21 04:48:55 2014 From: psismondi at arqux.com (Philippe Sismondi) Date: Thu, 20 Feb 2014 23:48:55 -0500 Subject: [Haskell-beginners] Type Class Instance Question Message-ID: <1BF9FBAB-3194-46F2-B910-26613D956DEA@arqux.com> In the Haskell 98 and 2010 reports it states that one may declare something of the form (tyvar1 -> tyvar2) to be an instance of a type class. Is that a function or what is it? Can anyone point me to an example of this? TIA. Best, - Phil - -------------- next part -------------- An HTML attachment was scrubbed... URL: From michael at orlitzky.com Fri Feb 21 05:02:10 2014 From: michael at orlitzky.com (Michael Orlitzky) Date: Fri, 21 Feb 2014 00:02:10 -0500 Subject: [Haskell-beginners] Type Class Instance Question In-Reply-To: <1BF9FBAB-3194-46F2-B910-26613D956DEA@arqux.com> References: <1BF9FBAB-3194-46F2-B910-26613D956DEA@arqux.com> Message-ID: <5306DDD2.7030204@orlitzky.com> On 02/20/2014 11:48 PM, Philippe Sismondi wrote: > In the Haskell 98 and 2010 reports it states that one may declare > something of the form /(tyvar1 -> tyvar2)/ to be an instance of a type > class. Is that a function or what is it? Can anyone point me to an > example of this? It refers to something like (a -> b) which is the type of functions from 'a' to 'b' (tyvar1 and tyvar2 in the report). Here's a not-terribly-useful example of such an instance: instance Show (a -> b) where show f = "some kinda function" main = print foldl A better example could make those functions an instance of Num, so that you could write f + g to represent f(x) + g(x), f * g for f(x) * g(x), and so on. From psismondi at arqux.com Fri Feb 21 05:39:21 2014 From: psismondi at arqux.com (Philippe Sismondi) Date: Fri, 21 Feb 2014 00:39:21 -0500 Subject: [Haskell-beginners] Type Class Instance Question In-Reply-To: <5306DDD2.7030204@orlitzky.com> References: <1BF9FBAB-3194-46F2-B910-26613D956DEA@arqux.com> <5306DDD2.7030204@orlitzky.com> Message-ID: <3BCD1563-2292-436A-9140-F12BDD4500AB@arqux.com> Oh, cool, thanks. That clears it up. I mean, I knew of course that "a -> b" means a function from type a to type b. What I was forgetting is that (->) is a type constructor of kind *->*->*, so an instance declaration could consistently treat (a -> b) as a concrete type like any other. My thinking is still often contaminated with my pre-Haskell intuitions sometimes. I sometimes revert to thinking of data and functions as being from two different universes. I wonder if I'll ever get over that, or of being a perpetual FP noob. Sigh. Thanks again. - Phil - On 2014-02-21, at 12:02 AM, Michael Orlitzky wrote: > On 02/20/2014 11:48 PM, Philippe Sismondi wrote: >> In the Haskell 98 and 2010 reports it states that one may declare >> something of the form /(tyvar1 -> tyvar2)/ to be an instance of a type >> class. Is that a function or what is it? Can anyone point me to an >> example of this? > > It refers to something like (a -> b) which is the type of functions from > 'a' to 'b' (tyvar1 and tyvar2 in the report). Here's a > not-terribly-useful example of such an instance: > > instance Show (a -> b) where > show f = "some kinda function" > > main = print foldl > > A better example could make those functions an instance of Num, so that > you could write f + g to represent f(x) + g(x), f * g for f(x) * g(x), > and so on. > > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://www.haskell.org/mailman/listinfo/beginners From vlatko.basic at gmail.com Fri Feb 21 05:43:57 2014 From: vlatko.basic at gmail.com (Vlatko Basic) Date: Fri, 21 Feb 2014 06:43:57 +0100 Subject: [Haskell-beginners] Need help with HXT In-Reply-To: References: <0FA49095-7484-4BA5-B18A-F2CADFE85B8D@arqux.com> <52FFE773.7010904@fuuzetsu.co.uk> <06CE1226-D891-4A27-A87C-ED779ED2E6D3@arqux.com> <53064E2E.4020307@orlitzky.com> Message-ID: <5306E79D.1080900@gmail.com> Hi Philippe, Have you taken a look at [1] That's what actually gets called from [2] [1]: http://hackage.haskell.org/package/curl-1.3.8/docs/Network-Curl.html [2]: http://hackage.haskell.org/package/hxt-curl-9.1.1/docs/src/Text-XML-HXT-Arrow-LibCurlInput.html#withCurl Best regards, vlatko -------- Original Message -------- Subject: Re: [Haskell-beginners] Need help with HXT From: Philippe Sismondi To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell Date: 20.02.2014 22:48 > > On 2014-02-20, at 1:49 PM, Michael Orlitzky wrote: > >> On 02/16/2014 09:34 AM, Philippe Sismondi wrote: >> >> I can't be sure, but the 'Attributes' type is a list of 2-tuples that >> contain... something. I would try the empty list and see what happens. >> For example, >> > Thanks, Michael. I can get withCurl to work when I supple an empty list, but I am guessing that the curl options allow more control. There is a link that purports to document curl and http options, but the links are broken. I contacted Uwe Schmidt (a prof who spearheaded development of HXT, I think). He replied to say that he would check into it when he has time. > > I may have to plunge into the source code to see how curl and/or http actually get called if nobody restores the broken links. > > Meanwhile thanks for the reply. > > - P - > >> readDocument [ withCurl [] ] "http://example.com/some.xml" >> >> _______________________________________________ >> Beginners mailing list >> Beginners at haskell.org >> http://www.haskell.org/mailman/listinfo/beginners > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://www.haskell.org/mailman/listinfo/beginners > From psismondi at arqux.com Fri Feb 21 05:54:37 2014 From: psismondi at arqux.com (Philippe Sismondi) Date: Fri, 21 Feb 2014 00:54:37 -0500 Subject: [Haskell-beginners] Need help with HXT In-Reply-To: <5306E79D.1080900@gmail.com> References: <0FA49095-7484-4BA5-B18A-F2CADFE85B8D@arqux.com> <52FFE773.7010904@fuuzetsu.co.uk> <06CE1226-D891-4A27-A87C-ED779ED2E6D3@arqux.com> <53064E2E.4020307@orlitzky.com> <5306E79D.1080900@gmail.com> Message-ID: Ah, beauty, thanks. I should have thought of that. Muchas Gracias. - P - On 2014-02-21, at 12:43 AM, Vlatko Basic wrote: > Hi Philippe, > > Have you taken a look at [1] > > That's what actually gets called from [2] > > > [1]: http://hackage.haskell.org/package/curl-1.3.8/docs/Network-Curl.html > [2]: http://hackage.haskell.org/package/hxt-curl-9.1.1/docs/src/Text-XML-HXT-Arrow-LibCurlInput.html#withCurl > > Best regards, > > vlatko > > > > -------- Original Message -------- > Subject: Re: [Haskell-beginners] Need help with HXT > From: Philippe Sismondi > To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell > Date: 20.02.2014 22:48 > >> >> On 2014-02-20, at 1:49 PM, Michael Orlitzky wrote: >> >>> On 02/16/2014 09:34 AM, Philippe Sismondi wrote: >>> >>> I can't be sure, but the 'Attributes' type is a list of 2-tuples that >>> contain... something. I would try the empty list and see what happens. >>> For example, >>> >> Thanks, Michael. I can get withCurl to work when I supple an empty list, but I am guessing that the curl options allow more control. There is a link that purports to document curl and http options, but the links are broken. I contacted Uwe Schmidt (a prof who spearheaded development of HXT, I think). He replied to say that he would check into it when he has time. >> >> I may have to plunge into the source code to see how curl and/or http actually get called if nobody restores the broken links. >> >> Meanwhile thanks for the reply. >> >> - P - >> >>> readDocument [ withCurl [] ] "http://example.com/some.xml" >>> >>> _______________________________________________ >>> Beginners mailing list >>> Beginners at haskell.org >>> http://www.haskell.org/mailman/listinfo/beginners >> >> _______________________________________________ >> Beginners mailing list >> Beginners at haskell.org >> http://www.haskell.org/mailman/listinfo/beginners >> > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://www.haskell.org/mailman/listinfo/beginners From gilbertomelfe at gmail.com Fri Feb 21 16:25:13 2014 From: gilbertomelfe at gmail.com (Gilberto Melfe) Date: Fri, 21 Feb 2014 16:25:13 +0000 Subject: [Haskell-beginners] Dynamic Loading of Haskell Code! Message-ID: Hi there All! I would like to ask: Is it possible for a Haskell program to load code while it's running, in order for it to facilitate the implementation of Plugins? (like it's possible in Perl or Python) Can someone enlighten me, please? Thank You Gilberto -------------- next part -------------- An HTML attachment was scrubbed... URL: From ollie at ocharles.org.uk Fri Feb 21 16:54:46 2014 From: ollie at ocharles.org.uk (Oliver Charles) Date: Fri, 21 Feb 2014 16:54:46 +0000 Subject: [Haskell-beginners] Dynamic Loading of Haskell Code! In-Reply-To: References: Message-ID: <877g8ojtih.fsf@nixos.i-did-not-set--mail-host-address--so-tickle-me> Gilberto Melfe writes: > Hi there All! > > I would like to ask: > Is it possible for a Haskell program to load code while it's running, > in order for it to facilitate the implementation of Plugins? > (like it's possible in Perl or Python) One possible solution is the Haskell `hint` library: http://hackage.haskell.org/package/hint This uses the GHC API to allow you to compile strings into Haskell functions at runtime. This is a lot like `eval` in other languages. - ocharles From allbery.b at gmail.com Fri Feb 21 16:59:49 2014 From: allbery.b at gmail.com (Brandon Allbery) Date: Fri, 21 Feb 2014 11:59:49 -0500 Subject: [Haskell-beginners] Dynamic Loading of Haskell Code! In-Reply-To: References: Message-ID: On Fri, Feb 21, 2014 at 11:25 AM, Gilberto Melfe wrote: > > I would like to ask: > Is it possible for a Haskell program to load code while it's running, > in order for it to facilitate the implementation of Plugins? > (like it's possible in Perl or Python) > > Can someone enlighten me, please? > There's a plugins package on Hackage for this, but it's something of a pain to use. The whole notion of plugins is kinda at cross-purposes with static type checking. -- brandon s allbery kf8nh sine nomine associates allbery.b at gmail.com ballbery at sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net -------------- next part -------------- An HTML attachment was scrubbed... URL: From jeremy at n-heptane.com Fri Feb 21 20:12:17 2014 From: jeremy at n-heptane.com (Jeremy Shaw) Date: Fri, 21 Feb 2014 14:12:17 -0600 Subject: [Haskell-beginners] Dynamic Loading of Haskell Code! In-Reply-To: References: Message-ID: The plugins package is a dying a slow death anyway. (I'm the current maintainer). The GHC api, with a little bit of glue, seems to replace everything that current plugins package does -- and better too. You are correct that loading plugins and static typing are a bit at odds. If you loading things at runtime, then you have to be willing to accept that some errors will appear at runtime. I have developed a generic 'web-plugins' package that supports the loading of plugins into a running application. The dynamic loading feature is only proof-of-concept at the moment. But it shows one system for creating a plugin system, http://hackage.haskell.org/package/web-plugins-0.2.5/docs/Web-Plugins-Core.html I am working on a independent library which adds extra wrappers around the ghc-api to us fsnotify to watch files and automatically recompile+reload, or to use cabal to fetch, build, and load plugin libraries from hackage into a running application. It's not a high priority at the moment though. I'd be happy to put the current code on github -- I just need a name. I'm not to fond of the name 'plugins' because it is a bit more general purpose than that and also doesn't directly provide plugins support -- just the tools need to create a plugins framework. - jeremy On Fri, Feb 21, 2014 at 10:59 AM, Brandon Allbery wrote: > On Fri, Feb 21, 2014 at 11:25 AM, Gilberto Melfe > wrote: >> >> >> I would like to ask: >> Is it possible for a Haskell program to load code while it's running, >> in order for it to facilitate the implementation of Plugins? >> (like it's possible in Perl or Python) >> >> Can someone enlighten me, please? > > > There's a plugins package on Hackage for this, but it's something of a pain > to use. > The whole notion of plugins is kinda at cross-purposes with static type > checking. > > -- > brandon s allbery kf8nh sine nomine associates > allbery.b at gmail.com ballbery at sinenomine.net > unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://www.haskell.org/mailman/listinfo/beginners > From karl at karlv.net Sun Feb 23 19:39:10 2014 From: karl at karlv.net (Karl Voelker) Date: Sun, 23 Feb 2014 11:39:10 -0800 Subject: [Haskell-beginners] make https request with client certificate In-Reply-To: <53009D33.1080608@eisenbits.com> References: <53009D33.1080608@eisenbits.com> Message-ID: <76EE9424-ABD0-401A-BB12-06F119BE8281@karlv.net> Are you already committed to a particular HTTP client library? It appears there are a bunch of them. I poked into the first one returned by Google (http-streams), and it appears to have client certificate support. http://hackage.haskell.org/package/http-streams-0.3.1.0/docs/Network-Http-Client.html#g:7 -Karl > On Feb 16, 2014, at 3:12 AM, Stanis?aw Findeisen wrote: > > Hi > > How can you issue a HTTPS request using client X.509 certificate for > authentication? Is it supported? > > -- > http://people.eisenbits.com/~stf/ > http://www.eisenbits.com/ > > OpenPGP: 80FC 1824 2EA4 9223 A986 DB4E 934E FEA0 F492 A63B > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://www.haskell.org/mailman/listinfo/beginners From derek.mahar at gmail.com Mon Feb 24 18:20:45 2014 From: derek.mahar at gmail.com (Derek Mahar) Date: Mon, 24 Feb 2014 13:20:45 -0500 Subject: [Haskell-beginners] Failure to install cabal-install. Message-ID: How can I tell the Haskell compiler where to find module Control.Monad.Error? After building GHC 7.6.3 and Haskell Platform 2013.2 on Red Hat Linux 6, I found that 'cabal install cabal-install' fails when it attempts to build library HTTP-4000.2.11 because the Haskell compiler cannot find module Control.Monad.Error. ******************************************************* * Installation completed successfully. * * Programs installed into: * /usr/local/bin * * Now do "cabal update" to initialize the package list * * Additional packages may be found at http://hackage.haskell.org * or via "cabal list " * * Use "cabal install " to install additional packages * ******************************************************* [dmahar at dmahar haskell-platform-2013.2.0.0]$ cabal update Downloading the latest package list from hackage.haskell.org Note: there is a new version of cabal-install available. To upgrade, run: cabal install cabal-install [dmahar at dmahar haskell-platform-2013.2.0.0]$ cabal install cabal-install Resolving dependencies... Configuring HTTP-4000.2.11... Building HTTP-4000.2.11... Preprocessing library HTTP-4000.2.11... Network/Stream.hs:35:8: Could not find module `Control.Monad.Error' There are files missing in the `mtl-2.1.2' package, try running 'ghc-pkg check'. Use -v to see a list of the files searched for. Failed to install HTTP-4000.2.11 cabal: Error: some packages failed to install: HTTP-4000.2.11 failed during the building phase. The exception was: ExitFailure 1 cabal-install-1.18.0.2 depends on HTTP-4000.2.11 which failed to install. Thank you, Derek -------------- next part -------------- An HTML attachment was scrubbed... URL: From derek.mahar at gmail.com Mon Feb 24 19:30:14 2014 From: derek.mahar at gmail.com (Derek Mahar) Date: Mon, 24 Feb 2014 14:30:14 -0500 Subject: [Haskell-beginners] Failure to install cabal-install. In-Reply-To: References: Message-ID: On Mon, Feb 24, 2014 at 1:20 PM, Derek Mahar wrote: > [dmahar at dmahar haskell-platform-2013.2.0.0]$ cabal update > Downloading the latest package list from hackage.haskell.org > Note: there is a new version of cabal-install available. > To upgrade, run: cabal install cabal-install > [dmahar at dmahar haskell-platform-2013.2.0.0]$ cabal install cabal-install > Resolving dependencies... > Configuring HTTP-4000.2.11... > Building HTTP-4000.2.11... > Preprocessing library HTTP-4000.2.11... > > Network/Stream.hs:35:8: > Could not find module `Control.Monad.Error' > There are files missing in the `mtl-2.1.2' package, > try running 'ghc-pkg check'. > Use -v to see a list of the files searched for. > Failed to install HTTP-4000.2.11 > cabal: Error: some packages failed to install: > HTTP-4000.2.11 failed during the building phase. The exception was: > ExitFailure 1 > cabal-install-1.18.0.2 depends on HTTP-4000.2.11 which failed to install. > 'ghc-pkg -v check' reports that my Haskell environment is missing many files and that many of its packages are broken. See the attached output of 'ghc-pkg -v check'. Derek -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: ghc-pkg-check.output Type: application/octet-stream Size: 38867 bytes Desc: not available URL: From kmandpjlynch at verizon.net Tue Feb 25 01:32:40 2014 From: kmandpjlynch at verizon.net (KMandPJLynch) Date: Mon, 24 Feb 2014 20:32:40 -0500 Subject: [Haskell-beginners] Beginners Digest, Vol 68, Issue 22 In-Reply-To: References: Message-ID: <609E40BD-3267-4F21-88A6-1BDC4DEDC609@verizon.net> Good evening, I'm trying to learn how to implement Haskell on a web site. I've got the O'Reilly book: "Developing Web Applications with Haskell and Yesod". I'd appreciate some guidance in regard to this. I'm having a bit of a problem getting the helloWorld.hs app up and running on Yesod. Thank you On Feb 24, 2014, at 2:30 PM, beginners-request at haskell.org wrote: > Send Beginners mailing list submissions to > beginners at haskell.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://www.haskell.org/mailman/listinfo/beginners > or, via email, send a message with subject or body 'help' to > beginners-request at haskell.org > > You can reach the person managing the list at > beginners-owner at haskell.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Beginners digest..." > > > Today's Topics: > > 1. Failure to install cabal-install. (Derek Mahar) > 2. Re: Failure to install cabal-install. (Derek Mahar) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Mon, 24 Feb 2014 13:20:45 -0500 > From: Derek Mahar > To: beginners at haskell.org > Subject: [Haskell-beginners] Failure to install cabal-install. > Message-ID: > > Content-Type: text/plain; charset="utf-8" > > How can I tell the Haskell compiler where to find module > Control.Monad.Error? After building GHC 7.6.3 and Haskell Platform 2013.2 > on Red Hat Linux 6, I found that 'cabal install cabal-install' fails when > it attempts to build library HTTP-4000.2.11 because the Haskell compiler > cannot find module Control.Monad.Error. > > ******************************************************* > * Installation completed successfully. > * > * Programs installed into: > * /usr/local/bin > * > * Now do "cabal update" to initialize the package list > * > * Additional packages may be found at http://hackage.haskell.org > * or via "cabal list " > * > * Use "cabal install " to install additional packages > * > ******************************************************* > [dmahar at dmahar haskell-platform-2013.2.0.0]$ cabal update > Downloading the latest package list from hackage.haskell.org > Note: there is a new version of cabal-install available. > To upgrade, run: cabal install cabal-install > [dmahar at dmahar haskell-platform-2013.2.0.0]$ cabal install cabal-install > Resolving dependencies... > Configuring HTTP-4000.2.11... > Building HTTP-4000.2.11... > Preprocessing library HTTP-4000.2.11... > > Network/Stream.hs:35:8: > Could not find module `Control.Monad.Error' > There are files missing in the `mtl-2.1.2' package, > try running 'ghc-pkg check'. > Use -v to see a list of the files searched for. > Failed to install HTTP-4000.2.11 > cabal: Error: some packages failed to install: > HTTP-4000.2.11 failed during the building phase. The exception was: > ExitFailure 1 > cabal-install-1.18.0.2 depends on HTTP-4000.2.11 which failed to install. > > Thank you, > > Derek > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: > > ------------------------------ > > Message: 2 > Date: Mon, 24 Feb 2014 14:30:14 -0500 > From: Derek Mahar > To: beginners at haskell.org > Subject: Re: [Haskell-beginners] Failure to install cabal-install. > Message-ID: > > Content-Type: text/plain; charset="utf-8" > > On Mon, Feb 24, 2014 at 1:20 PM, Derek Mahar wrote: > >> [dmahar at dmahar haskell-platform-2013.2.0.0]$ cabal update >> Downloading the latest package list from hackage.haskell.org >> Note: there is a new version of cabal-install available. >> To upgrade, run: cabal install cabal-install >> [dmahar at dmahar haskell-platform-2013.2.0.0]$ cabal install cabal-install >> Resolving dependencies... >> Configuring HTTP-4000.2.11... >> Building HTTP-4000.2.11... >> Preprocessing library HTTP-4000.2.11... >> >> Network/Stream.hs:35:8: >> Could not find module `Control.Monad.Error' >> There are files missing in the `mtl-2.1.2' package, >> try running 'ghc-pkg check'. >> Use -v to see a list of the files searched for. >> Failed to install HTTP-4000.2.11 >> cabal: Error: some packages failed to install: >> HTTP-4000.2.11 failed during the building phase. The exception was: >> ExitFailure 1 >> cabal-install-1.18.0.2 depends on HTTP-4000.2.11 which failed to install. >> > > 'ghc-pkg -v check' reports that my Haskell environment is missing many > files and that many of its packages are broken. See the attached output of > 'ghc-pkg -v check'. > > Derek > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: > -------------- next part -------------- > A non-text attachment was scrubbed... > Name: ghc-pkg-check.output > Type: application/octet-stream > Size: 38867 bytes > Desc: not available > URL: > > ------------------------------ > > Subject: Digest Footer > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://www.haskell.org/mailman/listinfo/beginners > > > ------------------------------ > > End of Beginners Digest, Vol 68, Issue 22 > ***************************************** From fuuzetsu at fuuzetsu.co.uk Tue Feb 25 01:56:01 2014 From: fuuzetsu at fuuzetsu.co.uk (Mateusz Kowalczyk) Date: Tue, 25 Feb 2014 01:56:01 +0000 Subject: [Haskell-beginners] Beginners Digest, Vol 68, Issue 22 In-Reply-To: <609E40BD-3267-4F21-88A6-1BDC4DEDC609@verizon.net> References: <609E40BD-3267-4F21-88A6-1BDC4DEDC609@verizon.net> Message-ID: <530BF831.50001@fuuzetsu.co.uk> On 25/02/14 01:32, KMandPJLynch wrote: > Good evening, > > I'm trying to learn how to implement Haskell on a web site. > I've got the O'Reilly book: "Developing Web Applications with Haskell and Yesod". > I'd appreciate some guidance in regard to this. > I'm having a bit of a problem getting the helloWorld.hs app up and running on Yesod. > > Thank you > Well, what's your problem? Saying that you have one doesn't help us help you ;). Paste in any relevant error messages that you can't figure out and post your system information. PS: Next time create a new thread instead of replying to an existing, irrelevant thread. -- Mateusz K. From kmandpjlynch at verizon.net Tue Feb 25 14:05:25 2014 From: kmandpjlynch at verizon.net (Patrick Lynch) Date: Tue, 25 Feb 2014 09:05:25 -0500 Subject: [Haskell-beginners] Beginners Digest, Vol 68, Issue 23 In-Reply-To: References: Message-ID: <7F5D27B903FD474AA7896F0E482A59EE@UserPC> Good morning, Re: Today's Topic 1 - see below. My apology for not including the error message. The following is what I did: I downloaded the source code and did the following [from the O'Reilly book]: 1. download was done on a Mac. 2. I saved the file to helloWorld.hs 3. I went to my terminal screen and executed: runhaskell helloworld.hs 4. on the terminal the following appeared: hell yeah 5. so far, so good 6. I went to my browser and entered the url: http://localhost:3000 7. I was expecting to see the following on my browser: </head><body>hell yeah</body></html> 8. Unfortunately, I get the following message: "Safari can't connect to Server Safari can't open page "http://localhost:3000" because Safari can't connect to server "localhost" Good day, Patrick ----- Original Message ----- From: <beginners-request at haskell.org> To: <beginners at haskell.org> Sent: Tuesday, February 25, 2014 7:00 AM Subject: Beginners Digest, Vol 68, Issue 23 > Send Beginners mailing list submissions to > beginners at haskell.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://www.haskell.org/mailman/listinfo/beginners > or, via email, send a message with subject or body 'help' to > beginners-request at haskell.org > > You can reach the person managing the list at > beginners-owner at haskell.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Beginners digest..." > > > Today's Topics: > > 1. Re: Beginners Digest, Vol 68, Issue 22 (KMandPJLynch) > 2. Re: Beginners Digest, Vol 68, Issue 22 (Mateusz Kowalczyk) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Mon, 24 Feb 2014 20:32:40 -0500 > From: KMandPJLynch <kmandpjlynch at verizon.net> > To: beginners at haskell.org > Subject: Re: [Haskell-beginners] Beginners Digest, Vol 68, Issue 22 > Message-ID: <609E40BD-3267-4F21-88A6-1BDC4DEDC609 at verizon.net> > Content-Type: text/plain; charset=us-ascii > > Good evening, > > I'm trying to learn how to implement Haskell on a web site. > I've got the O'Reilly book: "Developing Web Applications with Haskell and > Yesod". > I'd appreciate some guidance in regard to this. > I'm having a bit of a problem getting the helloWorld.hs app up and running > on Yesod. > > Thank you > > On Feb 24, 2014, at 2:30 PM, beginners-request at haskell.org wrote: > >> Send Beginners mailing list submissions to >> beginners at haskell.org >> >> To subscribe or unsubscribe via the World Wide Web, visit >> http://www.haskell.org/mailman/listinfo/beginners >> or, via email, send a message with subject or body 'help' to >> beginners-request at haskell.org >> >> You can reach the person managing the list at >> beginners-owner at haskell.org >> >> When replying, please edit your Subject line so it is more specific >> than "Re: Contents of Beginners digest..." >> >> >> Today's Topics: >> >> 1. Failure to install cabal-install. (Derek Mahar) >> 2. Re: Failure to install cabal-install. (Derek Mahar) >> >> >> ---------------------------------------------------------------------- >> >> Message: 1 >> Date: Mon, 24 Feb 2014 13:20:45 -0500 >> From: Derek Mahar <derek.mahar at gmail.com> >> To: beginners at haskell.org >> Subject: [Haskell-beginners] Failure to install cabal-install. >> Message-ID: >> <CABtfiZb7+p=DtGoz57GVXwgHCdK1vPL175UxmirRY1EXM4aEBA at mail.gmail.com> >> Content-Type: text/plain; charset="utf-8" >> >> How can I tell the Haskell compiler where to find module >> Control.Monad.Error? After building GHC 7.6.3 and Haskell Platform >> 2013.2 >> on Red Hat Linux 6, I found that 'cabal install cabal-install' fails when >> it attempts to build library HTTP-4000.2.11 because the Haskell compiler >> cannot find module Control.Monad.Error. >> >> ******************************************************* >> * Installation completed successfully. >> * >> * Programs installed into: >> * /usr/local/bin >> * >> * Now do "cabal update" to initialize the package list >> * >> * Additional packages may be found at http://hackage.haskell.org >> * or via "cabal list <pattern>" >> * >> * Use "cabal install <foo>" to install additional packages >> * >> ******************************************************* >> [dmahar at dmahar haskell-platform-2013.2.0.0]$ cabal update >> Downloading the latest package list from hackage.haskell.org >> Note: there is a new version of cabal-install available. >> To upgrade, run: cabal install cabal-install >> [dmahar at dmahar haskell-platform-2013.2.0.0]$ cabal install cabal-install >> Resolving dependencies... >> Configuring HTTP-4000.2.11... >> Building HTTP-4000.2.11... >> Preprocessing library HTTP-4000.2.11... >> >> Network/Stream.hs:35:8: >> Could not find module `Control.Monad.Error' >> There are files missing in the `mtl-2.1.2' package, >> try running 'ghc-pkg check'. >> Use -v to see a list of the files searched for. >> Failed to install HTTP-4000.2.11 >> cabal: Error: some packages failed to install: >> HTTP-4000.2.11 failed during the building phase. The exception was: >> ExitFailure 1 >> cabal-install-1.18.0.2 depends on HTTP-4000.2.11 which failed to install. >> >> Thank you, >> >> Derek >> -------------- next part -------------- >> An HTML attachment was scrubbed... >> URL: >> <http://www.haskell.org/pipermail/beginners/attachments/20140224/53adc45d/attachment-0001.html> >> >> ------------------------------ >> >> Message: 2 >> Date: Mon, 24 Feb 2014 14:30:14 -0500 >> From: Derek Mahar <derek.mahar at gmail.com> >> To: beginners at haskell.org >> Subject: Re: [Haskell-beginners] Failure to install cabal-install. >> Message-ID: >> <CABtfiZbF--Q93cx-GRHTU+FaX4+9d1uTSkoyb8E-N5e=c5Z4ow at mail.gmail.com> >> Content-Type: text/plain; charset="utf-8" >> >> On Mon, Feb 24, 2014 at 1:20 PM, Derek Mahar <derek.mahar at gmail.com> >> wrote: >> >>> [dmahar at dmahar haskell-platform-2013.2.0.0]$ cabal update >>> Downloading the latest package list from hackage.haskell.org >>> Note: there is a new version of cabal-install available. >>> To upgrade, run: cabal install cabal-install >>> [dmahar at dmahar haskell-platform-2013.2.0.0]$ cabal install cabal-install >>> Resolving dependencies... >>> Configuring HTTP-4000.2.11... >>> Building HTTP-4000.2.11... >>> Preprocessing library HTTP-4000.2.11... >>> >>> Network/Stream.hs:35:8: >>> Could not find module `Control.Monad.Error' >>> There are files missing in the `mtl-2.1.2' package, >>> try running 'ghc-pkg check'. >>> Use -v to see a list of the files searched for. >>> Failed to install HTTP-4000.2.11 >>> cabal: Error: some packages failed to install: >>> HTTP-4000.2.11 failed during the building phase. The exception was: >>> ExitFailure 1 >>> cabal-install-1.18.0.2 depends on HTTP-4000.2.11 which failed to >>> install. >>> >> >> 'ghc-pkg -v check' reports that my Haskell environment is missing many >> files and that many of its packages are broken. See the attached output >> of >> 'ghc-pkg -v check'. >> >> Derek >> -------------- next part -------------- >> An HTML attachment was scrubbed... >> URL: >> <http://www.haskell.org/pipermail/beginners/attachments/20140224/7c4e3467/attachment.html> >> -------------- next part -------------- >> A non-text attachment was scrubbed... >> Name: ghc-pkg-check.output >> Type: application/octet-stream >> Size: 38867 bytes >> Desc: not available >> URL: >> <http://www.haskell.org/pipermail/beginners/attachments/20140224/7c4e3467/attachment.obj> >> >> ------------------------------ >> >> Subject: Digest Footer >> >> _______________________________________________ >> Beginners mailing list >> Beginners at haskell.org >> http://www.haskell.org/mailman/listinfo/beginners >> >> >> ------------------------------ >> >> End of Beginners Digest, Vol 68, Issue 22 >> ***************************************** > > > > ------------------------------ > > Message: 2 > Date: Tue, 25 Feb 2014 01:56:01 +0000 > From: Mateusz Kowalczyk <fuuzetsu at fuuzetsu.co.uk> > To: beginners at haskell.org > Subject: Re: [Haskell-beginners] Beginners Digest, Vol 68, Issue 22 > Message-ID: <530BF831.50001 at fuuzetsu.co.uk> > Content-Type: text/plain; charset=ISO-8859-1 > > On 25/02/14 01:32, KMandPJLynch wrote: >> Good evening, >> >> I'm trying to learn how to implement Haskell on a web site. >> I've got the O'Reilly book: "Developing Web Applications with Haskell and >> Yesod". >> I'd appreciate some guidance in regard to this. >> I'm having a bit of a problem getting the helloWorld.hs app up and >> running on Yesod. >> >> Thank you >> > > Well, what's your problem? Saying that you have one doesn't help us help > you ;). Paste in any relevant error messages that you can't figure out > and post your system information. > > PS: Next time create a new thread instead of replying to an existing, > irrelevant thread. > > > -- > Mateusz K. > > > ------------------------------ > > Subject: Digest Footer > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://www.haskell.org/mailman/listinfo/beginners > > > ------------------------------ > > End of Beginners Digest, Vol 68, Issue 23 > ***************************************** From fuuzetsu at fuuzetsu.co.uk Tue Feb 25 15:59:58 2014 From: fuuzetsu at fuuzetsu.co.uk (Mateusz Kowalczyk) Date: Tue, 25 Feb 2014 15:59:58 +0000 Subject: [Haskell-beginners] Yesod server not starting In-Reply-To: <7F5D27B903FD474AA7896F0E482A59EE@UserPC> References: <mailman.1.1393329601.8982.beginners@haskell.org> <7F5D27B903FD474AA7896F0E482A59EE@UserPC> Message-ID: <530CBDFE.60307@fuuzetsu.co.uk> On 25/02/14 14:05, Patrick Lynch wrote: > Good morning, > > Re: Today's Topic 1 - see below. > > My apology for not including the error message. > > The following is what I did: > I downloaded the source code and did the following [from the O'Reilly > book]: > 1. download was done on a Mac. > 2. I saved the file to helloWorld.hs > 3. I went to my terminal screen and executed: > runhaskell helloworld.hs > 4. on the terminal the following appeared: > hell yeah > 5. so far, so good > 6. I went to my browser and entered the url: > http://localhost:3000 > 7. I was expecting to see the following on my browser: > <!DOCTYPE html> > <html><head><title></head><body>hell yeah</body></html> > 8. Unfortunately, I get the following message: > "Safari can't connect to Server > Safari can't open page "http://localhost:3000" because > Safari can't connect to server "localhost" > > Good day, > Patrick > >> On 25/02/14 01:32, KMandPJLynch wrote: >>> Good evening, >>> >>> I'm trying to learn how to implement Haskell on a web site. >>> I've got the O'Reilly book: "Developing Web Applications with Haskell and >>> Yesod". >>> I'd appreciate some guidance in regard to this. >>> I'm having a bit of a problem getting the helloWorld.hs app up and >>> running on Yesod. >>> >>> Thank you >>> >> >> Well, what's your problem? Saying that you have one doesn't help us help >> you ;). Paste in any relevant error messages that you can't figure out >> and post your system information. >> >> PS: Next time create a new thread instead of replying to an existing, >> irrelevant thread. >> >> >> -- >> Mateusz K. >> >> Hi again, I took the liberty to change the topic name to something clearer. Which code are you following? I don't have the copy of a book with me but it's available online. Is the code from http://www.yesodweb.com/book/basics what you're trying? -- Mateusz K. From renahs at suite-sol.com Wed Feb 26 07:24:19 2014 From: renahs at suite-sol.com (Renah Scarowsky) Date: Wed, 26 Feb 2014 07:24:19 +0000 Subject: [Haskell-beginners] copy file and create directory Message-ID: <33ada4af5f884249ac587c4821f567ef@DB4PR05MB271.eurprd05.prod.outlook.com> Is there a version of copyFile that will create the directory structure if it does not exist yet? Thanks, Renah Scarowsky Suite Solutions Create>Manage>Deploy http://www.suite-sol.com<http://www.suite-sol.com/> -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://www.haskell.org/pipermail/beginners/attachments/20140226/d29b4b5d/attachment.html> From magnus at therning.org Wed Feb 26 07:47:18 2014 From: magnus at therning.org (Magnus Therning) Date: Wed, 26 Feb 2014 08:47:18 +0100 Subject: [Haskell-beginners] copy file and create directory In-Reply-To: <33ada4af5f884249ac587c4821f567ef@DB4PR05MB271.eurprd05.prod.outlook.com> References: <33ada4af5f884249ac587c4821f567ef@DB4PR05MB271.eurprd05.prod.outlook.com> Message-ID: <CAAExw5vy=e5F4NVHSVXS8nWCsJOPjk8ns3DY+urayS_czCOHzQ@mail.gmail.com> On Wed, Feb 26, 2014 at 8:24 AM, Renah Scarowsky <renahs at suite-sol.com> wrote: > Is there a version of copyFile that will create the directory structure if > it does not exist yet? No, I don't think so, I think you'll have to write one by combining System.Directory.createDirectoryIfMissing with System.Directory.copyFile. /M -- Magnus Therning OpenPGP: 0xAB4DFBA4 email: magnus at therning.org jabber: magnus at therning.org twitter: magthe http://therning.org/magnus From derek.mahar at gmail.com Wed Feb 26 19:19:24 2014 From: derek.mahar at gmail.com (Derek Mahar) Date: Wed, 26 Feb 2014 14:19:24 -0500 Subject: [Haskell-beginners] Failure to install cabal-install. In-Reply-To: <CABtfiZbF--Q93cx-GRHTU+FaX4+9d1uTSkoyb8E-N5e=c5Z4ow@mail.gmail.com> References: <CABtfiZb7+p=DtGoz57GVXwgHCdK1vPL175UxmirRY1EXM4aEBA@mail.gmail.com> <CABtfiZbF--Q93cx-GRHTU+FaX4+9d1uTSkoyb8E-N5e=c5Z4ow@mail.gmail.com> Message-ID: <CABtfiZaycHSXGMXB73EPz+6fTsiD6KdufX4SLWt-v8Ju+mxMjQ@mail.gmail.com> On Mon, Feb 24, 2014 at 2:30 PM, Derek Mahar <derek.mahar at gmail.com> wrote: > On Mon, Feb 24, 2014 at 1:20 PM, Derek Mahar <derek.mahar at gmail.com>wrote: > >> [dmahar at dmahar haskell-platform-2013.2.0.0]$ cabal update >> Downloading the latest package list from hackage.haskell.org >> Note: there is a new version of cabal-install available. >> To upgrade, run: cabal install cabal-install >> [dmahar at dmahar haskell-platform-2013.2.0.0]$ cabal install cabal-install >> Resolving dependencies... >> Configuring HTTP-4000.2.11... >> Building HTTP-4000.2.11... >> Preprocessing library HTTP-4000.2.11... >> >> Network/Stream.hs:35:8: >> Could not find module `Control.Monad.Error' >> There are files missing in the `mtl-2.1.2' package, >> try running 'ghc-pkg check'. >> Use -v to see a list of the files searched for. >> Failed to install HTTP-4000.2.11 >> cabal: Error: some packages failed to install: >> HTTP-4000.2.11 failed during the building phase. The exception was: >> ExitFailure 1 >> cabal-install-1.18.0.2 depends on HTTP-4000.2.11 which failed to install. >> > > 'ghc-pkg -v check' reports that my Haskell environment is missing many > files and that many of its packages are broken. See the attached output of > 'ghc-pkg -v check'. > I abandoned the idea of fixing the Haskell Platform on my Red Hat Enterprise Linux 6 workstation and instead installed Ubuntu 13.10 in a virtual machine in VirtualBox and installed the much more recent Haskell Platform packages from the Ubuntu repository. Derek -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://www.haskell.org/pipermail/beginners/attachments/20140226/7c0f8657/attachment.html> From obscaenvs at gmail.com Thu Feb 27 16:09:01 2014 From: obscaenvs at gmail.com (Obscaenvs) Date: Thu, 27 Feb 2014 17:09:01 +0100 Subject: [Haskell-beginners] Cabal update possible? Message-ID: <530F631D.8080206@gmail.com> Have: * The Glorious Glasgow Haskell Compilation System, version 7.6.3 * cabal-install version 1.16.0.2 using version 1.16.0 of the Cabal library Can I update to Cabal 1.18 so I can use sandboxes without breaking my dependencies? I think that that is what broke my Haskell toolchain 2h ago. Now I redid it so everything's fine, but I'd like to use sandboxes. If impossible, hsenv has worked for me in the past, but... I did not want to use Haskell Platform, since it pulls in several OpenGL libs completely unnecessary *for* and potentially detrimental *to* my server. "Haskell Platform, Server Edition", anyone? fredrik From philip.dexter at gmail.com Thu Feb 27 16:24:35 2014 From: philip.dexter at gmail.com (Philip Dexter) Date: Thu, 27 Feb 2014 11:24:35 -0500 Subject: [Haskell-beginners] Cabal update possible? In-Reply-To: <530F631D.8080206@gmail.com> References: <530F631D.8080206@gmail.com> Message-ID: <CALyv6VCLNvcaxKhO=0+h0ZoEp7-0uBkPWGp2e76yJZ4EDd5L_w@mail.gmail.com> The second answer here [1] gives directions on how to remove the opengl dependencies from the haskell platform, assuming you're building from source. As for the original question, I'm not sure. Did you already try cabal install cabal-install? [1] http://stackoverflow.com/questions/18116201/how-can-i-disable-opengl-in-the-haskell-platform On Thu, Feb 27, 2014 at 11:09 AM, Obscaenvs <obscaenvs at gmail.com> wrote: > Have: > * The Glorious Glasgow Haskell Compilation System, version 7.6.3 > * cabal-install version 1.16.0.2 > using version 1.16.0 of the Cabal library > > Can I update to Cabal 1.18 so I can use sandboxes without breaking my > dependencies? I think that that is what broke my Haskell toolchain 2h > ago. Now I redid it so everything's fine, but I'd like to use sandboxes. > If impossible, hsenv has worked for me in the past, but... > > I did not want to use Haskell Platform, since it pulls in several OpenGL > libs completely unnecessary *for* and potentially detrimental *to* my > server. "Haskell Platform, Server Edition", anyone? > > fredrik > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://www.haskell.org/mailman/listinfo/beginners > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://www.haskell.org/pipermail/beginners/attachments/20140227/dc70a4eb/attachment.html> From maxim.kulkin at gmail.com Thu Feb 27 16:36:44 2014 From: maxim.kulkin at gmail.com (Maxim Kulkin) Date: Thu, 27 Feb 2014 20:36:44 +0400 Subject: [Haskell-beginners] Cabal update possible? In-Reply-To: <CALyv6VCLNvcaxKhO=0+h0ZoEp7-0uBkPWGp2e76yJZ4EDd5L_w@mail.gmail.com> References: <530F631D.8080206@gmail.com> <CALyv6VCLNvcaxKhO=0+h0ZoEp7-0uBkPWGp2e76yJZ4EDd5L_w@mail.gmail.com> Message-ID: <CAORmg627rTp2gmC9i=g=p_tf6rHecQ6NWPtsgZvvqjQbYQXmFg@mail.gmail.com> "cabal install cabal-install" works for me. Running Cabal 1.18 with GHC 7.6.3. On Thu, Feb 27, 2014 at 8:24 PM, Philip Dexter <philip.dexter at gmail.com>wrote: > The second answer here [1] gives directions on how to remove the opengl > dependencies from the haskell platform, assuming you're building from > source. > > As for the original question, I'm not sure. Did you already try cabal > install cabal-install? > > > [1] > http://stackoverflow.com/questions/18116201/how-can-i-disable-opengl-in-the-haskell-platform > > > On Thu, Feb 27, 2014 at 11:09 AM, Obscaenvs <obscaenvs at gmail.com> wrote: > >> Have: >> * The Glorious Glasgow Haskell Compilation System, version 7.6.3 >> * cabal-install version 1.16.0.2 >> using version 1.16.0 of the Cabal library >> >> Can I update to Cabal 1.18 so I can use sandboxes without breaking my >> dependencies? I think that that is what broke my Haskell toolchain 2h >> ago. Now I redid it so everything's fine, but I'd like to use sandboxes. >> If impossible, hsenv has worked for me in the past, but... >> >> I did not want to use Haskell Platform, since it pulls in several OpenGL >> libs completely unnecessary *for* and potentially detrimental *to* my >> server. "Haskell Platform, Server Edition", anyone? >> >> fredrik >> _______________________________________________ >> Beginners mailing list >> Beginners at haskell.org >> http://www.haskell.org/mailman/listinfo/beginners >> > > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://www.haskell.org/mailman/listinfo/beginners > > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://www.haskell.org/pipermail/beginners/attachments/20140227/e862d28d/attachment.html> From obscaenvs at gmail.com Thu Feb 27 18:36:44 2014 From: obscaenvs at gmail.com (Obscaenvs) Date: Thu, 27 Feb 2014 19:36:44 +0100 Subject: [Haskell-beginners] Cabal update possible? In-Reply-To: <CAORmg627rTp2gmC9i=g=p_tf6rHecQ6NWPtsgZvvqjQbYQXmFg@mail.gmail.com> References: <530F631D.8080206@gmail.com> <CALyv6VCLNvcaxKhO=0+h0ZoEp7-0uBkPWGp2e76yJZ4EDd5L_w@mail.gmail.com> <CAORmg627rTp2gmC9i=g=p_tf6rHecQ6NWPtsgZvvqjQbYQXmFg@mail.gmail.com> Message-ID: <530F85BC.3090806@gmail.com> Yep, did "cabal install cabal-install". That seems to have broken my deps. But nevermind, I shall go with hsenv. Thanks to both of you! f Le 2014-02-27 17:36, Maxim Kulkin a ?crit : > "cabal install cabal-install" works for me. Running Cabal 1.18 with GHC > 7.6.3. > > > On Thu, Feb 27, 2014 at 8:24 PM, Philip Dexter <philip.dexter at gmail.com>wrote: > >> The second answer here [1] gives directions on how to remove the opengl >> dependencies from the haskell platform, assuming you're building from >> source. >> >> As for the original question, I'm not sure. Did you already try cabal >> install cabal-install? >> >> >> [1] >> http://stackoverflow.com/questions/18116201/how-can-i-disable-opengl-in-the-haskell-platform >> >> >> On Thu, Feb 27, 2014 at 11:09 AM, Obscaenvs <obscaenvs at gmail.com> wrote: >> >>> Have: >>> * The Glorious Glasgow Haskell Compilation System, version 7.6.3 >>> * cabal-install version 1.16.0.2 >>> using version 1.16.0 of the Cabal library >>> >>> Can I update to Cabal 1.18 so I can use sandboxes without breaking my >>> dependencies? I think that that is what broke my Haskell toolchain 2h >>> ago. Now I redid it so everything's fine, but I'd like to use sandboxes. >>> If impossible, hsenv has worked for me in the past, but... >>> >>> I did not want to use Haskell Platform, since it pulls in several OpenGL >>> libs completely unnecessary *for* and potentially detrimental *to* my >>> server. "Haskell Platform, Server Edition", anyone? >>> >>> fredrik >>> _______________________________________________ >>> Beginners mailing list >>> Beginners at haskell.org >>> http://www.haskell.org/mailman/listinfo/beginners >>> >> >> >> _______________________________________________ >> Beginners mailing list >> Beginners at haskell.org >> http://www.haskell.org/mailman/listinfo/beginners >> >> > > > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://www.haskell.org/mailman/listinfo/beginners > -- bugthunk.net monoid.se @MonoidSe From miroslav.karpis at gmail.com Fri Feb 28 14:23:56 2014 From: miroslav.karpis at gmail.com (Miroslav Karpis) Date: Fri, 28 Feb 2014 15:23:56 +0100 Subject: [Haskell-beginners] web client/server app - what to choose Message-ID: <CF365A8C.6C7C%miroslav.karpis@gmail.com> Hi, please can you help me with following: I would like to make a server/client web app, but I'm not sure what packages/modules would do the best. I did several client/server applications not in Haskell, where I have used REST (JSON) API as a communication between client and server. In Haskell I'm not sure what would be best, but for future use most probably also REST/JSON would be best. Server will do some realtime mathematical calculations . After its done it will send to client results. Client will visualize the results via WebGL/Threejs. I was thinking about Snap for server but for client I'm not really not sure. Any ideas/comments more than appreciated ;-) Cheers, M. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://www.haskell.org/pipermail/beginners/attachments/20140228/c2bce47a/attachment.html> From ryan.trinkle at gmail.com Fri Feb 28 14:29:25 2014 From: ryan.trinkle at gmail.com (Ryan Trinkle) Date: Fri, 28 Feb 2014 09:29:25 -0500 Subject: [Haskell-beginners] web client/server app - what to choose In-Reply-To: <CF365A8C.6C7C%miroslav.karpis@gmail.com> References: <CF365A8C.6C7C%miroslav.karpis@gmail.com> Message-ID: <CAHNEpiwbZ+-CvXvB9jp+LMOvPZB2eA4Zt-eTuO-T-PUc16_KAw@mail.gmail.com> Hi M., At skedge.me, we use Snap, and we've been very happy with it. Ryan On Fri, Feb 28, 2014 at 9:23 AM, Miroslav Karpis <miroslav.karpis at gmail.com>wrote: > Hi, please can you help me with following: > > I would like to make a server/client web app, but I'm not sure what > packages/modules would do the best. I did several client/server > applications not in Haskell, where I have used REST (JSON) API as a > communication between client and server. In Haskell I'm not sure what would > be best, but for future use most probably also REST/JSON would be best. > > Server will do some realtime mathematical calculations . After its done it > will send to client results. Client will visualize the results via > WebGL/Threejs. > > I was thinking about Snap for server but for client I'm not really not > sure. > > Any ideas/comments more than appreciated ;-) > > > Cheers, > M. > > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://www.haskell.org/mailman/listinfo/beginners > > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://www.haskell.org/pipermail/beginners/attachments/20140228/eb9dcc48/attachment.html> From vlatko.basic at gmail.com Fri Feb 28 17:17:19 2014 From: vlatko.basic at gmail.com (Vlatko Basic) Date: Fri, 28 Feb 2014 18:17:19 +0100 Subject: [Haskell-beginners] web client/server app - what to choose In-Reply-To: <CF365A8C.6C7C%miroslav.karpis@gmail.com> References: <CF365A8C.6C7C%miroslav.karpis@gmail.com> Message-ID: <5310C49F.6030906@gmail.com> An HTML attachment was scrubbed... URL: <http://www.haskell.org/pipermail/beginners/attachments/20140228/1d52323f/attachment.html>