From mail at nh2.me Sun Jan 1 00:21:46 2017 From: mail at nh2.me (=?UTF-8?Q?Niklas_Hamb=c3=bcchen?=) Date: Sun, 1 Jan 2017 01:21:46 +0100 Subject: [Haskell-cafe] How to call python from haskell In-Reply-To: References: Message-ID: Can you provide an example that makes it crash? On 31/12/16 15:43, jun zhang wrote: > I can call python function once by the package, but when I call > function second time it will occur a "Segmentation fault”. From simon at joyful.com Sun Jan 1 06:44:41 2017 From: simon at joyful.com (Simon Michael) Date: Sat, 31 Dec 2016 22:44:41 -0800 Subject: [Haskell-cafe] ANN: hledger 1.1 Message-ID: Two months since last release, I'm pleased to announce hledger 1.1 ! Thank you to contributors Johannes Gerer, Nikolay Orlyuk, and Shubham Lagwankar, along with all others who contributed in other ways. hledger (http://hledger.org) is a dependable, precise, cross-platform program for tracking money, time, or any other commodity, using double-entry accounting and a simple plain text file format. Inspired by the Ledger project, hledger provides command-line, curses and web interfaces, and aims to be a robust, practical tool for daily use. Notable user-visible changes in this release: - hledger-ui --watch live-updates as files or the current date change, useful eg when reconciling or for a time log dashboard - Ledger-style balance assignments are now supported in journal files Full release notes: http://hledger.org/release-notes#hledger-1.1 To install this release: Get stack, eg from http://haskell-lang.org/get-started $ stack install --resolver=nightly hledger [hledger-ui] [hledger-web] [hledger-api] $ ~/.local/bin/hledger or see http://hledger.org/download for more installation options. Our IRC channel is #hledger on Freenode, and you can find out more at http://hledger.org. I hope you enjoy these tools and that they help you achieve your goals. If you like hledger, your support and participation is appreciated! Fund us on Gratipay or Bountysource, give feedback, report bugs, send pull requests, write about it, etc. Happy 2017! Best, -Simon From gale at sefer.org Sun Jan 1 09:42:48 2017 From: gale at sefer.org (Yitzchak Gale) Date: Sun, 1 Jan 2017 11:42:48 +0200 Subject: [Haskell-cafe] threadDelay delays less time than expected (Windows) In-Reply-To: References: <20161229162741.jjc3fdmjkjwr5k5o@kitenet.net> Message-ID: Bardur Arantsson wrote: > [1] Bascially before JodaTime made ordinary developers aware of just how > complex this Time/Date stuff really is and the importance of clearly > separating the concept of "calendar" time vs. "physical" time. By "ordinary developers", you mean non-Haskell developers? Because the standard Haskell time library used Haskell's rich type system to model the semantics of time correctly long before JodaTime existed. Some people like JodaTime, but I would be very hesitant to use it until I see a proof that it at least comes close to the Haskell time library, and I am skeptical. I have heard that the Smalltalk time library got the semantics of time right long before even the Haskell time library, but I have not seen it myself in detail. -Yitz From spam at scientician.net Sun Jan 1 10:37:57 2017 From: spam at scientician.net (Bardur Arantsson) Date: Sun, 1 Jan 2017 11:37:57 +0100 Subject: [Haskell-cafe] threadDelay delays less time than expected (Windows) In-Reply-To: References: <20161229162741.jjc3fdmjkjwr5k5o@kitenet.net> Message-ID: On 2017-01-01 10:42, Yitzchak Gale wrote: > Bardur Arantsson wrote: >> [1] Bascially before JodaTime made ordinary developers aware of just how >> complex this Time/Date stuff really is and the importance of clearly >> separating the concept of "calendar" time vs. "physical" time. > > By "ordinary developers", you mean non-Haskell developers? Because the > standard Haskell time library used Haskell's rich type system to model > the semantics of time correctly long before JodaTime existed. (Citation needed.) E.g. is there any representation of a duration of physical time in the Haskell library? > Some people like JodaTime, but I would be very hesitant to use it until I > see a proof that it at least comes close to the Haskell time library, > and I am skeptical. What problems do you see -- or are you just assuming? (I mean there *are* a few problems with Joda-time, most of which have been solved in java.time.* in JDK8.) Regards, From auke at tulcod.com Mon Jan 2 14:08:05 2017 From: auke at tulcod.com (Auke Booij) Date: Mon, 2 Jan 2017 15:08:05 +0100 Subject: [Haskell-cafe] How to tie knots in XML-style data structures Message-ID: I am reading an XML file, where some nodes have attributes that refer to other nodes. For example: Here, the point is that the inner refers to a that is not its parent by means of a "blah" attribute. But there might also be a mistake in the XML file, which I would then want to report: the inner might refer to a which does not exist. Using an XML parsing library, this XML file can easily be read into a data type such as the following: data Blah = Blah {blahName :: String, blahType :: Int, blahYadas :: [Yada]} data Yada = Yada {yadaBlah :: String} But for my application, it is useful to have the Yadas refer back to actual Blahs, instead of just their name Strings. So I'd like to parse the XML into the following data structure: data Blah' = Blah' {blah'Name :: String, blah'Type :: Int, blah'Yadas :: [Yada']} data Yada' = Yada' {yada'Blah :: Blah} (the only change is the type of yada'Bla from String to Blah) 1. How can I write a function that takes a Blah, and outputs a Blah', and reports a nice error when there is no with the name specified in the ? Can it be done at all without using partial functions like fromJust (when using Maybe to "report" errors)? 2. Is there a better way to define the types Blah, Yada, Blah' and Yada' (e.g. with less repetition)? After all, all I'm changing is the type of one field, but I end up having to redefine all my types. From simon.jakobi at googlemail.com Mon Jan 2 14:27:27 2017 From: simon.jakobi at googlemail.com (Simon Jakobi) Date: Mon, 2 Jan 2017 15:27:27 +0100 Subject: [Haskell-cafe] How to tie knots in XML-style data structures In-Reply-To: References: Message-ID: Hi Auke, I have admittedly only skimmed your email, but your problem reminds me of a talk by Joachim Breitner. A German transcript of the talk is available here: http://www.joachim-breitner.de/publications/MonadFix_HaL10_2015-12-04.pdf I hope this is useful to you! Simon 2017-01-02 15:08 GMT+01:00 Auke Booij : > I am reading an XML file, where some nodes have attributes that refer > to other nodes. For example: > > > > > > > > Here, the point is that the inner refers to a that is > not its parent by means of a "blah" attribute. But there might also be > a mistake in the XML file, which I would then want to report: the > inner might refer to a which does not exist. > > Using an XML parsing library, this XML file can easily be read into a > data type such as the following: > > data Blah = Blah {blahName :: String, blahType :: Int, blahYadas :: [Yada]} > data Yada = Yada {yadaBlah :: String} > > But for my application, it is useful to have the Yadas refer back to > actual Blahs, instead of just their name Strings. So I'd like to parse > the XML into the following data structure: > > data Blah' = Blah' {blah'Name :: String, blah'Type :: Int, blah'Yadas > :: [Yada']} > data Yada' = Yada' {yada'Blah :: Blah} > > (the only change is the type of yada'Bla from String to Blah) > > 1. How can I write a function that takes a Blah, and outputs a Blah', > and reports a nice error when there is no with the name > specified in the ? Can it be done at all without using partial > functions like fromJust (when using Maybe to "report" errors)? > > 2. Is there a better way to define the types Blah, Yada, Blah' and > Yada' (e.g. with less repetition)? After all, all I'm changing is the > type of one field, but I end up having to redefine all my types. > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. From wiggly at wiggly.org Mon Jan 2 16:05:43 2017 From: wiggly at wiggly.org (Nigel Rantor) Date: Mon, 2 Jan 2017 16:05:43 +0000 Subject: [Haskell-cafe] Code review - wrapping servant client to hide required parameters Message-ID: <3de5ec89-8847-8047-1edc-20568b7ecdcd@wiggly.org> Hello, So, I am still learning and would like someone to cast an eye over some code to see if I am missing something in terms of making it cleaner/more concise. I have begun wrapping the They Work For You API using the Servant Client library. All code is already online for you to grab at; https://github.com/wiggly/twfy-api-client https://hackage.haskell.org/package/twfy-api-client The API is not under my control so I can't change how it works or how it accepts parameters. Every API call requires a Key to be passed as a query string parameter. For a particular session/user this will always be the same, and there is no point in allowing the user to not provide it. Since it is a query parameter Servant forces the type to be within Maybe. For example; type TwfyAPI = "getConstituency" :> QueryParam "key" ApiKey :> QueryParam "name" T.Text :> QueryParam "postcode" T.Text :> Get '[JsonIso8859] Constituency Gives the following function signature; getConstituency :: Maybe ApiKey -- ^ API key -> Maybe T.Text -- ^ Name -> Maybe T.Text -- ^ Post code -> ClientM Constituency To make the API easier to use I have created a Client module that wraps these so that I can hide the passing of the API key for every call, and also allow the user to not have to deal with http client managers or URL parsing if they don't want to. The upshot is that I get a signature that now accepts a data type I have created that contains all the information required to run the client action and return a result, like so (where A.getConstituency is the function above taking a Maybe ApiKey as first argument); getConstituency :: Client -> Maybe T.Text -- ^ Name -> Maybe T.Text -- ^ Post code -> IO (Either ServantError Constituency) getConstituency c = do let key = Just $ clientApiKey c env = clientEnv c in (\name postCode -> (flip runClientM) env (A.getConstituency key name postCode)) So, this wraps up all of the calling of the servant client with an appropriate environment and arguments. I have two questions; 1) What do people think of this style of wrapping the servant client calls? 2) I am now returning a lambda that accepts the remaining arguments to the call, is there any way I can make this cleaner? i.e. is it possible for me to not have to specifically re-write all of the function parameters using something like uncurry or other machinery? I have played with trying to use uncurry but got nowhere fast. Thanks in advance, Nigel From serg.foo at gmail.com Mon Jan 2 23:08:06 2017 From: serg.foo at gmail.com (Sergey Vinokurov) Date: Tue, 3 Jan 2017 01:08:06 +0200 Subject: [Haskell-cafe] How to tie knots in XML-style data structures In-Reply-To: References: Message-ID: Hi Auke, > 2. Is there a better way to define the types Blah, Yada, Blah' and > Yada' (e.g. with less repetition)? After all, all I'm changing is the > type of one field, but I end up having to redefine all my types. I think one way to accomplish your task would be to employ functors as basic building blocks that you can parameterise to express either Blah or Blah' types. The complete code with my attempt is in the attachment. To get more information on Fix type I'd recommend to read on recursion schemes/F-algebras, e.g. https://github.com/willtim/recursion-schemes/raw/master/slides-final.pdf. > 1. How can I write a function that takes a Blah, and outputs a Blah', > and reports a nice error when there is no with the name > specified in the ? Can it be done at all without using partial > functions like fromJust (when using Maybe to "report" errors)? I included my attempt at defining such function in the attached code. The idea is that conversion works in the Either monad that allows to report errors. Monadic context is threaded through whole conversion, so if any error occurs it will appear in the result. However, the conversion function, resolveYadas, is still pure from the outside and you can easily find out whether there were any errors by analyzing the Either result. Sample run: λ> resolveYadas sampleEnv $ BlahF "first" 10 [YadaF "second"] Right (Fix (C (BlahF {blahName = "first", blahType = 10, blahYadas = [YadaF {yadaBlah = Fix (C (BlahF {blahName = "second", blahType = 3, blahYadas = []}))}]}))) λ> resolveYadas sampleEnv $ BlahF "first" 10 [YadaF "third"] Left "No Blah with name \"third\"" Hope this helps! Regards, Sergey -------------- next part -------------- A non-text attachment was scrubbed... Name: Parsing.hs Type: text/x-haskell Size: 1553 bytes Desc: not available URL: From gurudev.devanla at gmail.com Tue Jan 3 01:21:45 2017 From: gurudev.devanla at gmail.com (Guru Devanla) Date: Mon, 2 Jan 2017 17:21:45 -0800 Subject: [Haskell-cafe] Deploying Scotty based web app to Amazon Elastic Bean - One approach Message-ID: Hello All, Recently, I have been working on a web app in Haskell using Scotty as the web framework. I had to go through different sources and compile together an approach I took to deploy a dockerized version of web app to Amazon Elastic Beanstalk. There may be other approaches available and I am happy to hear about it. Meanwhile, I documented my experience with a simple Hello World app and documented the steps I had to take to get my app up and running on Elastic Beanstalk. I look forward to suggestions on a better way to do this. https://github.com/gdevanla/helloscotty/blob/master/README.md Hopefully, this documentation is helpful, and does not proposed an anti-pattern! Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From auke at tulcod.com Tue Jan 3 10:50:59 2017 From: auke at tulcod.com (Auke Booij) Date: Tue, 3 Jan 2017 11:50:59 +0100 Subject: [Haskell-cafe] How to tie knots in XML-style data structures In-Reply-To: References: Message-ID: On 3 January 2017 at 00:08, Sergey Vinokurov wrote: > The complete code with my attempt is in the attachment. Thanks a lot for your work, Sergey. Your suggested solution contains many useful elements. I am still not quite satisfied, however, as your solution does not let me convert the following: sampleEnv :: Map String Blah sampleEnv = M.fromList [ ("first", BlahF "first" 5 [YadaF "second"]) , ("second", BlahF "second" 3 [YadaF "first"]) ] (the point here is that the "tie knots" in the thread subject means that we end up with potentially cyclic values) > information on > Fix type I'd recommend to read on recursion schemes/F-algebras, e.g. > https://github.com/willtim/recursion-schemes/raw/master/slides-final.pdf. In retrospect this indeed sounds like the right solution, thanks for the pointer. From ok at cs.otago.ac.nz Thu Jan 5 02:05:22 2017 From: ok at cs.otago.ac.nz (Richard A. O'Keefe) Date: Thu, 5 Jan 2017 15:05:22 +1300 Subject: [Haskell-cafe] threadDelay delays less time than expected (Windows) In-Reply-To: References: <20161229162741.jjc3fdmjkjwr5k5o@kitenet.net> Message-ID: <17fb254f-c80b-60c2-d07f-500ad16f34b0@cs.otago.ac.nz> On 1/01/17 10:42 PM, Yitzchak Gale wrote: > I have heard that the Smalltalk time library got > the semantics of time right long before even the Haskell time library, > but I have not seen it myself in detail. What do you mean by "the" Smalltalk library? The classic Smalltalk-80 library included Date and Time classes for calendar calculations and a Delay class for suspending. The Date and Time classes were not sophisticated. The ANSI Smalltalk standard includes a unified DateAndTime class and a Duration class. When I tried to implement the standard class I found it impossible, because the standard requires both that DateAndTime be in UTC and that arithmetic work for an unspecified range of timepoints, apparently requiring you to predict leap seconds indefinitely far into the future. Despite requiring UTC, it does not let you specify second=60 when creating a timestamp. You can specify the *offset* of local time from UTC, but implementations are allowed to impose a limit or -12 hours to +12 hours, which excludes part of my country. Worse, you specify an *offset*, not a *zone*, yet an implementation is required to intuit, possibly by some form of clairvoyance, the *zone* name relative to a time. Since offsets do not uniquely determine zones, this is of course impossible. Frankly, it's a mess that looks like it was designed by someone who thought they were expert but weren't. Of course actual Smalltalk implementations don't pay all that much attention to the standard. Possibly "the" Smalltalk library is the Chrono package, in which case ignore my rant about the standard. From palotai.robin at gmail.com Thu Jan 5 14:42:09 2017 From: palotai.robin at gmail.com (Robin Palotai) Date: Thu, 5 Jan 2017 15:42:09 +0100 Subject: [Haskell-cafe] Build base with stack In-Reply-To: <1483150788-sup-3471@sabre> References: <1483150788-sup-3471@sabre> Message-ID: Thanks for the pointer Edward, new-build seems nice. It could build base indeed! Just a note - with the patch, if I had "tests: True" in cabal.project, I got an assertion for pkgStanzasEnabled `Set.isSubsetOf` pkgStanzasAvailable from Distribution/Client/ProjectPlanning.hs. Maybe WAI. Do you think the patch could make it upstream in a form of some flag? --no-require-install=x,y or so. Thank you, Robin 2016-12-31 3:28 GMT+01:00 Edward Z. Yang : > Excerpts from Brandon Allbery's message of 2016-12-30 19:45:46 -0500: > > On Fri, Dec 30, 2016 at 7:37 PM, Robin Palotai > > wrote: > > > > > > Do you know a way to force a rebuild of base with stack? I don't want > to > > > modify it, just want to feed it through a customized ghc pipeline. > > > > > > > base is part of ghc and must be built along with ghc. It cannot be built > > separately from ghc, regardless of tooling, if you want it to actually > work. > > > > (If you want to see some examples of why it is this way, play around with > > RebindableSyntax a bit, paying attention to the ways in which it breaks > if > > you do the wrong thing. You can also get some idea of it from the > behavior > > of type roles. In short: ghc must know the precise identity *at machine > > level*, not just source, of various key types in base. It can only do > this > > by ghc and base being built together so that various types' machine level > > representations can be wired into ghc as they are built.) > > Although it is true that GHC is closely tied to the particularities > of base, you CAN swap out base, as long as the new version of base has > all of the wired in entities that GHC expects to see. (This must be > the case, because we build stage 1 GHC before we build base.) > > To answer OP's question, I don't know how to do it with Stack but I've > rebuilt base with cabal-install new-build with a little patch. First you > have to > modify cabal-install/Distribution/Solver/Modular/Solver.hs, > changing the invocation of P.requireInstalled so that "base" isn't > on the list; this lets cabal-install decide that it can rebuild base. > Then, in your cabal.project, add: > > packages: path/to/base > constraints: base +integer-gmp > > (The integer-gmp flag is manual so you need to make sure you toggle > it yourself.) Then cabal new-build will build it, and other packages > will make use of it. > > Good luck! > > Edward > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jfsihenson at gmail.com Thu Jan 5 18:16:57 2017 From: jfsihenson at gmail.com (Henson) Date: Thu, 5 Jan 2017 16:16:57 -0200 Subject: [Haskell-cafe] Problems with truncate big float values in Haskell In-Reply-To: References: Message-ID: Hi, Firstly I desire one year brilliant for all on group. I have one simple problem but not solved for me for some mistake mine. I have one Rational number (3 + sqrt 5) and I need get the last three digits from integral part of that number. The question is the number is arbitrary and that number always is power of n and n is between 2(Two) and 2000000000(Two billions). I have attempted that on ghci for various values and get same result with different powers: let x = (truncate ((3 + sqrt 5) ^ 2000000)) `mod` 1000 and result is 216. let y = (truncate ((3 + sqrt 5) ^ 20000000)) `mod` 1000 and result is 216. let w = (truncate ((3 + sqrt 5) ^ 200000000)) `mod` 1000 and result is 216. let z = (truncate ((3 + sqrt 5) ^ 2000000000)) `mod` 1000 and result is 216. The result is same for all: 216, and is incorrect because any that expressions have one exclusive value. What I do for complete that task correctly and what I'm mistaken here?! Thank you, Josenildo Silva -------------- next part -------------- An HTML attachment was scrubbed... URL: From trebla at vex.net Thu Jan 5 19:30:57 2017 From: trebla at vex.net (Albert Y. C. Lai) Date: Thu, 5 Jan 2017 14:30:57 -0500 Subject: [Haskell-cafe] Problems with truncate big float values in Haskell In-Reply-To: References: Message-ID: <88e00fe9-076a-fd97-d9e8-3a5a9bd94b78@vex.net> On 2017-01-05 01:16 PM, Henson wrote: > I have one Rational number (3 + sqrt 5) Irrational Number. > let x = (truncate ((3 + sqrt 5) ^ 2000000)) `mod` 1000 and result is 216. You need to firstly read http://floating-point-gui.de/formats/fp/ , and secondly google for "goldberg floating point" and read "what every computer scientist should know about floating-point arithmetic". From targen at gmail.com Thu Jan 5 19:32:30 2017 From: targen at gmail.com (=?UTF-8?Q?Manuel_G=C3=B3mez?=) Date: Thu, 5 Jan 2017 15:32:30 -0400 Subject: [Haskell-cafe] Problems with truncate big float values in Haskell In-Reply-To: References: Message-ID: On Thu, Jan 5, 2017 at 2:18 PM Henson wrote: > I have one Rational number (3 + sqrt 5) and I need get the last three > digits from integral part of that number. But that number is irrational, not rational. The Haskell sqrt function from the Prelude is a method of the Floating class, so it works by default on the Double type, which is a floating point number type with a fixed-size finite representation that approximates real numbers with varying precision over a limited range. > The question is the number is arbitrary and that number always is power > of n and n is between 2(Two) and 2000000000(Two billions). > > I have attempted that on ghci for various values and get same result > with different powers: > > let x = (truncate ((3 + sqrt 5) ^ 2000000)) `mod` 1000 and result is 216. > > let y = (truncate ((3 + sqrt 5) ^ 20000000)) `mod` 1000 and result is 216. > > let w = (truncate ((3 + sqrt 5) ^ 200000000)) `mod` 1000 and result is 216. > > let z = (truncate ((3 + sqrt 5) ^ 2000000000)) `mod` 1000 and result is 216. > > The result is same for all: > > 216, and is incorrect because any that expressions have one exclusive value. The Double type has a special value, Infinity, to represent (roughly) numbers too large to represent otherwise. You can get at it with a zero division: λ> 1/0 :: Double Infinity You can also get it with computations resulting in numbers too large to represent otherwise: λ> 10^308 :: Double 1.0000000000000006e308 λ> 10^309 :: Double Infinity The truncate method of the RealFrac class applied to this Infinity value can convert it to the smallest Integer value that is represented as Infinity when converted to Double: λ> truncate (1/0 :: Double) 179769313486231590772930519078902473361797697894230657273430081157732675805500963132708477322407536021120113879871393357658789768814416622492847430639474124377767893424865485276302219601246094119453082952085005768838150682342462881473913110540827237163350510684586298239947245938479716304835356329624224137216 Indeed, the last three digits of the decimal representation of that number are 216. The immediately preceding Integer is indeed converted to a non-Infinity Double value: λ> fromInteger (pred (truncate (1/0 :: Double))) :: Double 1.7976931348623157e308 I believe this is all expected behavior. This article is very helpful and provides detailed explanations of many related topics: https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html --- While playing around with this, I discovered a curious difference between Float and Double. The smallest Integer that does not yield Infinity on conversion to Float is not anywhere close to the value of the expression «truncate (1/0 :: Float) :: Integer»: λ> let biggestFloat :: Integer; biggestFloat = 340282356779733661637539395458142568447 λ> fromInteger biggestFloat :: Float 3.4028235e38 λ> fromInteger (succ biggestFloat) :: Float Infinity λ> truncate (1/0 :: Float) 340282366920938463463374607431768211456 λ> truncate (1/0 :: Float) - biggestFloat 10141204801825835211973625643009 With Double, «truncate (1/0 :: Double)» is indeed the immediate successor of the largest Integer not converted to Infinity: λ> let biggestDouble :: Integer; biggestDouble = 179769313486231590772930519078902473361797697894230657273430081157732675805500963132708477322407536021120113879871393357658789768814416622492847430639474124377767893424865485276302219601246094119453082952085005768838150682342462881473913110540827237163350510684586298239947245938479716304835356329624224137215 λ> fromInteger biggestDouble :: Double 1.7976931348623157e308 λ> fromInteger (succ biggestDouble) :: Double Infinity λ> truncate (1/0 :: Double) - biggestDouble 1 From auke at tulcod.com Thu Jan 5 19:54:58 2017 From: auke at tulcod.com (Auke Booij) Date: Thu, 5 Jan 2017 20:54:58 +0100 Subject: [Haskell-cafe] How to tie knots in XML-style data structures In-Reply-To: References: Message-ID: I have found a way to do this which is good enough for my purposes - attached. I suspect this could also be modified to use Sergey's Fix trick for code deduplication On 3 January 2017 at 00:08, Sergey Vinokurov wrote: > Hi Auke, > >> 2. Is there a better way to define the types Blah, Yada, Blah' and >> Yada' (e.g. with less repetition)? After all, all I'm changing is the >> type of one field, but I end up having to redefine all my types. > > I think one way to accomplish your task would be to employ functors as basic > building blocks that you can parameterise to express either Blah or Blah' types. > > The complete code with my attempt is in the attachment. To get more > information on > Fix type I'd recommend to read on recursion schemes/F-algebras, e.g. > https://github.com/willtim/recursion-schemes/raw/master/slides-final.pdf. > >> 1. How can I write a function that takes a Blah, and outputs a Blah', >> and reports a nice error when there is no with the name >> specified in the ? Can it be done at all without using partial >> functions like fromJust (when using Maybe to "report" errors)? > > I included my attempt at defining such function in the attached code. > The idea is that > conversion works in the Either monad that allows to report errors. > Monadic context is > threaded through whole conversion, so if any error occurs it will > appear in the result. > However, the conversion function, resolveYadas, is still pure from the > outside and you > can easily find out whether there were any errors by analyzing the > Either result. > > Sample run: > λ> resolveYadas sampleEnv $ BlahF "first" 10 [YadaF "second"] > Right (Fix (C (BlahF {blahName = "first", blahType = 10, blahYadas = > [YadaF {yadaBlah = Fix (C (BlahF {blahName = "second", blahType = 3, > blahYadas = []}))}]}))) > λ> resolveYadas sampleEnv $ BlahF "first" 10 [YadaF "third"] > Left "No Blah with name \"third\"" > > Hope this helps! > > Regards, > Sergey -------------- next part -------------- A non-text attachment was scrubbed... Name: knot-test.hs Type: text/x-haskell Size: 1866 bytes Desc: not available URL: From targen at gmail.com Thu Jan 5 20:18:24 2017 From: targen at gmail.com (=?UTF-8?Q?Manuel_G=C3=B3mez?=) Date: Thu, 5 Jan 2017 16:18:24 -0400 Subject: [Haskell-cafe] Problems with truncate big float values in Haskell In-Reply-To: <9fa537ca-76ac-8998-3e49-ce206ec04ec5@gmail.com> References: <9fa537ca-76ac-8998-3e49-ce206ec04ec5@gmail.com> Message-ID: On Thu, Jan 5, 2017 at 3:51 PM, Henson wrote: > Ok! I have mistake the correct number. Really the number is Irrational and > the problem is the values are Infinity but How I work with BigFloat precision > for Arbitrary numbers in Haskell?! > > I need get the values for arbitrary precision numbers in haskell about > samples posted not is better implementation for that because range of double > implemented in various languages. > > The correct question here about that is How to resolve that problem?! > > I need get three last digits for arbitrary numbers and after search in > various places not found response for that. > > If exists any material about that but not only for explanations about Floats > and Doubles it's a good start for resolve question. I haven't used it, but this package looks like it might help in your situation: http://hackage.haskell.org/package/cyclotomic From litchard.michael at gmail.com Thu Jan 5 22:58:34 2017 From: litchard.michael at gmail.com (Michael Litchard) Date: Thu, 5 Jan 2017 14:58:34 -0800 Subject: [Haskell-cafe] install of ghc-8.0.1 failing Message-ID: I'm trying to install ghc-8.0.1 on ppc64 arch. Below is the truncated config.log, followed by the error that stops make. It was created by The Glorious Glasgow Haskell Compilation System configure 8.0.1, which was generated by GNU Autoconf 2.69. Invocation command line was $ ./configure ## --------- ## ## Platform. ## ## --------- ## hostname = ubuntu-ppc64 uname -m = ppc64 uname -r = 4.4.0-53-powerpc64-smp uname -s = Linux uname -v = #74-Ubuntu SMP Fri Dec 2 16:41:54 UTC 2016 /usr/bin/uname -p = unknown /bin/uname -X = unknown /bin/arch = unknown /usr/bin/arch -k = unknown /usr/convex/getsysinfo = unknown /usr/bin/hostinfo = unknown /bin/machine = unknown /usr/bin/oslevel = unknown /bin/universe = unknown PATH: /home/lambdafan/.cabal/bin PATH: /home/lambdafan/bin PATH: /home/lambdafan/.local/bin PATH: /usr/local/sbin PATH: /usr/local/bin PATH: /usr/sbin PATH: /usr/bin PATH: /sbin PATH: /bin PATH: /usr/games PATH: /usr/local/games PATH: /snap/bin PATH: /home/lambdafan/ghc-8.0.1 configure: exit 0 Now, the error that make stops at E: Unable to locate package gmake lambdafan at ubuntu-ppc64:~/ghc-8.0.1$ make ===--- building phase 0 make --no-print-directory -f ghc.mk phase=0 phase_0_builds make[1]: Nothing to be done for 'phase_0_builds'. ===--- building phase 1 make --no-print-directory -f ghc.mk phase=1 phase_1_builds utils/genapply/ghc.mk:23: utils/genapply/dist/build/.depend.haskell: No such file or directory utils/genapply/ghc.mk:23: utils/genapply/dist/build/.depend.c_asm: No such file or directory make[1]: *** No rule to make target '/home/kgardas/sfw/ghc-7.10.1/ lib/ghc-7.10.1/base_I5BErHzyOm07EBNpKBEeUv/Prelude.hi', needed by 'utils/deriveConstants/dist/build/Main.o'. Stop. Makefile:129: recipe for target 'all' failed make: *** [all] Error 2 I looked in utils/genapply/dist/build/ to find only this ls -la utils/genapply/dist/build/ total 12 drwxr-xr-x 3 lambdafan lambdafan 4096 Jan 4 13:07 . drwxr-xr-x 3 lambdafan lambdafan 4096 Jan 4 13:07 .. drwxr-xr-x 2 lambdafan lambdafan 4096 Jan 4 13:07 autogen advice on how to proceed? -------------- next part -------------- An HTML attachment was scrubbed... URL: From ok at cs.otago.ac.nz Fri Jan 6 01:22:56 2017 From: ok at cs.otago.ac.nz (Richard A. O'Keefe) Date: Fri, 6 Jan 2017 14:22:56 +1300 Subject: [Haskell-cafe] Problems with truncate big float values in Haskell In-Reply-To: References: Message-ID: <119c055e-8d99-dab4-c45a-185efdcfb092@cs.otago.ac.nz> On 6/01/17 7:16 AM, Henson wrote: > I have one Rational number (3 + sqrt 5) and I need get the last three > digits from integral part of that number. 3 + sqrt 5 is not a rational number. Prelude> :type 3 + sqrt 5 3 + sqrt 5 :: Floating a => a So it's not a value of type Rational either. What's more, the value is approximately 5.236067977499789696409173668731276235440618359611525724270897 (thanks, bc(1)) so it doesn't HAVE three digits in its integral part. > > The question is the number is arbitrary and that number always is power > of n and n is between 2(Two) and 2000000000(Two billions). Ah. So what you are really asking about is the integral part of (3 + sqrt 5)^n, which clearly lies somewhere strictly between 5^n and 6^n. If n can be 2x10**9, those are going to be very big numbers. It is useful to understand just what kind of number you have here. You have (a + b * sqrt p) where p is a prime. That is a quadratic surd http://mathworld.wolfram.com/QuadraticSurd.html or quadratic irrational number https://en.wikipedia.org/wiki/Quadratic_irrational_number Numbers (a + b sqrt c)/d where a and b are integers, d is a positive integer, and c is a positive square-free number, are real quadratic irrationals. The set of such numbers with the same value of c forms a field. For fixed c, let a b e f be rationals. (a + b sqrt c) ± (e + f sqrt c) = (a ± e) + (b ± f) sqrt c (a + b sqrt c) × (e + f sqrt c) = (a × e + b × f × c) + (a × f + b × e) sqrt c If a, b, e, f are integers, the sum difference and product also have integer coefficients, which is nice. So you can do data S = S Integer Integer c :: Integer c = 5 unit :: S unit = S 1 0 times :: S -> S -> S times (S a b) (S e f) = S (a*e+b*f*c) (a*f+b*e) power :: S -> Int -> S power x n = case compare n 0 of LT -> error "negative exponent" EQ -> unit GT -> f x (n-1) x where f _ 0 y = y f x n y = g x n g x n y = if even n then g (times x x) (n`quot`2) y else f x (n-1) (times x y) This lets you compute power (S 3 1) n *precisely* for any non-negative Int n. What it doesn't let you do is get the integer part. Using a good enough approximation to sqrt 5, I think the answers corresponding to n = 0..20 are [1,5,27,143,751,935,607,903,991,335,47,943,471,55,447,463,991,95,607,263,152] But there is another approach. A number is a quadratic irrational if and only if it is a regular periodic continued fraction. sqrt 5 = 2 + 1/(4 + 1/(4 + 1/(4 + ...))) so 3 + sqrt 5 = 5 + 1/(4 + 1/(4 + 1/(4 + ...))) -- which you will note *is* a regular periodic continued fraction -- so now all you have to do is find out how to multiply continued fractions. Haskell being lazy makes it a nice choice for handling continued fractions, but since these are *periodic* continued fractions we could do this even in a strict language. A web search will quickly turn up things like http://perl.plover.com/yak/cftalk/INFO/gosper.txt which admittedly isn't easy reading if you don't already understand continued fractions. On the other hand, *another* web search turns up https://hackage.haskell.org/package/continued-fractions https://hackage.haskell.org/package/cf and looking for example at https://hackage.haskell.org/package/continued-fractions-0.9.1.1/docs/Math-ContinuedFraction.html it seems that everything you need is there. From trebla at vex.net Fri Jan 6 01:35:02 2017 From: trebla at vex.net (Albert Y. C. Lai) Date: Thu, 5 Jan 2017 20:35:02 -0500 Subject: [Haskell-cafe] Problems with truncate big float values in Haskell In-Reply-To: <88e00fe9-076a-fd97-d9e8-3a5a9bd94b78@vex.net> References: <88e00fe9-076a-fd97-d9e8-3a5a9bd94b78@vex.net> Message-ID: <3e7dcb8c-f248-180b-b0fd-3fb437daa651@vex.net> On 2017-01-05 02:30 PM, Albert Y. C. Lai wrote: > On 2017-01-05 01:16 PM, Henson wrote: >> I have one Rational number (3 + sqrt 5) > > Irrational Number. > >> let x = (truncate ((3 + sqrt 5) ^ 2000000)) `mod` 1000 and result is 216. > > You need to firstly read http://floating-point-gui.de/formats/fp/ , and > secondly google for "goldberg floating point" and read "what every > computer scientist should know about floating-point arithmetic". And the conclusion at that point should be: A direct Double approach will not work. ("direct" means you don't do your own math first.) You will need to be either indirect (do your own math first) or forget Double. In fact I would do both indirect and forget Double. Let r = 3 + sqrt 5, s = 3 - sqrt 5. s is the evil twin of r. Define (as in math, not code) h n = r^n + s^n for natural n. (a) Prove: r and s are the roots of x^2 - 6x + 4 = 0. And so r^2 = 6r - 4, s^2 = 6s - 4. (How did I think up that equation? From (x - r)*(x - s).) (b) Prove: h satisfies the following recurrence h 0 = 2 h 1 = 6 h n = 6 * h (n-1) - 4 * h (n-2) for n>=2 (Sketch: Part (a) will be useful.) (c) Prove: floor(r^n) = h n - 1. (Sketch: 0 < s^n < 1, and the recurrence tells you that h n is a natural number.) (d) Give and/or code up an algorithm to compute the last three decimal digits of floor(r^n); it should use only O(n) time, O(lg n) space, and integer/natural arithmetic. In fact, the lg n space is only for counting from 0 to n, the algorithm is constant-space otherwise (for mod-1000 arithmetic). (Actually you could get it down to O(lg n) time too, but that's for another day.) (e) Do a similar thing to floor((the gold ratio)^n). How I came up with this idea: I recalled that the fibonacci numbers are related to (the golden ratio)^n (for example CLRS has a few lines on this). So I just had to adapt it to 3 + sqrt 5. * * * For a decade, I haven't had a good excuse to use my smug saying. So this is a good chance to say: The language of computing is not C, Node.js, or Haskell. The language of computing is mathematics. From ezyang at mit.edu Fri Jan 6 06:56:05 2017 From: ezyang at mit.edu (Edward Z. Yang) Date: Fri, 06 Jan 2017 01:56:05 -0500 Subject: [Haskell-cafe] Build base with stack In-Reply-To: References: <1483150788-sup-3471@sabre> Message-ID: <1483685704-sup-1379@sabre> Excerpts from Robin Palotai's message of 2017-01-05 15:42:09 +0100: > Thanks for the pointer Edward, new-build seems nice. It could build base > indeed! > > Just a note - with the patch, if I had "tests: True" in cabal.project, I > got an assertion for > pkgStanzasEnabled `Set.isSubsetOf` pkgStanzasAvailable > from Distribution/Client/ProjectPlanning.hs. Maybe WAI. OK, worth reporting as a bug on Cabal tracker if you have time. > Do you think the patch could make it upstream in a form of some flag? > --no-require-install=x,y or so. Yes, I think this would make sense! Edward > Thank you, > Robin > > 2016-12-31 3:28 GMT+01:00 Edward Z. Yang : > > > Excerpts from Brandon Allbery's message of 2016-12-30 19:45:46 -0500: > > > On Fri, Dec 30, 2016 at 7:37 PM, Robin Palotai > > > wrote: > > > > > > > > Do you know a way to force a rebuild of base with stack? I don't want > > to > > > > modify it, just want to feed it through a customized ghc pipeline. > > > > > > > > > > base is part of ghc and must be built along with ghc. It cannot be built > > > separately from ghc, regardless of tooling, if you want it to actually > > work. > > > > > > (If you want to see some examples of why it is this way, play around with > > > RebindableSyntax a bit, paying attention to the ways in which it breaks > > if > > > you do the wrong thing. You can also get some idea of it from the > > behavior > > > of type roles. In short: ghc must know the precise identity *at machine > > > level*, not just source, of various key types in base. It can only do > > this > > > by ghc and base being built together so that various types' machine level > > > representations can be wired into ghc as they are built.) > > > > Although it is true that GHC is closely tied to the particularities > > of base, you CAN swap out base, as long as the new version of base has > > all of the wired in entities that GHC expects to see. (This must be > > the case, because we build stage 1 GHC before we build base.) > > > > To answer OP's question, I don't know how to do it with Stack but I've > > rebuilt base with cabal-install new-build with a little patch. First you > > have to > > modify cabal-install/Distribution/Solver/Modular/Solver.hs, > > changing the invocation of P.requireInstalled so that "base" isn't > > on the list; this lets cabal-install decide that it can rebuild base. > > Then, in your cabal.project, add: > > > > packages: path/to/base > > constraints: base +integer-gmp > > > > (The integer-gmp flag is manual so you need to make sure you toggle > > it yourself.) Then cabal new-build will build it, and other packages > > will make use of it. > > > > Good luck! > > > > Edward > > From grayjay at wordroute.com Fri Jan 6 07:56:56 2017 From: grayjay at wordroute.com (Kristen Kozak) Date: Fri, 6 Jan 2017 02:56:56 -0500 Subject: [Haskell-cafe] Build base with stack In-Reply-To: <1483685704-sup-1379@sabre> References: <1483150788-sup-3471@sabre> <1483685704-sup-1379@sabre> Message-ID: <1517f54026c6a96b978f0222709d7d72.squirrel@reseller4.hrwebservices.net> On Fri, January 6, 2017 1:56 am, Edward Z. Yang wrote: > Excerpts from Robin Palotai's message of 2017-01-05 15:42:09 +0100: > >> Thanks for the pointer Edward, new-build seems nice. It could build >> base indeed! >> >> Just a note - with the patch, if I had "tests: True" in cabal.project, >> I >> got an assertion for pkgStanzasEnabled `Set.isSubsetOf` >> pkgStanzasAvailable from Distribution/Client/ProjectPlanning.hs. Maybe >> WAI. >> > > OK, worth reporting as a bug on Cabal tracker if you have time. > > >> Do you think the patch could make it upstream in a form of some flag? >> --no-require-install=x,y or so. >> > > Yes, I think this would make sense! There is a related issue at https://github.com/haskell/cabal/issues/3987. GHCJS also needs a flag for building the base libraries. -Kristen From mle+hs at mega-nerd.com Sat Jan 7 07:01:16 2017 From: mle+hs at mega-nerd.com (Erik de Castro Lopo) Date: Sat, 7 Jan 2017 18:01:16 +1100 Subject: [Haskell-cafe] install of ghc-8.0.1 failing In-Reply-To: References: Message-ID: <20170107180116.1f7e17e2afe9c97d746415e8@mega-nerd.com> Michael Litchard wrote: > make[1]: *** No rule to make target '/home/kgardas/sfw/ghc-7.10.1/ > lib/ghc-7.10.1/base_I5BErHzyOm07EBNpKBEeUv/Prelude.hi', needed by > 'utils/deriveConstants/dist/build/Main.o'. Stop. Looks like there's a path thats baked into the bindist that should not be there. Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/ From cdsmith at gmail.com Sun Jan 8 06:02:11 2017 From: cdsmith at gmail.com (Chris Smith) Date: Sat, 7 Jan 2017 22:02:11 -0800 Subject: [Haskell-cafe] Call for interest: Haskell in middle school math education Message-ID: Hello fellow Haskellers! Are you interested in getting Haskell into middle school (ages 11-14) math or other classes? I'd love to hear from you! Many of you are probably already aware that I've spent the last several years teaching Haskell to children and teens via my CodeWorld project ( http://code.world and http://github.com/google/codeworld). Well, 2017 is my year to make a bigger success of the whole effort. So, let's get Haskell into K-12 schools as a part of mathematics education. By incorporating a programming language like Haskell that's faithful to modeling using true functions, variables, and equations, we can make mathematical modeling and algebraic reasoning tangible and creative in a way it's never been before. There's a lot that's already been done, but the task is still daunting. With some help from some coworkers of mine at Google, and in conjunction with the New York Haskell User Group, I've put together a small budget of around $60K in USD, to start this ball rolling a bit faster with some paid help. Some possible goals include: - Produce quality instructional materials to help teachers around the world incorporate Haskell into their classes and after-school activities. - Produce videos and online resources to support students learning on their own. - Build software features make the CodeWorld tools more helpful, easier to use, easier for students share their work more broadly, and more supportive when students need help. - Make what we already have available to more students, and educate more teachers. - Spread the word and look for more support so we can keep up the effort after the initial investment is finished. Everything produced as part of the project will be distributed under either the Apache 2.0 open source license, or the latest Creative Commons attribution-only license, so that it's freely available for any educational institution (or anyone else) to use, modify, redistribute, etc. So here's where you can step in: - Join the codeworld-discuss@ mailing list (https://groups.google.com/ forum/#!forum/codeworld-discuss) - Introduce yourself, and tell us a bit about what vision you have, and what role you might want to play. This could be a spectator, teacher at a school near you, volunteer contributions on the side, or even a leadership role with a salary attached! Cognizant that solo decisions can be poor ones, I hope to follow some initial sharing of ideas with gathering a small handful of like-minded individuals - I know you're out there - to make decisions about the best way to manage the effort, and go from there. Some background reading: - Blog post on the defining decisions of my effort so far - The web site and its source code - A huge bag of partially incomplete stuff already produced - A similarly motivated project using Racket that gets a lot right I look forward to hearing from you. -------------- next part -------------- An HTML attachment was scrubbed... URL: From code at funwithsoftware.org Tue Jan 10 04:10:59 2017 From: code at funwithsoftware.org (Patrick Pelletier) Date: Mon, 9 Jan 2017 20:10:59 -0800 Subject: [Haskell-cafe] [ANN] powermate-1.0 Message-ID: As the new maintainer of the "powermate" package, I'm pleased to announce the first new release in nearly 9 years! This library is for interfacing the Griffin PowerMate USB (a big silver knob you can turn and click) with Haskell on Linux. You can read events from the PowerMate, and control the brightness, pulse speed, and pulse waveform of the built-in blue LED. https://hackage.haskell.org/package/powermate-1.0 https://github.com/ppelleti/powermate Version 1.0 is a major release with some breaking changes. The complete list of changes since version 0.1 is: * Now works with GHC 7.2.2 - 8.0.1. * Added Eq, Ord, Show, and Read instances for Event and Status. * Added example programs powermate-print and powermate-pulse. * Added documentation. * An open PowerMate is now represented by the opaque type 'PowerMate' instead of 'Handle'. A new function 'closeDevice' exists to close the opaque 'PowerMate' type. * Fixed a bug where the PowerMate would get confused and start dropping button presses if you set the LED. * Removed extraneous printing to stdout. * Removed getUSBName and readEventWithSkip; I didn't see the utility in these functions. * readEvent no longer returns a Maybe. There was no meaning to 'Nothing' and it just had to be ignored. * Removed the MPD module. It wasn't directly related to the PowerMate functionality, and the "libmpd" package seems to be an alternative which is more complete and better maintained. --Patrick From code at funwithsoftware.org Tue Jan 10 21:41:39 2017 From: code at funwithsoftware.org (Patrick Pelletier) Date: Tue, 10 Jan 2017 13:41:39 -0800 Subject: [Haskell-cafe] [ANN] wiringPi-0.1.0.0 Message-ID: <0397faf2-3f7d-9c98-9bf1-f31a9330c1e8@funwithsoftware.org> https://hackage.haskell.org/package/wiringPi-0.1.0.0 https://github.com/ppelleti/hs-wiringPi This is a Haskell binding to the wiringPi library, which allows you to interface with the GPIO pins on the Raspberry Pi. Unlike some other solutions for using the Raspberry Pi's GPIO pins, wiringPi provides access to more advanced features, such as enabling the internal pull-up or pull-down resistors. To use this library, you must either run as root, or set the WIRINGPI_GPIOMEM environment variable. (Set it to anything; the value does not matter.) However, PWM will not work if WIRINGPI_GPIOMEM is set. This library will only build on the Raspberry Pi. Before building this library, you must install the "wiringPi" C library on your Raspberry Pi, like this: sudo apt-get install wiringpi Tested on a Raspberry Pi Model B, with Raspbian Jessie Lite, using the system-provided Haskell compiler. (GHC 7.6.3.) This Haskell binding is licensed under the 3-clause BSD license, and the examples in the examples directory are in the public domain. However, be aware that the wiringPi C library itself is licensed under the LGPLv3+. --Patrick From ben at well-typed.com Wed Jan 11 18:40:45 2017 From: ben at well-typed.com (Ben Gamari) Date: Wed, 11 Jan 2017 13:40:45 -0500 Subject: [Haskell-cafe] [ANNOUNCE] Glasgow Haskell Compiler 8.0.2 is available! Message-ID: <87wpe1ignm.fsf@ben-laptop.smart-cactus.org> =============================================== The Glasgow Haskell Compiler -- version 8.0.2 =============================================== The GHC team is happy to at last announce the 8.0.2 release of the Glasgow Haskell Compiler. Source and binary distributions are available at http://downloads.haskell.org/~ghc/8.0.2/ This is the second release of the 8.0 series and fixes nearly two-hundred bugs. These include, * Interface file build determinism (#4012). * Compatibility with macOS Sierra and GCC compilers which compile position-independent executables by default * Compatibility with systems which use the gold linker * Runtime linker fixes on Windows (see #12797) * A compiler bug which resulted in undefined reference errors while compiling some packages (see #12076) * A number of memory consistency bugs in the runtime system * A number of efficiency issues in the threaded runtime which manifest on larger core counts and large numbers of bound threads. * A typechecker bug which caused some programs using -XDefaultSignatures to be incorrectly accepted. * More than two-hundred other bugs. See Trac [1] for a complete listing. * #12757, which lead to broken runtime behavior and even crashes in the presence of primitive strings. * #12844, a type inference issue affecting partial type signatures. * A bump of the `directory` library, fixing buggy path canonicalization behavior (#12894). Unfortunately this required a major version bump in `directory` and minor bumps in several other libraries. * #12912, where use of the `select` system call would lead to runtime system failures with large numbers of open file handles. * #10635, wherein -Wredundant-constraints was included in the -Wall warning set A more detailed list of the changes included in this release can be found in the release notes, https://downloads.haskell.org/~ghc/8.0.2/docs/html/users_guide/8.0.2-notes.html Please note that this release breaks with our usual tendency to avoid major version bumps of core libraries in minor GHC releases by including an upgrade of the `directory` library to 1.3.0.0. Also note that, due to a rather serious bug (#13100) affecting Windows noticed late in the release cycle, the Windows binary distributions were produced using a slightly patched [2] source tree. Users compiling from source for Windows should be certain to include this patch in their build. This release is the result of six months of effort by the GHC development community. We'd like to thank everyone who has contributed code, bug reports, and feedback to this release. It's only due to their efforts that GHC remains a vibrant and exciting project. [1] https://ghc.haskell.org/trac/ghc/query?status=closed&milestone=8.0.2&col=id&col=summary&col=status&col=type&col=priority&col=milestone&col=component&order=priority [2] http://downloads.haskell.org/~ghc/8.0.2/0001-SysTools-Revert-linker-flags-change.patch How to get it ~~~~~~~~~~~~~ Both the source tarball and binary distributions for a wide variety of platforms are available at, http://www.haskell.org/ghc/ Background ~~~~~~~~~~ Haskell is a standardized lazy functional programming language. The Glasgow Haskell Compiler (GHC) is a state-of-the-art programming suite for Haskell. Included is an optimising compiler generating efficient code for a variety of platforms, together with an interactive system for convenient, quick development. The distribution includes space and time profiling facilities, a large collection of libraries, and support for various language extensions, including concurrency, exceptions, and foreign language interfaces. GHC is distributed under a BSD-style open source license. Supported Platforms ~~~~~~~~~~~~~~~~~~~ The list of platforms we support, and the people responsible for them, can be found on the GHC wiki http://ghc.haskell.org/trac/ghc/wiki/Platforms Ports to other platforms are possible with varying degrees of difficulty. The Building Guide describes how to go about porting to a new platform: http://ghc.haskell.org/trac/ghc/wiki/Building Developers ~~~~~~~~~~ We welcome new contributors. Instructions on getting started with hacking on GHC are available from GHC's developer site, http://ghc.haskell.org/trac/ghc/ Community Resources ~~~~~~~~~~~~~~~~~~~ There are mailing lists for GHC users, develpoers, and monitoring bug tracker activity; to subscribe, use the web interfaces at http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets There are several other Haskell and GHC-related mailing lists on www.haskell.org; for the full list, see https://mail.haskell.org/cgi-bin/mailman/listinfo Some GHC developers hang out on the #ghc and #haskell of the Freenode IRC network, too: http://www.haskell.org/haskellwiki/IRC_channel Please report bugs using our bug tracking system. Instructions on reporting bugs can be found here: http://www.haskell.org/ghc/reportabug -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 487 bytes Desc: not available URL: From litchard.michael at gmail.com Wed Jan 11 22:55:04 2017 From: litchard.michael at gmail.com (Michael Litchard) Date: Wed, 11 Jan 2017 14:55:04 -0800 Subject: [Haskell-cafe] brainstorm help Message-ID: Hi There. I'm looking for ideas to flesh out a writing project I'm beginning. What I am looking for is a set of five games in increasing complexity that would allow for a wide discussion of Haskell. I originally began this project by centering the writing around one large game, but this idea has proven to be brittle. The set of five should include a discussion of: (1) Types (2) folds, maps, filters (3) monoids, functors, applicatives, and monads Thanks for what ever storms your brains bring forth. :) -------------- next part -------------- An HTML attachment was scrubbed... URL: From kc1956 at gmail.com Wed Jan 11 23:00:31 2017 From: kc1956 at gmail.com (KC) Date: Wed, 11 Jan 2017 15:00:31 -0800 Subject: [Haskell-cafe] brainstorm help In-Reply-To: References: Message-ID: Have you checked out making your first Haskell game? On Wed, Jan 11, 2017 at 2:55 PM, Michael Litchard < litchard.michael at gmail.com> wrote: > Hi There. > > I'm looking for ideas to flesh out a writing project I'm beginning. What I > am looking for is a set of five games in increasing complexity that would > allow for a wide discussion of Haskell. I originally began this project by > centering the writing around one large game, but this idea has proven to be > brittle. The set of five should include a discussion of: > > (1) Types > (2) folds, maps, filters > (3) monoids, functors, applicatives, and monads > > Thanks for what ever storms your brains bring forth. :) > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. > -- -- Sent from an expensive device which will be obsolete in a few months! :D Casey -------------- next part -------------- An HTML attachment was scrubbed... URL: From spam at scientician.net Wed Jan 11 23:13:55 2017 From: spam at scientician.net (Bardur Arantsson) Date: Thu, 12 Jan 2017 00:13:55 +0100 Subject: [Haskell-cafe] brainstorm help In-Reply-To: References: Message-ID: On 2017-01-11 23:55, Michael Litchard wrote: > Hi There. > > I'm looking for ideas to flesh out a writing project I'm beginning. Writing project? I'm guessing it's not "creative writing" per se. Is it a series of blog posts, or...? > What I am looking for is a set of five games in increasing complexity that > would allow for a wide discussion of Haskell. I originally began this > project by centering the writing around one large game, but this idea > has proven to be brittle. The set of five should include a discussion of: > > (1) Types > (2) folds, maps, filters > (3) monoids, functors, applicatives, and monads > > Thanks for what ever storms your brains bring forth. :) > At the highest level complexity I'd suggest reading[1] and trying something like Azad, though it obviously doesn't necessarily have easily-codified rules, per se. [1] https://en.wikipedia.org/wiki/The_Player_of_Games From dedgrant at gmail.com Thu Jan 12 00:30:27 2017 From: dedgrant at gmail.com (Darren Grant) Date: Wed, 11 Jan 2017 16:30:27 -0800 Subject: [Haskell-cafe] [ANNOUNCE] Glasgow Haskell Compiler 8.0.2 is available! In-Reply-To: <87wpe1ignm.fsf@ben-laptop.smart-cactus.org> References: <87wpe1ignm.fsf@ben-laptop.smart-cactus.org> Message-ID: Wow. Congrats on the release all and thank you for the fixes! Cheers, Darren On Jan 11, 2017 10:42 AM, "Ben Gamari" wrote: =============================================== The Glasgow Haskell Compiler -- version 8.0.2 =============================================== The GHC team is happy to at last announce the 8.0.2 release of the Glasgow Haskell Compiler. Source and binary distributions are available at http://downloads.haskell.org/~ghc/8.0.2/ This is the second release of the 8.0 series and fixes nearly two-hundred bugs. These include, * Interface file build determinism (#4012). * Compatibility with macOS Sierra and GCC compilers which compile position-independent executables by default * Compatibility with systems which use the gold linker * Runtime linker fixes on Windows (see #12797) * A compiler bug which resulted in undefined reference errors while compiling some packages (see #12076) * A number of memory consistency bugs in the runtime system * A number of efficiency issues in the threaded runtime which manifest on larger core counts and large numbers of bound threads. * A typechecker bug which caused some programs using -XDefaultSignatures to be incorrectly accepted. * More than two-hundred other bugs. See Trac [1] for a complete listing. * #12757, which lead to broken runtime behavior and even crashes in the presence of primitive strings. * #12844, a type inference issue affecting partial type signatures. * A bump of the `directory` library, fixing buggy path canonicalization behavior (#12894). Unfortunately this required a major version bump in `directory` and minor bumps in several other libraries. * #12912, where use of the `select` system call would lead to runtime system failures with large numbers of open file handles. * #10635, wherein -Wredundant-constraints was included in the -Wall warning set A more detailed list of the changes included in this release can be found in the release notes, https://downloads.haskell.org/~ghc/8.0.2/docs/html/users_gui de/8.0.2-notes.html Please note that this release breaks with our usual tendency to avoid major version bumps of core libraries in minor GHC releases by including an upgrade of the `directory` library to 1.3.0.0. Also note that, due to a rather serious bug (#13100) affecting Windows noticed late in the release cycle, the Windows binary distributions were produced using a slightly patched [2] source tree. Users compiling from source for Windows should be certain to include this patch in their build. This release is the result of six months of effort by the GHC development community. We'd like to thank everyone who has contributed code, bug reports, and feedback to this release. It's only due to their efforts that GHC remains a vibrant and exciting project. [1] https://ghc.haskell.org/trac/ghc/query?status=closed&milesto ne=8.0.2&col=id&col=summary&col=status&col=type&col= priority&col=milestone&col=component&order=priority [2] http://downloads.haskell.org/~ghc/8.0.2/0001-SysTools-Revert -linker-flags-change.patch How to get it ~~~~~~~~~~~~~ Both the source tarball and binary distributions for a wide variety of platforms are available at, http://www.haskell.org/ghc/ Background ~~~~~~~~~~ Haskell is a standardized lazy functional programming language. The Glasgow Haskell Compiler (GHC) is a state-of-the-art programming suite for Haskell. Included is an optimising compiler generating efficient code for a variety of platforms, together with an interactive system for convenient, quick development. The distribution includes space and time profiling facilities, a large collection of libraries, and support for various language extensions, including concurrency, exceptions, and foreign language interfaces. GHC is distributed under a BSD-style open source license. Supported Platforms ~~~~~~~~~~~~~~~~~~~ The list of platforms we support, and the people responsible for them, can be found on the GHC wiki http://ghc.haskell.org/trac/ghc/wiki/Platforms Ports to other platforms are possible with varying degrees of difficulty. The Building Guide describes how to go about porting to a new platform: http://ghc.haskell.org/trac/ghc/wiki/Building Developers ~~~~~~~~~~ We welcome new contributors. Instructions on getting started with hacking on GHC are available from GHC's developer site, http://ghc.haskell.org/trac/ghc/ Community Resources ~~~~~~~~~~~~~~~~~~~ There are mailing lists for GHC users, develpoers, and monitoring bug tracker activity; to subscribe, use the web interfaces at http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-tickets There are several other Haskell and GHC-related mailing lists on www.haskell.org; for the full list, see https://mail.haskell.org/cgi-bin/mailman/listinfo Some GHC developers hang out on the #ghc and #haskell of the Freenode IRC network, too: http://www.haskell.org/haskellwiki/IRC_channel Please report bugs using our bug tracking system. Instructions on reporting bugs can be found here: http://www.haskell.org/ghc/reportabug _______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post. -------------- next part -------------- An HTML attachment was scrubbed... URL: From ben at well-typed.com Thu Jan 12 06:04:43 2017 From: ben at well-typed.com (Ben Gamari) Date: Thu, 12 Jan 2017 01:04:43 -0500 Subject: [Haskell-cafe] [ANNOUNCE] Glasgow Haskell Compiler 8.0.2 is available! In-Reply-To: <87wpe1ignm.fsf@ben-laptop.smart-cactus.org> References: <87wpe1ignm.fsf@ben-laptop.smart-cactus.org> Message-ID: <87ziiwstj8.fsf@ben-laptop.smart-cactus.org> Ben Gamari writes: > =============================================== > The Glasgow Haskell Compiler -- version 8.0.2 > =============================================== > > The GHC team is happy to at last announce the 8.0.2 release of the > Glasgow Haskell Compiler. Source and binary distributions are available > at > I'm sorry to say that the Windows tarballs were built without profiling libraries and will need to be reissued. To prevent confusion I have removed the bad tarballs until I have a chance to rebuild them. Cheers, - Ben -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 487 bytes Desc: not available URL: From sivanov at colimite.fr Thu Jan 12 09:38:15 2017 From: sivanov at colimite.fr (Sergiu Ivanov) Date: Thu, 12 Jan 2017 10:38:15 +0100 Subject: [Haskell-cafe] brainstorm help In-Reply-To: References: Message-ID: <877f6039fc.fsf@colimite.fr> Hey Michael, Thus quoth Michael Litchard at 22:55 on Wed, Jan 11 2017: > > What I am looking for is a set of five games in increasing complexity > that would allow for a wide discussion of Haskell. Shamelessly stolen from the page of Eta (Haskell on JVM): https://github.com/rahulmutt/eta-2048 I'm not sure how well this fits into what you want, but, supposedly, a lot of fancy details can be left out, including those actually requiring Java (I've no idea what exactly I'm talking about here :D) -- Sergiu -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 487 bytes Desc: not available URL: From jo at durchholz.org Thu Jan 12 14:22:46 2017 From: jo at durchholz.org (Joachim Durchholz) Date: Thu, 12 Jan 2017 15:22:46 +0100 Subject: [Haskell-cafe] brainstorm help In-Reply-To: <877f6039fc.fsf@colimite.fr> References: <877f6039fc.fsf@colimite.fr> Message-ID: Am 12.01.2017 um 10:38 schrieb Sergiu Ivanov: > > Shamelessly stolen from the page of Eta (Haskell on JVM): > > https://github.com/rahulmutt/eta-2048 > > I'm not sure how well this fits into what you want, but, supposedly, a > lot of fancy details can be left out, including those actually requiring > Java (I've no idea what exactly I'm talking about here :D) JavaFX is Oracle's latest GUI library. It allows styling controls via CSS (styling was very difficult to do well with Swing, its predecessor). JavaFX is available as part of the standard library since Java 8. So yes you'll need to have Java installed to run that thing. You don't have to know much about Java itself, deployment may be complicated though (depends on what the Eta guys did in that area). From sivanov at colimite.fr Thu Jan 12 14:33:49 2017 From: sivanov at colimite.fr (Sergiu Ivanov) Date: Thu, 12 Jan 2017 15:33:49 +0100 Subject: [Haskell-cafe] brainstorm help In-Reply-To: References: <877f6039fc.fsf@colimite.fr> Message-ID: <8737go2vqq.fsf@colimite.fr> Thus quoth Joachim Durchholz at 14:22 on Thu, Jan 12 2017: > Am 12.01.2017 um 10:38 schrieb Sergiu Ivanov: >> >> Shamelessly stolen from the page of Eta (Haskell on JVM): >> >> https://github.com/rahulmutt/eta-2048 >> >> I'm not sure how well this fits into what you want, but, supposedly, a >> lot of fancy details can be left out, including those actually requiring >> Java (I've no idea what exactly I'm talking about here :D) > > JavaFX is Oracle's latest GUI library. It allows styling controls via > CSS (styling was very difficult to do well with Swing, its predecessor). > JavaFX is available as part of the standard library since Java 8. I was actually thinking about completely rewriting the GUI part in something less Oracle-specific, but, given my zero experience in GUIs for Haskell, I only have a very basic idea about the effort it may take. I was also vaguely considering a console interface, but I'm not sure how well it may work out for 2048. -- Sergiu -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 487 bytes Desc: not available URL: From lanablack at amok.cc Thu Jan 12 16:16:56 2017 From: lanablack at amok.cc (Lana Black) Date: Thu, 12 Jan 2017 16:16:56 +0000 Subject: [Haskell-cafe] module is a package module error Message-ID: <20170112161656.GA19533@rhea> Hi, I'm trying to use hint [1] to compile in runtime externally supplied haskell code. The compiled code must have certain modules imported. The problem is that I'm getting this error when loading modules >WontCompile [GhcError {errMsg = ": error: module >\8216Internal\8217 is a package module"}] I'm not really sure what to do with this. One way to fix this is to move Internal to a separate package so that hint could load it through cabal, but that's something I'd like to avoid. Is there any way I could make hint use the same modules from the package it's being called from? The code is located at [2]. [1]: http://hackage.haskell.org/package/hint [2]: https://github.com/greydot/hint-test/ From kc1956 at gmail.com Thu Jan 12 16:22:45 2017 From: kc1956 at gmail.com (KC) Date: Thu, 12 Jan 2017 08:22:45 -0800 Subject: [Haskell-cafe] brainstorm help In-Reply-To: References: Message-ID: Your first Haskell Game http://www.hgamer3d.org/FirstGame.html Note: the games are coded in an 'imperative' fashion but I'm thinking of transforming them to a more functional approach 😃 Might want help -- -- Sent from an expensive device which will be obsolete in a few months! :D Casey On Jan 11, 2017 2:55 PM, "Michael Litchard" wrote: > Hi There. > > I'm looking for ideas to flesh out a writing project I'm beginning. What I > am looking for is a set of five games in increasing complexity that would > allow for a wide discussion of Haskell. I originally began this project by > centering the writing around one large game, but this idea has proven to be > brittle. The set of five should include a discussion of: > > (1) Types > (2) folds, maps, filters > (3) monoids, functors, applicatives, and monads > > Thanks for what ever storms your brains bring forth. :) > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rahulmutt at gmail.com Thu Jan 12 16:54:27 2017 From: rahulmutt at gmail.com (Rahul Muttineni) Date: Thu, 12 Jan 2017 22:24:27 +0530 Subject: [Haskell-cafe] brainstorm help In-Reply-To: References: <877f6039fc.fsf@colimite.fr> Message-ID: Hi Joachim, You can compile the project as a standalone .jar file that can be run via `java -jar`. 'epm' can also generate a script that runs the 'java' command with the full classpath set for you if you don't want to wait for the uberjar generation which is currently a bit slow. Hope that helps, Rahul On Thu, Jan 12, 2017 at 7:52 PM, Joachim Durchholz wrote: > Am 12.01.2017 um 10:38 schrieb Sergiu Ivanov: > >> >> Shamelessly stolen from the page of Eta (Haskell on JVM): >> >> https://github.com/rahulmutt/eta-2048 >> >> I'm not sure how well this fits into what you want, but, supposedly, a >> lot of fancy details can be left out, including those actually requiring >> Java (I've no idea what exactly I'm talking about here :D) >> > > JavaFX is Oracle's latest GUI library. It allows styling controls via CSS > (styling was very difficult to do well with Swing, its predecessor). > JavaFX is available as part of the standard library since Java 8. > > So yes you'll need to have Java installed to run that thing. > You don't have to know much about Java itself, deployment may be > complicated though (depends on what the Eta guys did in that area). > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. > -- Rahul Muttineni -------------- next part -------------- An HTML attachment was scrubbed... URL: From rahulmutt at gmail.com Thu Jan 12 17:03:01 2017 From: rahulmutt at gmail.com (Rahul Muttineni) Date: Thu, 12 Jan 2017 22:33:01 +0530 Subject: [Haskell-cafe] brainstorm help In-Reply-To: <8737go2vqq.fsf@colimite.fr> References: <877f6039fc.fsf@colimite.fr> <8737go2vqq.fsf@colimite.fr> Message-ID: Hi Sergiu, Michael didn't mention arrows on his list and eta-2048 is heavy on them since Yampa is arrow-based, so it may not be suited for this project. You can find a console interface for 2048 here and it looks a lot simpler with very light dependencies: https://github.com/tfausak/hs2048 Hope that helps! Rahul On Thu, Jan 12, 2017 at 8:03 PM, Sergiu Ivanov wrote: > > Thus quoth Joachim Durchholz at 14:22 on Thu, Jan 12 2017: > > Am 12.01.2017 um 10:38 schrieb Sergiu Ivanov: > >> > >> Shamelessly stolen from the page of Eta (Haskell on JVM): > >> > >> https://github.com/rahulmutt/eta-2048 > >> > >> I'm not sure how well this fits into what you want, but, supposedly, a > >> lot of fancy details can be left out, including those actually requiring > >> Java (I've no idea what exactly I'm talking about here :D) > > > > JavaFX is Oracle's latest GUI library. It allows styling controls via > > CSS (styling was very difficult to do well with Swing, its predecessor). > > JavaFX is available as part of the standard library since Java 8. > > I was actually thinking about completely rewriting the GUI part in > something less Oracle-specific, but, given my zero experience in GUIs > for Haskell, I only have a very basic idea about the effort it may take. > > I was also vaguely considering a console interface, but I'm not sure how > well it may work out for 2048. > > -- > Sergiu > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. > -- Rahul Muttineni -------------- next part -------------- An HTML attachment was scrubbed... URL: From iavor.diatchki at gmail.com Thu Jan 12 18:36:12 2017 From: iavor.diatchki at gmail.com (Iavor Diatchki) Date: Thu, 12 Jan 2017 10:36:12 -0800 Subject: [Haskell-cafe] ANN: `dump-core` a prettier GHC core viewer Message-ID: Hello, Over the holidays I wrote a small GHC plugin to help me do some low-level optimizations of Haskell code. I thought it might be of use to other people too, so please try it out! When enabled, the plugin will save the Core generated by GHC in JSON format, and also render it in HTML for human inspection. The plugin is available on Hackage: http://hackage.haskell.org/package/dump-core The instructions on how to use it are in the README file. You may also read about it at the github page: http://hackage.haskell.org/package/dump-core There are many things that could probably be improved, just let me know. Also, if you are good at design, I could use some help making things look prettier :) Happy hacking, -Iavor -------------- next part -------------- An HTML attachment was scrubbed... URL: From ben at smart-cactus.org Thu Jan 12 18:51:16 2017 From: ben at smart-cactus.org (Ben Gamari) Date: Thu, 12 Jan 2017 13:51:16 -0500 Subject: [Haskell-cafe] ANN: `dump-core` a prettier GHC core viewer In-Reply-To: References: Message-ID: <1D00A7A7-16B9-4083-B491-F9A395C5373F@smart-cactus.org> On January 12, 2017 1:36:12 PM EST, Iavor Diatchki wrote: >Hello, > >Over the holidays I wrote a small GHC plugin to help me do some >low-level >optimizations of Haskell code. I thought it might be of use to other >people too, so please try it out! > >When enabled, the plugin will save the Core generated by GHC in JSON >format, and also render it in HTML for human inspection. > >The plugin is available on Hackage: >http://hackage.haskell.org/package/dump-core > >The instructions on how to use it are in the README file. >You may also read about it at the github page: >http://hackage.haskell.org/package/dump-core > >There are many things that could probably be improved, just let me >know. >Also, if you are good at design, I could use some help making things >look >prettier :) > >Happy hacking, >-Iavor > > >------------------------------------------------------------------------ > >_______________________________________________ >Haskell-Cafe mailing list >To (un)subscribe, modify options or view archives go to: >http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe >Only members subscribed via the mailman list are allowed to post. This looks fantastic, Iavor. I have often wanted something like this. It would be nice if the package would also expose a library providing the types along with FromJson instances so one can load a dump into ghci for further inspection. I've also long wanted a tool to easily fuzzily compare pairs of core dumps. This could be a great tool for enabling this. Cheers, - Ben From jo at durchholz.org Thu Jan 12 20:10:01 2017 From: jo at durchholz.org (Joachim Durchholz) Date: Thu, 12 Jan 2017 21:10:01 +0100 Subject: [Haskell-cafe] brainstorm help In-Reply-To: References: <877f6039fc.fsf@colimite.fr> Message-ID: <61f2f8fc-f9c6-53f5-f245-711a397392a1@durchholz.org> (Sorry, mostly OT.) Am 12.01.2017 um 17:54 schrieb Rahul Muttineni: > You can compile the project as a standalone .jar file that can be run > via `java -jar`. I once tried to use Gradle instead of Oracle's somewhat buggy and noncomposing JavaFX toolchain, but in the end I decided that it wasn't worth the trouble, so I wasn't sure that this problem was solved. Good to know it's solved for Eta. > 'epm' can also generate a script that runs the 'java' > command with the full classpath set for you if you don't want to wait > for the uberjar generation which is currently a bit slow. Oh yes, I have seen slow fatjar builds myself. More than once, so this problem does not seem to be uncommon. Regards, Jo From sivanov at colimite.fr Thu Jan 12 23:05:55 2017 From: sivanov at colimite.fr (Sergiu Ivanov) Date: Fri, 13 Jan 2017 00:05:55 +0100 Subject: [Haskell-cafe] brainstorm help In-Reply-To: References: <877f6039fc.fsf@colimite.fr> <8737go2vqq.fsf@colimite.fr> Message-ID: <87wpdz2818.fsf@colimite.fr> Hey Rahul, Thus quoth Rahul Muttineni at 17:03 on Thu, Jan 12 2017: > > Michael didn't mention arrows on his list and eta-2048 is heavy on > them since Yampa is arrow-based, so it may not be suited for this > project. Oh, I see, I didn't pay attention to those details, thanks for pointing out! > You can find a console interface for 2048 here and it looks a lot > simpler with very light dependencies:  > https://github.com/tfausak/hs2048 Ah, that's exactly what I was thinking about! Thanks for sharing the link, I think I'll keep it at hand for personal use :-) -- Sergiu -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 487 bytes Desc: not available URL: From will.yager at gmail.com Fri Jan 13 04:06:00 2017 From: will.yager at gmail.com (William Yager) Date: Thu, 12 Jan 2017 22:06:00 -0600 Subject: [Haskell-cafe] ANN: `dump-core` a prettier GHC core viewer In-Reply-To: References: Message-ID: On Thu, Jan 12, 2017 at 12:36 PM, Iavor Diatchki wrote: > When enabled, the plugin will save the Core generated by GHC in JSON > format, and also render it in HTML for human inspection. > Thank you, this is awesome! Much more friendly than standard core dumps. -------------- next part -------------- An HTML attachment was scrubbed... URL: From simon.jakobi at googlemail.com Fri Jan 13 05:41:37 2017 From: simon.jakobi at googlemail.com (Simon Jakobi) Date: Fri, 13 Jan 2017 06:41:37 +0100 Subject: [Haskell-cafe] ANN: `dump-core` a prettier GHC core viewer In-Reply-To: References: Message-ID: Wow, this looks great! Do you think you could write a very short tutorial on how to use this plugin in a stack project? A good example project might be Chris Done's "xeno" which raised a lot of interest in generating fast Core: https://www.reddit.com/r/haskell/comments/5ng8ov/fast_haskell_competing_with_c_at_parsing_xml/ Regarding the example output at http://yav.github.io/dump-core/example-output/Galua.OpcodeInterpreter.html: Is it intended that the variables in "$wsetStackSize" are (nearly) all named "ww"? I think it would be more readable if I didn't have to hover the cursor over a variable to tell which is which. Lastly, could you please include the README in the extra-source-files, so it's rendered on Hackage? Thanks, Simon 2017-01-12 19:36 GMT+01:00 Iavor Diatchki : > Hello, > > Over the holidays I wrote a small GHC plugin to help me do some low-level > optimizations of Haskell code. I thought it might be of use to other people > too, so please try it out! > > When enabled, the plugin will save the Core generated by GHC in JSON format, > and also render it in HTML for human inspection. > > The plugin is available on Hackage: > http://hackage.haskell.org/package/dump-core > > The instructions on how to use it are in the README file. > You may also read about it at the github page: > http://hackage.haskell.org/package/dump-core > > There are many things that could probably be improved, just let me know. > Also, if you are good at design, I could use some help making things look > prettier :) > > Happy hacking, > -Iavor > > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. From codygman.consulting at gmail.com Fri Jan 13 05:48:42 2017 From: codygman.consulting at gmail.com (Cody Goodman) Date: Thu, 12 Jan 2017 23:48:42 -0600 Subject: [Haskell-cafe] Can I allow multiple rigid type variables? Message-ID: I know my question doesn't quite make sense and you can't have "multiple rigid type variables" but I couldn't think of a better way to characterize it or explain it. So I'll also try to give more detail below along with the code example and error at the end. I have an inner join function using vinyl which does cool stuff like giving a type error if you try to join on a column that doesn't exist. I previously had an implementation that blindly built an index based on the left argument. I then tried to dispatch based on the lengths of the left and right producer arguments. The problem is my return type is: Rec f (as ++ bs) That means I have two different producers, one of as and one of bs. I then do a case statement on the lengths and I want to store the producer to use for a given piece in that variable. The problem is ghc "pins" the type variable as either (Rec f as) or (Rec f bs) when I need to make that choice at runtime. My code and error is both at github here: https://github.com/codygman/frames-diff/blob/inner-join-fix/Frames/Diff.hs#L113 and below: -- | Performs an inner join and keeps any duplicate column -- Recommend keeping columns in producers disjoint because accessing -- anything but the leftmost duplicate column could prove difficult. -- see: https://github.com/VinylRecords/Vinyl/issues/55#issuecomment-269891633 innerJoin :: (MonadIO m, Ord k) => Producer (Rec f leftRows) IO () -- leftProducer -> Getting k (Rec f leftRows) k -- leftProducer lens -> Producer (Rec f rightRows) IO () -- rightProducer -> Getting k (Rec f rightRows) k -- rightProducer lens -> m (P.Proxy P.X () () (Rec f (leftRows ++ rightRows)) IO ()) innerJoin leftProducer leftLens rightProducer rightLens = do leftProducerLen <- P.liftIO $ P.length leftProducer rightProducerLen <- P.liftIO $ P.length rightProducer let curProducer = case rightProducerLen < leftProducerLen of True -> rightProducer -- False -> leftProducer let curKeymapProducer = case rightProducerLen < leftProducerLen of True -> leftProducer -- False -> rightProducer let curLensLookup = case rightProducerLen < leftProducerLen of True -> rightLens -- False -> leftLens let curLensInsert = case rightProducerLen < leftProducerLen of True -> leftLens -- False -> rightLens let appender km row = case rightProducerLen < leftProducerLen of True -> case M.lookup (view curLensLookup row) km of Just otherRow -> pure $ rappend otherRow row Nothing -> P.mzero -- False -> case M.lookup (view curLensLookup row) km of -- Just otherRow -> pure $ rappend row otherRow -- Nothing -> P.mzero keyMap <- P.liftIO $ P.fold (\m r -> M.insert (view curLensInsert r) r m) M.empty id curKeymapProducer pure $ curProducer >-> P.mapM (\r -> appender keyMap r) -- error if I uncomment my false cases (specifically the False case for curProducer) -- [5 of 5] Compiling Frames.Diff ( Frames/Diff.hs, interpreted ) -- Frames/Diff.hs:125:32: error: -- • Couldn't match type ‘leftRows’ with ‘rightRows’ -- ‘leftRows’ is a rigid type variable bound by -- the type signature for: -- innerJoin :: forall (m :: * -> *) k (f :: * -- -> *) (leftRows :: [*]) (rightRows :: [*]). -- (MonadIO m, Ord k) => -- Producer (Rec f leftRows) IO () -- -> Getting k (Rec f leftRows) k -- -> Producer (Rec f rightRows) IO () -- -> Getting k (Rec f rightRows) k -- -> m (P.Proxy P.X () () (Rec f (leftRows ++ rightRows)) IO ()) -- at Frames/Diff.hs:113:14 -- ‘rightRows’ is a rigid type variable bound by -- the type signature for: -- innerJoin :: forall (m :: * -> *) k (f :: * -- -> *) (leftRows :: [*]) (rightRows :: [*]). -- (MonadIO m, Ord k) => -- Producer (Rec f leftRows) IO () -- -> Getting k (Rec f leftRows) k -- -> Producer (Rec f rightRows) IO () -- -> Getting k (Rec f rightRows) k -- -> m (P.Proxy P.X () () (Rec f (leftRows ++ rightRows)) IO ()) -- at Frames/Diff.hs:113:14 -- Expected type: Producer (Rec f rightRows) IO () -- Actual type: Producer (Rec f leftRows) IO () -- • In the expression: leftProducer -- In a case alternative: False -> leftProducer -- In the expression: -- case rightProducerLen < leftProducerLen of { -- True -> rightProducer -- False -> leftProducer } -- • Relevant bindings include -- curProducer :: Producer (Rec f rightRows) IO () -- (bound at Frames/Diff.hs:123:7) -- rightLens :: Getting k (Rec f rightRows) k -- (bound at Frames/Diff.hs:119:47) -- rightProducer :: Producer (Rec f rightRows) IO () -- (bound at Frames/Diff.hs:119:33) -- leftLens :: Getting k (Rec f leftRows) k -- (bound at Frames/Diff.hs:119:24) -- leftProducer :: Producer (Rec f leftRows) IO () -- (bound at Frames/Diff.hs:119:11) -- innerJoin :: Producer (Rec f leftRows) IO () -- -> Getting k (Rec f leftRows) k -- -> Producer (Rec f rightRows) IO () -- -> Getting k (Rec f rightRows) k -- -> m (P.Proxy P.X () () (Rec f (leftRows ++ rightRows)) IO ()) -- (bound at Frames/Diff.hs:119:1) -------------- next part -------------- An HTML attachment was scrubbed... URL: From codygman.consulting at gmail.com Fri Jan 13 05:55:26 2017 From: codygman.consulting at gmail.com (Cody Goodman) Date: Thu, 12 Jan 2017 23:55:26 -0600 Subject: [Haskell-cafe] Can I allow multiple rigid type variables? In-Reply-To: References: Message-ID: I figured out a way to kind of sideskirt the problem where I define my main join as a helper and then dispatch on length in the calling function. GHC generated this type for it: innerJoin :: ((as ++ bs) ~ (bs ++ as), PrimMonad m, Ord k, RecVec (bs ++ as)) => Producer (Rec Identity bs) m () -> Getting k (Rec Identity bs) k -> Producer (Rec Identity as) m () -> Getting k (Rec Identity as) k -> m (FrameRec (bs ++ as)) What exactly does (as ++ bs) ~ (bs ++ as) mean? On Thu, Jan 12, 2017 at 11:48 PM, Cody Goodman < codygman.consulting at gmail.com> wrote: > I know my question doesn't quite make sense and you can't have "multiple > rigid type variables" but I couldn't think of a better way to characterize > it or explain it. So I'll also try to give more detail below along with the > code example and error at the end. > > I have an inner join function using vinyl which does cool stuff like > giving a type error if you try to join on a column that doesn't exist. I > previously had an implementation that blindly built an index based on the > left argument. > > I then tried to dispatch based on the lengths of the left and right > producer arguments. The problem is my return type is: > > Rec f (as ++ bs) > > That means I have two different producers, one of as and one of bs. I then > do a case statement on the lengths and I want to store the producer to use > for a given piece in that variable. The problem is ghc "pins" the type > variable as either (Rec f as) or (Rec f bs) when I need to make that choice > at runtime. > > > My code and error is both at github here: https://github.com/codygman/ > frames-diff/blob/inner-join-fix/Frames/Diff.hs#L113 > > and below: > > -- | Performs an inner join and keeps any duplicate column > -- Recommend keeping columns in producers disjoint because accessing > -- anything but the leftmost duplicate column could prove difficult. > -- see: https://github.com/VinylRecords/Vinyl/issues/55# > issuecomment-269891633 > innerJoin :: (MonadIO m, Ord k) => > Producer (Rec f leftRows) IO () -- leftProducer > -> Getting k (Rec f leftRows) k -- leftProducer lens > -> Producer (Rec f rightRows) IO () -- rightProducer > -> Getting k (Rec f rightRows) k -- rightProducer lens > -> m (P.Proxy P.X () () (Rec f (leftRows ++ rightRows)) IO ()) > innerJoin leftProducer leftLens rightProducer rightLens = do > leftProducerLen <- P.liftIO $ P.length leftProducer > rightProducerLen <- P.liftIO $ P.length rightProducer > let curProducer = case rightProducerLen < leftProducerLen of > True -> rightProducer > -- False -> leftProducer > let curKeymapProducer = case rightProducerLen < leftProducerLen of > True -> leftProducer > -- False -> rightProducer > let curLensLookup = case rightProducerLen < leftProducerLen of > True -> rightLens > -- False -> leftLens > let curLensInsert = case rightProducerLen < leftProducerLen of > True -> leftLens > -- False -> rightLens > let appender km row = case rightProducerLen < leftProducerLen of > True -> case M.lookup (view curLensLookup row) km of > Just otherRow -> pure $ rappend otherRow row > Nothing -> P.mzero > -- False -> case M.lookup (view curLensLookup row) km of > -- Just otherRow -> pure $ rappend row otherRow > -- Nothing -> P.mzero > keyMap <- P.liftIO $ P.fold (\m r -> M.insert (view curLensInsert r) r m) > M.empty id curKeymapProducer > pure $ curProducer >-> P.mapM (\r -> appender keyMap r) > -- error if I uncomment my false cases (specifically the False case for > curProducer) > -- [5 of 5] Compiling Frames.Diff ( Frames/Diff.hs, interpreted ) > -- Frames/Diff.hs:125:32: error: > -- • Couldn't match type ‘leftRows’ with ‘rightRows’ > -- ‘leftRows’ is a rigid type variable bound by > -- the type signature for: > -- innerJoin :: forall (m :: * -> *) k (f :: * > -- -> *) (leftRows :: [*]) (rightRows :: [*]). > -- (MonadIO m, Ord k) => > -- Producer (Rec f leftRows) IO () > -- -> Getting k (Rec f leftRows) k > -- -> Producer (Rec f rightRows) IO () > -- -> Getting k (Rec f rightRows) k > -- -> m (P.Proxy P.X () () (Rec f (leftRows ++ rightRows)) IO ()) > -- at Frames/Diff.hs:113:14 > -- ‘rightRows’ is a rigid type variable bound by > -- the type signature for: > -- innerJoin :: forall (m :: * -> *) k (f :: * > -- -> *) (leftRows :: [*]) (rightRows :: [*]). > -- (MonadIO m, Ord k) => > -- Producer (Rec f leftRows) IO () > -- -> Getting k (Rec f leftRows) k > -- -> Producer (Rec f rightRows) IO () > -- -> Getting k (Rec f rightRows) k > -- -> m (P.Proxy P.X () () (Rec f (leftRows ++ rightRows)) IO ()) > -- at Frames/Diff.hs:113:14 > -- Expected type: Producer (Rec f rightRows) IO () > -- Actual type: Producer (Rec f leftRows) IO () > -- • In the expression: leftProducer > -- In a case alternative: False -> leftProducer > -- In the expression: > -- case rightProducerLen < leftProducerLen of { > -- True -> rightProducer > -- False -> leftProducer } > -- • Relevant bindings include > -- curProducer :: Producer (Rec f rightRows) IO () > -- (bound at Frames/Diff.hs:123:7) > -- rightLens :: Getting k (Rec f rightRows) k > -- (bound at Frames/Diff.hs:119:47) > -- rightProducer :: Producer (Rec f rightRows) IO () > -- (bound at Frames/Diff.hs:119:33) > -- leftLens :: Getting k (Rec f leftRows) k > -- (bound at Frames/Diff.hs:119:24) > -- leftProducer :: Producer (Rec f leftRows) IO () > -- (bound at Frames/Diff.hs:119:11) > -- innerJoin :: Producer (Rec f leftRows) IO () > -- -> Getting k (Rec f leftRows) k > -- -> Producer (Rec f rightRows) IO () > -- -> Getting k (Rec f rightRows) k > -- -> m (P.Proxy P.X () () (Rec f (leftRows ++ rightRows)) IO ()) > -- (bound at Frames/Diff.hs:119:1) > -------------- next part -------------- An HTML attachment was scrubbed... URL: From codygman.consulting at gmail.com Fri Jan 13 06:05:13 2017 From: codygman.consulting at gmail.com (Cody Goodman) Date: Fri, 13 Jan 2017 00:05:13 -0600 Subject: [Haskell-cafe] Can I allow multiple rigid type variables? In-Reply-To: References: Message-ID: Nevermind, my last message would only ever allow me to do self inner joins. On Thu, Jan 12, 2017 at 11:55 PM, Cody Goodman < codygman.consulting at gmail.com> wrote: > I figured out a way to kind of sideskirt the problem where I define my > main join as a helper and then dispatch on length in the calling function. > GHC generated this type for it: > > > innerJoin > :: ((as ++ bs) ~ (bs ++ as), PrimMonad m, Ord k, > RecVec (bs ++ as)) => > Producer (Rec Identity bs) m () > -> Getting k (Rec Identity bs) k > -> Producer (Rec Identity as) m () > -> Getting k (Rec Identity as) k > -> m (FrameRec (bs ++ as)) > > > What exactly does (as ++ bs) ~ (bs ++ as) mean? > > > On Thu, Jan 12, 2017 at 11:48 PM, Cody Goodman < > codygman.consulting at gmail.com> wrote: > >> I know my question doesn't quite make sense and you can't have "multiple >> rigid type variables" but I couldn't think of a better way to characterize >> it or explain it. So I'll also try to give more detail below along with the >> code example and error at the end. >> >> I have an inner join function using vinyl which does cool stuff like >> giving a type error if you try to join on a column that doesn't exist. I >> previously had an implementation that blindly built an index based on the >> left argument. >> >> I then tried to dispatch based on the lengths of the left and right >> producer arguments. The problem is my return type is: >> >> Rec f (as ++ bs) >> >> That means I have two different producers, one of as and one of bs. I >> then do a case statement on the lengths and I want to store the producer to >> use for a given piece in that variable. The problem is ghc "pins" the type >> variable as either (Rec f as) or (Rec f bs) when I need to make that choice >> at runtime. >> >> >> My code and error is both at github here: https://github.com/codygman/fr >> ames-diff/blob/inner-join-fix/Frames/Diff.hs#L113 >> >> and below: >> >> -- | Performs an inner join and keeps any duplicate column >> -- Recommend keeping columns in producers disjoint because accessing >> -- anything but the leftmost duplicate column could prove difficult. >> -- see: https://github.com/VinylRecords/Vinyl/issues/55#issuecomment >> -269891633 >> innerJoin :: (MonadIO m, Ord k) => >> Producer (Rec f leftRows) IO () -- leftProducer >> -> Getting k (Rec f leftRows) k -- leftProducer lens >> -> Producer (Rec f rightRows) IO () -- rightProducer >> -> Getting k (Rec f rightRows) k -- rightProducer lens >> -> m (P.Proxy P.X () () (Rec f (leftRows ++ rightRows)) IO ()) >> innerJoin leftProducer leftLens rightProducer rightLens = do >> leftProducerLen <- P.liftIO $ P.length leftProducer >> rightProducerLen <- P.liftIO $ P.length rightProducer >> let curProducer = case rightProducerLen < leftProducerLen of >> True -> rightProducer >> -- False -> leftProducer >> let curKeymapProducer = case rightProducerLen < leftProducerLen of >> True -> leftProducer >> -- False -> rightProducer >> let curLensLookup = case rightProducerLen < leftProducerLen of >> True -> rightLens >> -- False -> leftLens >> let curLensInsert = case rightProducerLen < leftProducerLen of >> True -> leftLens >> -- False -> rightLens >> let appender km row = case rightProducerLen < leftProducerLen of >> True -> case M.lookup (view curLensLookup row) km of >> Just otherRow -> pure $ rappend otherRow row >> Nothing -> P.mzero >> -- False -> case M.lookup (view curLensLookup row) km of >> -- Just otherRow -> pure $ rappend row otherRow >> -- Nothing -> P.mzero >> keyMap <- P.liftIO $ P.fold (\m r -> M.insert (view curLensInsert r) r >> m) M.empty id curKeymapProducer >> pure $ curProducer >-> P.mapM (\r -> appender keyMap r) >> -- error if I uncomment my false cases (specifically the False case for >> curProducer) >> -- [5 of 5] Compiling Frames.Diff ( Frames/Diff.hs, interpreted ) >> -- Frames/Diff.hs:125:32: error: >> -- • Couldn't match type ‘leftRows’ with ‘rightRows’ >> -- ‘leftRows’ is a rigid type variable bound by >> -- the type signature for: >> -- innerJoin :: forall (m :: * -> *) k (f :: * >> -- -> *) (leftRows :: [*]) (rightRows :: [*]). >> -- (MonadIO m, Ord k) => >> -- Producer (Rec f leftRows) IO () >> -- -> Getting k (Rec f leftRows) k >> -- -> Producer (Rec f rightRows) IO () >> -- -> Getting k (Rec f rightRows) k >> -- -> m (P.Proxy P.X () () (Rec f (leftRows ++ rightRows)) IO ()) >> -- at Frames/Diff.hs:113:14 >> -- ‘rightRows’ is a rigid type variable bound by >> -- the type signature for: >> -- innerJoin :: forall (m :: * -> *) k (f :: * >> -- -> *) (leftRows :: [*]) (rightRows :: [*]). >> -- (MonadIO m, Ord k) => >> -- Producer (Rec f leftRows) IO () >> -- -> Getting k (Rec f leftRows) k >> -- -> Producer (Rec f rightRows) IO () >> -- -> Getting k (Rec f rightRows) k >> -- -> m (P.Proxy P.X () () (Rec f (leftRows ++ rightRows)) IO ()) >> -- at Frames/Diff.hs:113:14 >> -- Expected type: Producer (Rec f rightRows) IO () >> -- Actual type: Producer (Rec f leftRows) IO () >> -- • In the expression: leftProducer >> -- In a case alternative: False -> leftProducer >> -- In the expression: >> -- case rightProducerLen < leftProducerLen of { >> -- True -> rightProducer >> -- False -> leftProducer } >> -- • Relevant bindings include >> -- curProducer :: Producer (Rec f rightRows) IO () >> -- (bound at Frames/Diff.hs:123:7) >> -- rightLens :: Getting k (Rec f rightRows) k >> -- (bound at Frames/Diff.hs:119:47) >> -- rightProducer :: Producer (Rec f rightRows) IO () >> -- (bound at Frames/Diff.hs:119:33) >> -- leftLens :: Getting k (Rec f leftRows) k >> -- (bound at Frames/Diff.hs:119:24) >> -- leftProducer :: Producer (Rec f leftRows) IO () >> -- (bound at Frames/Diff.hs:119:11) >> -- innerJoin :: Producer (Rec f leftRows) IO () >> -- -> Getting k (Rec f leftRows) k >> -- -> Producer (Rec f rightRows) IO () >> -- -> Getting k (Rec f rightRows) k >> -- -> m (P.Proxy P.X () () (Rec f (leftRows ++ rightRows)) IO ()) >> -- (bound at Frames/Diff.hs:119:1) >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From highfly22 at gmail.com Fri Jan 13 08:31:20 2017 From: highfly22 at gmail.com (Haiwei Zhou) Date: Fri, 13 Jan 2017 16:31:20 +0800 Subject: [Haskell-cafe] A question on datakinds syntax Message-ID: Hi, I am reading the document of spock-0.11, and found two strange definitions in the Web.Spock. ```` type Var a = Path ((:) * a ([] *)) Open var :: (Typeable * a, PathPiece a) => Path ((:) * a ([] *)) Open ```` What's the meaning of the star between Typeable and a ? The kind of Typeable is * -> *. I cannot understand why the Typeable in the var prototype takes two kinds. In the Web.Routing.Combinators of reroute-0.4, those are defined as following: ```` type Var a = Path (a ': '[]) Open var :: (Typeable a, PathPiece a) => Path (a ': '[]) Open ```` Why there are two difference definition about the same thing? Thanks, Haiwei -------------- next part -------------- An HTML attachment was scrubbed... URL: From dominic at steinitz.org Fri Jan 13 10:59:40 2017 From: dominic at steinitz.org (Dominic Steinitz) Date: Fri, 13 Jan 2017 10:59:40 +0000 Subject: [Haskell-cafe] Calling Haskell from C Message-ID: I've been trying to get the example in https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/ffi-chap.html?highlight=foreign#using-foreign-export-and-foreign-import-ccall-wrapper-with-ghc working. I have a cabal file name: test-via-c version: 0.1.0.0 homepage: TBD license: MIT author: Dominic Steinitz maintainer: idontgetoutmuch at gmail.com category: System build-type: Simple cabal-version: >=1.10 executable Foo.dylib main-is: Foo.hs other-extensions: ForeignFunctionInterface build-depends: base >=4.7 && <4.10, primitive >=0.6 && <0.7 hs-source-dirs: src default-language: Haskell2010 include-dirs: src ghc-options: -O2 -shared -fPIC -dynamic extra-libraries: HSrts-ghc8.0.1 which installs /Users/dom/Library/Haskell/ghc-8.0.1/lib/test-via-c-0.1.0.0/bin/Foo.dylib I then compile the C with gcc-6 Bar.c /Users/dom/Library/Haskell/ghc-8.0.1/lib/test-via-c-0.1.0.0/bin/Foo.dylib -I/Library/Frameworks/GHC.framework/Versions/8.0.1-x86_64/usr/lib/ghc-8.0.1/include -L/Library/Frameworks/GHC.framework/Versions/8.0.1-x86_64/usr/lib/ghc-8.0.1/rts -lHSrts-ghc8.0.1 Sadly when I try to run the executable I get ~/Dropbox/Private/TestU01-1.2.3/examples/src $ ./a.out dyld: Library not loaded: @rpath/Foo.dylib Referenced from: /Users/dom/Dropbox/Private/TestU01-1.2.3/examples/src/./a.out Reason: image not found Trace/BPT trap: 5 I am guessing the executable is looking for the dynamic library. I copied Foo.dylib to the current directory but still get the same error. I know this is really an OS X question but I am hoping someone who has done before will be able to help. Dominic Steinitz dominic at steinitz.org http://idontgetoutmuch.wordpress.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From dominic at steinitz.org Fri Jan 13 13:53:32 2017 From: dominic at steinitz.org (dominic at steinitz.org) Date: Fri, 13 Jan 2017 13:53:32 +0000 Subject: [Haskell-cafe] Calling Haskell from C In-Reply-To: References: Message-ID: <22C8390C-EE0D-4244-A8D6-A0FD22AC8DFE@steinitz.org> Answering my own question: > export DYLD_LIBRARY_PATH=/Users/dom/Library/Haskell/ghc-8.0.1/lib/test-via-c-0.1.0.0/bin:/Library/Frameworks/GHC.framework/Versions/8.0.1-x86_64/usr/lib/ghc-8.0.1/rts > ./a.out > 2500 > 2500 > 2500 > 2500 > 2500 > On 13 Jan 2017, at 10:59, Dominic Steinitz wrote: > > I've been trying to get the example in > https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/ffi-chap.html?highlight=foreign#using-foreign-export-and-foreign-import-ccall-wrapper-with-ghc > working. > > I have a cabal file > > name: test-via-c > version: 0.1.0.0 > homepage: TBD > license: MIT > author: Dominic Steinitz > maintainer: idontgetoutmuch at gmail.com > category: System > build-type: Simple > cabal-version: >=1.10 > > executable Foo.dylib > main-is: Foo.hs > other-extensions: ForeignFunctionInterface > build-depends: base >=4.7 && <4.10, > primitive >=0.6 && <0.7 > hs-source-dirs: src > default-language: Haskell2010 > include-dirs: src > ghc-options: -O2 -shared -fPIC -dynamic > extra-libraries: HSrts-ghc8.0.1 > > which installs > > /Users/dom/Library/Haskell/ghc-8.0.1/lib/test-via-c-0.1.0.0/bin/Foo.dylib > > I then compile the C with > > gcc-6 Bar.c > /Users/dom/Library/Haskell/ghc-8.0.1/lib/test-via-c-0.1.0.0/bin/Foo.dylib > -I/Library/Frameworks/GHC.framework/Versions/8.0.1-x86_64/usr/lib/ghc-8.0.1/include > -L/Library/Frameworks/GHC.framework/Versions/8.0.1-x86_64/usr/lib/ghc-8.0.1/rts > -lHSrts-ghc8.0.1 > > Sadly when I try to run the executable I get > > ~/Dropbox/Private/TestU01-1.2.3/examples/src $ ./a.out > dyld: Library not loaded: @rpath/Foo.dylib > Referenced from: /Users/dom/Dropbox/Private/TestU01-1.2.3/examples/src/./a.out > Reason: image not found > Trace/BPT trap: 5 > > I am guessing the executable is looking for the dynamic library. I > copied Foo.dylib to the current directory but still get the same > error. > > I know this is really an OS X question but I am hoping someone who has > done before will be able to help. > > Dominic Steinitz > dominic at steinitz.org > http://idontgetoutmuch.wordpress.com Dominic Steinitz dominic at steinitz.org http://idontgetoutmuch.wordpress.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at joachim-breitner.de Fri Jan 13 15:22:05 2017 From: mail at joachim-breitner.de (Joachim Breitner) Date: Fri, 13 Jan 2017 10:22:05 -0500 Subject: [Haskell-cafe] ANN: `dump-core` a prettier GHC core viewer In-Reply-To: References: Message-ID: <1484320925.471.8.camel@joachim-breitner.de> Hi, Am Freitag, den 13.01.2017, 06:41 +0100 schrieb Simon Jakobi via Haskell-Cafe: > Is it intended that the variables in "$wsetStackSize" are (nearly) > all > named "ww"? I think it would be more readable if I didn't have to > hover the cursor over a variable to tell which is which. this might be a good motivation to maybe have more speaking names already generated by GHC ;-) Greetings, Joachim -- Joachim “nomeata” Breitner   mail at joachim-breitner.de • https://www.joachim-breitner.de/   XMPP: nomeata at joachim-breitner.de • OpenPGP-Key: 0xF0FBF51F   Debian Developer: nomeata at debian.org -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: This is a digitally signed message part URL: From allbery.b at gmail.com Fri Jan 13 16:06:39 2017 From: allbery.b at gmail.com (Brandon Allbery) Date: Fri, 13 Jan 2017 11:06:39 -0500 Subject: [Haskell-cafe] Calling Haskell from C In-Reply-To: <22C8390C-EE0D-4244-A8D6-A0FD22AC8DFE@steinitz.org> References: <22C8390C-EE0D-4244-A8D6-A0FD22AC8DFE@steinitz.org> Message-ID: On Fri, Jan 13, 2017 at 8:53 AM, wrote: > export DYLD_LIBRARY_PATH=/Users/dom/Library/Haskell/ghc-8.0.1/lib/ > test-via-c-0.1.0.0/bin:/Library/Frameworks/GHC. > framework/Versions/8.0.1-x86_64/usr/lib/ghc-8.0.1/rts > > That's a good way to break things. Consider DYLD_FALLBACK_LIBRARY_PATH instead. Also, use otool -l a.out to inspect the RPATH commands embedded in a.out; that will tell you where dyld searches when it sees @rpath/Foo.dylib. -- 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 allbery.b at gmail.com Fri Jan 13 16:20:52 2017 From: allbery.b at gmail.com (Brandon Allbery) Date: Fri, 13 Jan 2017 11:20:52 -0500 Subject: [Haskell-cafe] A question on datakinds syntax In-Reply-To: References: Message-ID: Haddock displays kind annotations oddly. At a guess (which could well be off base; I'm still rather weak on this stuff), Spock has PolyKinds enabled, so an explicit (x :: *) kind annotation must be preserved as an override to the default of allowing any kind; if PolyKinds is not enabled, then * is the default kind and wouldn't be annotated. (Reader beware: * is not a wildcard/"match any", it is specifically the kind of inhabited boxed types!) On Fri, Jan 13, 2017 at 3:31 AM, Haiwei Zhou wrote: > Hi, > > I am reading the document of spock-0.11, and found two strange > definitions in the Web.Spock. > > ```` > type Var a = Path ((:) * a ([] *)) Open > > var :: (Typeable * a, PathPiece a) => Path ((:) * a ([] *)) Open > > ```` > > What's the meaning of the star between Typeable and a ? > > The kind of Typeable is * -> *. I cannot understand why the Typeable in > the var prototype takes two kinds. > > In the Web.Routing.Combinators of reroute-0.4, those are defined as > following: > > ```` > type Var a = Path (a ': '[]) Open > > var :: (Typeable a, PathPiece a) => Path (a ': '[]) Open > > ```` > > Why there are two difference definition about the same thing? > > Thanks, > Haiwei > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. > -- 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 allbery.b at gmail.com Fri Jan 13 16:24:04 2017 From: allbery.b at gmail.com (Brandon Allbery) Date: Fri, 13 Jan 2017 11:24:04 -0500 Subject: [Haskell-cafe] Can I allow multiple rigid type variables? In-Reply-To: References: Message-ID: On Fri, Jan 13, 2017 at 12:55 AM, Cody Goodman < codygman.consulting at gmail.com> wrote: > > What exactly does (as ++ bs) ~ (bs ++ as) mean? It tells the typechecker that the parameters to type-level (++) can be swapped and still produce the same result type (that is, type-level (++) is commutative). -- 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 simon at joyful.com Fri Jan 13 16:45:02 2017 From: simon at joyful.com (Simon Michael) Date: Fri, 13 Jan 2017 08:45:02 -0800 Subject: [Haskell-cafe] brainstorm help In-Reply-To: References: Message-ID: Hi Michael, I like the idea a lot. I'm having fond flashbacks to David Ahl's BASIC Computer Games (http://www.atariarchives.org/basicgames). Here are two very minimal haskell games, FYI: http://hub.darcs.net/simon/guess-the-number https://github.com/simonmichael/symon On 1/11/17 2:55 PM, Michael Litchard wrote: > Hi There. > > I'm looking for ideas to flesh out a writing project I'm beginning. What I > am looking for is a set of five games in increasing complexity that would > allow for a wide discussion of Haskell. I originally began this project by > centering the writing around one large game, but this idea has proven to be > brittle. The set of five should include a discussion of: > > (1) Types > (2) folds, maps, filters > (3) monoids, functors, applicatives, and monads > > Thanks for what ever storms your brains bring forth. :) > > > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. From dominic at steinitz.org Fri Jan 13 17:35:17 2017 From: dominic at steinitz.org (dominic at steinitz.org) Date: Fri, 13 Jan 2017 17:35:17 +0000 Subject: [Haskell-cafe] Calling Haskell from C In-Reply-To: References: <22C8390C-EE0D-4244-A8D6-A0FD22AC8DFE@steinitz.org> Message-ID: Thanks very much - I am very ignorant in this area and all help is much appreciated. However, when I do as you suggest I get > $ otool -L a.out > a.out: > @rpath/Foo.dylib (compatibility version 0.0.0, current version 0.0.0) > @rpath/libHSrts-ghc8.0.1.dylib (compatibility version 0.0.0, current version 0.0.0) > /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1226.10.1) > /usr/local/lib/gcc/6/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0) > $ set | grep -i dyld > DYLD_FALLBACK_LIBRARY_PATH=/Users/dom/Library/Haskell/ghc-8.0.1/lib/test-via-c-0.1.0.0/bin:/Library/Frameworks/GHC.framework/Versions/8.0.1-x86_64/usr/lib/ghc-8.0.1/rts > ~/Dropbox/Private/TestU01-1.2.3/examples/src $ ./a.out > dyld: Library not loaded: /usr/local/lib/gcc/5/libgcc_s.1.dylib > Referenced from: /Library/Frameworks/GHC.framework/Versions/8.0.1-x86_64/usr/lib/ghc-8.0.1/rts/libHSrts-ghc8.0.1.dylib > Reason: image not found > Trace/BPT trap: 5 It’s not clear to me why it’s looking for `gcc/5` which is not installed when it looks as though it should be looking for `gcc/6`. > On 13 Jan 2017, at 16:06, Brandon Allbery wrote: > > > On Fri, Jan 13, 2017 at 8:53 AM, > wrote: >> export DYLD_LIBRARY_PATH=/Users/dom/Library/Haskell/ghc-8.0.1/lib/test-via-c-0.1.0.0/bin:/Library/Frameworks/GHC.framework/Versions/8.0.1-x86_64/usr/lib/ghc-8.0.1/rts > > That's a good way to break things. Consider DYLD_FALLBACK_LIBRARY_PATH instead. > Also, use otool -l a.out to inspect the RPATH commands embedded in a.out; that will tell you where dyld searches when it sees @rpath/Foo.dylib. > > -- > brandon s allbery kf8nh sine nomine associates > allbery.b at gmail.com ballbery at sinenomine.net > unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net Dominic Steinitz dominic at steinitz.org http://idontgetoutmuch.wordpress.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From allbery.b at gmail.com Fri Jan 13 17:46:16 2017 From: allbery.b at gmail.com (Brandon Allbery) Date: Fri, 13 Jan 2017 12:46:16 -0500 Subject: [Haskell-cafe] Calling Haskell from C In-Reply-To: References: <22C8390C-EE0D-4244-A8D6-A0FD22AC8DFE@steinitz.org> Message-ID: On Fri, Jan 13, 2017 at 12:35 PM, wrote: > > $ otool -L a.out > > I said "-l". "-L" shows how it resolves shared objects; "-l" dumps the load commands table, which includes RPATH entries that tell it how to resolve @rpath. > DYLD_FALLBACK_LIBRARY_PATH=/Users/dom/Library/Haskell/ghc- > 8.0.1/lib/test-via-c-0.1.0.0/bin:/Library/Frameworks/GHC. > framework/Versions/8.0.1-x86_64/usr/lib/ghc-8.0.1/rts > ~/Dropbox/Private/TestU01-1.2.3/examples/src $ ./a.out > > This is odd, unless Apple changed things yet again (I should not be surprised, the loader stuff is about as stable as water /o\ ) It’s not clear to me why it’s looking for `gcc/5` which is not installed > when it looks as though it should be looking for `gcc/6`. > That might be indicated by the RPATH entries, since DYLD_FALLBACK_LIBRARY_PATH changes how lookups work (so does DYLD_LIBRARY_PATH, in a different way, which is why it's dangerous). -- 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 cmscalzo at gmail.com Fri Jan 13 17:51:15 2017 From: cmscalzo at gmail.com (Carlo Matteo Scalzo) Date: Fri, 13 Jan 2017 17:51:15 +0000 Subject: [Haskell-cafe] Feedback needed: CLI app + guide In-Reply-To: References: Message-ID: Hi all, I've already posted this in beginners@, but I thought it might be of interest to a wider audience too (apologies for double-posting). I started learning Haskell about a year ago, and I couldn't find any example of a simple, real world application written in Haskell, so as usual I ended up writing my own :-) The code is available for free (it's a simple command-line app), and I've also written a short guide that uses the application as a case study to talk about Haskell's features. Could you guys please download the guide (for free, of course) and let me know if you find it useful? You can get the guide here: https://fifohaskell.com Please send me your feedback either here or to my personal email address (it's on the website), and thank you very much for your help! Carlo -------------- next part -------------- An HTML attachment was scrubbed... URL: From auke at tulcod.com Fri Jan 13 18:29:56 2017 From: auke at tulcod.com (Auke Booij) Date: Fri, 13 Jan 2017 18:29:56 +0000 Subject: [Haskell-cafe] Calling Haskell from C In-Reply-To: References: Message-ID: The development version of cabal has support for building dynamic objects. See: https://github.com/haskell/cabal/blob/master/Cabal/doc/developing-packages.rst#foreign-libraries On 13 January 2017 at 10:59, Dominic Steinitz wrote: > I've been trying to get the example in > https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/ffi-chap.html?highlight=foreign#using-foreign-export-and-foreign-import-ccall-wrapper-with-ghc > working. > > I have a cabal file > > name: test-via-c > version: 0.1.0.0 > homepage: TBD > license: MIT > author: Dominic Steinitz > maintainer: idontgetoutmuch at gmail.com > category: System > build-type: Simple > cabal-version: >=1.10 > > executable Foo.dylib > main-is: Foo.hs > other-extensions: ForeignFunctionInterface > build-depends: base >=4.7 && <4.10, > primitive >=0.6 && <0.7 > hs-source-dirs: src > default-language: Haskell2010 > include-dirs: src > ghc-options: -O2 -shared -fPIC -dynamic > extra-libraries: HSrts-ghc8.0.1 > > which installs > > /Users/dom/Library/Haskell/ghc-8.0.1/lib/test-via-c-0.1.0.0/bin/Foo.dylib > > I then compile the C with > > gcc-6 Bar.c > /Users/dom/Library/Haskell/ghc-8.0.1/lib/test-via-c-0.1.0.0/bin/Foo.dylib > -I/Library/Frameworks/GHC.framework/Versions/8.0.1-x86_64/usr/lib/ghc-8.0.1/include > -L/Library/Frameworks/GHC.framework/Versions/8.0.1-x86_64/usr/lib/ghc-8.0.1/rts > -lHSrts-ghc8.0.1 > > Sadly when I try to run the executable I get > > ~/Dropbox/Private/TestU01-1.2.3/examples/src $ ./a.out > dyld: Library not loaded: @rpath/Foo.dylib > Referenced from: > /Users/dom/Dropbox/Private/TestU01-1.2.3/examples/src/./a.out > Reason: image not found > Trace/BPT trap: 5 > > I am guessing the executable is looking for the dynamic library. I > copied Foo.dylib to the current directory but still get the same > error. > > I know this is really an OS X question but I am hoping someone who has > done before will be able to help. > > Dominic Steinitz > dominic at steinitz.org > http://idontgetoutmuch.wordpress.com > > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. From jan.loewenstein at gmail.com Fri Jan 13 19:28:41 2017 From: jan.loewenstein at gmail.com (=?UTF-8?Q?Jan_von_L=C3=B6wenstein?=) Date: Fri, 13 Jan 2017 19:28:41 +0000 Subject: [Haskell-cafe] Strange encoding issue with Text and Servant Message-ID: Hi, I have got a two places with a `QueryParam "q" Text` and call it with a Text that contains a `=` literal. In one place the `=` is correctly encoded as %3D, in the other I see a `!D(MISSING)`. This has to happen somewhere in Servant or the lower layers. Both Texts print out nicely with an `=` sign if I just print them to stdout. Google does not find `!D(MISSING)` anywhere. Any idea what could possibly be the problem here? Best Jan -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at mhilbig.de Sat Jan 14 03:55:17 2017 From: lists at mhilbig.de (Martin Hilbig) Date: Sat, 14 Jan 2017 04:55:17 +0100 Subject: [Haskell-cafe] module is a package module error In-Reply-To: <20170112161656.GA19533@rhea> References: <20170112161656.GA19533@rhea> Message-ID: <661cdd22-0acd-734c-2ed6-1d80f5983966@mhilbig.de> hi, i got it to OK by removing your 'loadModules ["Internal"]' line. i think this works, because you imported Internal in your Main module and set it as Import. but you might want to check up on loadModules description at [1]. is the Internal module's source file available when you compile your Main module or will it be provided during run-time? in the latter case you will need the loadModules call, but shouldn't import the module. have fun martin [1]:https://hackage.haskell.org/package/hint-0.6.0/docs/Language-Haskell-Interpreter.html#v:loadModules On 12.01.2017 17:16, Lana Black wrote: > Hi, > > I'm trying to use hint [1] to compile in runtime externally supplied > haskell code. The compiled code must have certain modules imported. The > problem is that I'm getting this error when loading modules > >> WontCompile [GhcError {errMsg = ": error: module >> \8216Internal\8217 is a package module"}] > > I'm not really sure what to do with this. One way to fix this is to move > Internal to a separate package so that hint could load it through cabal, > but that's something I'd like to avoid. Is there any way I could make hint > use the same modules from the package it's being called from? The code > is located at [2]. > > [1]: http://hackage.haskell.org/package/hint > [2]: https://github.com/greydot/hint-test/ > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. > From lists at mhilbig.de Sat Jan 14 04:09:46 2017 From: lists at mhilbig.de (Martin Hilbig) Date: Sat, 14 Jan 2017 05:09:46 +0100 Subject: [Haskell-cafe] module is a package module error In-Reply-To: <661cdd22-0acd-734c-2ed6-1d80f5983966@mhilbig.de> References: <20170112161656.GA19533@rhea> <661cdd22-0acd-734c-2ed6-1d80f5983966@mhilbig.de> Message-ID: meh, i got confused with my different tests and not using cabal clean. add this paragraph to your hint-test.cabal: library hs-source-dirs: src default-language: Haskell2010 Exposed-Modules: Internal remove 'import Internal' (or not) remove 'loadModules ["Internal"]' enjoy. i think the error meant to say, this module source file you are trying to load is already part of a package, which would be bad if loaded twice. and since it's part of your package, you dont need to load it, just import it. On 14.01.2017 04:55, Martin Hilbig wrote: > hi, > > i got it to OK by removing your 'loadModules ["Internal"]' line. > > i think this works, because you imported Internal in your Main module > and set it as Import. > > but you might want to check up on loadModules description at [1]. > > is the Internal module's source file available when you compile your > Main module or will it be provided during run-time? in the latter case > you will need the loadModules call, but shouldn't import the module. > > have fun > martin > > [1]:https://hackage.haskell.org/package/hint-0.6.0/docs/Language-Haskell-Interpreter.html#v:loadModules > > On 12.01.2017 17:16, Lana Black wrote: >> Hi, >> >> I'm trying to use hint [1] to compile in runtime externally supplied >> haskell code. The compiled code must have certain modules imported. The >> problem is that I'm getting this error when loading modules >> >>> WontCompile [GhcError {errMsg = ": error: module >>> \8216Internal\8217 is a package module"}] >> >> I'm not really sure what to do with this. One way to fix this is to move >> Internal to a separate package so that hint could load it through cabal, >> but that's something I'd like to avoid. Is there any way I could make hint >> use the same modules from the package it's being called from? The code >> is located at [2]. >> >> [1]: http://hackage.haskell.org/package/hint >> [2]: https://github.com/greydot/hint-test/ >> _______________________________________________ >> Haskell-Cafe mailing list >> To (un)subscribe, modify options or view archives go to: >> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe >> Only members subscribed via the mailman list are allowed to post. >> > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. > From dominic at steinitz.org Sat Jan 14 08:45:36 2017 From: dominic at steinitz.org (dominic at steinitz.org) Date: Sat, 14 Jan 2017 08:45:36 +0000 Subject: [Haskell-cafe] Calling Haskell from C In-Reply-To: References: <22C8390C-EE0D-4244-A8D6-A0FD22AC8DFE@steinitz.org> Message-ID: <4326526F-40AA-4BD0-9297-A57B36D17A30@steinitz.org> Apologies. I put the output of “-l” (not “-L”) here: https://gist.github.com/idontgetoutmuch/654007ac57e863a293b76a0cf98250c1 I couldn’t immediately see anything that tells me how @rpath is resolved. > On 13 Jan 2017, at 17:46, Brandon Allbery wrote: > > On Fri, Jan 13, 2017 at 12:35 PM, > wrote: >> >> $ otool -L a.out > > I said "-l". "-L" shows how it resolves shared objects; "-l" dumps the load commands table, which includes RPATH entries that tell it how to resolve @rpath. >> DYLD_FALLBACK_LIBRARY_PATH=/Users/dom/Library/Haskell/ghc-8.0.1/lib/test-via-c-0.1.0.0/bin:/Library/Frameworks/GHC.framework/Versions/8.0.1-x86_64/usr/lib/ghc-8.0.1/rts >> ~/Dropbox/Private/TestU01-1.2.3/examples/src $ ./a.out > > This is odd, unless Apple changed things yet again (I should not be surprised, the loader stuff is about as stable as water /o\ ) > > It’s not clear to me why it’s looking for `gcc/5` which is not installed when it looks as though it should be looking for `gcc/6`. > > That might be indicated by the RPATH entries, since DYLD_FALLBACK_LIBRARY_PATH changes how lookups work (so does DYLD_LIBRARY_PATH, in a different way, which is why it's dangerous). > > -- > brandon s allbery kf8nh sine nomine associates > allbery.b at gmail.com ballbery at sinenomine.net > unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net Dominic Steinitz dominic at steinitz.org http://idontgetoutmuch.wordpress.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From dominic at steinitz.org Sat Jan 14 08:46:59 2017 From: dominic at steinitz.org (dominic at steinitz.org) Date: Sat, 14 Jan 2017 08:46:59 +0000 Subject: [Haskell-cafe] Calling Haskell from C In-Reply-To: References: Message-ID: <81143746-2D23-4881-B873-43A1E38FB9EE@steinitz.org> That does look useful. I think I won’t complicate my environment even more with an experimental version of cabal but I look forward to its release. > On 13 Jan 2017, at 18:29, Auke Booij wrote: > > The development version of cabal has support for building dynamic objects. See: > https://github.com/haskell/cabal/blob/master/Cabal/doc/developing-packages.rst#foreign-libraries > > On 13 January 2017 at 10:59, Dominic Steinitz wrote: >> I've been trying to get the example in >> https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/ffi-chap.html?highlight=foreign#using-foreign-export-and-foreign-import-ccall-wrapper-with-ghc >> working. >> >> I have a cabal file >> >> name: test-via-c >> version: 0.1.0.0 >> homepage: TBD >> license: MIT >> author: Dominic Steinitz >> maintainer: idontgetoutmuch at gmail.com >> category: System >> build-type: Simple >> cabal-version: >=1.10 >> >> executable Foo.dylib >> main-is: Foo.hs >> other-extensions: ForeignFunctionInterface >> build-depends: base >=4.7 && <4.10, >> primitive >=0.6 && <0.7 >> hs-source-dirs: src >> default-language: Haskell2010 >> include-dirs: src >> ghc-options: -O2 -shared -fPIC -dynamic >> extra-libraries: HSrts-ghc8.0.1 >> >> which installs >> >> /Users/dom/Library/Haskell/ghc-8.0.1/lib/test-via-c-0.1.0.0/bin/Foo.dylib >> >> I then compile the C with >> >> gcc-6 Bar.c >> /Users/dom/Library/Haskell/ghc-8.0.1/lib/test-via-c-0.1.0.0/bin/Foo.dylib >> -I/Library/Frameworks/GHC.framework/Versions/8.0.1-x86_64/usr/lib/ghc-8.0.1/include >> -L/Library/Frameworks/GHC.framework/Versions/8.0.1-x86_64/usr/lib/ghc-8.0.1/rts >> -lHSrts-ghc8.0.1 >> >> Sadly when I try to run the executable I get >> >> ~/Dropbox/Private/TestU01-1.2.3/examples/src $ ./a.out >> dyld: Library not loaded: @rpath/Foo.dylib >> Referenced from: >> /Users/dom/Dropbox/Private/TestU01-1.2.3/examples/src/./a.out >> Reason: image not found >> Trace/BPT trap: 5 >> >> I am guessing the executable is looking for the dynamic library. I >> copied Foo.dylib to the current directory but still get the same >> error. >> >> I know this is really an OS X question but I am hoping someone who has >> done before will be able to help. >> >> Dominic Steinitz >> dominic at steinitz.org >> http://idontgetoutmuch.wordpress.com >> >> >> _______________________________________________ >> Haskell-Cafe mailing list >> To (un)subscribe, modify options or view archives go to: >> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe >> Only members subscribed via the mailman list are allowed to post. Dominic Steinitz dominic at steinitz.org http://idontgetoutmuch.wordpress.com From erkokl at gmail.com Sat Jan 14 09:10:20 2017 From: erkokl at gmail.com (Levent Erkok) Date: Sat, 14 Jan 2017 01:10:20 -0800 Subject: [Haskell-cafe] [ANN] FloatingHex: Hexadecimal floats (quasiquoter and pretty-printer) Message-ID: FloatingHex (http://hackage.haskell.org/package/FloatingHex) is a simple package that implement hexadecimal notation for floating point numbers, as described in p57-58 of http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf The package provides a quasi-quoter for hexadecimal floats: hf, and a pretty-printer for floats to show them in this notation: showFFloat. (Note that the latter is not 100% compatible with C's %a modifier for printf, but it does render a faithful representation of its input.) Hex-floats are useful as they allow writing floating-point constants without any loss of precision, while remaining human readable. For instance, the float 2 is written as 0x1p1. (With the quasiquoter, the syntax is [hf|0x1p1|].) This representation is to be preferred over decimal rendering where loss of precision can be a problem: Note that not all floating point numbers have a terminating decimal representation as currently required by the Haskell syntax. It would be nice if Haskell itself allowed for such literals in the language specs itself, following the recent changes to other language standards. (Again, see p57-58 of http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf for the new C standard.) In the mean time, I hope FloatingHex library will provide a workaround for the numerophilias amongst us. Bug reports and improvements always welcome! Cheers, -Levent. -------------- next part -------------- An HTML attachment was scrubbed... URL: From lanablack at amok.cc Sat Jan 14 11:12:39 2017 From: lanablack at amok.cc (Lana Black) Date: Sat, 14 Jan 2017 11:12:39 +0000 Subject: [Haskell-cafe] module is a package module error In-Reply-To: References: <20170112161656.GA19533@rhea> <661cdd22-0acd-734c-2ed6-1d80f5983966@mhilbig.de> Message-ID: <20170114111239.GA29492@rhea> On 05:09 Sat 14 Jan , Martin Hilbig wrote: > meh, i got confused with my different tests and not using cabal clean. > > add this paragraph to your hint-test.cabal: > > library > hs-source-dirs: src > default-language: Haskell2010 > Exposed-Modules: Internal > > remove 'import Internal' (or not) > remove 'loadModules ["Internal"]' > enjoy. > > i think the error meant to say, this module source file you are trying > to load is already part of a package, which would be bad if loaded twice. > > and since it's part of your package, you dont need to load it, just > import it. > > On 14.01.2017 04:55, Martin Hilbig wrote: > > hi, > > > > i got it to OK by removing your 'loadModules ["Internal"]' line. > > > > i think this works, because you imported Internal in your Main module > > and set it as Import. > > > > but you might want to check up on loadModules description at [1]. > > > > is the Internal module's source file available when you compile your > > Main module or will it be provided during run-time? in the latter case > > you will need the loadModules call, but shouldn't import the module. > > > > have fun > > martin > > > > [1]:https://hackage.haskell.org/package/hint-0.6.0/docs/Language-Haskell-Interpreter.html#v:loadModules > > Unfortunately, this will not work because what I'm actually working on is a library, and cabal doesn't allow for having multiple libraries in a single project. Anyway, I have solved the problem by moving Internal into a separate package and using stack to build the whole thing. Turned out to be the easiest solution. From allbery.b at gmail.com Sat Jan 14 12:48:58 2017 From: allbery.b at gmail.com (Brandon Allbery) Date: Sat, 14 Jan 2017 12:48:58 +0000 Subject: [Haskell-cafe] Calling Haskell from C In-Reply-To: <4326526F-40AA-4BD0-9297-A57B36D17A30@steinitz.org> References: <22C8390C-EE0D-4244-A8D6-A0FD22AC8DFE@steinitz.org> <4326526F-40AA-4BD0-9297-A57B36D17A30@steinitz.org> Message-ID: On Sat, Jan 14, 2017 at 8:45 AM, wrote: > Apologies. I put the output of “-l” (not “-L”) here: > https://gist.github.com/idontgetoutmuch/654007ac57e863a293b76a0cf98250c1 > > I couldn’t immediately see anything that tells me how @rpath is resolved. > Hm, no RPATH entries indeed. There's no fallback for executables, so it's probably not even looking for the library but just failing immediately. You could probably make this work by forcing an RPATH entry (-Wl,-rpath,...). (Or, use "install_name_tool -add_rpath the_path_here a.out" to patch one into the existing binary.) -- 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 wiggly at wiggly.org Sat Jan 14 17:10:23 2017 From: wiggly at wiggly.org (Nigel Rantor) Date: Sat, 14 Jan 2017 17:10:23 +0000 Subject: [Haskell-cafe] Strange encoding issue with Text and Servant In-Reply-To: References: Message-ID: <9507e43e-8c2b-fdf3-73d1-9135c6cb2a49@wiggly.org> On 13/01/17 19:28, Jan von Löwenstein wrote: > Hi, > > I have got a two places with a `QueryParam "q" Text` and call it with a > Text that contains a `=` literal. In one place the `=` is correctly > encoded as %3D, in the other I see a `!D(MISSING)`. > > This has to happen somewhere in Servant or the lower layers. Both Texts > print out nicely with an `=` sign if I just print them to stdout. > > Google does not find `!D(MISSING)` anywhere. > > Any idea what could possibly be the problem here? It would be really useful to see exactly how you are 'calling' this. Do you have a curl command line or are you using some other client? n From jan.loewenstein at gmail.com Sat Jan 14 17:37:22 2017 From: jan.loewenstein at gmail.com (=?UTF-8?Q?Jan_von_L=C3=B6wenstein?=) Date: Sat, 14 Jan 2017 17:37:22 +0000 Subject: [Haskell-cafe] Strange encoding issue with Text and Servant In-Reply-To: <9507e43e-8c2b-fdf3-73d1-9135c6cb2a49@wiggly.org> References: <9507e43e-8c2b-fdf3-73d1-9135c6cb2a49@wiggly.org> Message-ID: Oh, it happens with servant on the client side. I use a swagger-codegen generated servant based client to access kubernetes. Calling https://github.com/soundcloud/haskell-kubernetes/blob/master/lib/Kubernetes/Api/ApivApi.hs#L475 works Calling https://github.com/soundcloud/haskell-kubernetes/blob/master/lib/Kubernetes/Api/ApivApi.hs#L473 doesn't. >From what I see the `QueryParam "labelSelector" Text` is the same in both. Logging the value gives the literal `=` as expected. Logging the (http-client) requests shows the difference. Best Jan Nigel Rantor schrieb am Sa., 14. Jan. 2017 um 18:11 Uhr: > On 13/01/17 19:28, Jan von Löwenstein wrote: > > Hi, > > > > I have got a two places with a `QueryParam "q" Text` and call it with a > > Text that contains a `=` literal. In one place the `=` is correctly > > encoded as %3D, in the other I see a `!D(MISSING)`. > > > > This has to happen somewhere in Servant or the lower layers. Both Texts > > print out nicely with an `=` sign if I just print them to stdout. > > > > Google does not find `!D(MISSING)` anywhere. > > > > Any idea what could possibly be the problem here? > > It would be really useful to see exactly how you are 'calling' this. > > Do you have a curl command line or are you using some other client? > > n > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. -------------- next part -------------- An HTML attachment was scrubbed... URL: From wiggly at wiggly.org Sat Jan 14 18:47:02 2017 From: wiggly at wiggly.org (Nigel Rantor) Date: Sat, 14 Jan 2017 18:47:02 +0000 Subject: [Haskell-cafe] Strange encoding issue with Text and Servant In-Reply-To: References: <9507e43e-8c2b-fdf3-73d1-9135c6cb2a49@wiggly.org> Message-ID: On 14/01/17 17:37, Jan von Löwenstein wrote: > Oh, it happens with servant on the client side. > > I use a swagger-codegen generated servant based client to access kubernetes. > Calling https://github.com/soundcloud/haskell-kubernetes/blob/master/lib/Kubernetes/Api/ApivApi.hs#L475 works > Calling https://github.com/soundcloud/haskell-kubernetes/blob/master/lib/Kubernetes/Api/ApivApi.hs#L473 doesn't. > > From what I see the `QueryParam"labelSelector" Text`is the same in both. > > Logging the value gives the literal `=` as expected. Logging the > (http-client) requests shows the difference. So I went ahead and wrote a simple client by hand and when I call the two functions on a local endpoint that shows me the request URL I get the following. Same arguments for 'pretty' and 'labelSelector' in both cases. Code: runListSecret :: Manager -> BaseUrl -> ClientM SecretList runListSecret manager baseUrl = listSecret (Just "prettyArg") (Just "=") Nothing Nothing Nothing Nothing manager baseUrl runListService :: Manager -> BaseUrl -> ClientM ServiceList runListService manager baseUrl = listService (Just "prettyArg") (Just "=") Nothing Nothing Nothing Nothing manager baseUrl Server log: 127.0.0.1 - - [14/Jan/2017:18:39:49 +0000] "GET /api/v1/secrets?pretty=prettyArg&labelSelector=%3D HTTP/1.1" 404 - 0.0003 127.0.0.1 - - [14/Jan/2017:18:39:49 +0000] "GET /api/v1/services?pretty=prettyArg&labelSelector=%3D HTTP/1.1" 404 - 0.0003 I haven't used swagger-codegen but the servant-client code works for me so I would look more into that. Swagger codegen looks like it might take me a while to get my head into so maybe you could look at the generated code, or sling it to me here or directly. The two calls are so similar that I can't see why the generated client would behave differently in those cases. Regards, n > Best > Jan > > Nigel Rantor > schrieb am > Sa., 14. Jan. 2017 um 18:11 Uhr: > > On 13/01/17 19:28, Jan von Löwenstein wrote: > > Hi, > > > > I have got a two places with a `QueryParam "q" Text` and call it > with a > > Text that contains a `=` literal. In one place the `=` is correctly > > encoded as %3D, in the other I see a `!D(MISSING)`. > > > > This has to happen somewhere in Servant or the lower layers. Both > Texts > > print out nicely with an `=` sign if I just print them to stdout. > > > > Google does not find `!D(MISSING)` anywhere. > > > > Any idea what could possibly be the problem here? > > It would be really useful to see exactly how you are 'calling' this. > > Do you have a curl command line or are you using some other client? > > n > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. > From dct25-561bs at mythic-beasts.com Sat Jan 14 19:07:59 2017 From: dct25-561bs at mythic-beasts.com (David Turner) Date: Sat, 14 Jan 2017 19:07:59 +0000 Subject: [Haskell-cafe] Strange encoding issue with Text and Servant In-Reply-To: References: <9507e43e-8c2b-fdf3-73d1-9135c6cb2a49@wiggly.org> Message-ID: Grasping at straws a little bit here, but can you (a) do a packet capture (e.g. `tcpdump -X`) to see what's going back and forth on the wire, just to make absolutely sure all of the oddness is on the client's end? A string like `!D(MISSING)` sorta looks like a decoding error so perhaps it will be instructive to look at the bytes on the wire it's trying to decode, although I can't think what could be confused with an equals sign. It's not like that blooming Greek question mark ( http://www.fileformat.info/info/unicode/char/037e/index.htm). Cheers, On 14 January 2017 at 18:47, Nigel Rantor wrote: > On 14/01/17 17:37, Jan von Löwenstein wrote: > >> Oh, it happens with servant on the client side. >> >> I use a swagger-codegen generated servant based client to access >> kubernetes. >> Calling https://github.com/soundcloud/haskell-kubernetes/blob/master >> /lib/Kubernetes/Api/ApivApi.hs#L475 works >> Calling https://github.com/soundcloud/haskell-kubernetes/blob/master >> /lib/Kubernetes/Api/ApivApi.hs#L473 doesn't. >> >> From what I see the `QueryParam"labelSelector" Text`is the same in both. >> >> Logging the value gives the literal `=` as expected. Logging the >> (http-client) requests shows the difference. >> > > So I went ahead and wrote a simple client by hand and when I call the two > functions on a local endpoint that shows me the request URL I get the > following. > > Same arguments for 'pretty' and 'labelSelector' in both cases. > > Code: > > runListSecret :: Manager -> BaseUrl -> ClientM SecretList > > runListSecret manager baseUrl = listSecret (Just "prettyArg") (Just "=") > Nothing Nothing Nothing Nothing manager baseUrl > > > > runListService :: Manager -> BaseUrl -> ClientM ServiceList > > runListService manager baseUrl = listService (Just "prettyArg") (Just "=") > Nothing Nothing Nothing Nothing manager baseUrl > > Server log: > > 127.0.0.1 - - [14/Jan/2017:18:39:49 +0000] "GET > /api/v1/secrets?pretty=prettyArg&labelSelector=%3D HTTP/1.1" 404 - 0.0003 > 127.0.0.1 - - [14/Jan/2017:18:39:49 +0000] "GET > /api/v1/services?pretty=prettyArg&labelSelector=%3D HTTP/1.1" 404 - 0.0003 > > I haven't used swagger-codegen but the servant-client code works for me so > I would look more into that. > > Swagger codegen looks like it might take me a while to get my head into so > maybe you could look at the generated code, or sling it to me here or > directly. > > The two calls are so similar that I can't see why the generated client > would behave differently in those cases. > > Regards, > > n > > Best >> Jan >> >> Nigel Rantor > schrieb am >> >> Sa., 14. Jan. 2017 um 18:11 Uhr: >> >> On 13/01/17 19:28, Jan von Löwenstein wrote: >> > Hi, >> > >> > I have got a two places with a `QueryParam "q" Text` and call it >> with a >> > Text that contains a `=` literal. In one place the `=` is correctly >> > encoded as %3D, in the other I see a `!D(MISSING)`. >> > >> > This has to happen somewhere in Servant or the lower layers. Both >> Texts >> > print out nicely with an `=` sign if I just print them to stdout. >> > >> > Google does not find `!D(MISSING)` anywhere. >> > >> > Any idea what could possibly be the problem here? >> >> It would be really useful to see exactly how you are 'calling' this. >> >> Do you have a curl command line or are you using some other client? >> >> n >> >> _______________________________________________ >> Haskell-Cafe mailing list >> To (un)subscribe, modify options or view archives go to: >> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe >> Only members subscribed via the mailman list are allowed to post. >> >> > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jan.loewenstein at gmail.com Sat Jan 14 19:48:24 2017 From: jan.loewenstein at gmail.com (=?UTF-8?Q?Jan_von_L=C3=B6wenstein?=) Date: Sat, 14 Jan 2017 19:48:24 +0000 Subject: [Haskell-cafe] Strange encoding issue with Text and Servant In-Reply-To: References: <9507e43e-8c2b-fdf3-73d1-9135c6cb2a49@wiggly.org> Message-ID: Actually the code I pointed at _is_ the swagger-codegen generated client. I have got a very small wrapper around it: ``` listService :: (MonadIO m, MonadCatch m, MonadReader Config m, MonadLog Text m) => Text -> m ServiceList.ServiceList listService labelSelector = namespacedF $ \namespace -> Kube.listNamespacedService namespace Nothing (Just labelSelector) Nothing Nothing Nothing Nothing listSecret :: (MonadIO m, MonadThrow m, MonadReader Config m, MonadLog Text m) => Text -> m SecretList.SecretList listSecret labelSelector = namespacedF $ \namespace -> Kube.listNamespacedSecret namespace Nothing (Just labelSelector) Nothing Nothing Nothing Nothing namespacedF :: (MonadIO m, MonadThrow m, MonadReader Config m, MonadLog Text m) => NamespacedF model -> m model namespacedF f = do config <- ask result <- let baseUrl = apiEndpoint config tlsSettings = Base.tlsSettings baseUrl (credentials config) kubeNamespace = namespace config in do manager <- liftIO $ newManager $ (mkManagerSettings tlsSettings Nothing) { managerModifyRequest = \req -> return req { checkResponse = \req res -> do Text.IO.hPutStrLn stderr (Text.pack (show req)) responseMessage <- showResponse res Text.IO.hPutStrLn stderr responseMessage return () } } liftIO $ runExceptT $ f kubeNamespace manager baseUrl either throwM return result ``` I call them like: ``` do let Just agentId = ... selector = "agentId" <> "=" <> agentId logMessage $ "listSecret selector: '" <> selector <> "'" secretList <- listSecret selector ``` `logMessage` gives a literal equals sign in both cases. `Text.IO.hPutStrLn stderr (Text.pack (show req))` from namespacedF gives `%3D` and `%!D(MISSING)` depending on which function I call. >From what I understand this is definitely happening on the client side. Do you still think a tcpdump might be worth it? ``` listSecret selector: 'agentId=b49d4406-8020-44e6-7788-6f92d5c0e732' Request { host = "192.168.99.100" port = 8443 secure = True requestHeaders = [("Accept","application/json")] path = "/api/v1/namespaces/default/secrets" queryString = "?labelSelector=agentId%!D(MISSING)b49d4406-8020-44e6-7788-6f92d5c0e732" method = "GET" proxy = Nothing rawBody = False redirectCount = 10 responseTimeout = ResponseTimeoutDefault requestVersion = HTTP/1.1 } ``` ``` listService selector: 'agentId=24f99a4b-1682-44da-7ba4-dba935d107d2' Request { host = "192.168.99.100" port = 8443 secure = True requestHeaders = [("Accept","application/json")] path = "/api/v1/namespaces/default/services" queryString = "?labelSelector=agentId%3D24f99a4b-1682-44da-7ba4-dba935d107d2" method = "GET" proxy = Nothing rawBody = False redirectCount = 10 responseTimeout = ResponseTimeoutDefault requestVersion = HTTP/1.1 } ``` Thanks for the time you already invested. I am completely puzzled because I see no chance how the code could behave as it does. (From my experience that points out I am looking at the wrong place ;) ) Best Jan David Turner schrieb am Sa., 14. Jan. 2017 um 20:08 Uhr: > Grasping at straws a little bit here, but can you (a) do a packet capture > (e.g. `tcpdump -X`) to see what's going back and forth on the wire, just to > make absolutely sure all of the oddness is on the client's end? > > A string like `!D(MISSING)` sorta looks like a decoding error so perhaps > it will be instructive to look at the bytes on the wire it's trying to > decode, although I can't think what could be confused with an equals sign. > It's not like that blooming Greek question mark ( > http://www.fileformat.info/info/unicode/char/037e/index.htm). > > Cheers, > > > > > On 14 January 2017 at 18:47, Nigel Rantor wrote: > > On 14/01/17 17:37, Jan von Löwenstein wrote: > > Oh, it happens with servant on the client side. > > I use a swagger-codegen generated servant based client to access > kubernetes. > Calling > https://github.com/soundcloud/haskell-kubernetes/blob/master/lib/Kubernetes/Api/ApivApi.hs#L475 > works > Calling > https://github.com/soundcloud/haskell-kubernetes/blob/master/lib/Kubernetes/Api/ApivApi.hs#L473 > doesn't. > > From what I see the `QueryParam"labelSelector" Text`is the same in both. > > Logging the value gives the literal `=` as expected. Logging the > (http-client) requests shows the difference. > > > So I went ahead and wrote a simple client by hand and when I call the two > functions on a local endpoint that shows me the request URL I get the > following. > > Same arguments for 'pretty' and 'labelSelector' in both cases. > > Code: > > runListSecret :: Manager -> BaseUrl -> ClientM SecretList > > runListSecret manager baseUrl = listSecret (Just "prettyArg") (Just "=") > Nothing Nothing Nothing Nothing manager baseUrl > > > > runListService :: Manager -> BaseUrl -> ClientM ServiceList > > runListService manager baseUrl = listService (Just "prettyArg") (Just "=") > Nothing Nothing Nothing Nothing manager baseUrl > > Server log: > > 127.0.0.1 - - [14/Jan/2017:18:39:49 +0000] "GET > /api/v1/secrets?pretty=prettyArg&labelSelector=%3D HTTP/1.1" 404 - 0.0003 > 127.0.0.1 - - [14/Jan/2017:18:39:49 +0000] "GET > /api/v1/services?pretty=prettyArg&labelSelector=%3D HTTP/1.1" 404 - 0.0003 > > I haven't used swagger-codegen but the servant-client code works for me so > I would look more into that. > > Swagger codegen looks like it might take me a while to get my head into so > maybe you could look at the generated code, or sling it to me here or > directly. > > The two calls are so similar that I can't see why the generated client > would behave differently in those cases. > > Regards, > > n > > Best > Jan > > Nigel Rantor > schrieb am > > Sa., 14. Jan. 2017 um 18:11 Uhr: > > On 13/01/17 19:28, Jan von Löwenstein wrote: > > Hi, > > > > I have got a two places with a `QueryParam "q" Text` and call it > with a > > Text that contains a `=` literal. In one place the `=` is correctly > > encoded as %3D, in the other I see a `!D(MISSING)`. > > > > This has to happen somewhere in Servant or the lower layers. Both > Texts > > print out nicely with an `=` sign if I just print them to stdout. > > > > Google does not find `!D(MISSING)` anywhere. > > > > Any idea what could possibly be the problem here? > > It would be really useful to see exactly how you are 'calling' this. > > Do you have a curl command line or are you using some other client? > > n > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. > > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dct25-561bs at mythic-beasts.com Sat Jan 14 20:00:21 2017 From: dct25-561bs at mythic-beasts.com (David Turner) Date: Sat, 14 Jan 2017 20:00:21 +0000 Subject: [Haskell-cafe] Strange encoding issue with Text and Servant In-Reply-To: References: <9507e43e-8c2b-fdf3-73d1-9135c6cb2a49@wiggly.org> Message-ID: Ok, so there's definitely a difference of some kind client-side. It'd be useful to see the network traffic nonetheless, as the source of the '!D(MISSING)' is still a bit of a mystery and you may see something suggestive in the raw bytes. I can't find the string 'MISSING' anywhere in servant or its dependencies, even looking in libs and binaries. Any chance of tracking its source down using `find` and `grep` and `strings`? On 14 Jan 2017 19:48, "Jan von Löwenstein" wrote: Actually the code I pointed at _is_ the swagger-codegen generated client. I have got a very small wrapper around it: ``` listService :: (MonadIO m, MonadCatch m, MonadReader Config m, MonadLog Text m) => Text -> m ServiceList.ServiceList listService labelSelector = namespacedF $ \namespace -> Kube.listNamespacedService namespace Nothing (Just labelSelector) Nothing Nothing Nothing Nothing listSecret :: (MonadIO m, MonadThrow m, MonadReader Config m, MonadLog Text m) => Text -> m SecretList.SecretList listSecret labelSelector = namespacedF $ \namespace -> Kube.listNamespacedSecret namespace Nothing (Just labelSelector) Nothing Nothing Nothing Nothing namespacedF :: (MonadIO m, MonadThrow m, MonadReader Config m, MonadLog Text m) => NamespacedF model -> m model namespacedF f = do config <- ask result <- let baseUrl = apiEndpoint config tlsSettings = Base.tlsSettings baseUrl (credentials config) kubeNamespace = namespace config in do manager <- liftIO $ newManager $ (mkManagerSettings tlsSettings Nothing) { managerModifyRequest = \req -> return req { checkResponse = \req res -> do Text.IO.hPutStrLn stderr (Text.pack (show req)) responseMessage <- showResponse res Text.IO.hPutStrLn stderr responseMessage return () } } liftIO $ runExceptT $ f kubeNamespace manager baseUrl either throwM return result ``` I call them like: ``` do let Just agentId = ... selector = "agentId" <> "=" <> agentId logMessage $ "listSecret selector: '" <> selector <> "'" secretList <- listSecret selector ``` `logMessage` gives a literal equals sign in both cases. `Text.IO.hPutStrLn stderr (Text.pack (show req))` from namespacedF gives `%3D` and `%!D(MISSING)` depending on which function I call. >From what I understand this is definitely happening on the client side. Do you still think a tcpdump might be worth it? ``` listSecret selector: 'agentId=b49d4406-8020-44e6-7788-6f92d5c0e732' Request { host = "192.168.99.100" port = 8443 secure = True requestHeaders = [("Accept","application/json")] path = "/api/v1/namespaces/default/secrets" queryString = "?labelSelector=agentId%!D( MISSING)b49d4406-8020-44e6-7788-6f92d5c0e732" method = "GET" proxy = Nothing rawBody = False redirectCount = 10 responseTimeout = ResponseTimeoutDefault requestVersion = HTTP/1.1 } ``` ``` listService selector: 'agentId=24f99a4b-1682-44da-7ba4-dba935d107d2' Request { host = "192.168.99.100" port = 8443 secure = True requestHeaders = [("Accept","application/json")] path = "/api/v1/namespaces/default/services" queryString = "?labelSelector=agentId%3D24f99a4b-1682-44da-7ba4- dba935d107d2" method = "GET" proxy = Nothing rawBody = False redirectCount = 10 responseTimeout = ResponseTimeoutDefault requestVersion = HTTP/1.1 } ``` Thanks for the time you already invested. I am completely puzzled because I see no chance how the code could behave as it does. (From my experience that points out I am looking at the wrong place ;) ) Best Jan David Turner schrieb am Sa., 14. Jan. 2017 um 20:08 Uhr: > Grasping at straws a little bit here, but can you (a) do a packet capture > (e.g. `tcpdump -X`) to see what's going back and forth on the wire, just to > make absolutely sure all of the oddness is on the client's end? > > A string like `!D(MISSING)` sorta looks like a decoding error so perhaps > it will be instructive to look at the bytes on the wire it's trying to > decode, although I can't think what could be confused with an equals sign. > It's not like that blooming Greek question mark ( > http://www.fileformat.info/info/unicode/char/037e/index.htm). > > Cheers, > > > > > On 14 January 2017 at 18:47, Nigel Rantor wrote: > > On 14/01/17 17:37, Jan von Löwenstein wrote: > > Oh, it happens with servant on the client side. > > I use a swagger-codegen generated servant based client to access > kubernetes. > Calling https://github.com/soundcloud/haskell-kubernetes/blob/ > master/lib/Kubernetes/Api/ApivApi.hs#L475 works > Calling https://github.com/soundcloud/haskell-kubernetes/blob/ > master/lib/Kubernetes/Api/ApivApi.hs#L473 doesn't. > > From what I see the `QueryParam"labelSelector" Text`is the same in both. > > Logging the value gives the literal `=` as expected. Logging the > (http-client) requests shows the difference. > > > So I went ahead and wrote a simple client by hand and when I call the two > functions on a local endpoint that shows me the request URL I get the > following. > > Same arguments for 'pretty' and 'labelSelector' in both cases. > > Code: > > runListSecret :: Manager -> BaseUrl -> ClientM SecretList > > runListSecret manager baseUrl = listSecret (Just "prettyArg") (Just "=") > Nothing Nothing Nothing Nothing manager baseUrl > > > > runListService :: Manager -> BaseUrl -> ClientM ServiceList > > runListService manager baseUrl = listService (Just "prettyArg") (Just "=") > Nothing Nothing Nothing Nothing manager baseUrl > > Server log: > > 127.0.0.1 - - [14/Jan/2017:18:39:49 +0000] "GET /api/v1/secrets?pretty=prettyArg&labelSelector=%3D > HTTP/1.1" 404 - 0.0003 > 127.0.0.1 - - [14/Jan/2017:18:39:49 +0000] "GET /api/v1/services?pretty=prettyArg&labelSelector=%3D > HTTP/1.1" 404 - 0.0003 > > I haven't used swagger-codegen but the servant-client code works for me so > I would look more into that. > > Swagger codegen looks like it might take me a while to get my head into so > maybe you could look at the generated code, or sling it to me here or > directly. > > The two calls are so similar that I can't see why the generated client > would behave differently in those cases. > > Regards, > > n > > Best > Jan > > Nigel Rantor > schrieb am > > Sa., 14. Jan. 2017 um 18:11 Uhr: > > On 13/01/17 19:28, Jan von Löwenstein wrote: > > Hi, > > > > I have got a two places with a `QueryParam "q" Text` and call it > with a > > Text that contains a `=` literal. In one place the `=` is correctly > > encoded as %3D, in the other I see a `!D(MISSING)`. > > > > This has to happen somewhere in Servant or the lower layers. Both > Texts > > print out nicely with an `=` sign if I just print them to stdout. > > > > Google does not find `!D(MISSING)` anywhere. > > > > Any idea what could possibly be the problem here? > > It would be really useful to see exactly how you are 'calling' this. > > Do you have a curl command line or are you using some other client? > > n > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. > > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From wiggly at wiggly.org Sat Jan 14 20:34:16 2017 From: wiggly at wiggly.org (Nigel Rantor) Date: Sat, 14 Jan 2017 20:34:16 +0000 Subject: [Haskell-cafe] Strange encoding issue with Text and Servant In-Reply-To: References: <9507e43e-8c2b-fdf3-73d1-9135c6cb2a49@wiggly.org> Message-ID: So, yes, I think it is in your client code Could you call both of them with *exactly* the same input? i.e. create a single selector and call both of them with exactly that input? I just feel like this might be a really silly typo or something somewhere. Alternatively can you give us the code you're using so we can play with it? n On 14/01/17 19:48, Jan von Löwenstein wrote: > Actually the code I pointed at _is_ the swagger-codegen generated client. > > I have got a very small wrapper around it: > > ``` > listService :: (MonadIO m, MonadCatch m, MonadReader Config m, MonadLog > Text m) => > Text > -> m ServiceList.ServiceList > listService labelSelector = namespacedF $ \namespace -> > Kube.listNamespacedService namespace Nothing (Just labelSelector) > Nothing Nothing Nothing Nothing > > listSecret :: (MonadIO m, MonadThrow m, MonadReader Config m, MonadLog > Text m) => > Text > -> m SecretList.SecretList > listSecret labelSelector = namespacedF $ \namespace -> > Kube.listNamespacedSecret namespace Nothing (Just labelSelector) Nothing > Nothing Nothing Nothing > > namespacedF :: (MonadIO m, MonadThrow m, MonadReader Config m, MonadLog > Text m) => > NamespacedF model > -> m model > namespacedF f = do > config <- ask > result <- let > baseUrl = apiEndpoint config > tlsSettings = Base.tlsSettings baseUrl (credentials config) > kubeNamespace = namespace config > in do > manager <- liftIO $ newManager $ (mkManagerSettings tlsSettings > Nothing) > { > managerModifyRequest = \req -> > return req { > checkResponse = \req res -> do > Text.IO.hPutStrLn stderr > (Text.pack (show req)) > responseMessage <- > showResponse res > Text.IO.hPutStrLn stderr > responseMessage > return () > } > } > liftIO $ runExceptT $ f kubeNamespace manager baseUrl > either throwM return result > ``` > > I call them like: > ``` > do > let Just agentId = ... > selector = "agentId" <> "=" <> agentId > logMessage $ "listSecret selector: '" <> selector <> "'" > secretList <- listSecret selector > ``` > > `logMessage` gives a literal equals sign in both cases. > `Text.IO.hPutStrLn stderr (Text.pack (show req))` from namespacedF gives > `%3D` and `%!D(MISSING)` depending on which function I call. > > From what I understand this is definitely happening on the client side. > Do you still think a tcpdump might be worth it? > > ``` > listSecret selector: 'agentId=b49d4406-8020-44e6-7788-6f92d5c0e732' > Request { > host = "192.168.99.100" > port = 8443 > secure = True > requestHeaders = [("Accept","application/json")] > path = "/api/v1/namespaces/default/secrets" > queryString = > "?labelSelector=agentId%!D(MISSING)b49d4406-8020-44e6-7788-6f92d5c0e732" > method = "GET" > proxy = Nothing > rawBody = False > redirectCount = 10 > responseTimeout = ResponseTimeoutDefault > requestVersion = HTTP/1.1 > } > ``` > > ``` > listService selector: 'agentId=24f99a4b-1682-44da-7ba4-dba935d107d2' > Request { > host = "192.168.99.100" > port = 8443 > secure = True > requestHeaders = [("Accept","application/json")] > path = "/api/v1/namespaces/default/services" > queryString = > "?labelSelector=agentId%3D24f99a4b-1682-44da-7ba4-dba935d107d2" > method = "GET" > proxy = Nothing > rawBody = False > redirectCount = 10 > responseTimeout = ResponseTimeoutDefault > requestVersion = HTTP/1.1 > } > ``` > > Thanks for the time you already invested. I am completely puzzled > because I see no chance how the code could behave as it does. (From my > experience that points out I am looking at the wrong place ;) ) > > Best > Jan > > David Turner > schrieb am Sa., 14. Jan. 2017 um > 20:08 Uhr: > > Grasping at straws a little bit here, but can you (a) do a packet > capture (e.g. `tcpdump -X`) to see what's going back and forth on > the wire, just to make absolutely sure all of the oddness is on the > client's end? > > A string like `!D(MISSING)` sorta looks like a decoding error so > perhaps it will be instructive to look at the bytes on the wire it's > trying to decode, although I can't think what could be confused with > an equals sign. It's not like that blooming Greek question mark > (http://www.fileformat.info/info/unicode/char/037e/index.htm). > > Cheers, > > > > > On 14 January 2017 at 18:47, Nigel Rantor > wrote: > > On 14/01/17 17:37, Jan von Löwenstein wrote: > > Oh, it happens with servant on the client side. > > I use a swagger-codegen generated servant based client to > access kubernetes. > Calling > https://github.com/soundcloud/haskell-kubernetes/blob/master/lib/Kubernetes/Api/ApivApi.hs#L475 > works > Calling > https://github.com/soundcloud/haskell-kubernetes/blob/master/lib/Kubernetes/Api/ApivApi.hs#L473 > doesn't. > > From what I see the `QueryParam"labelSelector" Text`is the > same in both. > > Logging the value gives the literal `=` as expected. Logging the > (http-client) requests shows the difference. > > > So I went ahead and wrote a simple client by hand and when I > call the two functions on a local endpoint that shows me the > request URL I get the following. > > Same arguments for 'pretty' and 'labelSelector' in both cases. > > Code: > > runListSecret :: Manager -> BaseUrl -> ClientM SecretList > > runListSecret manager baseUrl = listSecret (Just "prettyArg") > (Just "=") Nothing Nothing Nothing Nothing manager baseUrl > > > > runListService :: Manager -> BaseUrl -> ClientM ServiceList > > runListService manager baseUrl = listService (Just "prettyArg") > (Just "=") Nothing Nothing Nothing Nothing manager baseUrl > > Server log: > > 127.0.0.1 - - [14/Jan/2017:18:39:49 +0000] "GET > /api/v1/secrets?pretty=prettyArg&labelSelector=%3D HTTP/1.1" 404 > - 0.0003 > 127.0.0.1 - - [14/Jan/2017:18:39:49 +0000] "GET > /api/v1/services?pretty=prettyArg&labelSelector=%3D HTTP/1.1" > 404 - 0.0003 > > I haven't used swagger-codegen but the servant-client code works > for me so I would look more into that. > > Swagger codegen looks like it might take me a while to get my > head into so maybe you could look at the generated code, or > sling it to me here or directly. > > The two calls are so similar that I can't see why the generated > client would behave differently in those cases. > > Regards, > > n > > Best > Jan > > Nigel Rantor > >> > schrieb am > > Sa., 14. Jan. 2017 um 18:11 Uhr: > > On 13/01/17 19:28, Jan von Löwenstein wrote: > > Hi, > > > > I have got a two places with a `QueryParam "q" Text` > and call it > with a > > Text that contains a `=` literal. In one place the `=` > is correctly > > encoded as %3D, in the other I see a `!D(MISSING)`. > > > > This has to happen somewhere in Servant or the lower > layers. Both > Texts > > print out nicely with an `=` sign if I just print them > to stdout. > > > > Google does not find `!D(MISSING)` anywhere. > > > > Any idea what could possibly be the problem here? > > It would be really useful to see exactly how you are > 'calling' this. > > Do you have a curl command line or are you using some > other client? > > n > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed > to post. > > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. > > From allbery.b at gmail.com Sat Jan 14 21:03:56 2017 From: allbery.b at gmail.com (Brandon Allbery) Date: Sat, 14 Jan 2017 21:03:56 +0000 Subject: [Haskell-cafe] Strange encoding issue with Text and Servant In-Reply-To: References: <9507e43e-8c2b-fdf3-73d1-9135c6cb2a49@wiggly.org> Message-ID: On Sat, Jan 14, 2017 at 8:34 PM, Nigel Rantor wrote: > So, yes, I think it is in your client code On very little evidence (mostly the ! prefix) I am wondering if the client is using an XML library and it's glitching for some reason. -- 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 wiggly at wiggly.org Sat Jan 14 21:13:31 2017 From: wiggly at wiggly.org (Nigel Rantor) Date: Sat, 14 Jan 2017 21:13:31 +0000 Subject: [Haskell-cafe] Strange encoding issue with Text and Servant In-Reply-To: References: <9507e43e-8c2b-fdf3-73d1-9135c6cb2a49@wiggly.org> Message-ID: <2c6e12cf-7ce7-ebae-428c-b9a1e8665c52@wiggly.org> On 14/01/17 21:03, Brandon Allbery wrote: > > On Sat, Jan 14, 2017 at 8:34 PM, Nigel Rantor > wrote: > > So, yes, I think it is in your client code > > > On very little evidence (mostly the ! prefix) I am wondering if the > client is using an XML library and it's glitching for some reason. These are query parameters within the URL that is being requested, I'm not sure why any particular content-type being used would have an effect here. Regards, n From erkokl at gmail.com Sat Jan 14 23:06:16 2017 From: erkokl at gmail.com (Levent Erkok) Date: Sat, 14 Jan 2017 15:06:16 -0800 Subject: [Haskell-cafe] [ANN] FloatingHex: Hexadecimal floats (quasiquoter and pretty-printer) In-Reply-To: References: Message-ID: Quick update: version 0.2 of FloatingHex is now on hackage ( http://hackage.haskell.org/package/FloatingHex) which fixes a few glitches and makes the pretty-printer compatible with C's %a modifier. This brings the support on par with that in C/C++. The quasi-quoter is called qf, and the pretty-printer is called showHFloat, following the naming of other float-printers already available. On Sat, Jan 14, 2017 at 1:10 AM, Levent Erkok wrote: > FloatingHex (http://hackage.haskell.org/package/FloatingHex) is a simple > package that implement hexadecimal notation for floating point numbers, as > described in p57-58 of http://www.open-std.org/ > jtc1/sc22/wg14/www/docs/n1256.pdf > > The package provides a quasi-quoter for hexadecimal floats: hf, and a > pretty-printer for floats to show them in this notation: showFFloat. (Note > that the latter is not 100% compatible with C's %a modifier for printf, but > it does render a faithful representation of its input.) > > Hex-floats are useful as they allow writing floating-point constants > without any loss of precision, while remaining human readable. For > instance, the float 2 is written as 0x1p1. (With the quasiquoter, the > syntax is [hf|0x1p1|].) This representation is to be preferred over decimal > rendering where loss of precision can be a problem: Note that not all > floating point numbers have a terminating decimal representation as > currently required by the Haskell syntax. > > It would be nice if Haskell itself allowed for such literals in the > language specs itself, following the recent changes to other language > standards. (Again, see p57-58 of http://www.open-std.org/ > jtc1/sc22/wg14/www/docs/n1256.pdf for the new C standard.) In the mean > time, I hope FloatingHex library will provide a workaround for > the numerophilias amongst us. > > Bug reports and improvements always welcome! > > Cheers, > > -Levent. > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From cred+haskell at begriffs.com Sun Jan 15 03:06:51 2017 From: cred+haskell at begriffs.com (Joe Nelson) Date: Sat, 14 Jan 2017 19:06:51 -0800 Subject: [Haskell-cafe] The design and use of QuickCheck Message-ID: <224606B8-51C1-4612-83C7-7717F4988394@begriffs.com> Hey Haskellers, I decided to learn more about QuickCheck because it seems useful, and after a two weeks of reading papers and trying experiments, I wrote about my findings. https://begriffs.com/posts/2017-01-14-design-use-quickcheck.html Hope you find the article useful. Cheers, Joe From danburton.email at gmail.com Sun Jan 15 07:57:39 2017 From: danburton.email at gmail.com (Dan Burton) Date: Sat, 14 Jan 2017 23:57:39 -0800 Subject: [Haskell-cafe] BayHac 2017 announcement Message-ID: I am pleased to announce that BayHac 2017 will be held at the Takt office in San Francisco on the weekend of Friday, April 7th thru Sunday, April 9th. BayHac is a Haskell hackathon weekend event for the San Francisco Bay Area and Silicon Valley. It will be a weekend of learning, hacking, and connecting with fellow Haskell enthusiasts. See the page for BayHac 2017 on the haskell.org wiki for details: https://wiki.haskell.org/BayHac2017 -- Dan Burton -------------- next part -------------- An HTML attachment was scrubbed... URL: From john at degoes.net Sun Jan 15 18:29:01 2017 From: john at degoes.net (John A. De Goes) Date: Sun, 15 Jan 2017 11:29:01 -0700 Subject: [Haskell-cafe] LambdaConf 2017 CFP Message-ID: The LambdaConf 2017 Call for Proposals (CFP) is open until the end of January: http://surveymonkey.com/r/lambdaconf-2017-cfp LambdaConf is an interdisciplinary functional programming conference held in the Mountain West, and seeks to bring together aspiring and practicing functional programmers, as well as researchers. Traditionally, the conference has had a very large amount of Haskell content (second only to Scala content in some years). The conference takes place May 25 - 27, in Boulder, Colorado, and is preceded by commercial training opportunities and a day of third-party mini-conferences on selected topics. If you are an educator, a researcher, a speaker, a speaker coach, or someone aspiring to one of the preceding, then we warmly welcome you to submit a proposal for LambdaConf 2017. All LambdaConf speakers receive free registration, an appreciation dinner, a special gift, accommodations for up to 4 nights (May 24 - May 28), and ample travel assistance based on need and availability. LambdaConf attracts everyone from the FP-curious to researchers; hobbyists and professionals; academics and commercial developers. Material at all levels, including beginner content and very advanced content, will find an audience at LambdaConf. LambdaConf welcomes the following kinds of proposals: Languages. Proposals that overview or dive into specific features of functional, math, or logic programming languages (both new and existing), with the goal of exposing developers to new ideas or helping them master features of languages they already know. Libraries. Proposals that discuss libraries that leverage functional or logic programming to help programmers solve real-world problems. Concepts. Proposals that discuss functional programming idioms, patterns, or abstractions; or concepts from mathematics, logic, and computer science, all directed at helping developers write software that's easier to test, easier to reason about, and easier to change safely. Aspects. Proposals that discuss how functional programming can help with specific aspects of modern software development, including scalability, distributed systems, concurrency, data processing, security, performance, correctness, user-interfaces, machine learning, and big data. Use Cases. Proposals that discuss how functional programming enabled a project or team to thrive, or deliver more business value than possible with other approaches. Cherry-Picking. Proposals that show how techniques and approaches from functional programming can be adapted and incorporated into mainstream development languages and practices, to the benefit of developers using them. Cracks. Proposals that call attention to difficulties of functional programming (both as a cautionary tale but also to raise awareness), especially such proposals that suggest alternatives or a path forward. Data. Proposals that present data, measurements, or analysis that suggests different techniques, paradigms, languages, libraries, concepts, or approaches have different efficacies for given specified metrics, which provide actionable takeaways to practicing functional and logic programmers. Off-Topic. Proposals that have appeal to a mainstream developer audience (the number of off-topic proposals we accept is small, but we do accept some, especially for keynotes). LambdaConf welcomes proposals for dynamic and static programming languages, category theoretic and otherwise, both functional and logic, or mainstream languages that can benefit from functional programming. Challengers and alternatives are also welcome. We are currently soliciting for the following session formats: Speaker Coaches. Speaker Coaches have extensive experience preparing material and giving polished, well-structured, educational, entertaining talks. Speaker Coaches review material and practice sessions for 5 - 10 speakers, & provide constructive feedback to speakers about how to improve the focus, content, & presentation of material. Coaches receive accommodations, free registration, & airfare reimbursement, & a 10 minute speaking slot (if interested). Leap Workshops. Leap Workshops take place on May 25, and are approximately 6 hours in length. They are in-depth, hands-on workshops designed to teach mainstream functional programming topics in enough detail, attendees can immediately apply what they learn in their jobs. Instructors for Leap Workshops receive accommodations, free registration, airfare reimbursement (including family), and a small stipend. If you are an author with a relevant book, we can also make it easy for attendees to purchase the book as part of registration for your workshop. Workshops must use a containerized cloud environment provided and paid for by LambdaConf. Hop Workshops. Hop Workshops are 2 hours in length. Like Leap Workshops, these workshops are in-depth and hands-on, but they cover reduced content and may be specialized to topics that may not have mainstream appeal. Guides receive accommodations, free registration, and travel assistance based on need and availability. Workshops must use a containerized cloud environment provided and paid for by LambdaConf. De Novo Sessions. De Novo Sessions are 1 hour in length. These sessions are designed to present original work from industry and academia. While the requirements for proposals are more rigorous, there is less competition for De Novo slots. Speakers receive accommodations, free registration, and travel assistance based on need and availability. Educational Sessions. Educational Sessions are 1 hour in length. These sessions are designed to clearly and concisely teach one useful concept, skill, aspect, library, or language to attendees. Teachers receive accommodations, free registration, and travel assistance based on need and availability. Inspire Talks. Inspire talks are 10 minutes in length and focus on clear communication of a single takeaway. These sessions are intended to inspire attendees to learn more about particular subjects or to try new approaches. Speakers receive accommodations, free registration, and travel assistance based on need and availability. Note: While only 10 minutes in length, we require a high-level of polish, structure, and rehearsal for Inspire Talks; despite shorter length, they are as much work to prepare for as other sessions. Keynotes. Keynotes are 40 minutes in length, and are presented before all attendees (there are no other sessions concurrent with keynotes). Keynotes are designed to offer thought-provoking, opinionated, and insightful commentary on topics of interest to the community. Keynotes have more latitude to stray from functional programming and into related areas such as computer science, mathematics, and science. Keynote speakers receive accommodations, free registration, and travel assistance based on need and availability. LambdaConf requires tailored content. This does not mean you cannot reuse existing content, only that you should incorporate updates into your material, respond to feedback from your speaker coach, and tailor the material to the LambdaConf audience as appropriate. Note: The Call for Proposals closes January 31. Submitters will be notified by March 1st at latest. -- John A. De Goes john at degoes.net Follow me on Twitter @jdegoes -------------- next part -------------- An HTML attachment was scrubbed... URL: From michael at schmong.org Sun Jan 15 19:06:04 2017 From: michael at schmong.org (Michael Litchard) Date: Sun, 15 Jan 2017 11:06:04 -0800 Subject: [Haskell-cafe] BayHac 2017 announcement In-Reply-To: References: Message-ID: Nice! On Sat, Jan 14, 2017 at 11:57 PM, Dan Burton wrote: > I am pleased to announce that BayHac 2017 will be held at the Takt office > in San Francisco on the weekend of Friday, April 7th thru Sunday, April 9th. > > BayHac is a Haskell hackathon weekend event for the San Francisco Bay Area > and Silicon Valley. It will be a weekend of learning, hacking, and > connecting with fellow Haskell enthusiasts. > > See the page for BayHac 2017 on the haskell.org wiki for details: > https://wiki.haskell.org/BayHac2017 > > -- Dan Burton > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dennis.raddle at gmail.com Sun Jan 15 20:37:37 2017 From: dennis.raddle at gmail.com (Dennis Raddle) Date: Sun, 15 Jan 2017 15:37:37 -0500 Subject: [Haskell-cafe] dynamic code compilation and loading Message-ID: Hello, I wrote a Haskell program which reads a MusicXML score and plays it through real-time MIDI messages (using the portmidi module) via some algorithms that are customized depending on the MIDI synthesizer that is receiving the messages. The program also plays back the music with musically expressive nuances. In the next version of this program, I am going to add more complicated algorithms for the expressive nuances, and it would be helpful to configure them and express them in actual Haskell code. My workflow will look like this: A. write a score using the music typesetting program Sibelius B. write some Haskell code to provide expressive nuances C. play the music through a MIDI synthesizer and listen. D. based on what I hear and where I want to take the music, modify the score and the Haskell code E. loop back to C Therefore, if I don't want to recompile the program each time I do step D, I need to compile and load code dynamically. Let's say that a data structure which contains a MusicXML score and a nominal rendition into MIDI messages together with time tags is of type Score. Then I want to write, and dynamically compile/load, a function vary :: Score -> Score which varies the MIDI messages and time tags to add expressive nuances. Let's say 'vary' is contained in Vary.hs. I want to write 'vary' in terms of already-compiled functions that provide the basic music-processing operations. Let's say that these functions are in the module MusicBase. Then Vary.hs will look like import MusicBase vary = ... operations in MusicBase ... Can I get some basic idea of how to do this? D -------------- next part -------------- An HTML attachment was scrubbed... URL: From allbery.b at gmail.com Sun Jan 15 20:44:04 2017 From: allbery.b at gmail.com (Brandon Allbery) Date: Sun, 15 Jan 2017 15:44:04 -0500 Subject: [Haskell-cafe] dynamic code compilation and loading In-Reply-To: References: Message-ID: On Sun, Jan 15, 2017 at 3:37 PM, Dennis Raddle wrote: > Therefore, if I don't want to recompile the program each time I do step D, > I need to compile and load code dynamically. Take a look at the hint and plugins packages. There's also the recompile/exec trick used by Dyre and xmonad that preserves a session across mostly-transparent recompiles. -- 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 jmartty at hotmail.com Sun Jan 15 23:31:18 2017 From: jmartty at hotmail.com (Juan Luis Martty) Date: Sun, 15 Jan 2017 23:31:18 +0000 Subject: [Haskell-cafe] Control.Parallel seemingly randomly behaviour In-Reply-To: References: Message-ID: Hello everyone, I'm having a consistency issue with the following piece of code: heavyAm = 500 lightAm = 1000 heavyCalc :: Int -> Int heavyCalc s = sum [1..1000000*s] parallel = (heavyCalc lightAm, heavyCalc heavyAm) `using` (parTuple2 rseq rseq) For some reason, during runtime the RTS sometimes parallelizes the evaluation and sometimes it doesn't. I'm running with all the RTS/compile time options correctly afaik. Here is the output from a couple of runs of the program: jmartty at walrus:~/hs/parallel$ stack build && time stack exec par-exe Warning: File listed in par.cabal file does not exist: README.md (500000000500000000,125000000250000000) Computation time: 1.557007s real 0m1.732s user 0m2.528s sys 0m0.464s jmartty at walrus:~/hs/parallel$ stack build && time stack exec par-exe Warning: File listed in par.cabal file does not exist: README.md (500000000500000000,125000000250000000) Computation time: 1.544837s real 0m1.720s user 0m2.544s sys 0m0.712s jmartty at walrus:~/hs/parallel$ stack build && time stack exec par-exe Warning: File listed in par.cabal file does not exist: README.md (500000000500000000,125000000250000000) Computation time: 2.316537s real 0m2.484s user 0m2.592s sys 0m0.680s jmartty at walrus:~/hs/parallel$ stack build && time stack exec par-exe Warning: File listed in par.cabal file does not exist: README.md (500000000500000000,125000000250000000) Computation time: 2.318514s real 0m2.489s user 0m2.612s sys 0m0.688s jmartty at walrus:~/hs/parallel$ stack build && time stack exec par-exe Warning: File listed in par.cabal file does not exist: README.md (500000000500000000,125000000250000000) Computation time: 1.544975s real 0m1.718s user 0m2.512s sys 0m0.456s As you can see, sometimes wall time roughly equals userspace time, sometimes it doesn't (meaning it parallelized at least some amount). I'm running on a dual core machine under Ubuntu using stack with lts-7.14 (GHC 8.0.1) and parallel-3.2.1.0. Regards, Juan -------------- next part -------------- An HTML attachment was scrubbed... URL: From heraldhoi at gmail.com Mon Jan 16 02:34:02 2017 From: heraldhoi at gmail.com (Geraldus) Date: Mon, 16 Jan 2017 02:34:02 +0000 Subject: [Haskell-cafe] Yesod devel issue: cannot satisfy -package-key main Message-ID: Hi folks! I haven't used Yesod quite a while; now when I'm trying to run development server of freshly scaffolded PostgreSQL stack's template I see this error message: Rebuilding application... (using cabal) Starting development server... *: cannot satisfy -package-key main* (use -v for more information) Exit code: ExitFailure 1 I've found several issues on the web, however I wasn't able to resolve this. I've tried to upgrade my Yesod binary first via `stack install yesod-bin`. Now I have: stack exec yesod version *yesod-bin version: 1.4.18.7* stack --version *Version 1.1.2 x86_64 hpack-0.14.0* I also tried to comment out the test suite section in cabal file, but devel server still fails to run. Can someone clarify how to deal with this? -------------- next part -------------- An HTML attachment was scrubbed... URL: From borgauf at gmail.com Mon Jan 16 04:42:20 2017 From: borgauf at gmail.com (Lawrence Bottorff) Date: Sun, 15 Jan 2017 23:42:20 -0500 Subject: [Haskell-cafe] Hyper-recursion? Message-ID: A while back I worked at an assessor's office, i.e., the people responsible for handling properties as land parcels. I was brought in to do GIS. One of the things we wanted was to get a sense of the history of land use, specifically how property changed hands, and especially how property lines changed due to properties either merging or being split up. That is to say, how the parcel map changed over time. Problematic was how the rugged old mainframe system (IBM AS/400 and a Cobol app) simply updated the data -- with no concept of remembering how things used to be. My GIS system (ESRI) also lacked any state memory -- other than simply snapshooting everything ad nauseum. Years later I become familiar with the world of functional programming. Somewhere in the functional paradigm, specifically recursion, would seem to be a model for this issue. That is, the whole issue of parcels changing through merges or splits might be a simple question of recursion. If functional is "beyond state," then changes in a map would only be stages, places in a never-ending outward-growing recursion. Seen as "infinite mirrors," one map change would simply be a mirror layer -- click on it to call it up. So in chapter 1 of any functional programming tutorial is the factorial calculation function done with recursion. We beginners see the recursion "going out" to the "last one," then "coming back," adding up the results of each stage as it returns . . . like a yo-yo winding out, then winding up again. But what I'm describing with changing parcels maps would seem to be a process that never comes out of recursion, rather, lives inside a "hyper-recursion." That is to say, an overarching recursion is the whole world. However, today's mentality would simply say, *Obviously, you want to save off each change you make to your parcel map *. . . again, the whole snapshot idea. This thinking is typical data management coupled, perhaps, with the human penchant to see things in terms of time and timelines. So, again, the standard solution would be to timestamp a parcel change and save it off, i.e., a "change" is a tick on the timeline, mark it, make note of it. But again, couldn't we see this whole issue of parcel changes as (using my yo-you analogy) just levels in what seems like a continual winding out -- which in a topological sense doesn't even need to be seen as geographical? This would seem to put the *process in a recursion,* rather than *recursion(s) in a process.* Haskell being the most pure functional language, is, hence, my starting point on this question. I'm a bright enough person, but I can't believe I'm the first person to notice this Alice in Wonderland situation. . . BTW, we could see a chess game in a similar light. . . . if not many, many other evolving phenomena of supposed (cumulative, consequential?) change. Thanks, Lawrence Bottorff -------------- next part -------------- An HTML attachment was scrubbed... URL: From michael at snoyman.com Mon Jan 16 05:52:42 2017 From: michael at snoyman.com (Michael Snoyman) Date: Mon, 16 Jan 2017 07:52:42 +0200 Subject: [Haskell-cafe] Yesod devel issue: cannot satisfy -package-key main In-Reply-To: References: Message-ID: Can you try upgrading to yesod-bin-1.5.0? Some of the issues with the old yesod-bin are documented at: http://www.yesodweb.com/blog/2016/11/new-yesod-devel-server Looking at that error message, I'm going to take a (very bad) guess and say you're using GHC 8. If that's the case, yesod-bin 1.4 is definitely _not_ compatible with it. On Mon, Jan 16, 2017 at 4:34 AM, Geraldus wrote: > Hi folks! > > I haven't used Yesod quite a while; now when I'm trying to run development > server of freshly scaffolded PostgreSQL stack's template I see this error > message: > > Rebuilding application... (using cabal) > Starting development server... > *: cannot satisfy -package-key main* > (use -v for more information) > Exit code: ExitFailure 1 > > > I've found several issues on the web, however I wasn't able to resolve > this. > > I've tried to upgrade my Yesod binary first via `stack install > yesod-bin`. Now > I have: > > stack exec yesod version > *yesod-bin version: 1.4.18.7* > > stack --version > *Version 1.1.2 x86_64 hpack-0.14.0* > > I also tried to comment out the test suite section in cabal file, but devel > server still fails to run. > > Can someone clarify how to deal with this? > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dct25-561bs at mythic-beasts.com Mon Jan 16 07:47:41 2017 From: dct25-561bs at mythic-beasts.com (David Turner) Date: Mon, 16 Jan 2017 07:47:41 +0000 Subject: [Haskell-cafe] Hyper-recursion? In-Reply-To: References: Message-ID: Hi Lawrence, I suspect you have stumbled onto the dual concept of corecursion: rather than starting from a complex structure and recursively consuming it until you reach a simple base case, you're starting from a simple base case and corecursively producing more complex ones. See also Event Sourcing. Best wishes, David On 16 Jan 2017 04:43, "Lawrence Bottorff" wrote: A while back I worked at an assessor's office, i.e., the people responsible for handling properties as land parcels. I was brought in to do GIS. One of the things we wanted was to get a sense of the history of land use, specifically how property changed hands, and especially how property lines changed due to properties either merging or being split up. That is to say, how the parcel map changed over time. Problematic was how the rugged old mainframe system (IBM AS/400 and a Cobol app) simply updated the data -- with no concept of remembering how things used to be. My GIS system (ESRI) also lacked any state memory -- other than simply snapshooting everything ad nauseum. Years later I become familiar with the world of functional programming. Somewhere in the functional paradigm, specifically recursion, would seem to be a model for this issue. That is, the whole issue of parcels changing through merges or splits might be a simple question of recursion. If functional is "beyond state," then changes in a map would only be stages, places in a never-ending outward-growing recursion. Seen as "infinite mirrors," one map change would simply be a mirror layer -- click on it to call it up. So in chapter 1 of any functional programming tutorial is the factorial calculation function done with recursion. We beginners see the recursion "going out" to the "last one," then "coming back," adding up the results of each stage as it returns . . . like a yo-yo winding out, then winding up again. But what I'm describing with changing parcels maps would seem to be a process that never comes out of recursion, rather, lives inside a "hyper-recursion." That is to say, an overarching recursion is the whole world. However, today's mentality would simply say, *Obviously, you want to save off each change you make to your parcel map *. . . again, the whole snapshot idea. This thinking is typical data management coupled, perhaps, with the human penchant to see things in terms of time and timelines. So, again, the standard solution would be to timestamp a parcel change and save it off, i.e., a "change" is a tick on the timeline, mark it, make note of it. But again, couldn't we see this whole issue of parcel changes as (using my yo-you analogy) just levels in what seems like a continual winding out -- which in a topological sense doesn't even need to be seen as geographical? This would seem to put the *process in a recursion,* rather than *recursion(s) in a process.* Haskell being the most pure functional language, is, hence, my starting point on this question. I'm a bright enough person, but I can't believe I'm the first person to notice this Alice in Wonderland situation. . . BTW, we could see a chess game in a similar light. . . . if not many, many other evolving phenomena of supposed (cumulative, consequential?) change. Thanks, Lawrence Bottorff _______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post. -------------- next part -------------- An HTML attachment was scrubbed... URL: From qdunkan at gmail.com Mon Jan 16 23:38:42 2017 From: qdunkan at gmail.com (Evan Laforge) Date: Mon, 16 Jan 2017 15:38:42 -0800 Subject: [Haskell-cafe] dynamic code compilation and loading In-Reply-To: References: Message-ID: I used to use hint for a somewhat similar situation (I wanted to give a REPL to my program, which incidentally is also concerned with interpreting music). I found that hint didn't give enough control (it wanted to reload everything on every expression, instead of only reloading when I told it to) and it was too hard to dig through it's ghc compatibility layers, so I directly used the GHC API and it was a lot easier than expected. However, that's for inserting code into a running program. If you want to just run a function to transform a Score, couldn't you just load the support modules in ghci, and run the main function from there? Change the source, type :r, and type 'main' again. You could hook up your editor to that automatically on every save. By the way, I'm also interested in expressive score realization, since I'm doing something similar, though in my case I'm using a custom score format rather than staff notation. If you have anything to show off I'd be interested to see. On Sun, Jan 15, 2017 at 12:37 PM, Dennis Raddle wrote: > Hello, > I wrote a Haskell program which reads a MusicXML score and plays it through > real-time MIDI messages (using the portmidi module) via some algorithms that > are customized depending on the MIDI synthesizer that is receiving the > messages. The program also plays back the music with musically expressive > nuances. > > In the next version of this program, I am going to add more complicated > algorithms for the expressive nuances, and it would be helpful to configure > them and express them in actual Haskell code. My workflow will look like > this: > > A. write a score using the music typesetting program Sibelius > > B. write some Haskell code to provide expressive nuances > > C. play the music through a MIDI synthesizer and listen. > > D. based on what I hear and where I want to take the music, modify the score > and the Haskell code > > E. loop back to C > > Therefore, if I don't want to recompile the program each time I do step D, I > need to compile and load code dynamically. > > Let's say that a data structure which contains a MusicXML score and a > nominal rendition into MIDI messages together with time tags is of type > Score. Then I want to write, and dynamically compile/load, a function > > vary :: Score -> Score > > which varies the MIDI messages and time tags to add expressive nuances. > > Let's say 'vary' is contained in Vary.hs. > > I want to write 'vary' in terms of already-compiled functions that provide > the basic music-processing operations. Let's say that these functions are in > the module MusicBase. Then Vary.hs will look like > > import MusicBase > > vary = ... operations in MusicBase ... > > Can I get some basic idea of how to do this? > > D > > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. From david.feuer at gmail.com Tue Jan 17 00:01:20 2017 From: david.feuer at gmail.com (David Feuer) Date: Mon, 16 Jan 2017 19:01:20 -0500 Subject: [Haskell-cafe] Control.Parallel seemingly randomly behaviour In-Reply-To: References: Message-ID: Just to remove one variable: what happens if you run the same executable multiple times, rather than rebuilding it each time? On Jan 15, 2017 6:34 PM, "Juan Luis Martty" wrote: Hello everyone, I'm having a consistency issue with the following piece of code: heavyAm = 500 lightAm = 1000 heavyCalc :: Int -> Int heavyCalc s = sum [1..1000000*s] parallel = (heavyCalc lightAm, heavyCalc heavyAm) `using` (parTuple2 rseq rseq) For some reason, during runtime the RTS sometimes parallelizes the evaluation and sometimes it doesn't. I'm running with all the RTS/compile time options correctly afaik. Here is the output from a couple of runs of the program: jmartty at walrus:~/hs/parallel$ stack build && time stack exec par-exe Warning: File listed in par.cabal file does not exist: README.md (500000000500000000,125000000250000000) Computation time: 1.557007s real 0m1.732s user 0m2.528s sys 0m0.464s jmartty at walrus:~/hs/parallel$ stack build && time stack exec par-exe Warning: File listed in par.cabal file does not exist: README.md (500000000500000000,125000000250000000) Computation time: 1.544837s real 0m1.720s user 0m2.544s sys 0m0.712s jmartty at walrus:~/hs/parallel$ stack build && time stack exec par-exe Warning: File listed in par.cabal file does not exist: README.md (500000000500000000,125000000250000000) Computation time: 2.316537s real 0m2.484s user 0m2.592s sys 0m0.680s jmartty at walrus:~/hs/parallel$ stack build && time stack exec par-exe Warning: File listed in par.cabal file does not exist: README.md (500000000500000000,125000000250000000) Computation time: 2.318514s real 0m2.489s user 0m2.612s sys 0m0.688s jmartty at walrus:~/hs/parallel$ stack build && time stack exec par-exe Warning: File listed in par.cabal file does not exist: README.md (500000000500000000,125000000250000000) Computation time: 1.544975s real 0m1.718s user 0m2.512s sys 0m0.456s As you can see, sometimes wall time roughly equals userspace time, sometimes it doesn't (meaning it parallelized at least some amount). I'm running on a dual core machine under Ubuntu using stack with lts-7.14 (GHC 8.0.1) and parallel-3.2.1.0. Regards, Juan _______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post. -------------- next part -------------- An HTML attachment was scrubbed... URL: From david.feuer at gmail.com Tue Jan 17 00:02:47 2017 From: david.feuer at gmail.com (David Feuer) Date: Mon, 16 Jan 2017 19:02:47 -0500 Subject: [Haskell-cafe] Control.Parallel seemingly randomly behaviour In-Reply-To: References: Message-ID: Oh, and you should probably be passing your program an explicit +RTS option to tell it how many OS threads to use. On Jan 16, 2017 7:01 PM, "David Feuer" wrote: > Just to remove one variable: what happens if you run the same executable > multiple times, rather than rebuilding it each time? > > On Jan 15, 2017 6:34 PM, "Juan Luis Martty" wrote: > > Hello everyone, > > I'm having a consistency issue with the following piece of code: > > heavyAm = 500 > lightAm = 1000 > > heavyCalc :: Int -> Int > heavyCalc s = sum [1..1000000*s] > > parallel = (heavyCalc lightAm, heavyCalc heavyAm) `using` (parTuple2 rseq > rseq) > > For some reason, during runtime the RTS sometimes parallelizes the > evaluation and sometimes it doesn't. I'm running with all the RTS/compile > time options correctly afaik. Here is the output from a couple of runs of > the program: > > jmartty at walrus:~/hs/parallel$ stack build && time stack exec par-exe > Warning: File listed in par.cabal file does not exist: README.md > (500000000500000000,125000000250000000) > Computation time: 1.557007s > > real 0m1.732s > user 0m2.528s > sys 0m0.464s > jmartty at walrus:~/hs/parallel$ stack build && time stack exec par-exe > Warning: File listed in par.cabal file does not exist: README.md > (500000000500000000,125000000250000000) > Computation time: 1.544837s > > real 0m1.720s > user 0m2.544s > sys 0m0.712s > jmartty at walrus:~/hs/parallel$ stack build && time stack exec par-exe > Warning: File listed in par.cabal file does not exist: README.md > (500000000500000000,125000000250000000) > Computation time: 2.316537s > > real 0m2.484s > user 0m2.592s > sys 0m0.680s > jmartty at walrus:~/hs/parallel$ stack build && time stack exec par-exe > Warning: File listed in par.cabal file does not exist: README.md > (500000000500000000,125000000250000000) > Computation time: 2.318514s > > real 0m2.489s > user 0m2.612s > sys 0m0.688s > jmartty at walrus:~/hs/parallel$ stack build && time stack exec par-exe > Warning: File listed in par.cabal file does not exist: README.md > (500000000500000000,125000000250000000) > Computation time: 1.544975s > > real 0m1.718s > user 0m2.512s > sys 0m0.456s > > As you can see, sometimes wall time roughly equals userspace time, > sometimes it doesn't (meaning it parallelized at least some amount). I'm > running on a dual core machine under Ubuntu using stack with lts-7.14 (GHC > 8.0.1) and parallel-3.2.1.0. > > Regards, > Juan > > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From trebla at vex.net Tue Jan 17 01:54:58 2017 From: trebla at vex.net (Albert Y. C. Lai) Date: Mon, 16 Jan 2017 20:54:58 -0500 Subject: [Haskell-cafe] Hyper-recursion? In-Reply-To: References: Message-ID: There is an idea called "open recursion". Illustrating by Fibonacci (the direct but naively slow way) and factorial (the direct but naively slow way again, see http://www.luschny.de/math/factorial/FastFactorialFunctions.htm ): Instead of writing "fac x = x * fac (x-1)", we write: fac x = fac_essence fac x fac_essence f 0 = 0 fac_essence f x = x * f (x-1) And instead of writing "fib x = fib (x-1) + fib (x-2)", we write: fib x = fib_essence fib x fib_essence f 0 = 0 fib_essence f 1 = 1 fib_essence f x = f (x-1) + f (x-2) The general pattern: Write a helper essence function that takes one more parameter, a function parameter; don't recurse yet, use the function parameter instead. Leave the recursion to the main function. Why would we do this? One reason is philosophical, like you said, to factor out the recursion from the essence of one iteration of the process. Another reason is that you don't have to merely put back the recursion in the main function. You can now play some dependency injection trick before recursing, or maybe you don't even recurse. For example, how about injecting a dependency on a lookup-list, with the content of said lookup-list coming from said injection --- there hides the recursion. fib_list = [fib_essence (fib_list !!) i | i <- [0..]] or maybe you prefer fib_list = map (fib_essence (fib_list !!)) [0..] You will find that "fib_list !! 100" is less slow than "fib 100". Sometimes you prefer a function-application interface. So we go on to write: fib_notslow x = fib_list !! x In fact sometimes we turn it around, hide away the lookup table, and write: fib_notslow = (fib_list !!) where fib_list = [fib_essence fib_notslow i | i <- [0..]] -- I could write "fib_essence (fib_list !!)", -- but now that (fib_list !!) has a name, "fib_notslow"... Thus we have obtained a revisionist-history definition of dynamic programming and memoization: Dependency injection of a lookup table into a recursion. List is still not fast enough; a binary search tree (lazily generated) is even better. The "memoize" library (http://hackage.haskell.org/package/memoize) does that. Your next food for thought: You have seen open recursion for recursive programs. How about open recursion for recursive data? From anthony_clayden at clear.net.nz Tue Jan 17 02:09:08 2017 From: anthony_clayden at clear.net.nz (Anthony Clayden) Date: Tue, 17 Jan 2017 15:09:08 +1300 Subject: [Haskell-cafe] Hyper-recursion? Message-ID: <587d7cc4.36c.3f19.11530@clear.net.nz> >> On 16 Jan 2017 04:43, "Lawrence Bottorff" wrote: >> >> A while back I worked at an assessor's office, i.e., the people responsible >> for handling properties as land parcels. ... Hi Lawrence, I too worked on land parcels -- a local government rates billing and land valuation application. >> ... how property changed hands, and especially how property lines >> changed due to properties either merging or being split up. >> That is to say, how the parcel map changed over time. I think the important aspect is that the a parcel can be split, and one of the splits merged with another parcel that was not originally with it. (I don't know how it was in your application. but in mine a legal parcel might consist of discontiguous areas of land -- for example a house in a terrace parcelled with a garage amongst a block of garages at the end of the street,) That is, looking over history you cannot group the parcels into a strict hierarchy of splits. >> Somewhere in the functional paradigm, specifically recursion, >> would seem to be a model for this issue. No I'm not seeing anything specifically functional about this. It's a directed graph, where each node is an instance of parcel ownership. >> So in chapter 1 of any functional programming tutorial is the factorial >> calculation function done with recursion. We beginners see the recursion >> "going out" to the "last one," then "coming back," adding up the results of >> each stage as it returns . . . like a yo-yo winding out, >> then winding up again. Nice image, but there's no "last one" here (nor a "first one" that we could make sense of), There's no boundary from where we could be "coming back". Recursion does not apply [see more below] >> David Turner dct25-561bs at mythic-beasts.com >> Mon Jan 16 07:47:41 UTC 2017 >> >> I suspect you have stumbled onto the dual concept of corecursion: ... Nor corecursion. a) because of the infinite and arbitrary potential for splits/mergers; b) because even if there was some time in the distant past when the whole country was a single parcel with a single owner. (The Emperor? But even empires and countries split and merge. Or no owner, only hunter-gatherers/nomads, which might as well be a single parcel.) We're never going to try to rebuild that history. c) because there's never going to be a future end-state. Arbitrary splits/mergers will continue forever. We can't predict what might be the smallest parcels some area of land could be split into. (Note that one trick to prevent mineral exploitation companies from buying up glorious scenery is to split it into $1-parcels and sell each to a different owner.) >> ... Haskell being the most pure functional language, is, hence, >> my starting point on this question. There's nothing specifically Haskell in this. A better place to ask might be lambda-the-ultimate. Anthony From borgauf at gmail.com Tue Jan 17 04:56:33 2017 From: borgauf at gmail.com (Lawrence Bottorff) Date: Mon, 16 Jan 2017 23:56:33 -0500 Subject: [Haskell-cafe] Hyper-recursion? In-Reply-To: <587d7cc4.36c.3f19.11530@clear.net.nz> References: <587d7cc4.36c.3f19.11530@clear.net.nz> Message-ID: @Albert Y. C. Lai, Yes, I'll look into open recursion. @Anthony Clayden, I like the idea of the directed graph, no matter what the final answer. Land parcel changes can be seen as hierarchical trees growing branches -- until something needs to jump to another tree -- or a tree pruned and moved to a new home. The WWW is a great example of this, i.e., a DOM page inside a hierarchical site -- with links jumping outside. True, the splitting and recombining of parcels goes on forever. But I see that as recursion, like one of the classic examples, "infinite mirrors" (the cascading layers produced when two mirrors face one another and you stand in the middle). Basically, anything that is changing is bifurcating and, thus, can be seen as recursion -- whether it "comes back" or not. Programs "execute," which means they do steps, and then they're through and give an answer or result. They leave logs, paper printouts, new things on the disk, answers on the screen, etc. These are terminating discrete events -- with no natural sense of connection other than piping to a next discrete step or a historical recounting we set up ("chess software, show me my last two moves."). Sure, looped GUI apps or your bash terminal or a REPL place a wrappers around this; but there is no concept of having an event be just one layer of the persistent mirror stack. Of course my infinite mirrors analogy breaks down, because progressing from one layer to the next can totally reshape the whole landscape, like completing a row in Tetris can collapse lots of real estate instantly. And yet with today's Tetris (or chess) software, what you see is just a graphical of the continually updated memory field underneath. Again, any chaining of the events or remembering a previous state is unnatural, intentional after-the-fact incursion we have done, not a look at a truly stateless, timeless "unfolding." This may be getting a bit theoretical, but consider the WWW. It grows like an organism -- and, surely, not inside a "program" doing it, imposing direction; there's no program stepping through tasks, no loop creating sites and pages. This is recursion in the wild. For that matter, life is recursion in the wild. Maybe software simply can't go there. The best we can do is have stuff live in a REPL session; but I'm not sure a REPL could be true hyper-recursion. I harp on all this because if Haskell is stateless/immutable and in total disregard of any underlying memory field, then it seems it should progress to hyper-recursion. All examples like parcel maps, Tetris screens, chess apps changing -- is just -- as I said above -- graphical views of an underlying memory field's undoubtedly destructive overwriting. I guess I'm asking, What is the opposite of this? What would we have if the memory field wasn't changing state? The most obvious answer would be -- a runaway memory leak. But could we avoid the runaway memory consumption, but have the "unfolding," the statelessness by some comp-sci sleight of hand? On Mon, Jan 16, 2017 at 9:09 PM, Anthony Clayden < anthony_clayden at clear.net.nz> wrote: > >> On 16 Jan 2017 04:43, "Lawrence Bottorff" gmail.com> wrote: > >> > >> A while back I worked at an assessor's office, i.e., the > people responsible > >> for handling properties as land parcels. ... > > Hi Lawrence, I too worked on land parcels -- a local > government rates billing > and land valuation application. > > >> ... how property changed hands, and especially how > property lines > >> changed due to properties either merging or being split > up. > >> That is to say, how the parcel map changed over time. > > I think the important aspect is that the a parcel > can be split, and one of the splits merged with another > parcel > that was not originally with it. > > (I don't know how it was in your application. but in mine > a legal parcel might consist of discontiguous areas of land > -- for example a house in a terrace parcelled with a garage > amongst > a block of garages at the end of the street,) > > That is, looking over history you cannot group the parcels > into a > strict hierarchy of splits. > > >> Somewhere in the functional paradigm, specifically > recursion, > >> would seem to be a model for this issue. > > No I'm not seeing anything specifically functional about > this. > It's a directed graph, where each node is an instance of > parcel ownership. > > >> So in chapter 1 of any functional programming tutorial is > the factorial > >> calculation function done with recursion. We beginners > see the recursion > >> "going out" to the "last one," then "coming back," adding > up the results of > >> each stage as it returns . . . like a yo-yo winding out, > >> then winding up again. > > Nice image, but there's no "last one" here (nor a "first > one" > that we could make sense of), There's no boundary > from where we could be "coming back". > > Recursion does not apply [see more below] > > >> David Turner dct25-561bs at mythic-beasts.com > >> Mon Jan 16 07:47:41 UTC 2017 > >> > >> I suspect you have stumbled onto the dual concept of > corecursion: ... > > Nor corecursion. > > a) because of the infinite and arbitrary potential for > splits/mergers; > b) because even if there was some time in the distant past > when the whole country was a single parcel with a single > owner. > (The Emperor? But even empires and countries split and > merge. > Or no owner, only hunter-gatherers/nomads, > which might as well be a single parcel.) > We're never going to try to rebuild that history. > c) because there's never going to be a future end-state. > Arbitrary splits/mergers will continue forever. > We can't predict what might be the smallest parcels > some area of land could be split into. > (Note that one trick to prevent mineral exploitation > companies > from buying up glorious scenery > is to split it into $1-parcels and sell each to a > different owner.) > > > >> ... Haskell being the most pure functional language, is, > hence, > >> my starting point on this question. > > There's nothing specifically Haskell in this. > A better place to ask might be lambda-the-ultimate. > > > Anthony > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From will.yager at gmail.com Tue Jan 17 05:27:07 2017 From: will.yager at gmail.com (William Yager) Date: Mon, 16 Jan 2017 23:27:07 -0600 Subject: [Haskell-cafe] Hyper-recursion? In-Reply-To: References: <587d7cc4.36c.3f19.11530@clear.net.nz> Message-ID: I'm not sure if this is what you're looking for, but all this talk of bifurcation and infinite recursion suggests to me that you might be interested in Control.Monad.Free and Data.Fix. They may correspond to the concept you're getting at. > But could we avoid the runaway memory consumption, but have the "unfolding," the statelessness by some comp-sci sleight of hand? Garbage collection? --Will -------------- next part -------------- An HTML attachment was scrubbed... URL: From dennis.raddle at gmail.com Tue Jan 17 07:16:21 2017 From: dennis.raddle at gmail.com (Dennis Raddle) Date: Tue, 17 Jan 2017 02:16:21 -0500 Subject: [Haskell-cafe] dynamic code compilation and loading In-Reply-To: References: Message-ID: I'm not clear on everything you've saying. My program, at present, opens some MIDI ports and leaves them open while it is running. It presents me with a command line prompt from which I can configure the program and initiate MIDI playback. I can also halt playback in progress. Every time I change the score (in the Sibelius typesetter program), I initiate a new playback action. What you are saying sounds like running the program once for each playback. I guess the program wouldn't leave the MIDI ports open, as it has to close them before it exits. But that should work fine. I would also need a different way of configuring the program -- the current settings would have to be stored in a file so they won't be lost when the program exits. I wonder about two things. First, I would like the majority of the program to be compiled. It needs speed. Is there a way to compile everything but the module that "varies" a Score? Second, the Vary.hs module would need to be located on the disk in the same directory as the music score, to keep things organized. But on my disk (MacBook Pro with SS drive) there is one tree for Haskell source, /Users/Dennis/haskell. I use the option "-i/Users/Dennis/haskell" which compiling or running ghci. The musical scores are all stored in a different tree, "/Users/Dennis/Dropbox/music/comp". So I don't know how to "import" a file that is not in my Haskell source tree, and more important, is not determined until run time. Oh yeah, I don't specify the specific score when I run my program, but rather let it search the /Users/Dennis/Dropbox/music/comp tree for the most recently modified score. This is convenient, because over the course of an hour or two that I compose, I would switch several times between scores, and as soon as I modify and save a particular score, that one becomes the source for playback. So the program would locate a recently modified Sibelius score, say $MUSIC/piano/tocatta1.sib. (Where $MUSIC is /Users/Dennis/Dropbox/music/comp). Then the program would assume there is some Haskell source in the same directory, called "toccata1.hs". This source would contain functions that vary the expression in ways I like for that particular composition. Does this sound doable with ghci? Or the GHC API? About what I've learned about expression score realization, I could perhaps share some things at some point. Unfortunately I have bad work habits... I often don't take care to finish projects in a way that is presentable, so I have many years of half-finished compositions that can't even be played back with the current version of my program. I'm 48 years old and finally realizing just how important it is to organize and finish things. And to collaborate. I found another musician to collaborate with -- I will make computer "interpretations" of his compositions. So my top priority over the next several months is to look over back projects and finish things enough to get some sound, then archive the *sound files* -- so they don't become obsolete. (Assuming wav or mp3 is trustworthy for a while.) D On Mon, Jan 16, 2017 at 6:38 PM, Evan Laforge wrote: > I used to use hint for a somewhat similar situation (I wanted to give > a REPL to my program, which incidentally is also concerned with > interpreting music). I found that hint didn't give enough control (it > wanted to reload everything on every expression, instead of only > reloading when I told it to) and it was too hard to dig through it's > ghc compatibility layers, so I directly used the GHC API and it was a > lot easier than expected. > > However, that's for inserting code into a running program. If you > want to just run a function to transform a Score, couldn't you just > load the support modules in ghci, and run the main function from > there? Change the source, type :r, and type 'main' again. You could > hook up your editor to that automatically on every save. > > By the way, I'm also interested in expressive score realization, since > I'm doing something similar, though in my case I'm using a custom > score format rather than staff notation. If you have anything to show > off I'd be interested to see. > > On Sun, Jan 15, 2017 at 12:37 PM, Dennis Raddle > wrote: > > Hello, > > I wrote a Haskell program which reads a MusicXML score and plays it > through > > real-time MIDI messages (using the portmidi module) via some algorithms > that > > are customized depending on the MIDI synthesizer that is receiving the > > messages. The program also plays back the music with musically expressive > > nuances. > > > > In the next version of this program, I am going to add more complicated > > algorithms for the expressive nuances, and it would be helpful to > configure > > them and express them in actual Haskell code. My workflow will look like > > this: > > > > A. write a score using the music typesetting program Sibelius > > > > B. write some Haskell code to provide expressive nuances > > > > C. play the music through a MIDI synthesizer and listen. > > > > D. based on what I hear and where I want to take the music, modify the > score > > and the Haskell code > > > > E. loop back to C > > > > Therefore, if I don't want to recompile the program each time I do step > D, I > > need to compile and load code dynamically. > > > > Let's say that a data structure which contains a MusicXML score and a > > nominal rendition into MIDI messages together with time tags is of type > > Score. Then I want to write, and dynamically compile/load, a function > > > > vary :: Score -> Score > > > > which varies the MIDI messages and time tags to add expressive nuances. > > > > Let's say 'vary' is contained in Vary.hs. > > > > I want to write 'vary' in terms of already-compiled functions that > provide > > the basic music-processing operations. Let's say that these functions > are in > > the module MusicBase. Then Vary.hs will look like > > > > import MusicBase > > > > vary = ... operations in MusicBase ... > > > > Can I get some basic idea of how to do this? > > > > D > > > > > > _______________________________________________ > > Haskell-Cafe mailing list > > To (un)subscribe, modify options or view archives go to: > > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > > Only members subscribed via the mailman list are allowed to post. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From qdunkan at gmail.com Tue Jan 17 08:33:53 2017 From: qdunkan at gmail.com (Evan Laforge) Date: Tue, 17 Jan 2017 00:33:53 -0800 Subject: [Haskell-cafe] dynamic code compilation and loading In-Reply-To: References: Message-ID: On Mon, Jan 16, 2017 at 11:16 PM, Dennis Raddle wrote: > I'm not clear on everything you've saying. > > My program, at present, opens some MIDI ports and leaves them open while it > is running. It presents me with a command line prompt from which I can > configure the program and initiate MIDI playback. I can also halt playback > in progress. Every time I change the score (in the Sibelius typesetter > program), I initiate a new playback action. > > What you are saying sounds like running the program once for each playback. > I guess the program wouldn't leave the MIDI ports open, as it has to close > them before it exits. But that should work fine. I would also need a > different way of configuring the program -- the current settings would have > to be stored in a file so they won't be lost when the program exits. I was thinking you'd have ghci running persistently. Start it up, run the initialize function which will configure MIDI. Then every time you want to process a score, just rerun the "process" function. > I wonder about two things. First, I would like the majority of the program > to be compiled. It needs speed. Is there a way to compile everything but the > module that "varies" a Score? Yes, you can compile modules and ghci will load the compiled version. When you change one and do a :r, it will recompile the changed module and its dependents. Normally it uses bytecode for this, but you can also have it compile to binary. See the ghci section of the ghc manual. > Second, the Vary.hs module would need to be located on the disk in the same > directory as the music score, to keep things organized. But on my disk > (MacBook Pro with SS drive) there is one tree for Haskell source, > /Users/Dennis/haskell. I use the option "-i/Users/Dennis/haskell" which > compiling or running ghci. The musical scores are all stored in a different > tree, "/Users/Dennis/Dropbox/music/comp". > > So I don't know how to "import" a file that is not in my Haskell source > tree, and more important, is not determined until run time. You can set flags from ghci, so you can add a -i at runtime. :l also understands plain paths, so you could give it the complete path, or generate it via :def. > Oh yeah, I don't specify the specific score when I run my program, but > rather let it search the /Users/Dennis/Dropbox/music/comp tree for the most > recently modified score. This is convenient, because over the course of an > hour or two that I compose, I would switch several times between scores, and > as soon as I modify and save a particular score, that one becomes the source > for playback. > > So the program would locate a recently modified Sibelius score, say > $MUSIC/piano/tocatta1.sib. (Where $MUSIC is > /Users/Dennis/Dropbox/music/comp). Then the program would assume there is > some Haskell source in the same directory, called "toccata1.hs". This source > would contain functions that vary the expression in ways I like for that > particular composition. > > Does this sound doable with ghci? Or the GHC API? ghci has some limited but surprisingly flexible scripting ability. For instance, you could do :def L (\_ -> loadNewest), and then define a loadNewest function that looks for the relevant .sib file and emits the path to a parallel .hs file. I actually use a :L macro to load the currently edited file in vim, so I'd probably make a vim macro to load (or create) an .hs for the "current" .sib file, and then use :L to load it. For interactive work, my :l is overridden to :m +Utils so I can get a bunch of interactive utils without having to import them into every module. Also, you are not limited to just rerunning a single "vary" function. You can use the full power of haskell to configure the realization. I use the REPL for analysis and debugging as well. > About what I've learned about expression score realization, I could perhaps > share some things at some point. Unfortunately I have bad work habits... I > often don't take care to finish projects in a way that is presentable, so I > have many years of half-finished compositions that can't even be played back > with the current version of my program. I'm 48 years old and finally > realizing just how important it is to organize and finish things. And to > collaborate. I found another musician to collaborate with -- I will make > computer "interpretations" of his compositions. I keep each score saved with a "known good" version of the MIDI output, along with a commit ID for the time it was generated. So it not only archives a known good realization, it also acts as a regression test against code changes (checking all saved scores is part of the commit validation, in addition to the more usual unit tests), and if all else fails, I can get back to the original performance by rewinding the repo. mp3 is good for archiving of course, but you'll never be able to change it again. From dennis.raddle at gmail.com Tue Jan 17 10:16:50 2017 From: dennis.raddle at gmail.com (Dennis Raddle) Date: Tue, 17 Jan 2017 05:16:50 -0500 Subject: [Haskell-cafe] dynamic code compilation and loading In-Reply-To: References: Message-ID: Thanks, I will refer to your email as I try to develop my working method. On Tue, Jan 17, 2017 at 3:33 AM, Evan Laforge wrote: > On Mon, Jan 16, 2017 at 11:16 PM, Dennis Raddle > wrote: > > About what I've learned about expression score realization, I could > perhaps > > share some things at some point. Unfortunately I have bad work habits... > I > > often don't take care to finish projects in a way that is presentable, > so I > > have many years of half-finished compositions that can't even be played > back > > with the current version of my program. I'm 48 years old and finally > > realizing just how important it is to organize and finish things. And to > > collaborate. I found another musician to collaborate with -- I will make > > computer "interpretations" of his compositions. > > I keep each score saved with a "known good" version of the MIDI > output, along with a commit ID for the time it was generated. So it > not only archives a known good realization, it also acts as a > regression test against code changes (checking all saved scores is > part of the commit validation, in addition to the more usual unit > tests), and if all else fails, I can get back to the original > performance by rewinding the repo. mp3 is good for archiving of > course, but you'll never be able to change it again. > Ah, yes, those are good ideas. But to get things to sound right, I have to configure my software synthesizers (such as samplers, modeled pianos, and analog synth emulators). I can set up all the synthesizers as VST plugins in Reaper, but versions change and there may be configuration elements not captured in the Reaper file, so I really need to archive a mp3 as a record of what I did. I can and should take greater care in managing the versions of the Haskell source, but it's harder to manage the configuration of the software synths and I would rather not invest the effort to reach a point of high confidence... when it's easy to archive an mp3. If I really want to revisit something I did a while back, it might take some work to get it going again with the current version of my Haskell source, but that's not such a bad thing... often I can learn things serendipitously from unintended software behavior. But the other approach, the one Knuth took with TeX, which is to make it 100% backward compatible for its entire life, is fascinating. I'm just one guy messing around as a hobby so it's obviously much more important for a widely used community resource like TeX. D -------------- next part -------------- An HTML attachment was scrubbed... URL: From sivanov at colimite.fr Tue Jan 17 11:32:27 2017 From: sivanov at colimite.fr (Sergiu Ivanov) Date: Tue, 17 Jan 2017 12:32:27 +0100 Subject: [Haskell-cafe] Hyper-recursion? In-Reply-To: References: <587d7cc4.36c.3f19.11530@clear.net.nz> Message-ID: <87tw8x2a7o.fsf@colimite.fr> Hi Lawrence, Thus quoth Lawrence Bottorff at 04:56 on Tue, Jan 17 2017: > > I harp on all this because if Haskell is stateless/immutable and in > total disregard of any underlying memory field, then it seems it > should progress to hyper-recursion. The characteristics you are putting forward are generally attributed to declarative programming (kinda): loosely put, programming in which you describe your intentions instead of describing how they should actually be implemented. While Haskell falls rather heavily within declarative programming, some (theoretically proven undecidability) issues prevent it from entirely having the mentioned characteristics. On the other hand, hyper-recursion seems to be an informal metaphor overhanging a couple formal concepts (fixed points, corecursion, but not only). Haskell aims to be a "well formalised" language, so while it can handle fixed points and corecursion, it cannot handle some abstractions which are too loose and therefore difficult to formalise (but still useful as tools for intuitive exploration). Conclusion: you are describing an intuition of a model of computing, which could fall within declarative programming once formalised. Haskell also falls within declarative programming, but this does not mean it is particularly better suited than any other programming language. I believe I'm indirectly citing what people have already said in this discussion. I do not mean to criticise your point of view, I actually find it rather interesting. -- Sergiu https://en.wikipedia.org/wiki/Declarative_programming -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 487 bytes Desc: not available URL: From jmartty at hotmail.com Tue Jan 17 13:17:56 2017 From: jmartty at hotmail.com (Juan Luis Martty) Date: Tue, 17 Jan 2017 13:17:56 +0000 Subject: [Haskell-cafe] Control.Parallel seemingly randomly behaviour In-Reply-To: References: , Message-ID: The build isn't really doing anything after the first build cause it doesn't detect any changes. And stack exec is already passing the right RTS options ________________________________ From: David Feuer Sent: Monday, January 16, 2017 9:02 PM To: Juan Luis Martty Cc: haskell-cafe at haskell.org Subject: Re: [Haskell-cafe] Control.Parallel seemingly randomly behaviour Oh, and you should probably be passing your program an explicit +RTS option to tell it how many OS threads to use. On Jan 16, 2017 7:01 PM, "David Feuer" > wrote: Just to remove one variable: what happens if you run the same executable multiple times, rather than rebuilding it each time? On Jan 15, 2017 6:34 PM, "Juan Luis Martty" > wrote: Hello everyone, I'm having a consistency issue with the following piece of code: heavyAm = 500 lightAm = 1000 heavyCalc :: Int -> Int heavyCalc s = sum [1..1000000*s] parallel = (heavyCalc lightAm, heavyCalc heavyAm) `using` (parTuple2 rseq rseq) For some reason, during runtime the RTS sometimes parallelizes the evaluation and sometimes it doesn't. I'm running with all the RTS/compile time options correctly afaik. Here is the output from a couple of runs of the program: jmartty at walrus:~/hs/parallel$ stack build && time stack exec par-exe Warning: File listed in par.cabal file does not exist: README.md (500000000500000000,125000000250000000) Computation time: 1.557007s real 0m1.732s user 0m2.528s sys 0m0.464s jmartty at walrus:~/hs/parallel$ stack build && time stack exec par-exe Warning: File listed in par.cabal file does not exist: README.md (500000000500000000,125000000250000000) Computation time: 1.544837s real 0m1.720s user 0m2.544s sys 0m0.712s jmartty at walrus:~/hs/parallel$ stack build && time stack exec par-exe Warning: File listed in par.cabal file does not exist: README.md (500000000500000000,125000000250000000) Computation time: 2.316537s real 0m2.484s user 0m2.592s sys 0m0.680s jmartty at walrus:~/hs/parallel$ stack build && time stack exec par-exe Warning: File listed in par.cabal file does not exist: README.md (500000000500000000,125000000250000000) Computation time: 2.318514s real 0m2.489s user 0m2.612s sys 0m0.688s jmartty at walrus:~/hs/parallel$ stack build && time stack exec par-exe Warning: File listed in par.cabal file does not exist: README.md (500000000500000000,125000000250000000) Computation time: 1.544975s real 0m1.718s user 0m2.512s sys 0m0.456s As you can see, sometimes wall time roughly equals userspace time, sometimes it doesn't (meaning it parallelized at least some amount). I'm running on a dual core machine under Ubuntu using stack with lts-7.14 (GHC 8.0.1) and parallel-3.2.1.0. Regards, Juan _______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post. -------------- next part -------------- An HTML attachment was scrubbed... URL: From rae at cs.brynmawr.edu Tue Jan 17 14:57:12 2017 From: rae at cs.brynmawr.edu (Richard Eisenberg) Date: Tue, 17 Jan 2017 07:57:12 -0700 Subject: [Haskell-cafe] A question on datakinds syntax In-Reply-To: References: Message-ID: Haddock struggles sometimes to render types with -XPolyKinds enabled. The problem is that GHC generally does not require kind arguments to be written and it does not print them out (unless you say -fprint-explicit-kinds). But Haddock, I believe, prints out kinds whenever -XPolyKinds is on. So the two different definitions are really the same: it's just that one module has -XPolyKinds and the other doesn't. The * is the kind of ordinary types. So Int has kind * (we write Int :: *) while Maybe has kind * -> *. Typeable actually has kind `forall k. k -> Constraint`, meaning that it's polykinded. In the first snippet below, the * argument to Typeable instantiates k with *, because type variable a has kind *. This all tends to be quite confusing, and I wish I could point you to a tutorial or some such on it all... but I don't know if one exists! I hope this is helpful, Richard > On Jan 13, 2017, at 1:31 AM, Haiwei Zhou wrote: > > Hi, > > I am reading the document of spock-0.11, and found two strange definitions in the Web.Spock. > > ```` > type Var a = Path ((:) * a ([] *)) Open > > var :: (Typeable * a, PathPiece a) => Path ((:) * a ([] *)) Open > > ```` > > What's the meaning of the star between Typeable and a ? > > The kind of Typeable is * -> *. I cannot understand why the Typeable in the var prototype takes two kinds. > > In the Web.Routing.Combinators of reroute-0.4, those are defined as following: > > ```` > type Var a = Path (a ': '[]) Open > > var :: (Typeable a, PathPiece a) => Path (a ': '[]) Open > > ```` > > Why there are two difference definition about the same thing? > > Thanks, > Haiwei > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. From fa-ml at ariis.it Tue Jan 17 16:05:57 2017 From: fa-ml at ariis.it (Francesco Ariis) Date: Tue, 17 Jan 2017 17:05:57 +0100 Subject: [Haskell-cafe] [ANN] Haskell ITA meetup in Milan, Italy (2017-02-25) Message-ID: <20170117160557.GA10016@casa.casa> Good evening -cafe, the italian Haskell Community (http://haskell-ita.it/) is happy to announce its winter Haskell meetup. The event is going to be hosted in Milano, on February 25th (Saturday). It will be kindly hosted by MIKAMAI [1], Via Giulio e Corrado Venini, 42 - 20127 Milano (MI), IT [1] https://www.mikamai.com/ To register, check: https://www.metooo.io/e/incontro-haskell-ita-inverno-2017 Any haskeller (beginner, experienced, curious) is welcome! *** italian follows *** Buonasera a tutti, abbiamo finalmente deciso la data dell'incontro invernale di Haskell-ITA! Ci riuniremo il 25 Febbraio 2017 (un Sabato), presso MIKAMAI [1], che gentilmente mette i locali a disposizione. [1] https://www.mikamai.com/ L'indirizzo è: Via Giulio e Corrado Venini, 42 - 20127 Milano (MI), IT Per registrarvi: https://www.metooo.io/e/incontro-haskell-ita-inverno-2017 From johannes.waldmann at htwk-leipzig.de Tue Jan 17 18:56:22 2017 From: johannes.waldmann at htwk-leipzig.de (Johannes Waldmann) Date: Tue, 17 Jan 2017 19:56:22 +0100 Subject: [Haskell-cafe] Control.Parallel seemingly randomly behaviour Message-ID: Hi Juan, I am interested in this because I use Control.Parallel in teaching currently. But - * what is your actual Main program / main function (it was not included in your message?) * what is your actual cabal / stack config file? * on what machine (OS, CPU) are you running this (it seems pretty slow)? * have you looked at eventlogs with threadscope? - J. From iavor.diatchki at gmail.com Tue Jan 17 19:38:29 2017 From: iavor.diatchki at gmail.com (Iavor Diatchki) Date: Tue, 17 Jan 2017 11:38:29 -0800 Subject: [Haskell-cafe] [ANN] FloatingHex: Hexadecimal floats (quasiquoter and pretty-printer) In-Reply-To: References: Message-ID: Nicely done! I agree that this would be much nicer to just implement directly in GHC (and eventually add to the standard). Would you like to write it up as GHC proposal? Here is info on how to do that: https://github.com/ghc-proposals/ghc-proposals -Iavor On Sat, Jan 14, 2017 at 3:06 PM, Levent Erkok wrote: > Quick update: version 0.2 of FloatingHex is now on hackage ( > http://hackage.haskell.org/package/FloatingHex) which fixes a few > glitches and makes the pretty-printer compatible with C's %a modifier. This > brings the support on par with that in C/C++. The quasi-quoter is called > qf, and the pretty-printer is called showHFloat, following the naming of > other float-printers already available. > > On Sat, Jan 14, 2017 at 1:10 AM, Levent Erkok wrote: > >> FloatingHex (http://hackage.haskell.org/package/FloatingHex) is a simple >> package that implement hexadecimal notation for floating point numbers, as >> described in p57-58 of http://www.open-std.org/jtc >> 1/sc22/wg14/www/docs/n1256.pdf >> >> The package provides a quasi-quoter for hexadecimal floats: hf, and a >> pretty-printer for floats to show them in this notation: showFFloat. (Note >> that the latter is not 100% compatible with C's %a modifier for printf, but >> it does render a faithful representation of its input.) >> >> Hex-floats are useful as they allow writing floating-point constants >> without any loss of precision, while remaining human readable. For >> instance, the float 2 is written as 0x1p1. (With the quasiquoter, the >> syntax is [hf|0x1p1|].) This representation is to be preferred over decimal >> rendering where loss of precision can be a problem: Note that not all >> floating point numbers have a terminating decimal representation as >> currently required by the Haskell syntax. >> >> It would be nice if Haskell itself allowed for such literals in the >> language specs itself, following the recent changes to other language >> standards. (Again, see p57-58 of http://www.open-std.org/jtc >> 1/sc22/wg14/www/docs/n1256.pdf for the new C standard.) In the mean >> time, I hope FloatingHex library will provide a workaround for >> the numerophilias amongst us. >> >> Bug reports and improvements always welcome! >> >> Cheers, >> >> -Levent. >> >> >> > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From olf at aatal-apotheke.de Tue Jan 17 20:14:14 2017 From: olf at aatal-apotheke.de (Olaf Klinke) Date: Tue, 17 Jan 2017 21:14:14 +0100 Subject: [Haskell-cafe] Hyper-recursion? Message-ID: <042EE61F-24AE-457A-A3D5-2BFAAFBC197E@aatal-apotheke.de> If I may step into this discussion, I'd like to suggest you start modelling your world of parcels more concretely, as data types. From there it should be easier to grasp our hyper-recursion. Question: Does every parcel have its own time, or is there a universal clock ticking in the background? If you have a uiversal clock, you could model your world as a linear series of state changes, stretching infinitely into the past and future. Hence two streams going out form a "now" would be the overarching data type. This has been used e.g. for doubly linked lists. Doesn't functional reactive programming use a similar model? Question: How does one identify a parcel of land? Is it a polygon of coordinates in some reference system? Hence can the state be seen as a finite set of (Polygon,Owner) pairs? Question: What is more important: The state or the state change? If the state is more important, a kind of graph might be the appropriate data structure. If the change is important, it might be interesting to model the world (and time) as a network of functions. Question to all mathematicians on this list: Suppose (again assuming a universal clock) there is a type (a set?) X and a function change :: Integer -> (X -> X) where the state of "now" is to be understood as the value now = change 0 . change (-1) . change (-2) . {...ad infinitum} Under which circumstances does this determine the value of "now"? The only instance I can think of are contractions on a (compact) metric space. (Brouwer's/Banach's fixed point theorems) I second the contributors who suggest that this has not much to do with recursion nor corecursion. To me, the essence of recusion is self-reference. A function building e.g. an infinite stream from a seed is not self-referential in itself, it is the resulting data that is self-referential. Olaf From erkokl at gmail.com Tue Jan 17 23:29:56 2017 From: erkokl at gmail.com (Levent Erkok) Date: Tue, 17 Jan 2017 15:29:56 -0800 Subject: [Haskell-cafe] [ANN] FloatingHex: Hexadecimal floats (quasiquoter and pretty-printer) In-Reply-To: References: Message-ID: Thanks Iavor.. I should've indeed done that, but instead I directly opened a GHC feature request: http://ghc.haskell.org/trac/ghc/ticket/13126. Old habits die hard. I've since turned it into a proper proposal: https://github.com/LeventErkok/ghc-proposals/blob/hexFloats/proposals/0000-hexFloats.rst However, I was *not* able to add the label "Under discussion" as suggested by the instructions in: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposal-submission.rst I didn't see a way of doing that in the pull-request. Perhaps a guru can fix that? Thanks, -Levent. On Tue, Jan 17, 2017 at 11:38 AM, Iavor Diatchki wrote: > Nicely done! I agree that this would be much nicer to just implement > directly in GHC (and eventually add to the standard). Would you like to > write it up as GHC proposal? > > Here is info on how to do that: > https://github.com/ghc-proposals/ghc-proposals > > -Iavor > > On Sat, Jan 14, 2017 at 3:06 PM, Levent Erkok wrote: > >> Quick update: version 0.2 of FloatingHex is now on hackage ( >> http://hackage.haskell.org/package/FloatingHex) which fixes a few >> glitches and makes the pretty-printer compatible with C's %a modifier. This >> brings the support on par with that in C/C++. The quasi-quoter is called >> qf, and the pretty-printer is called showHFloat, following the naming of >> other float-printers already available. >> >> On Sat, Jan 14, 2017 at 1:10 AM, Levent Erkok wrote: >> >>> FloatingHex (http://hackage.haskell.org/package/FloatingHex) is a >>> simple package that implement hexadecimal notation for floating point >>> numbers, as described in p57-58 of http://www.open-std.org/jtc >>> 1/sc22/wg14/www/docs/n1256.pdf >>> >>> The package provides a quasi-quoter for hexadecimal floats: hf, and a >>> pretty-printer for floats to show them in this notation: showFFloat. (Note >>> that the latter is not 100% compatible with C's %a modifier for printf, but >>> it does render a faithful representation of its input.) >>> >>> Hex-floats are useful as they allow writing floating-point constants >>> without any loss of precision, while remaining human readable. For >>> instance, the float 2 is written as 0x1p1. (With the quasiquoter, the >>> syntax is [hf|0x1p1|].) This representation is to be preferred over decimal >>> rendering where loss of precision can be a problem: Note that not all >>> floating point numbers have a terminating decimal representation as >>> currently required by the Haskell syntax. >>> >>> It would be nice if Haskell itself allowed for such literals in the >>> language specs itself, following the recent changes to other language >>> standards. (Again, see p57-58 of http://www.open-std.org/jtc >>> 1/sc22/wg14/www/docs/n1256.pdf for the new C standard.) In the mean >>> time, I hope FloatingHex library will provide a workaround for >>> the numerophilias amongst us. >>> >>> Bug reports and improvements always welcome! >>> >>> Cheers, >>> >>> -Levent. >>> >>> >>> >> >> _______________________________________________ >> Haskell-Cafe mailing list >> To (un)subscribe, modify options or view archives go to: >> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe >> Only members subscribed via the mailman list are allowed to post. >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From borgauf at gmail.com Wed Jan 18 01:11:15 2017 From: borgauf at gmail.com (Lawrence Bottorff) Date: Tue, 17 Jan 2017 20:11:15 -0500 Subject: [Haskell-cafe] Hyper-recursion? In-Reply-To: <042EE61F-24AE-457A-A3D5-2BFAAFBC197E@aatal-apotheke.de> References: <042EE61F-24AE-457A-A3D5-2BFAAFBC197E@aatal-apotheke.de> Message-ID: I guess I'm using a looser definition of recursion, something not exactly "self-referential." For example, I'm on the phone with someone, and then I accept a call-waiting call. You can go into multiple depths of call waiting, then wind your way back out as you hang up on each -- all the way back to the original caller. Or, with my example, I could have a state represented as some polynomial, a_nx^n + a_n-1x^(n-1) + . . ., then a "change" happens when a new polynomial "goes into" the first, a_n(b_ny^n + b_n-1y^n-1 + ...)^n + a_n-1x^n-1 ... This could go on and on, new polynomials substituted into one of the variables of the previous. All I want to say with this is that I consider this also recursive in nature, even though I can't imagine how this would be "self-referential" or looking typically inductive. I'm not a expert on the whole Bitcoin blockchain, but your (Olaf) now = change 0 . change (-1) . change (-2) . {...ad infinitum} looks like one. And no, there shouldn't be a clock, per se. Yes, parcels would be polygons, with sides shared -- although this isn't germane to the bigger question. On Tue, Jan 17, 2017 at 3:14 PM, Olaf Klinke wrote: > If I may step into this discussion, I'd like to suggest you start > modelling your world of parcels more concretely, as data types. From there > it should be easier to grasp our hyper-recursion. > > Question: Does every parcel have its own time, or is there a universal > clock ticking in the background? > > If you have a uiversal clock, you could model your world as a linear > series of state changes, stretching infinitely into the past and future. > Hence two streams going out form a "now" would be the overarching data > type. This has been used e.g. for doubly linked lists. Doesn't functional > reactive programming use a similar model? > > Question: How does one identify a parcel of land? Is it a polygon of > coordinates in some reference system? Hence can the state be seen as a > finite set of (Polygon,Owner) pairs? > > Question: What is more important: The state or the state change? If the > state is more important, a kind of graph might be the appropriate data > structure. If the change is important, it might be interesting to model the > world (and time) as a network of functions. > > Question to all mathematicians on this list: Suppose (again assuming a > universal clock) there is a type (a set?) X and a function > > change :: Integer -> (X -> X) > > where the state of "now" is to be understood as the value > > now = change 0 . change (-1) . change (-2) . {...ad infinitum} > > Under which circumstances does this determine the value of "now"? The only > instance I can think of are contractions on a (compact) metric space. > (Brouwer's/Banach's fixed point theorems) > > I second the contributors who suggest that this has not much to do with > recursion nor corecursion. To me, the essence of recusion is > self-reference. A function building e.g. an infinite stream from a seed is > not self-referential in itself, it is the resulting data that is > self-referential. > > Olaf -------------- next part -------------- An HTML attachment was scrubbed... URL: From sivanov at colimite.fr Wed Jan 18 08:32:52 2017 From: sivanov at colimite.fr (Sergiu Ivanov) Date: Wed, 18 Jan 2017 09:32:52 +0100 Subject: [Haskell-cafe] Hyper-recursion? In-Reply-To: References: <042EE61F-24AE-457A-A3D5-2BFAAFBC197E@aatal-apotheke.de> Message-ID: <87k29s22ff.fsf@colimite.fr> Thus quoth Lawrence Bottorff at 01:11 on Wed, Jan 18 2017: > > I guess I'm using a looser definition of recursion, something not > exactly "self-referential." For example, I'm on the phone with > someone, and then I accept a call-waiting call. You can go into > multiple depths of call waiting, then wind your way back out as you > hang up on each -- all the way back to the original caller. [...] > This could go on and on, new polynomials substituted into one of the > variables of the previous. This sounds a lot like recursive (inductive/coinductive) data structures. -- Sergiu -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 487 bytes Desc: not available URL: From heraldhoi at gmail.com Wed Jan 18 10:38:09 2017 From: heraldhoi at gmail.com (Geraldus) Date: Wed, 18 Jan 2017 10:38:09 +0000 Subject: [Haskell-cafe] Yesod devel issue: cannot satisfy -package-key main In-Reply-To: References: Message-ID: I've had rebuild `yesod-bin` using same snapshot as in project, which was selected as 6.27. Otherwise `yesod devel` reported an error about compiler version mismatch. But default compiler is GHC 8, you're right. I was able to resolve this doing `stack install --resolver=6.27` using sources from Git HEAD and removing `yesod` binary already installed in ~/.stack/snapshots//lts-6.27/7.10.3/bin. Thanks. -------------- next part -------------- An HTML attachment was scrubbed... URL: From litchard.michael at gmail.com Wed Jan 18 19:14:25 2017 From: litchard.michael at gmail.com (Michael Litchard) Date: Wed, 18 Jan 2017 11:14:25 -0800 Subject: [Haskell-cafe] free monad versus operational for blackjack game Message-ID: I'm studying the code for a blackjack game: See marked answer. http://codereview.stackexchange.com/questions/46809/blackjack-in-haskell It uses the operational package, and mentions one could write equivalent code using a free monad. But my question is, for this use case is there any benefit for using a free monad? -------------- next part -------------- An HTML attachment was scrubbed... URL: From allbery.b at gmail.com Wed Jan 18 19:20:52 2017 From: allbery.b at gmail.com (Brandon Allbery) Date: Wed, 18 Jan 2017 14:20:52 -0500 Subject: [Haskell-cafe] free monad versus operational for blackjack game In-Reply-To: References: Message-ID: The operational package is just a free monad with some canned conveniences. If what it provides is sufficient for your use case, there's no reason to switch; but if they don't fit your use case, you can use one of the other embellished free monads (e.g. MonadPrompt) or start from a bare free monad and write what you need. On Wed, Jan 18, 2017 at 2:14 PM, Michael Litchard < litchard.michael at gmail.com> wrote: > I'm studying the code for a blackjack game: See marked answer. > http://codereview.stackexchange.com/questions/46809/blackjack-in-haskell > > It uses the operational package, and mentions one could write equivalent > code using a free monad. But my question is, for this use case is there any > benefit for using a free monad? > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. > -- 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 ben.franksen at online.de Wed Jan 18 22:39:33 2017 From: ben.franksen at online.de (Ben Franksen) Date: Wed, 18 Jan 2017 23:39:33 +0100 Subject: [Haskell-cafe] Using stringize and string concatenation in ghc preprocessing In-Reply-To: References: Message-ID: Am 20.08.2016 um 20:33 schrieb Brandon Allbery: > You might want to look at cpphs as an alternative preprocessor. There are > some ancient K&R-era hacks that could be used if absolutely necessary, but > cpphs should be a much simpler and cleaner solution. Is there any reason /not/ to prefer cpphs over cpp? If not, why does anyone still use cpp for Haskell? Cheers Ben -- "Make it so they have to reboot after every typo." ― Scott Adams From allbery.b at gmail.com Wed Jan 18 22:43:57 2017 From: allbery.b at gmail.com (Brandon Allbery) Date: Wed, 18 Jan 2017 17:43:57 -0500 Subject: [Haskell-cafe] Using stringize and string concatenation in ghc preprocessing In-Reply-To: References: Message-ID: On Wed, Jan 18, 2017 at 5:39 PM, Ben Franksen wrote: > Am 20.08.2016 um 20:33 schrieb Brandon Allbery: > > You might want to look at cpphs as an alternative preprocessor. There are > > some ancient K&R-era hacks that could be used if absolutely necessary, > but > > cpphs should be a much simpler and cleaner solution. > > Is there any reason /not/ to prefer cpphs over cpp? If not, why does > anyone still use cpp for Haskell? > Licensing. -- 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 jmartty at hotmail.com Wed Jan 18 22:52:44 2017 From: jmartty at hotmail.com (Juan Luis Martty) Date: Wed, 18 Jan 2017 22:52:44 +0000 Subject: [Haskell-cafe] Control.Parallel seemingly randomly behaviour In-Reply-To: References: Message-ID: The program is attached in this mail, along with stack & cabal config. The machine is an old T400 with an Intel dual core. Followin some advice, I checked the output of `+RTS -s` and apparently sometimes one of the sparks is fizzled which is what causes the unexpected behaviour ________________________________ From: Haskell-Cafe on behalf of Johannes Waldmann Sent: Tuesday, January 17, 2017 3:56 PM To: haskell-cafe at haskell.org Subject: Re: [Haskell-cafe] Control.Parallel seemingly randomly behaviour Hi Juan, I am interested in this because I use Control.Parallel in teaching currently. But - * what is your actual Main program / main function (it was not included in your message?) * what is your actual cabal / stack config file? * on what machine (OS, CPU) are you running this (it seems pretty slow)? * have you looked at eventlogs with threadscope? - J. _______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Haskell-Cafe Info Page mail.haskell.org This mailing list is for the discussion of topics related to Haskell. The volume may at times be high, as the scope is broader than the main Haskell mailing list. Only members subscribed via the mailman list are allowed to post. -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: par.cabal Type: application/octet-stream Size: 1020 bytes Desc: par.cabal URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: stack.yaml Type: application/x-yaml Size: 2173 bytes Desc: stack.yaml URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: Main.hs Type: text/x-haskell Size: 675 bytes Desc: Main.hs URL: From ben.franksen at online.de Wed Jan 18 23:04:47 2017 From: ben.franksen at online.de (Ben Franksen) Date: Thu, 19 Jan 2017 00:04:47 +0100 Subject: [Haskell-cafe] Using stringize and string concatenation in ghc preprocessing In-Reply-To: References: Message-ID: Am 18.01.2017 um 23:43 schrieb Brandon Allbery: > On Wed, Jan 18, 2017 at 5:39 PM, Ben Franksen > wrote: > >> Am 20.08.2016 um 20:33 schrieb Brandon Allbery: >>> You might want to look at cpphs as an alternative preprocessor. There are >>> some ancient K&R-era hacks that could be used if absolutely necessary, >> but >>> cpphs should be a much simpler and cleaner solution. >> >> Is there any reason /not/ to prefer cpphs over cpp? If not, why does >> anyone still use cpp for Haskell? >> > > Licensing. http://projects.haskell.org/cpphs/ says: """ License: The library modules in cpphs are distributed under the terms of the LGPL (see file LICENCE-LGPL for more details). If that's a problem for you, contact me to make other arrangements. The application module 'cpphs.hs' itself is GPL (see file LICENCE-GPL). If you have a commercial use for cpphs and find the terms of the (L)GPL too onerous, you can instead choose to distribute unmodified binaries (not source), under the terms of LICENCE-commercial """ I can't see how this would inconvenience anyone. Besides, GNU's cpp is certainly GPL licensed; I wonder why different standards are applied here. Cheers Ben -- "Make it so they have to reboot after every typo." ― Scott Adams From juhpetersen at gmail.com Thu Jan 19 00:37:54 2017 From: juhpetersen at gmail.com (Jens Petersen) Date: Thu, 19 Jan 2017 09:37:54 +0900 Subject: [Haskell-cafe] [ANNOUNCE] Glasgow Haskell Compiler 8.0.2 is available! In-Reply-To: <87wpe1ignm.fsf@ben-laptop.smart-cactus.org> References: <87wpe1ignm.fsf@ben-laptop.smart-cactus.org> Message-ID: On 12 January 2017 at 03:40, Ben Gamari wrote: > The GHC team is happy to at last announce the 8.0.2 release of the > Glasgow Haskell Compiler. Source and binary distributions are available > Thank you Fedora 24+ and RHEL 7 et al users can install it from my Fedora Copr repo: https://copr.fedorainfracloud.org/coprs/petersen/ghc-8.0.2/ The Fedora builds have been there for some time now but I just added the EPEL7 build yesterday. Jens -------------- next part -------------- An HTML attachment was scrubbed... URL: From ok at cs.otago.ac.nz Thu Jan 19 01:17:14 2017 From: ok at cs.otago.ac.nz (Richard A. O'Keefe) Date: Thu, 19 Jan 2017 14:17:14 +1300 Subject: [Haskell-cafe] Using stringize and string concatenation in ghc preprocessing In-Reply-To: References: Message-ID: On 19/01/17 12:04 PM, Ben Franksen wrote: > Besides, GNU's cpp is certainly GPL licensed; I wonder why different > standards are applied here. GNU's cpp is not the only one around. I have the Sun/Oracle compilers, which don't use GNU cpp; I had the Intel compilers, which don't use GNU cpp; there's the preprocessor that comes with lcc, which isn't GNU cpp; and I also have mcpp and warp (in D) and jcpp (in Java). There must be others out there. From allbery.b at gmail.com Thu Jan 19 01:21:33 2017 From: allbery.b at gmail.com (Brandon Allbery) Date: Wed, 18 Jan 2017 20:21:33 -0500 Subject: [Haskell-cafe] Using stringize and string concatenation in ghc preprocessing In-Reply-To: References: Message-ID: On Wed, Jan 18, 2017 at 8:17 PM, Richard A. O'Keefe wrote: > On 19/01/17 12:04 PM, Ben Franksen wrote: > >> Besides, GNU's cpp is certainly GPL licensed; I wonder why different >> standards are applied here. >> > > GNU's cpp is not the only one around. Which gets at the real point: these compilers come with the system or are otherwise provided by the vendor for more general purposes. (If someone downloaded icc and used its cpp, monitoring license compliance is their problem). Someone with corporate lawyers to satisfy may well need to avoid GPL, so they would use neither gcc nor cpphs (but the alternatives after that are few on the ground, given that clang's cpp doesn't like being abused for Haskell source...). -- 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 damian.nadales at gmail.com Thu Jan 19 11:32:05 2017 From: damian.nadales at gmail.com (Damian Nadales) Date: Thu, 19 Jan 2017 12:32:05 +0100 Subject: [Haskell-cafe] Approaches for a DSL for API-level testing Message-ID: Hello, I'm writing an embedded DSL for API level testing. The idea in a nutshell is that I can write tests like the following one: createProjectCreates = do p <- createProject "foobar" ps <- getProjects ps `shouldContain` p Here http://stackoverflow.com/questions/41740658/separating-concerns-in-a-dsl-using-mtl I show a sketch of the solution I'm working on, and the issues I'm running into. I wonder whether there are other approaches to embedded DSL writing in Haskell that allows for a better compositionality and separation of concerns. Thanks! Damian. From info at haskellweekly.news Thu Jan 19 15:03:53 2017 From: info at haskellweekly.news (=?utf-8?Q?Haskell=20Weekly?=) Date: Thu, 19 Jan 2017 15:03:53 +0000 Subject: [Haskell-cafe] =?utf-8?q?Haskell_Weekly_-_01/18/2017?= Message-ID: <49a6a2e17b12be2c5c4dcb232.cb0e043b77.20170119150337.d1f16b3bfc.a3294545@mail70.atl51.rsgsv.net> View this email in your browser (http://us10.campaign-archive2.com/?u=49a6a2e17b12be2c5c4dcb232&id=d1f16b3bfc&e=cb0e043b77) ** Haskell Weekly (http://news.us10.list-manage1.com/track/click?u=49a6a2e17b12be2c5c4dcb232&id=b2ce8a0cac&e=cb0e043b77) ------------------------------------------------------------ ** Issue 38 (http://news.us10.list-manage.com/track/click?u=49a6a2e17b12be2c5c4dcb232&id=de22dd7431&e=cb0e043b77) ------------------------------------------------------------ Welcome to Haskell Weekly! Haskell (http://news.us10.list-manage.com/track/click?u=49a6a2e17b12be2c5c4dcb232&id=252536aed4&e=cb0e043b77) is an advanced, purely functional programming language. This is a weekly summary of what’s going on in its community. You can subscribe to the email newsletter (http://news.us10.list-manage1.com/track/click?u=49a6a2e17b12be2c5c4dcb232&id=9cce0b8a8d&e=cb0e043b77) or the Atom feed (/haskell-weekly.atom) . Want to contribute to Haskell Weekly? Send us a message on Twitter (http://news.us10.list-manage.com/track/click?u=49a6a2e17b12be2c5c4dcb232&id=99e52877ab&e=cb0e043b77) or open an issue on GitHub (http://news.us10.list-manage1.com/track/click?u=49a6a2e17b12be2c5c4dcb232&id=5d277e761c&e=cb0e043b77) . ** News from the Haskell community ------------------------------------------------------------ * Brent Yorgey’s new programming languages course (http://news.us10.list-manage.com/track/click?u=49a6a2e17b12be2c5c4dcb232&id=2e0a4d0417&e=cb0e043b77) My new PL course is now finished, and all the course materials are freely available. Working through all the exercises should be a great option for anyone wishing to learn some basics of programming language design and implementation. * CLaSH 0.7 released: GHC 8 support and more (http://news.us10.list-manage.com/track/click?u=49a6a2e17b12be2c5c4dcb232&id=b4d5dfb3a2&e=cb0e043b77) Our company has been hired to do FPGA development work, and best of all, we get to use CLaSH. As a consequence, I cannot put as much time into CLaSH development as during my days as a PhD/PostDoc. However, we do now get to use CLaSH in industry! And as part of the contract there is time to find and fix bugs in CLaSH! * safe-prelude: a thought experiment (http://news.us10.list-manage.com/track/click?u=49a6a2e17b12be2c5c4dcb232&id=fd6c641c69&e=cb0e043b77) This is a thought experiment in a different point in the alternative prelude design space. After my blog post on readFile, I realized I was unhappy with the polymorphic nature of readFile in classy-prelude. Adding that with Haskell Pitfalls I’ve been itching to try something else. * Selecting a platform: JavaScript vs Elm vs PureScript vs GHCJS vs Scala.js (http://news.us10.list-manage.com/track/click?u=49a6a2e17b12be2c5c4dcb232&id=d5f09e7db8&e=cb0e043b77) There are not many people who have worked on production applications in multiple frontend FP systems, and lived to tell the tale. So here goes, my guide to selecting a functional programming platform for the browser. * The design and use of QuickCheck (http://news.us10.list-manage.com/track/click?u=49a6a2e17b12be2c5c4dcb232&id=a96ae75e06&e=cb0e043b77) The typical examples you’ll find online have deceptively simple code. The examples make it hard to learn how their succinct tests are possible, and how to customize them when things go wrong. This guide puts it all together piece by piece so you can use QuickCheck with confidence. * Monads made difficult (http://news.us10.list-manage.com/track/click?u=49a6a2e17b12be2c5c4dcb232&id=d433789262&e=cb0e043b77) This is a short, fast and analogy-free introduction to Haskell monads derived from a categorical perspective. This assumes you are familiar with Haskell and basic category theory. * Constraint kinds (http://news.us10.list-manage.com/track/click?u=49a6a2e17b12be2c5c4dcb232&id=debdb1a734&e=cb0e043b77) In this blog post, I will show some examples of using the ConstraintKinds GHC extension. Classes and contexts were not first-class citizens in Haskell, but the introduction of the Constraint kind has changed this and allows them to be used as parameters of types. * Expressive types, not oppressive types (http://news.us10.list-manage.com/track/click?u=49a6a2e17b12be2c5c4dcb232&id=08a4ca590a&e=cb0e043b77) Uncle Bob looks at advanced type systems and sees them as more oppressive rather than more expressive. Being able to describe whether or not a function can return null is an opportunity, not a constraint. * LiquidHaskell (http://news.us10.list-manage.com/track/click?u=49a6a2e17b12be2c5c4dcb232&id=1642bf1cdf&e=cb0e043b77) LiquidHaskell (LH) refines Haskell’s types with logical predicates that let you enforce critical properties at compile time. ** Package of the week ------------------------------------------------------------ This week’s package of the week is dump-core (http://news.us10.list-manage.com/track/click?u=49a6a2e17b12be2c5c4dcb232&id=f3e328227e&e=cb0e043b77) , a GHC plugin for rendering Core. Send us a message on Twitter (http://news.us10.list-manage2.com/track/click?u=49a6a2e17b12be2c5c4dcb232&id=cb9d63a38a&e=cb0e043b77) to nominate next week’s package! ============================================================ Copyright © 2017 Haskell Weekly, All rights reserved. You are receiving this email because you opted in at our website haskellweekly.news. Our mailing address is: Haskell Weekly 13140 Coit Rd Ste 405 Dallas, TX 75240 USA Want to change how you receive these emails? You can ** update your preferences (http://news.us10.list-manage.com/profile?u=49a6a2e17b12be2c5c4dcb232&id=ffbbbbd930&e=cb0e043b77) or ** unsubscribe from this list (http://news.us10.list-manage.com/unsubscribe?u=49a6a2e17b12be2c5c4dcb232&id=ffbbbbd930&e=cb0e043b77&c=d1f16b3bfc) Email Marketing Powered by MailChimp http://www.mailchimp.com/monkey-rewards/?utm_source=freemium_newsletter&utm_medium=email&utm_campaign=monkey_rewards&aid=49a6a2e17b12be2c5c4dcb232&afl=1 -------------- next part -------------- An HTML attachment was scrubbed... URL: From aditya.siram at gmail.com Thu Jan 19 22:16:48 2017 From: aditya.siram at gmail.com (aditya siram) Date: Thu, 19 Jan 2017 14:16:48 -0800 Subject: [Haskell-cafe] Haskell with C++: removing runtime dependencies on Windows 10. Message-ID: Hi, I am trying to create an executable on Windows 10 with some Haskell->C++ bindings I wrote but having trouble getting rid of some runtime DLL dependencies. I'm currently compiling and linking using the MSYS2 and GHC environment that ships with Windows Stack installer but no matter what I do I end up with the following dependencies: $ ldd ... libwinpthread-1.dll => /c/Users/user/AppData/Local/Programs/stack/x86_64-windows/ghc-8.0.1/mingw/bin/libwinpthread-1.dll (0x64940000) libstdc++-6.dll => /c/Users/user/AppData/Local/Programs/stack/x86_64-windows/ghc-8.0.1/mingw/bin/libstdc++-6.dll (0x6fc40000) libgcc_s_seh-1.dll => /c/Users/user/AppData/Local/Programs/stack/x86_64-windows/ghc-8.0.1/mingw/bin/libgcc_s_seh-1.dll (0x61440000) I have verified that the standalone versions of those libs are in available in stack install: libstdc++: ../stack/x86_64-windows/ghc-8.0.1/mingw/lib/gcc/x86_64-w64-mingw32/5.2.0/libstdc++.a ../stack/x86_64-windows/ghc-8.0.1/mingw/lib/gcc/x86_64-w64-mingw32/5.2.0/libstdc++.dll.a ../stack/x86_64-windows/ghc-8.0.1/mingw/lib/gcc/x86_64-w64-mingw32/5.2.0/libgcc.a libgcc: ../stack/x86_64-windows/ghc-8.0.1/mingw/lib/gcc/x86_64-w64-mingw32/5.2.0/libgcc_eh.a ../stack/x86_64-windows/ghc-8.0.1/mingw/lib/gcc/x86_64-w64-mingw32/5.2.0/libgcc_s.a libpthread: ../stack/x86_64-windows/ghc-8.0.1/mingw/x86_64-w64-mingw32/lib/libpthread.a ../stack/x86_64-windows/ghc-8.0.1/mingw/x86_64-w64-mingw32/lib/libpthread.dll.a I've unsuccessfully tried to link them into the executable using many combinations of `-optl-static`, `-optl-static-gcc`, and `-optl-static-stdc++` and also passing along these libraries " raw" to the linker like: `ghc-Options: -pgml g++ "-optl-Wl,--whole-archive" "-optl-Wl,-Bstatic" "-optl-Wl,-lstdc++" "-optl-Wl,-Bdynamic" "-optl-Wl,--no-whole-archive" Short of shipping these DLL with the executable (which I'd really rather not do) I'm running out of ideas so any suggestions would be appreciated. Thanks! -deech -------------- next part -------------- An HTML attachment was scrubbed... URL: From litchard.michael at gmail.com Fri Jan 20 01:19:14 2017 From: litchard.michael at gmail.com (Michael Litchard) Date: Thu, 19 Jan 2017 17:19:14 -0800 Subject: [Haskell-cafe] monad prompt example missing Message-ID: There's an example from the Monad.Prompt documentation https://hackage.haskell.org/package/MonadPrompt-1.0.0.5/docs/Control-Monad-Prompt.html That is a dead link. http://paste.lisp.org/display/53766 Does anyone have a copy of this example, and of course any other ones you may know of. -------------- next part -------------- An HTML attachment was scrubbed... URL: From wiggly at wiggly.org Fri Jan 20 11:09:53 2017 From: wiggly at wiggly.org (Nigel Rantor) Date: Fri, 20 Jan 2017 11:09:53 +0000 Subject: [Haskell-cafe] Strange encoding issue with Text and Servant In-Reply-To: References: <9507e43e-8c2b-fdf3-73d1-9135c6cb2a49@wiggly.org> Message-ID: Just wondering if you figured out what was going weird here. n From capn.freako at gmail.com Fri Jan 20 14:42:43 2017 From: capn.freako at gmail.com (David Banas) Date: Fri, 20 Jan 2017 06:42:43 -0800 Subject: [Haskell-cafe] Haskell with C++: removing runtime dependencies on Windows 10. In-Reply-To: References: Message-ID: <99591CB6-434C-49A0-AA03-19819EF576D1@gmail.com> Hi Deech, Not sure this is helpful, as I haven’t tested it on Windows 10, but here are the gcc/ghc compile/link options I use for a project that has a similar need: CC = gcc CFLAGS += -I/usr/lib/ghc-7.4.2/include/ -g -fPIC HC = ghc HC_OPTS = -cpp -O3 $(EXTRA_HC_OPTS) EXTRA_HC_OPTS = -package parsec -dynamic -fPIC -rtsopts HC_LOPTS = -shared -dynamic -package parsec -lHSrts -lm -lffi -lrt -db From mail at stefanwehr.de Fri Jan 20 17:30:16 2017 From: mail at stefanwehr.de (Stefan Wehr) Date: Fri, 20 Jan 2017 17:30:16 +0000 Subject: [Haskell-cafe] Call for Participation: BOB 2017 (February 24, Berlin) Message-ID: Reminder: early registration ends this Monday! ================================================================ BOB 2017 Conference "What happens if we simply use what's best?" February 24, 2017 Berlin http://bobkonf.de/2017/ Program: http://bobkonf.de/2017/program.html Registration: http://bobkonf.de/2017/registration.html ================================================================ BOB is the conference for developers, architects and decision-makers to explore technologies beyond the mainstream in software development, and to find the best tools available to software developers today. Our goal is for all participants of BOB to return home with new insights that enable them to improve their own software development experiences. The program features 14 talks and 8 tutorials on current topics: http://bobkonf.de/2017/program.html The subject range of talks includes functional programming, advanced front-end development, and sophisticated uses of types. The tutorials feature introductions to Haskell, Swift, PureScript, React, QuickCheck, Agda, CRDTs and Servant. John Hughes will give the keynote talk. Registration is open online: http://bobkonf.de/2017/registration.html NOTE: The early-bird rates expire on January 23, 2017! BOB cooperates with the :clojured conference on the following day. There is a registration discount available for participants of both events. http://www.clojured.de/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From johannes.waldmann at htwk-leipzig.de Fri Jan 20 21:34:25 2017 From: johannes.waldmann at htwk-leipzig.de (Johannes Waldmann) Date: Fri, 20 Jan 2017 22:34:25 +0100 Subject: [Haskell-cafe] gloss from ghci Message-ID: <6dad72fc-8720-2f95-486f-c331e4013bd3@htwk-leipzig.de> Dear Cafe - I am trying to use gloss https://hackage.haskell.org/package/gloss from ghci. The "display" command will open a window and draw the picture on it just fine. But when I close this window by hitting ESC, ghci prints : interrupted and exits, so I'm back at the shell from where I started ghci. This is somewhat annoying - especially since ghci's command line history does not get written, so when I re-start it, I have to re-type (work-around: before "display", close ghci, this will write history, then restart and draw. Ugly.) The gloss FAQ suggests ghci -fno-ghci-sandbox but this does not help (ghci still exits, this time, without printing the message). - J. From gershomb at gmail.com Sat Jan 21 07:30:35 2017 From: gershomb at gmail.com (Gershom B) Date: Sat, 21 Jan 2017 02:30:35 -0500 Subject: [Haskell-cafe] Announce: Haskell Platform 8.0.2 Message-ID: On behalf of the Haskell Platform team, I'm happy to announce the release of Haskell Platform 8.0.2 Now available at https://www.haskell.org/platform/ This includes GHC 8.0.2, cabal-install 1.24.0.2, and stack 1.3.2, all with many bugfixes and improvements since the last platform release. This platform release we've cleaned up the webpage a bit, and renamed the "minimal" distribution to the "core" distribution to highlight that it is the recommended approach (and simplified the accompanying text). A number of improvements have been made to the windows installer -- notably the /S option for silent install is now in fully working order, and we have the flags /STACK and /D (for stack and platform-ghc install paths). The installer expects no quoting of paths, even with spaces within the paths, like so: HaskellPlatform-8.0.2-full-x86_64-setup.exe /S /STACK=c:\My install path for stack\local\bin /D=c:\program files\Haskell\Platform\8.0.2 There is also an updated version of msys2 included, which includes pacman, et al. to ease the installation of libraries with more complex foreign dependencies. Changes to Contents: * As a result of transitive dependencies of platform packages, the integer-logarithms and call-stack packages have been added to the full platform. A full list of contents is available at https://www.haskell.org/platform/contents.html Thanks to all the contributors to this release, thanks to all the package and tool maintainers and authors, and a big thanks to the GHC team for all their hard work. A list of new GHC changes is available at: https://ghc.haskell.org/trac/ghc/blog/ghc-8.0.2-released A list of cabal changes is available at: https://hackage.haskell.org/package/cabal-install-1.24.0.2/changelog The new cabal documentation page is at: https://cabal.readthedocs.io/en/latest/ A list of stack changes is at: https://docs.haskellstack.org/en/stable/ChangeLog/ Happy Haskell Hacking all, Gershom (Note -- one feature we have not implemented yet for the platform but would like to is a generic linux installer that allows one to set a custom location and does not require root. Anyone who would like to volunteer to help with this, please get in touch!) From codygman.consulting at gmail.com Sun Jan 22 11:27:23 2017 From: codygman.consulting at gmail.com (Cody Goodman) Date: Sun, 22 Jan 2017 05:27:23 -0600 Subject: [Haskell-cafe] Soliciting feedback on my lens json parsing tutorial (please don't share yet!) Message-ID: Hi All, I wrote a lens json parsing tutorial here: https://github.com/codygman/concise-json-parsing-in-haskell I'd appreciate any feedback. My approach tries to use a prior understanding of Python into understanding lens enough to do something useful. Perhaps I can include links to tutorials that cover more of the theoretical foundations as well. Any criticism and/or ideas is welcome! Thanks, Cody Goodman -------------- next part -------------- An HTML attachment was scrubbed... URL: From ben.franksen at online.de Sun Jan 22 15:46:04 2017 From: ben.franksen at online.de (Ben Franksen) Date: Sun, 22 Jan 2017 16:46:04 +0100 Subject: [Haskell-cafe] Using stringize and string concatenation in ghc preprocessing In-Reply-To: References: Message-ID: Am 19.01.2017 um 02:17 schrieb Richard A. O'Keefe: > On 19/01/17 12:04 PM, Ben Franksen wrote: >> Besides, GNU's cpp is certainly GPL licensed; I wonder why different >> standards are applied here. > > GNU's cpp is not the only one around. I did not mean to suggest that. > I have the Sun/Oracle compilers, which don't use GNU cpp; > I had the Intel compilers, which don't use GNU cpp; > there's the preprocessor that comes with lcc, which isn't GNU cpp; > and I also have mcpp and warp (in D) and jcpp (in Java). > There must be others out there. Fine. What is the point you want to make with that listing? Cheers Ben -- "Make it so they have to reboot after every typo." ― Scott Adams From ben.franksen at online.de Sun Jan 22 16:14:33 2017 From: ben.franksen at online.de (Ben Franksen) Date: Sun, 22 Jan 2017 17:14:33 +0100 Subject: [Haskell-cafe] Using stringize and string concatenation in ghc preprocessing In-Reply-To: References: Message-ID: Am 19.01.2017 um 02:21 schrieb Brandon Allbery: > On Wed, Jan 18, 2017 at 8:17 PM, Richard A. O'Keefe > wrote: > >> On 19/01/17 12:04 PM, Ben Franksen wrote: >> >>> Besides, GNU's cpp is certainly GPL licensed; I wonder why different >>> standards are applied here. >>> >> >> GNU's cpp is not the only one around. > > Which gets at the real point: these compilers come with the system or are > otherwise provided by the vendor for more general purposes. (If someone > downloaded icc and used its cpp, monitoring license compliance is their > problem). > Someone with corporate lawyers to satisfy may well need to avoid > GPL, so they would use neither gcc nor cpphs This would be a problem only if they anticipate a need to distibute modified versions of cpphs or other sorts of work derived from it. How probable is that? To re-iterate, GPL in no way restricts usage, not even modification (for whatever purpose), merely the re-distribution of derived work. The whole argument strikes me as a transparent attempt to discredit GPL licensed software, brough forward by certain parties that, for political reasons, dislike GPL and want to spead FUD against it. Cheers Ben -- "Make it so they have to reboot after every typo." ― Scott Adams From allbery.b at gmail.com Sun Jan 22 16:18:08 2017 From: allbery.b at gmail.com (Brandon Allbery) Date: Sun, 22 Jan 2017 11:18:08 -0500 Subject: [Haskell-cafe] Using stringize and string concatenation in ghc preprocessing In-Reply-To: References: Message-ID: On Sun, Jan 22, 2017 at 11:14 AM, Ben Franksen wrote: > This would be a problem only if they anticipate a need to distibute > modified versions of cpphs or other sorts of work derived from it. > Corporate lawyers are not interested in *your* interpretation of GPL, only their own. And most of them won't touch GPL3 or even LGPL3 with a ten foot pole. Shouting your interpretation of it at them won't change anything. -- 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 will.yager at gmail.com Sun Jan 22 19:35:24 2017 From: will.yager at gmail.com (Will Yager) Date: Sun, 22 Jan 2017 13:35:24 -0600 Subject: [Haskell-cafe] Soliciting feedback on my lens json parsing tutorial (please don't share yet!) In-Reply-To: References: Message-ID: Looks good! I would suggest putting near the beginning a note to the effect of "Note: This may look very verbose now, but I am going to explain how to make these statements idiomatic and compact further down. I'm just being explicit now." Otherwise, I would worry about people being scared off by the fact that the parenthesized, non-eta-reduced version is much longer and harder to read than the Python version. Maybe also compare the short version to the Python version, just to wrap up the tutorial? Cheers, Will > On Jan 22, 2017, at 05:27, Cody Goodman wrote: > > Hi All, I wrote a lens json parsing tutorial here: https://github.com/codygman/concise-json-parsing-in-haskell > > I'd appreciate any feedback. My approach tries to use a prior understanding of Python into understanding lens enough to do something useful. Perhaps I can include links to tutorials that cover more of the theoretical foundations as well. > > Any criticism and/or ideas is welcome! > > Thanks, > > Cody Goodman > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. -------------- next part -------------- An HTML attachment was scrubbed... URL: From heraldhoi at gmail.com Sun Jan 22 21:06:46 2017 From: heraldhoi at gmail.com (Geraldus) Date: Sun, 22 Jan 2017 21:06:46 +0000 Subject: [Haskell-cafe] Soliciting feedback on my lens json parsing tutorial (please don't share yet!) In-Reply-To: References: Message-ID: Also, after you've defined isHkOrLU function you use it only once (in the same code block), however there are few use cases of "naked" (`elem` ["HK", "LU"]) in the rest part of article. Would it make sense to substitute them with defined alias? пн, 23 янв. 2017 г. в 0:37, Will Yager : > Looks good! I would suggest putting near the beginning a note to the > effect of "Note: This may look very verbose now, but I am going to explain > how to make these statements idiomatic and compact further down. I'm just > being explicit now." Otherwise, I would worry about people being scared off > by the fact that the parenthesized, non-eta-reduced version is much longer > and harder to read than the Python version. > > Maybe also compare the short version to the Python version, just to wrap > up the tutorial? > > Cheers, > Will > > On Jan 22, 2017, at 05:27, Cody Goodman > wrote: > > Hi All, I wrote a lens json parsing tutorial here: > https://github.com/codygman/concise-json-parsing-in-haskell > > I'd appreciate any feedback. My approach tries to use a prior > understanding of Python into understanding lens enough to do something > useful. Perhaps I can include links to tutorials that cover more of the > theoretical foundations as well. > > Any criticism and/or ideas is welcome! > > Thanks, > > Cody Goodman > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. -------------- next part -------------- An HTML attachment was scrubbed... URL: From ok at cs.otago.ac.nz Mon Jan 23 00:48:14 2017 From: ok at cs.otago.ac.nz (ok at cs.otago.ac.nz) Date: Mon, 23 Jan 2017 13:48:14 +1300 Subject: [Haskell-cafe] Using stringize and string concatenation in ghc preprocessing In-Reply-To: References: Message-ID: <6c1e4d02fb7ab32df510f64b04267f43.squirrel@chasm.otago.ac.nz> > Am 19.01.2017 um 02:17 schrieb Richard A. O'Keefe: >> On 19/01/17 12:04 PM, Ben Franksen wrote: >>> Besides, GNU's cpp is certainly GPL licensed; I wonder why different >>> standards are applied here. >> >> GNU's cpp is not the only one around. > > I did not mean to suggest that. > Fine. What is the point you want to make with that listing? I read you as saying that it was inappropriate to use any other licence before GCC's preprocessor is GPL-licensed, and I was making the point that alternatives (including proprietary and free) with different license are available. From ok at cs.otago.ac.nz Mon Jan 23 00:48:15 2017 From: ok at cs.otago.ac.nz (ok at cs.otago.ac.nz) Date: Mon, 23 Jan 2017 13:48:15 +1300 Subject: [Haskell-cafe] Using stringize and string concatenation in ghc preprocessing In-Reply-To: References: Message-ID: > Am 19.01.2017 um 02:17 schrieb Richard A. O'Keefe: >> On 19/01/17 12:04 PM, Ben Franksen wrote: >>> Besides, GNU's cpp is certainly GPL licensed; I wonder why different >>> standards are applied here. >> >> GNU's cpp is not the only one around. > > I did not mean to suggest that. > Fine. What is the point you want to make with that listing? I read you as saying that it was inappropriate to use any other licence before GCC's preprocessor is GPL-licensed, and I was making the point that alternatives (including proprietary and free) with different licences are available. From ok at cs.otago.ac.nz Mon Jan 23 00:48:30 2017 From: ok at cs.otago.ac.nz (ok at cs.otago.ac.nz) Date: Mon, 23 Jan 2017 13:48:30 +1300 Subject: [Haskell-cafe] Using stringize and string concatenation in ghc preprocessing In-Reply-To: References: Message-ID: <4de211a5256dbe7baefa61ee003c782d.squirrel@chasm.otago.ac.nz> > Am 19.01.2017 um 02:17 schrieb Richard A. O'Keefe: >> On 19/01/17 12:04 PM, Ben Franksen wrote: >>> Besides, GNU's cpp is certainly GPL licensed; I wonder why different >>> standards are applied here. >> >> GNU's cpp is not the only one around. > > I did not mean to suggest that. > Fine. What is the point you want to make with that listing? I read you as saying that it was inappropriate to use any other licence because GCC's preprocessor is GPL-licensed, and I was making the point that alternatives (including proprietary and free) with different licences are available. From haskell-cafe at brisammon.fastmail.fm Mon Jan 23 03:38:19 2017 From: haskell-cafe at brisammon.fastmail.fm (Brian Sammon) Date: Sun, 22 Jan 2017 22:38:19 -0500 Subject: [Haskell-cafe] interfacing to C library - c2hs/hsc2hs/GreenCard? Message-ID: <20170122223819.a78a985ee4dda08f192d4102@brisammon.fastmail.fm> I'd like to write a haskell app that calls a C library that I wrote. This is my first time trying to do something like this. What would people here recommend I start with? c2hs? hsc2hs? GreenCard? One of the newer tools like bindings-dsl or inline-c? It's a relatively small library -- a handful of structs and a bunch of functions that take them as input, often returning another as output, and ultimately doing some libcurl to exchange data with websites. Also, can anyone recommend some documentation to read, that's applicable to GHC 8? A lot of the stuff I found on google predates GHC 8 (and a fair amount predates GHC 7)--not sure if that's likely to be a problem. From simon at mintsource.org Mon Jan 23 06:25:57 2017 From: simon at mintsource.org (Simon Peter Nicholls) Date: Mon, 23 Jan 2017 07:25:57 +0100 Subject: [Haskell-cafe] Possible to use Cabal-1.18 with ghc-6.12.3? Message-ID: Can I improve my setup, so that Cabal-1.18 will work better with ghc-6.12.3? I have an old project that I’m updating, which is currently compilable with 6.12.3. I’ve managed to get Cabal-1.18.1.7 and cabal-install-1.18.0.1 to build it, which gives me some handy extra tooling, but only if I pre-install all the project dependencies before updating Cabal. If I try to use a sandbox instead, the build will fail at the point where template-haskell is used: > Loading package utf8-string-0.3.7 ... : can't load .so/.DLL for: HSutf8-string-0.3.7 (libHSutf8-string-0.3.7.so: cannot open shared object file: No such file or directory) That’s a dependency in my sandbox, but this also fails if it’s installed to the default `~/.cabal`. I see a similar error if I try `runhaskell Setup.hs` instead of cabal: > Setup.hs: : can't load .so/.DLL for: HSCabal-1.18.1.7 (libHSCabal-1.18.1.7.so: cannot open shared object file: No such file or directory) So I figure Cabal-1.18 and my default 6.12.3 are not co-operating as well as they could. If I use —enable-shared in my dependency builds, I still get this error, and I also see it if I try to build statically. The template-haskell “Loading” steps always seems to fail by not finding a shared library, as if it’s stepping outside of Cabal (and my!) control. I note that installation locations are different in Cabal-1.18 (vs 1.16), but figure the GHC registration process takes care of something like `.cabal/lib/x86_64-linux-ghc-6.12.3/utf8-string-0.3.7/libHSutf8-string-0.3.7-ghc6.12.3.so`. A pre-installed parsec dependency looks like `ghc-6.12.3/lib/parsec-3.1.1/ghc-6.12.3/libHSparsec-3.1.1-ghc6.12.3.so`. Neither has the name format reported by the error. Is there something in my Cabal or my GHC setup that I can change, to get these working together? A clean fix would be great, but a bodge is fine, since this transition work is isolated in a docker container. Thanks. From polux2001 at gmail.com Mon Jan 23 07:47:28 2017 From: polux2001 at gmail.com (Paul Brauner) Date: Mon, 23 Jan 2017 07:47:28 +0000 Subject: [Haskell-cafe] free monad versus operational for blackjack game In-Reply-To: References: Message-ID: As far as I understand there's a more profound difference, see http://stackoverflow.com/a/14295488/357732. On Wed, Jan 18, 2017 at 8:23 PM Brandon Allbery wrote: > The operational package is just a free monad with some canned > conveniences. If what it provides is sufficient for your use case, there's > no reason to switch; but if they don't fit your use case, you can use one > of the other embellished free monads (e.g. MonadPrompt) or start from a > bare free monad and write what you need. > > On Wed, Jan 18, 2017 at 2:14 PM, Michael Litchard < > litchard.michael at gmail.com> wrote: > > I'm studying the code for a blackjack game: See marked answer. > http://codereview.stackexchange.com/questions/46809/blackjack-in-haskell > > It uses the operational package, and mentions one could write equivalent > code using a free monad. But my question is, for this use case is there any > benefit for using a free monad? > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. > > > > > -- > brandon s allbery kf8nh sine nomine > associates > allbery.b at gmail.com > ballbery at sinenomine.net > unix, openafs, kerberos, infrastructure, xmonad > http://sinenomine.net > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. -------------- next part -------------- An HTML attachment was scrubbed... URL: From mle+hs at mega-nerd.com Mon Jan 23 08:36:58 2017 From: mle+hs at mega-nerd.com (Erik de Castro Lopo) Date: Mon, 23 Jan 2017 19:36:58 +1100 Subject: [Haskell-cafe] interfacing to C library - c2hs/hsc2hs/GreenCard? In-Reply-To: <20170122223819.a78a985ee4dda08f192d4102@brisammon.fastmail.fm> References: <20170122223819.a78a985ee4dda08f192d4102@brisammon.fastmail.fm> Message-ID: <20170123193658.41b646d932a32d6d218472e2@mega-nerd.com> Brian Sammon wrote: > I'd like to write a haskell app that calls a C library that I wrote. > This is my first time trying to do something like this. What would > people here recommend I start with? c2hs? hsc2hs? GreenCard? One > of the newer tools like bindings-dsl or inline-c? I'm prety sure GreenCard is dead. Hsc2hs has the advantage of being bundled with GHC and used in the GHC build system to build the boostrap libraries. I've not used the others. Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/ From saurabhnanda at gmail.com Mon Jan 23 10:52:42 2017 From: saurabhnanda at gmail.com (Saurabh Nanda) Date: Mon, 23 Jan 2017 16:22:42 +0530 Subject: [Haskell-cafe] Bug-free, leak-free, battle-tested library for broadcast channels? Message-ID: (cross-posted from Reddit because I'm not sure of the audience overlap between haskell-cafe & reddit) I want to broadcast some instrumentation data from deep within my Haskell app. This data will have listeners in some environments (say, debug), but not others (say, production). Which library should I be using? A little searching threw two possible candidates: * http://hackage.haskell.org/package/split-channel * https://hackage.haskell.org/package/broadcast-chan But, I'm not sure if these are battle-tested. Any help would be appreciated. -- Saurabh. -------------- next part -------------- An HTML attachment was scrubbed... URL: From iblech at web.de Mon Jan 23 12:04:00 2017 From: iblech at web.de (Ingo Blechschmidt) Date: Mon, 23 Jan 2017 13:04:00 +0100 Subject: [Haskell-cafe] A proof that the list monad is not a free monad Message-ID: <20170123120400.GA15662@speicherleck.de> Dear lovers of generalized abstract nonsense, recall that we can construct, for any functor f, the free monad over f: data Free f a = Pure a | Roll (f (Free f a)) Intuitively, Free f a is the type of f-shaped trees with leaves of type a. The join operation merely grafts trees together and doesn't perform any further computations. Values of the form (Roll _) shall be called "nontrivial" in this posting. Some of the usual monads are in fact free monads over some functor: * The Tree monad is the free monad over the functor Pair, where data Pair a = MkPair a a. The intuition as Pair-shaped trees is most strong in this example. Every parent node has a pair of children. * The Maybe monad is the free monad over the functor Unit, where data Unit a = MkUnit. In the graphical picture parent nodes have a Unit of children, so no children at all. So there are exactly two Unit-shaped trees: the tree consisting only of a leaf (corresponding to Just _) and the three consisting of a childless parent node (corresponding to Nothing). * The Identity monad is the free monad over the functor Void, where Void a is a type without constructors. * The Partiality monad is the free monad over Maybe. * The Writer [r] monad is the free monad over the functor (r,). In an (r,)-shaped tree, a parent node is decorated with a value of type r and has exactly one child node. Traversing such a path yields a list of r's and a leaf value of type a, so in total a value of type ([r],a) = Writer r a. (In particular, Free (r,) () is isomorphic to [r]. This observation led to the claim that the list monad is free. But this claim is false and indeed doesn't follow from the observation. To show that a monad m is free, one has to exhibit a monad isomorphism forall a. m a -> Free f a for some functor f. In contrast, exhibiting an isomorphism of m a with Free (f a) () is neither sufficient nor required.) Even more monads are quotients of free monads. For instance, State s is a quotient of Free (StateF s), where data StateF s a = Put s a | Get (s -> a). -- NB: This functor is itself a free functor over a type constructor -- which is sometimes called StateI [1], rendering Free (StateF s) what -- Oleg and Hiromi Ishii call a "freer monad" [2]. The quotient is exhibited by the following monad morphism, which gives semantics to the purely syntactical values of the free monad. run :: Free (StateF s) a -> State s a run (Pure x) = return x run (Roll (Put s m)) = put s >> run m run (Roll (Get k)) = get >>= run . k This point of view is the basis of the operational package by apfelmus [1] and is also talked about in an StackOverflow thread [3]. It's the main reason why free monads are useful in a programming context. So, is the list monad a free monad? Intuitively, it's not, because the join operation of the list monad (concatenation) doesn't merely graft expressions together, but flattens them [4]. Here is a proof that the list monad is not free. I'm recording it since I've been interested in a proof for quite some time, but searching for it didn't yield any results. The threads [3] and [5] came close, though. In the free monad over any functor, the result of binding a nontrivial action with any function is always nontrivial, i.e. (Roll _ >>= _) = Roll _ This can be checked directly from the definition of (>>=) for the free monad or alternatively with Reid Barton's trick of exploiting a monad morphism to Maybe, see [3]. If the list monad was isomorphic-as-a-monad to the free monad over some functor, the isomorphism would map only singleton lists [x] to values of the form (Pure _) and all other lists to nontrivial values. This is because monad isomorphisms have to commute with "return" and return x is [x] in the list monad and Pure x in the free monad. These two facts contradict each other, as can be seen with the following example: do b <- [False,True] -- not of the form (return _) if b then return 47 else [] -- The result is the singleton list [47], so of the form (return _). After applying a hypothetical isomorphism to the free monad over some functor, we'd have that the binding of a nontrivial value (the image of [False,True] under the isomorphism) with some function results in a trivial value (the image of [47], i.e. return 47). Cheers, Ingo [1] http://projects.haskell.org/operational/Documentation.html [2] http://okmij.org/ftp/Haskell/extensible/more.pdf [3] http://stackoverflow.com/questions/14641864/what-monads-can-be-expressed-as-free-over-some-functor [4] https://hackage.haskell.org/package/free-4.12.4/docs/Control-Monad-Free.html [5] https://www.reddit.com/r/haskell/comments/50zvyb/why_is_liststate_not_a_free_monad/ From pieter at laeremans.org Mon Jan 23 14:11:12 2017 From: pieter at laeremans.org (Pieter Laeremans) Date: Mon, 23 Jan 2017 15:11:12 +0100 Subject: [Haskell-cafe] Dropbox sdk Message-ID: <1485180672.2760162.856546344.22D6BB8F@webmail.messagingengine.com> Hi all, I've tried using the dropbox sdk package from package today. But it is a bit outdated I can't get it to compile. I 've tried using stack init, with various resolvers. One of the problems seems to be that the dependencies for the certificate package used to by dropbox-sdk, enforces base < 4.8. How should I best tackle this problem ? Should I assume that the certificate package should be replaced by something else? And just try to modify the code ? I know it's open source, so I would prefer trying out a fix, and submitting a patch request, rather than bothering the maintainers. Thanks for your help, Pieter -- Pieter Laeremans pieter at laeremans.org From svenpanne at gmail.com Mon Jan 23 14:50:54 2017 From: svenpanne at gmail.com (Sven Panne) Date: Mon, 23 Jan 2017 15:50:54 +0100 Subject: [Haskell-cafe] gloss from ghci In-Reply-To: <6dad72fc-8720-2f95-486f-c331e4013bd3@htwk-leipzig.de> References: <6dad72fc-8720-2f95-486f-c331e4013bd3@htwk-leipzig.de> Message-ID: 2017-01-20 22:34 GMT+01:00 Johannes Waldmann < johannes.waldmann at htwk-leipzig.de>: > I am trying to use gloss https://hackage.haskell.org/package/gloss from > ghci. The "display" command will open a indow and draw the picture on it > just fine. > > But when I close this window by hitting ESC, ghci prints : > interrupted and exits, so I'm back at the shell from where I started ghci. > [...] > This is caused by: https://github.com/benl23x5/gloss/blob/277a89ec539471ad1f82ed1086ae4fdf55b4e81b/gloss/Graphics/Gloss/Internals/Interface/Backend/GLUT.hs#L51 GLUT's actionOnWindowClose *does* work, at least it does nowadays, the line in question is from 2011. I've just tested my HSuperBible7 package under ghci, and you can start/stop/restart the examples from the prompt. The relevant lines: https://github.com/svenpanne/HSuperBible7/blob/7e298a5d3cbfa5f739847a538b875aac7a634ee1/src/SB7/SB7/Application.hs#L124 https://github.com/svenpanne/HSuperBible7/blob/7e298a5d3cbfa5f739847a538b875aac7a634ee1/src/SB7/SB7/Application.hs#L201 I think this is worth a ticket in the gloss project... Cheers, S. -------------- next part -------------- An HTML attachment was scrubbed... URL: From mle+hs at mega-nerd.com Mon Jan 23 19:55:58 2017 From: mle+hs at mega-nerd.com (Erik de Castro Lopo) Date: Tue, 24 Jan 2017 06:55:58 +1100 Subject: [Haskell-cafe] Dropbox sdk In-Reply-To: <1485180672.2760162.856546344.22D6BB8F@webmail.messagingengine.com> References: <1485180672.2760162.856546344.22D6BB8F@webmail.messagingengine.com> Message-ID: <20170124065558.1a870d7e47bcca95126779d0@mega-nerd.com> Pieter Laeremans wrote: > Hi all, > > I've tried using the dropbox sdk package from package today. > But it is a bit outdated I can't get it to compile. > > I 've tried using stack init, with various resolvers. > One of the problems seems to be that the dependencies for the > certificate package used to > by dropbox-sdk, enforces base < 4.8. The certificate package: https://hackage.haskell.org/package/certificate is deprecated. Dropbox-sdk should be update to use the package that replaces it: https://hackage.haskell.org/package/x509 > How should I best tackle this problem ? > Should I assume that the certificate package should be replaced by > something else? > And just try to modify the code ? Once you replace the certificate dependency with x509 some code modifcations may be needed. Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/ From ben.franksen at online.de Mon Jan 23 19:55:14 2017 From: ben.franksen at online.de (Ben Franksen) Date: Mon, 23 Jan 2017 20:55:14 +0100 Subject: [Haskell-cafe] Using stringize and string concatenation in ghc preprocessing In-Reply-To: References: Message-ID: Am 22.01.2017 um 17:18 schrieb Brandon Allbery: > On Sun, Jan 22, 2017 at 11:14 AM, Ben Franksen > wrote: > >> This would be a problem only if they anticipate a need to distibute >> modified versions of cpphs or other sorts of work derived from it. >> > > Corporate lawyers are not interested in *your* interpretation of GPL, only > their own. It is not "my" intepretation, rather it is the "official" interpretation of the GPL according to the people who created it (the FSF). > And most of them won't touch GPL3 or even LGPL3 with a ten foot > pole. Shouting your interpretation of it at them won't change anything. Do you have any evidence to support this statement? I ask because if what you say is true, most companies willfully and severely restrict their options. For instance, a company that employs lawyers who "won't touch GPL3 or even LGPL3 with a ten foot pole" could not use Linux in any way (the kernel is GPL licensed), nor e.g. Android (based on Linux kernel). I have no data on how many companies in the world use Linux. What I do know is that many companies, even big corporations, actually support the Linux kernel with code (e.g. drivers), thus triggering the most restricting clauses in the GPL. For instance, Volkswagen AG has contributed socketcan to the kernel. Cheers Ben -- "Make it so they have to reboot after every typo." ― Scott Adams From ben.franksen at online.de Mon Jan 23 20:10:10 2017 From: ben.franksen at online.de (Ben Franksen) Date: Mon, 23 Jan 2017 21:10:10 +0100 Subject: [Haskell-cafe] Using stringize and string concatenation in ghc preprocessing In-Reply-To: <6c1e4d02fb7ab32df510f64b04267f43.squirrel@chasm.otago.ac.nz> References: <6c1e4d02fb7ab32df510f64b04267f43.squirrel@chasm.otago.ac.nz> Message-ID: Am 23.01.2017 um 01:48 schrieb ok at cs.otago.ac.nz: >> Am 19.01.2017 um 02:17 schrieb Richard A. O'Keefe: >>> On 19/01/17 12:04 PM, Ben Franksen wrote: >>>> Besides, GNU's cpp is certainly GPL licensed; I wonder why different >>>> standards are applied here. >>> >>> GNU's cpp is not the only one around. >> >> I did not mean to suggest that. >> Fine. What is the point you want to make with that listing? > > I read you as saying that it was inappropriate to use any > other licence before GCC's preprocessor is GPL-licensed, > and I was making the point that alternatives (including > proprietary and free) with different license are available. Right. So my argument about GNU cpp was not valid, since, in principle at least, there are non-GPL alternatives. How does that work in practice? What are people using on e.g. Windows as GHC's C-backend to avoid GPL? I venture that the native (Microsoft's) C compiler does not enter the picture here, it does not even support C90. Perhaps they use the LLVM backend? Cheers Ben -- "Make it so they have to reboot after every typo." ― Scott Adams From allbery.b at gmail.com Mon Jan 23 20:15:17 2017 From: allbery.b at gmail.com (Brandon Allbery) Date: Mon, 23 Jan 2017 15:15:17 -0500 Subject: [Haskell-cafe] Using stringize and string concatenation in ghc preprocessing In-Reply-To: References: Message-ID: On Mon, Jan 23, 2017 at 2:55 PM, Ben Franksen wrote: > Do you have any evidence to support this statement? I ask because if > what you say is true, most companies willfully and severely restrict > their options. > I suppose Apple isn't evidence. Perhaps Apple is a figment of my imagination? And no, they are not a singleton. Additionally, it's not hard to find past discussions of integrating cpphs into ghc, which were effectively blocked by many people reporting that corporate lawyers would force them to stop using ghc if it happened. GPL3 is *toxic* in the corporate world. Doesn't matter what RMS and co. claim outside the license itself; what decides reality is what lawyers determine from the working of the license, and their willingness to face court challenges based thereon. -- 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 svenpanne at gmail.com Mon Jan 23 20:21:57 2017 From: svenpanne at gmail.com (Sven Panne) Date: Mon, 23 Jan 2017 21:21:57 +0100 Subject: [Haskell-cafe] Using stringize and string concatenation in ghc preprocessing In-Reply-To: References: Message-ID: 2017-01-23 20:55 GMT+01:00 Ben Franksen : > It is not "my" intepretation, rather it is the "official" interpretation > of the GPL according to the people who created it (the FSF). > But "official" is not the same as "is accepted by any court". Of course the people who created the license have a biased view, but so do company lawyers (and the rest of the management): The "safe mode" for them is to say "no", you can't be blamed then and don't do anything wrong, at least not immediately. As a lot of things in life, such decisions are not driven by desire to improve the well-being of a greater entity (company/society/...), but purely personal interests. > Do you have any evidence to support this statement? Something like this happened to me at least three times in my career, and even if it's not direct refusal to accept such licenses, there are quite a few companies (especially bigger ones) which require a *lenghty* process to get SW with such licenses approved. This doesn't exactly encourage engineers to take that route... > I ask because if what you say is true, most companies willfully and > severely restrict > their options. There is no such thing as "the company", basically people are acting as individuals (see above). > For instance, a company that employs lawyers who "won't > touch GPL3 or even LGPL3 with a ten foot pole" could not use Linux in > any way (the kernel is GPL licensed), nor e.g. Android (based on Linux > kernel). [...] > That's not true: If you take $$$ and e.g. license your RedHat Enterprise Linux/SLES/..., you have a legal entity (RedHat, SuSE, ...) which takes the responsibility before court, not *your* company. So that's the easy way for lawyers. Alas, there is no GHC/cpphs company of sufficient size for this to work in our case. Disclaimer: I don't say that this is a perfect situation, but it's just what I've experienced. Just shouting "GPL is fine, you can use it!" ignores the darker side of company life... Cheers, S. -------------- next part -------------- An HTML attachment was scrubbed... URL: From spam at scientician.net Mon Jan 23 20:46:29 2017 From: spam at scientician.net (Bardur Arantsson) Date: Mon, 23 Jan 2017 21:46:29 +0100 Subject: [Haskell-cafe] Using stringize and string concatenation in ghc preprocessing In-Reply-To: References: Message-ID: On 2017-01-23 21:21, Sven Panne wrote: > If you take $$$ and e.g. license your RedHat Enterprise Linux/SLES/..., > you have a legal entity (RedHat, SuSE, ...) which takes the > responsibility before court, not *your* company. This is not true, unless there's some sort of idemnification clause in your license/contract with RH/SuSE/etc. (Of course you're not liable for copyright infrement done by RH/SuSE/etc., but you still have to comply with all licenses of whatever you derive your works from.) Such clauses are pretty rare and is basically in the realm of insurance. Regards, From pieter at laeremans.org Mon Jan 23 21:03:49 2017 From: pieter at laeremans.org (Pieter Laeremans) Date: Mon, 23 Jan 2017 22:03:49 +0100 Subject: [Haskell-cafe] Dropbox sdk In-Reply-To: <20170124065558.1a870d7e47bcca95126779d0@mega-nerd.com> References: <1485180672.2760162.856546344.22D6BB8F@webmail.messagingengine.com> <20170124065558.1a870d7e47bcca95126779d0@mega-nerd.com> Message-ID: <1485205429.3683066.857058760.2C115C5B@webmail.messagingengine.com> Thanks Erik, I've should have looked better. kind regards, Pieter -- Pieter Laeremans pieter at laeremans.org On Mon, Jan 23, 2017, at 08:55 PM, Erik de Castro Lopo wrote: > Pieter Laeremans wrote: > > > Hi all, > > > > I've tried using the dropbox sdk package from package today. > > But it is a bit outdated I can't get it to compile. > > > > I 've tried using stack init, with various resolvers. > > One of the problems seems to be that the dependencies for the > > certificate package used to > > by dropbox-sdk, enforces base < 4.8. > > The certificate package: > > https://hackage.haskell.org/package/certificate > > is deprecated. Dropbox-sdk should be update to use the package > that replaces it: > > https://hackage.haskell.org/package/x509 > > > How should I best tackle this problem ? > > Should I assume that the certificate package should be replaced by > > something else? > > And just try to modify the code ? > > Once you replace the certificate dependency with x509 some code > modifcations may be needed. > > Erik > -- > ---------------------------------------------------------------------- > Erik de Castro Lopo > http://www.mega-nerd.com/ From ben.franksen at online.de Mon Jan 23 21:10:12 2017 From: ben.franksen at online.de (Ben Franksen) Date: Mon, 23 Jan 2017 22:10:12 +0100 Subject: [Haskell-cafe] Using stringize and string concatenation in ghc preprocessing In-Reply-To: References: Message-ID: Am 23.01.2017 um 21:15 schrieb Brandon Allbery: > On Mon, Jan 23, 2017 at 2:55 PM, Ben Franksen > wrote: > >> Do you have any evidence to support this statement? I ask because if >> what you say is true, most companies willfully and severely restrict >> their options. >> > > I suppose Apple isn't evidence. Perhaps Apple is a figment of my > imagination? And no, they are not a singleton. Are you saying that Apple's lawyers are afraid of litigation because of GPL infringement? I very much doubt that. I think Apple is just opposed to GPL because their business model is built around proprietary hard- and software. They are against GPL because they *do* want to just grab stuff and sell it as closed source. > Additionally, it's not hard to find past discussions of integrating cpphs > into ghc, which were effectively blocked by many people reporting that > corporate lawyers would force them to stop using ghc if it happened. I have no doubt that there are companies and/or lawyers like that. What I doubt is that this is the overwhelming majority, as you seemed to suggest ("...most corporate lawyers..."). All the evidence you and Sven provided is merely anecdotal. > GPL3 is *toxic* in the corporate world. The wording you choose to express this suggests that either you agree with this point of view or else have listened too much to the wrong people, adopting their jargon. > Doesn't matter what RMS and co. > claim outside the license itself; what decides reality is what lawyers > determine from the working of the license, and their willingness to face > court challenges based thereon. Are there, at least, public statements on the net (by such lawyers), preferably with some sort of justification? Cheers Ben -- "Make it so they have to reboot after every typo." ― Scott Adams From olf at aatal-apotheke.de Mon Jan 23 21:17:07 2017 From: olf at aatal-apotheke.de (Olaf Klinke) Date: Mon, 23 Jan 2017 22:17:07 +0100 Subject: [Haskell-cafe] A proof that the list monad is not a free monad Message-ID: On a mostly unrelated note, Dan Doel elaborated [1] that the list monad is not the monad of free monoids either, even though mathematically the free monoid over x is the set of words of finite length with alphabet x. Briefly, the reason is that Haskell types are domains, not sets. Below is a proof that the free monad is not the free algebra. One approximant to free algebraic structures is to look at the free F-algebra for a functor F. This approach does not take into account any equations between the algebraic operations. {-# LANGUAGE Rank2Types,MultiParamTypeClasses,FlexibleInstances,FlexibleContexts #-} module FreeFAlg where import Control.Applicative import Control.Monad -- F-algebras (sans laws). class Functor f => Alg f a where alg :: f a -> a -- The free F-algebra over x, following Dan Doel's ideas, -- with the universal property baked in. newtype FreeAlg f x = FreeAlg (forall a. Alg f a => (x -> a) -> a) runFree :: Alg f a => FreeAlg f x -> (x -> a) -> a runFree (FreeAlg f) = f universal :: Alg f a => (x -> a) -> FreeAlg f x -> a universal = flip runFree instance Functor f => Alg f (FreeAlg f x) where alg ff = FreeAlg (\f -> alg (fmap (($f).runFree) ff)) instance Functor (FreeAlg f) where fmap h (FreeAlg fx) = FreeAlg (\f -> fx (f.h)) instance Monad (FreeAlg f) where return x = FreeAlg ($x) (FreeAlg fx) >>= k = FreeAlg (\f -> fx (\x -> runFree (k x) f)) instance Applicative (FreeAlg f) where pure = return (<*>) = ap data FreeMonad f x = Pure x | Roll (f (FreeMonad f x)) instance Functor f => Alg f (FreeMonad f x) where alg = Roll -- This looks like the same universal property... universal' :: Alg f a => (x -> a) -> FreeMonad f x -> a universal' f (Pure x) = f x universal' f (Roll ffree) = alg (fmap (universal' f) ffree) freeAlg2freeMonad :: Functor f => FreeAlg f x -> FreeMonad f x freeAlg2freeMonad = universal Pure freeMonad2freeAlg :: Functor f => FreeMonad f x -> FreeAlg f x freeMonad2freeAlg = universal' return The free monad is not the free F-algebra, because uniqueness fails. Consider the constant functor data Point a = Point instance Functor Point where fmap f Point = Point -- universal' f (Pure x) = f x -- universal' f (Roll Point) = alg Point -- but we have another function with the same type as universal': notUnique :: Alg Point a => (x -> a) -> FreeMonad Point x -> a notUnique f = const (alg Point) For classes like Monoid, which have equations between the algebraic operations (such as mappend mempty = id), we'd need the language extension that allows constraints as type parameters. I'd like to write Free Monoid x = Free (forall a. Monid a => (x -> a) -> a) but I am not experienced with the ConstraintKinds extension. Anyone help? Olaf [1] http://comonad.com/reader/2015/free-monoids-in-haskell/ From allbery.b at gmail.com Mon Jan 23 21:37:38 2017 From: allbery.b at gmail.com (Brandon Allbery) Date: Mon, 23 Jan 2017 16:37:38 -0500 Subject: [Haskell-cafe] Using stringize and string concatenation in ghc preprocessing In-Reply-To: References: Message-ID: On Mon, Jan 23, 2017 at 4:10 PM, Ben Franksen wrote: > I have no doubt that there are companies and/or lawyers like that. What > I doubt is that this is the overwhelming majority, as you seemed to > suggest ("...most corporate lawyers..."). All the evidence you and Sven > provided is merely anecdotal. > Mrrr. I was trying to back that off a bit; the real issue is not that it's "most", it's "enough to make ghc problematic". The last thread about cpphs (quick search gets me https://mail.haskell.org/pipermail/ghc-devs/2015-May/009106.html from the middle of it and containing a decent summary) indicated that a significant number of high profile Haskell users would be forced to drop Haskell if cpphs went into ghc, because they'd have to face the uphill battle of getting corporate lawyers to okay it again. "Just do it and fix the fallout afterward" is not a solution; once in, those lawyers would think twice about reinstating ghc if it were subsequently removed, because that's the safe stance legally speaking. -- 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 ben.franksen at online.de Mon Jan 23 21:42:54 2017 From: ben.franksen at online.de (Ben Franksen) Date: Mon, 23 Jan 2017 22:42:54 +0100 Subject: [Haskell-cafe] Using stringize and string concatenation in ghc preprocessing In-Reply-To: References: Message-ID: Am 23.01.2017 um 21:21 schrieb Sven Panne: > 2017-01-23 20:55 GMT+01:00 Ben Franksen : > >> It is not "my" intepretation, rather it is the "official" interpretation >> of the GPL according to the people who created it (the FSF). > > But "official" is not the same as "is accepted by any court". Of course the > people who created the license have a biased view, but so do company > lawyers (and the rest of the management): The "safe mode" for them is to > say "no", you can't be blamed then and don't do anything wrong, at least > not immediately. As a lot of things in life, such decisions are not driven > by desire to improve the well-being of a greater entity > (company/society/...), but purely personal interests. I can understand how this works. However, I would think that this is also a matter of weighing risks against opportunities. I would really like to talk to such a lawyer (in private) and ask him to explain to me how he thinks the GPL could cause legal risk for a company that merely uses the software. >> Do you have any evidence to support this statement? > > Something like this happened to me at least three times in my career, and > even if it's not direct refusal to accept such licenses, there are quite a > few companies (especially bigger ones) which require a *lenghty* process to > get SW with such licenses approved. This doesn't exactly encourage > engineers to take that route... Ok, still anecdotal evidence. Yes, there are such companies/lawyers. Perhaps this is enough to justify caution. I would still like to see some numbers. >> I ask because if what you say is true, most companies willfully and >> severely restrict >> their options. > > There is no such thing as "the company", basically people are acting as > individuals (see above). Ah, well. So if the CEO thinks opportunities trump the risks he/she *could* just overrule whatever the lawyers say. >> For instance, a company that employs lawyers who "won't >> touch GPL3 or even LGPL3 with a ten foot pole" could not use Linux in >> any way (the kernel is GPL licensed), nor e.g. Android (based on Linux >> kernel). [...] >> > > That's not true: If you take $$$ and e.g. license your RedHat Enterprise > Linux/SLES/..., you have a legal entity (RedHat, SuSE, ...) which takes the > responsibility before court, not *your* company. So that's the easy way for > lawyers. Alas, there is no GHC/cpphs company of sufficient size for this to > work in our case. I really don't understand that kind of logic. In particular, how exactly does getting GPL'd software from a vendor sich as RedHat allow the client to shift legal risks to that vendor? And what about RedHat themselves? Wouldn't *their* lawyers warn them against taking on such risks? This just doesn't make any sense to me. > Disclaimer: I don't say that this is a perfect situation, but it's just > what I've experienced. Just shouting "GPL is fine, you can use it!" ignores > the darker side of company life... Perhaps. I suspect that whatever corporate lawyers may say against GPL is simply irrational fear and stupid conservatism. BTW, are there *any* examples of court decisions against companies because of GPL infringements that may lend substance to these vague claims of terrible risks when using GPL licensed software? Cheers Ben -- "Make it so they have to reboot after every typo." ― Scott Adams From allbery.b at gmail.com Mon Jan 23 21:53:12 2017 From: allbery.b at gmail.com (Brandon Allbery) Date: Mon, 23 Jan 2017 16:53:12 -0500 Subject: [Haskell-cafe] Using stringize and string concatenation in ghc preprocessing In-Reply-To: References: Message-ID: On Mon, Jan 23, 2017 at 4:42 PM, Ben Franksen wrote: > > Perhaps. I suspect that whatever corporate lawyers may say against GPL > is simply irrational fear and stupid conservatism. > People aren't programs. Irrational fear and stupid conservatism are *reality*; if you don't factor them in, you lose. And you can't undo your mistakes by reverting. -- 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 svenpanne at gmail.com Mon Jan 23 22:25:57 2017 From: svenpanne at gmail.com (Sven Panne) Date: Mon, 23 Jan 2017 23:25:57 +0100 Subject: [Haskell-cafe] Using stringize and string concatenation in ghc preprocessing In-Reply-To: References: Message-ID: 2017-01-23 22:42 GMT+01:00 Ben Franksen : > Am 23.01.2017 um 21:21 schrieb Sven Panne: > > [...] Something like this happened to me at least three times in my > career, and > > even if it's not direct refusal to accept such licenses, there are quite > a > > few companies (especially bigger ones) which require a *lenghty* process > to > > get SW with such licenses approved. This doesn't exactly encourage > > engineers to take that route... [...] > > Ok, still anecdotal evidence. Well, seriously: What did you expect? That somebody here comes up with numbers like: "X% of company lawyers prefer to take the safe (i.e. ban GPL) route because of personal reasons and don't care about the greater good of their company"? Interesting numbers, sure, but a bit hard to figure out, I guess... > Yes, there are such companies/lawyers. Perhaps this is enough to justify > caution. I would still like to see > some numbers. > OK, how to get them? > > There is no such thing as "the company", basically people are acting as > > individuals (see above). > > Ah, well. So if the CEO thinks opportunities trump the risks he/she > *could* just overrule whatever the lawyers say. [...] > Same reasoning again: You basically get promoted by avoiding disaster (= law suit), not by being a hero who took some risks. Or at least take the risks and get quickly promoted away, before disaster happens. :-P So yes, they could overrule, but from my anecdotal evidence, this rarely happens. Would you like to be the one who said "I didn't care about what my lawyers said, and now we have this multi-million dollar law suit."? [...] Perhaps. I suspect that whatever corporate lawyers may say against GPL > is simply irrational fear and stupid conservatism. > We could talk endlessly about this, and this might even be true, but it doesn't change the basic fact: Lawyers are there to avoid damage for the company, and so they act... -------------- next part -------------- An HTML attachment was scrubbed... URL: From ben.franksen at online.de Mon Jan 23 22:45:37 2017 From: ben.franksen at online.de (Ben Franksen) Date: Mon, 23 Jan 2017 23:45:37 +0100 Subject: [Haskell-cafe] Using stringize and string concatenation in ghc preprocessing In-Reply-To: References: Message-ID: Am 23.01.2017 um 22:37 schrieb Brandon Allbery: > On Mon, Jan 23, 2017 at 4:10 PM, Ben Franksen > wrote: > >> I have no doubt that there are companies and/or lawyers like that. What >> I doubt is that this is the overwhelming majority, as you seemed to >> suggest ("...most corporate lawyers..."). All the evidence you and Sven >> provided is merely anecdotal. >> > > Mrrr. I was trying to back that off a bit; the real issue is not that it's > "most", it's "enough to make ghc problematic". The last thread about cpphs > (quick search gets me > https://mail.haskell.org/pipermail/ghc-devs/2015-May/009106.html from the > middle of it and containing a decent summary) indicated that a significant > number of high profile Haskell users would be forced to drop Haskell if > cpphs went into ghc, because they'd have to face the uphill battle of > getting corporate lawyers to okay it again. I can accept that. > "Just do it and fix the fallout afterward" is not a solution; once in, > those lawyers would think twice about reinstating ghc if it were > subsequently removed, because that's the safe stance legally speaking. Ok. So it is not advisable to integrate cpphs in ghc. I have no problem with that. Could we, instead, make it easy to use cpphs as drop-in replacement for cpp, so that it gets used whenever when the CPP language pragma is in effect? On platforms where the standard CPP is the one by GNU, cpphs could even be made the default. Cheers Ben -- "Make it so they have to reboot after every typo." ― Scott Adams From ben.franksen at online.de Mon Jan 23 23:43:15 2017 From: ben.franksen at online.de (Ben Franksen) Date: Tue, 24 Jan 2017 00:43:15 +0100 Subject: [Haskell-cafe] Using stringize and string concatenation in ghc preprocessing In-Reply-To: References: Message-ID: Am 23.01.2017 um 23:25 schrieb Sven Panne: > 2017-01-23 22:42 GMT+01:00 Ben Franksen : > We could talk endlessly about this Right. I am tired of it, too. I am ready to concede that there are /enough/ of these people around that it is a real problem for some Haskell users. For me things are exactly the opposite: as a Haskell preprocessor, using cpphs is the much safer option compared to CPP. History has shown that e.g. the gcc developers change cpp's behaviour in ways that are incompatible with using cpp for anything other than C or C++, even if that means interpreting the C standard in quite a liberal way. I would very much like to be able to use cpphs as a drop-in replacement for cpp and to be able to change the default cpp in a ghc configuration file, rather than at compile time (so I can still use a ghc packaged for my distro). Cheers Ben -- "Make it so they have to reboot after every typo." ― Scott Adams From ok at cs.otago.ac.nz Tue Jan 24 00:10:27 2017 From: ok at cs.otago.ac.nz (Richard A. O'Keefe) Date: Tue, 24 Jan 2017 13:10:27 +1300 Subject: [Haskell-cafe] Using stringize and string concatenation in ghc preprocessing In-Reply-To: References: Message-ID: I note that a company I worked for refused to have any GPL software on their machines, even GCC, due to legal advice. That was a couple of revisions of the GPL ago, but some scars last. From code at funwithsoftware.org Tue Jan 24 03:03:07 2017 From: code at funwithsoftware.org (Patrick Pelletier) Date: Mon, 23 Jan 2017 19:03:07 -0800 Subject: [Haskell-cafe] [ANN] wiringPi-1.0 Message-ID: <6db26e10-aa4a-3457-f2e6-2f7309af09df@funwithsoftware.org> https://hackage.haskell.org/package/wiringPi-1.0 https://github.com/ppelleti/hs-wiringPi I released wiringPi-0.1.0.0 less than two weeks ago, but already I have a new major version, with a breaking change. wiringPi-0.1.0.0 kept close to the C wiringPi library, which required calling a setup function. There were four different setup functions, and the choice of setup function determined the pin numbering scheme, which would affect all subsequent functions which used pin numbers. This sort of far-reaching global state felt very un-Haskell-like, and antithetical to modularity. So, in wiringPi-1.0, the setup function is called automatically the first time a wiringPi function is used. The wiringPi binding always configures the underlying C library to use the "Broadcom GPIO" pin numbering scheme. However, the Pin type now has three different constructors, to allow a pin to use any of the three pin-numbering schemes. These pin numbers are automatically converted to the "Broadcom GPIO" scheme internally. So now you can use any pin numbering scheme on a case-by-case basis, without having to make a global choice. About wiringPi: This is a Haskell binding to the wiringPi library, which allows you to interface with the GPIO pins on the Raspberry Pi. Unlike some other solutions for using the Raspberry Pi's GPIO pins, wiringPi provides access to more advanced features, such as enabling the internal pull-up or pull-down resistors. --Patrick From will.yager at gmail.com Tue Jan 24 05:19:54 2017 From: will.yager at gmail.com (William Yager) Date: Mon, 23 Jan 2017 23:19:54 -0600 Subject: [Haskell-cafe] [ANN] FastPush 0.1.0.0 Message-ID: In response to a bit of an obscure use case I had, I created this very simple library which gives you a Monad with a single operation, `push :: a -> m ()`. This operation pushes an item onto a stack (represented under the hood by a mutable ST vector). When you run the monad, you get the stack out as a vector. The library is quite fast. It's about 2x faster than C++'s std::vec::push_back compiled without optimizations, and about 40% as fast as std::vec::push_back when compiled with G++ -O2. There's almost certainly some low-hanging optimization fruit for anyone skilled at Haskell optimizing. The library is parametric over choice of mutable vector. You can use Unboxed, Storable, or normal vectors. I've even included a Push Monad Transformer based on Control.Monad.ST.Trans, but that's almost certainly unsafe, per the caveats listed in the Control.Monad.ST.Trans docs. https://hackage.haskell.org/package/FastPush-0.1.0.0 https://github.com/wyager/FastPush/ Cheers, Will -------------- next part -------------- An HTML attachment was scrubbed... URL: From harendra.kumar at gmail.com Tue Jan 24 06:22:04 2017 From: harendra.kumar at gmail.com (Harendra Kumar) Date: Tue, 24 Jan 2017 11:52:04 +0530 Subject: [Haskell-cafe] is it normal for docs to be pending for 24 hours? In-Reply-To: References: Message-ID: I am not sure if the problem has been resolved or if it has resurfaced again after getting resolved. I uploaded a package recently and the docs have not been generated even after a day. Here is the link to the package candidate that I uploaded: https://hackage.haskell.org/package/unicode-transforms-0.2.1/candidate Is there a place where I can see any debug logs or diagnostic messages to figure out what went wrong? -harendra On 16 November 2016 at 23:31, Gershom B wrote: > As an update -- the builder had a few other issues besides disk-space > in terms of getting a better retry policy in place, and properly > prioritizing new over older packages, etc. I think as of this morning > they're finally all worked through and it seems to be slowly chugging > through the backlog in a reasonable order, prioritizing new > uploads.I'll be checking in on the logs daily for the time being to > make sure it does't seem to be getting stuck. > > If your docs haven't built and you're impatient (understandably so!), > please don't bump your package version to kick the priority -- that'll > just put more metadata on the server we don't need. Instead, you can > build and upload your own docs as in this sample shell script: > > https://github.com/ekmett/lens/blob/master/scripts/hackage-docs.sh > > Best, > Gershom > > > On Fri, Nov 11, 2016 at 11:43 AM, Gershom B wrote: > > Sorry — the builder for docs has been in rough shape and we’re working > on it. In this case it got stuck due to disk space issues and monitoring > didn’t catch it. Its now running again but doing some catching up. (And > lots of stuff in the queue it failed to build due to other problems needs > to be replaced there, which is a manual process at the moment if we don’t > want the queue as a whole to just drown out any new things at all with > backlog). It would be much better to expose more queues and have better > monitoring (and real prioritization), and another volunteer to help ben out > on this would be very welcome (please contact me if you’re interested — the > code lives at https://github.com/haskell/hackage-server/blob/master/ > BuildClient.hs and there’s some uncommitted work on queuing as well). > > > > —gerhsom > > > > On November 8, 2016 at 8:37:19 PM, Patrick Pelletier ( > code at funwithsoftware.org) wrote: > >> This is only my second time uploading a package to Hackage, so I don't > >> yet have a feel for how it's supposed to go. I uploaded > >> normalization-insensitive-2.0.0.1 about 24 hours ago: > >> > >> https://hackage.haskell.org/package/normalization-insensitive-2.0.0.1 > >> > >> Under "Status", it says "Docs pending". (And the module names are all > >> non-clickable.) Is it normal to take this long to build the docs? Is > >> there some way to find out where in the queue my job is? Is this an > >> indication that something has gone wrong? How do I fix it? > >> > >> Thanks, > >> > >> --Patrick > >> > >> _______________________________________________ > >> Haskell-Cafe mailing list > >> To (un)subscribe, modify options or view archives go to: > >> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > >> Only members subscribed via the mailman list are allowed to post. > > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From simon.jakobi at googlemail.com Tue Jan 24 06:26:48 2017 From: simon.jakobi at googlemail.com (Simon Jakobi) Date: Tue, 24 Jan 2017 07:26:48 +0100 Subject: [Haskell-cafe] [ANN] FastPush 0.1.0.0 In-Reply-To: References: Message-ID: Thanks Will, This looks like a useful package! Would you mind extending the lower bound on vector a bit, in order to simplify installation with stack? Stackage lts and nightly still include vector-0.11. Cheers, Simon From will.yager at gmail.com Tue Jan 24 07:00:47 2017 From: will.yager at gmail.com (William Yager) Date: Tue, 24 Jan 2017 01:00:47 -0600 Subject: [Haskell-cafe] [ANN] FastPush 0.1.0.0 In-Reply-To: References: Message-ID: Alright, give that a shot. I also removed some unnecessary dependencies. The only dependencies now are base, vector, and STMonadTrans. Cheers, Will On Tue, Jan 24, 2017 at 12:26 AM, Simon Jakobi wrote: > Thanks Will, > > This looks like a useful package! Would you mind extending the lower > bound on vector a bit, in order to simplify installation with stack? > Stackage lts and nightly still include vector-0.11. > > Cheers, > Simon > -------------- next part -------------- An HTML attachment was scrubbed... URL: From imantc at gmail.com Tue Jan 24 07:02:17 2017 From: imantc at gmail.com (Imants Cekusins) Date: Tue, 24 Jan 2017 08:02:17 +0100 Subject: [Haskell-cafe] is it normal for docs to be pending for 24 hours? In-Reply-To: References: Message-ID: > the docs have not been generated if you installed Cabal 1.24, run cabal upload --doc ​ after you upload the package. With this command, the docs reliably appear in less than 1 minute. Option of generating docs on the hackage server is not even necessary any more. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gershomb at gmail.com Tue Jan 24 07:13:02 2017 From: gershomb at gmail.com (Gershom B) Date: Tue, 24 Jan 2017 02:13:02 -0500 Subject: [Haskell-cafe] is it normal for docs to be pending for 24 hours? In-Reply-To: References: Message-ID: Good question! The current incarnation of the builder doesn’t build candidate documentation — this is something we should change/implement. (Not sure if it ever built candidate documentation, actually?) The builder itself (I just checked) is running just fine and generating documentation for fully released packages. Best, Gershom On January 24, 2017 at 1:22:05 AM, Harendra Kumar (harendra.kumar at gmail.com) wrote: > I am not sure if the problem has been resolved or if it has resurfaced > again after getting resolved. I uploaded a package recently and the docs > have not been generated even after a day. Here is the link to the package > candidate that I uploaded: > > https://hackage.haskell.org/package/unicode-transforms-0.2.1/candidate > > Is there a place where I can see any debug logs or diagnostic messages to > figure out what went wrong? > > -harendra > > On 16 November 2016 at 23:31, Gershom B wrote: > > > As an update -- the builder had a few other issues besides disk-space > > in terms of getting a better retry policy in place, and properly > > prioritizing new over older packages, etc. I think as of this morning > > they're finally all worked through and it seems to be slowly chugging > > through the backlog in a reasonable order, prioritizing new > > uploads.I'll be checking in on the logs daily for the time being to > > make sure it does't seem to be getting stuck. > > > > If your docs haven't built and you're impatient (understandably so!), > > please don't bump your package version to kick the priority -- that'll > > just put more metadata on the server we don't need. Instead, you can > > build and upload your own docs as in this sample shell script: > > > > https://github.com/ekmett/lens/blob/master/scripts/hackage-docs.sh > > > > Best, > > Gershom > > > > > > On Fri, Nov 11, 2016 at 11:43 AM, Gershom B wrote: > > > Sorry — the builder for docs has been in rough shape and we’re working > > on it. In this case it got stuck due to disk space issues and monitoring > > didn’t catch it. Its now running again but doing some catching up. (And > > lots of stuff in the queue it failed to build due to other problems needs > > to be replaced there, which is a manual process at the moment if we don’t > > want the queue as a whole to just drown out any new things at all with > > backlog). It would be much better to expose more queues and have better > > monitoring (and real prioritization), and another volunteer to help ben out > > on this would be very welcome (please contact me if you’re interested — the > > code lives at https://github.com/haskell/hackage-server/blob/master/ > > BuildClient.hs and there’s some uncommitted work on queuing as well). > > > > > > —gerhsom > > > > > > On November 8, 2016 at 8:37:19 PM, Patrick Pelletier ( > > code at funwithsoftware.org) wrote: > > >> This is only my second time uploading a package to Hackage, so I don't > > >> yet have a feel for how it's supposed to go. I uploaded > > >> normalization-insensitive-2.0.0.1 about 24 hours ago: > > >> > > >> https://hackage.haskell.org/package/normalization-insensitive-2.0.0.1 > > >> > > >> Under "Status", it says "Docs pending". (And the module names are all > > >> non-clickable.) Is it normal to take this long to build the docs? Is > > >> there some way to find out where in the queue my job is? Is this an > > >> indication that something has gone wrong? How do I fix it? > > >> > > >> Thanks, > > >> > > >> --Patrick > > >> > > >> _______________________________________________ > > >> Haskell-Cafe mailing list > > >> To (un)subscribe, modify options or view archives go to: > > >> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > > >> Only members subscribed via the mailman list are allowed to post. > > > > > _______________________________________________ > > Haskell-Cafe mailing list > > To (un)subscribe, modify options or view archives go to: > > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > > Only members subscribed via the mailman list are allowed to post. > > > From harendra.kumar at gmail.com Tue Jan 24 07:56:46 2017 From: harendra.kumar at gmail.com (Harendra Kumar) Date: Tue, 24 Jan 2017 13:26:46 +0530 Subject: [Haskell-cafe] is it normal for docs to be pending for 24 hours? In-Reply-To: References: Message-ID: It did build candidate documentation earlier for me. Not sure if something changed recently. I always uploaded candidates, and when the documentation was generated, I reviewed it and then published the candidate. -harendra On 24 January 2017 at 12:43, Gershom B wrote: > Good question! > > The current incarnation of the builder doesn’t build candidate > documentation — this is something we should change/implement. (Not > sure if it ever built candidate documentation, actually?) > > The builder itself (I just checked) is running just fine and > generating documentation for fully released packages. > > Best, > Gershom > > On January 24, 2017 at 1:22:05 AM, Harendra Kumar > (harendra.kumar at gmail.com) wrote: > > I am not sure if the problem has been resolved or if it has resurfaced > > again after getting resolved. I uploaded a package recently and the docs > > have not been generated even after a day. Here is the link to the package > > candidate that I uploaded: > > > > https://hackage.haskell.org/package/unicode-transforms-0.2.1/candidate > > > > Is there a place where I can see any debug logs or diagnostic messages to > > figure out what went wrong? > > > > -harendra > > > > On 16 November 2016 at 23:31, Gershom B wrote: > > > > > As an update -- the builder had a few other issues besides disk-space > > > in terms of getting a better retry policy in place, and properly > > > prioritizing new over older packages, etc. I think as of this morning > > > they're finally all worked through and it seems to be slowly chugging > > > through the backlog in a reasonable order, prioritizing new > > > uploads.I'll be checking in on the logs daily for the time being to > > > make sure it does't seem to be getting stuck. > > > > > > If your docs haven't built and you're impatient (understandably so!), > > > please don't bump your package version to kick the priority -- that'll > > > just put more metadata on the server we don't need. Instead, you can > > > build and upload your own docs as in this sample shell script: > > > > > > https://github.com/ekmett/lens/blob/master/scripts/hackage-docs.sh > > > > > > Best, > > > Gershom > > > > > > > > > On Fri, Nov 11, 2016 at 11:43 AM, Gershom B wrote: > > > > Sorry — the builder for docs has been in rough shape and we’re > working > > > on it. In this case it got stuck due to disk space issues and > monitoring > > > didn’t catch it. Its now running again but doing some catching up. (And > > > lots of stuff in the queue it failed to build due to other problems > needs > > > to be replaced there, which is a manual process at the moment if we > don’t > > > want the queue as a whole to just drown out any new things at all with > > > backlog). It would be much better to expose more queues and have better > > > monitoring (and real prioritization), and another volunteer to help > ben out > > > on this would be very welcome (please contact me if you’re interested > — the > > > code lives at https://github.com/haskell/hackage-server/blob/master/ > > > BuildClient.hs and there’s some uncommitted work on queuing as well). > > > > > > > > —gerhsom > > > > > > > > On November 8, 2016 at 8:37:19 PM, Patrick Pelletier ( > > > code at funwithsoftware.org) wrote: > > > >> This is only my second time uploading a package to Hackage, so I > don't > > > >> yet have a feel for how it's supposed to go. I uploaded > > > >> normalization-insensitive-2.0.0.1 about 24 hours ago: > > > >> > > > >> https://hackage.haskell.org/package/normalization- > insensitive-2.0.0.1 > > > >> > > > >> Under "Status", it says "Docs pending". (And the module names are > all > > > >> non-clickable.) Is it normal to take this long to build the docs? Is > > > >> there some way to find out where in the queue my job is? Is this an > > > >> indication that something has gone wrong? How do I fix it? > > > >> > > > >> Thanks, > > > >> > > > >> --Patrick > > > >> > > > >> _______________________________________________ > > > >> Haskell-Cafe mailing list > > > >> To (un)subscribe, modify options or view archives go to: > > > >> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > > > >> Only members subscribed via the mailman list are allowed to post. > > > > > > > _______________________________________________ > > > Haskell-Cafe mailing list > > > To (un)subscribe, modify options or view archives go to: > > > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > > > Only members subscribed via the mailman list are allowed to post. > > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From simon.jakobi at googlemail.com Tue Jan 24 08:04:50 2017 From: simon.jakobi at googlemail.com (Simon Jakobi) Date: Tue, 24 Jan 2017 09:04:50 +0100 Subject: [Haskell-cafe] [ANN] FastPush 0.1.0.0 In-Reply-To: References: Message-ID: Thanks, works great! 2017-01-24 8:00 GMT+01:00 William Yager : > Alright, give that a shot. I also removed some unnecessary dependencies. The > only dependencies now are base, vector, and STMonadTrans. > > Cheers, > Will > > On Tue, Jan 24, 2017 at 12:26 AM, Simon Jakobi > wrote: >> >> Thanks Will, >> >> This looks like a useful package! Would you mind extending the lower >> bound on vector a bit, in order to simplify installation with stack? >> Stackage lts and nightly still include vector-0.11. >> >> Cheers, >> Simon > > From gershomb at gmail.com Tue Jan 24 08:06:43 2017 From: gershomb at gmail.com (Gershom B) Date: Tue, 24 Jan 2017 03:06:43 -0500 Subject: [Haskell-cafe] is it normal for docs to be pending for 24 hours? In-Reply-To: References: Message-ID: Right — we changed the builder to improve stability and handle things chronologically to avoid backlog when things got out of wack. But in the process I think we lost the candidate building. I filed a ticket to improve this: https://github.com/haskell/hackage-server/issues/568 Thanks again for the report! —Gershom On January 24, 2017 at 3:00:45 AM, Harendra Kumar (harendra.kumar at gmail.com) wrote: > It did build candidate documentation earlier for me. Not sure if something > changed recently. I always uploaded candidates, and when the documentation > was generated, I reviewed it and then published the candidate. > > -harendra > > On 24 January 2017 at 12:43, Gershom B wrote: > > > Good question! > > > > The current incarnation of the builder doesn’t build candidate > > documentation — this is something we should change/implement. (Not > > sure if it ever built candidate documentation, actually?) > > > > The builder itself (I just checked) is running just fine and > > generating documentation for fully released packages. > > > > Best, > > Gershom > > > > On January 24, 2017 at 1:22:05 AM, Harendra Kumar > > (harendra.kumar at gmail.com) wrote: > > > I am not sure if the problem has been resolved or if it has resurfaced > > > again after getting resolved. I uploaded a package recently and the docs > > > have not been generated even after a day. Here is the link to the package > > > candidate that I uploaded: > > > > > > https://hackage.haskell.org/package/unicode-transforms-0.2.1/candidate > > > > > > Is there a place where I can see any debug logs or diagnostic messages to > > > figure out what went wrong? > > > > > > -harendra > > > > > > On 16 November 2016 at 23:31, Gershom B wrote: > > > > > > > As an update -- the builder had a few other issues besides disk-space > > > > in terms of getting a better retry policy in place, and properly > > > > prioritizing new over older packages, etc. I think as of this morning > > > > they're finally all worked through and it seems to be slowly chugging > > > > through the backlog in a reasonable order, prioritizing new > > > > uploads.I'll be checking in on the logs daily for the time being to > > > > make sure it does't seem to be getting stuck. > > > > > > > > If your docs haven't built and you're impatient (understandably so!), > > > > please don't bump your package version to kick the priority -- that'll > > > > just put more metadata on the server we don't need. Instead, you can > > > > build and upload your own docs as in this sample shell script: > > > > > > > > https://github.com/ekmett/lens/blob/master/scripts/hackage-docs.sh > > > > > > > > Best, > > > > Gershom > > > > > > > > > > > > On Fri, Nov 11, 2016 at 11:43 AM, Gershom B wrote: > > > > > Sorry — the builder for docs has been in rough shape and we’re > > working > > > > on it. In this case it got stuck due to disk space issues and > > monitoring > > > > didn’t catch it. Its now running again but doing some catching up. (And > > > > lots of stuff in the queue it failed to build due to other problems > > needs > > > > to be replaced there, which is a manual process at the moment if we > > don’t > > > > want the queue as a whole to just drown out any new things at all with > > > > backlog). It would be much better to expose more queues and have better > > > > monitoring (and real prioritization), and another volunteer to help > > ben out > > > > on this would be very welcome (please contact me if you’re interested > > — the > > > > code lives at https://github.com/haskell/hackage-server/blob/master/ > > > > BuildClient.hs and there’s some uncommitted work on queuing as well). > > > > > > > > > > —gerhsom > > > > > > > > > > On November 8, 2016 at 8:37:19 PM, Patrick Pelletier ( > > > > code at funwithsoftware.org) wrote: > > > > >> This is only my second time uploading a package to Hackage, so I > > don't > > > > >> yet have a feel for how it's supposed to go. I uploaded > > > > >> normalization-insensitive-2.0.0.1 about 24 hours ago: > > > > >> > > > > >> https://hackage.haskell.org/package/normalization- > > insensitive-2.0.0.1 > > > > >> > > > > >> Under "Status", it says "Docs pending". (And the module names are > > all > > > > >> non-clickable.) Is it normal to take this long to build the docs? Is > > > > >> there some way to find out where in the queue my job is? Is this an > > > > >> indication that something has gone wrong? How do I fix it? > > > > >> > > > > >> Thanks, > > > > >> > > > > >> --Patrick > > > > >> > > > > >> _______________________________________________ > > > > >> Haskell-Cafe mailing list > > > > >> To (un)subscribe, modify options or view archives go to: > > > > >> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > > > > >> Only members subscribed via the mailman list are allowed to post. > > > > > > > > > _______________________________________________ > > > > Haskell-Cafe mailing list > > > > To (un)subscribe, modify options or view archives go to: > > > > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > > > > Only members subscribed via the mailman list are allowed to post. > > > > > > > > > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. From cdsmith at gmail.com Tue Jan 24 08:07:37 2017 From: cdsmith at gmail.com (Chris Smith) Date: Tue, 24 Jan 2017 00:07:37 -0800 Subject: [Haskell-cafe] Early feedback on a GHC proposal Message-ID: Anyone want to offer some early feedback on a GHC proposal I'm working on? It's called OverloadedApplication. Current version at https://github.com/cdsmith/ghc-proposals/blob/overloadedapplication/proposals/0000-overloaded-application.rst I am proposing something a bit more ambitious than what I need, because the proposal as written seems more likely to be broadly useful. The bit that I actually need is about desugaring of infix operators in the presence of RebindableSyntax. I'd love to get early thoughts from anyone who has a solid use case for the rest of the proposal. It feels like a thing that *ought* to be useful, but I'm drawing blanks at the moment. -------------- next part -------------- An HTML attachment was scrubbed... URL: From Andrew.Butterfield at scss.tcd.ie Tue Jan 24 08:11:35 2017 From: Andrew.Butterfield at scss.tcd.ie (Andrew Butterfield) Date: Tue, 24 Jan 2017 08:11:35 +0000 Subject: [Haskell-cafe] Using stringize and string concatenation in ghc preprocessing In-Reply-To: References: Message-ID: Why not write a new Haskell version of CPP with a more corporate-friendly OS license? (HPP ?) > On 23 Jan 2017, at 23:43, Ben Franksen wrote: > > Am 23.01.2017 um 23:25 schrieb Sven Panne: >> 2017-01-23 22:42 GMT+01:00 Ben Franksen : >> We could talk endlessly about this > > Right. I am tired of it, too. I am ready to concede that there are > /enough/ of these people around that it is a real problem for some > Haskell users. > > For me things are exactly the opposite: as a Haskell preprocessor, using > cpphs is the much safer option compared to CPP. History has shown that > e.g. the gcc developers change cpp's behaviour in ways that are > incompatible with using cpp for anything other than C or C++, even if > that means interpreting the C standard in quite a liberal way. > > I would very much like to be able to use cpphs as a drop-in replacement > for cpp and to be able to change the default cpp in a ghc configuration > file, rather than at compile time (so I can still use a ghc packaged for > my distro). > > Cheers > Ben > -- > "Make it so they have to reboot after every typo." ― Scott Adams > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. Andrew Butterfield School of Computer Science & Statistics Trinity College Dublin 2, Ireland From harendra.kumar at gmail.com Tue Jan 24 08:55:26 2017 From: harendra.kumar at gmail.com (Harendra Kumar) Date: Tue, 24 Jan 2017 14:25:26 +0530 Subject: [Haskell-cafe] is it normal for docs to be pending for 24 hours? In-Reply-To: References: Message-ID: You are right, it is broken for candidates but works for package upload. I just uploaded the package directly and documentation was generated fine. Thanks, harendra On 24 January 2017 at 13:36, Gershom B wrote: > Right — we changed the builder to improve stability and handle things > chronologically to avoid backlog when things got out of wack. But in the > process I think we lost the candidate building. I filed a ticket to improve > this: > > https://github.com/haskell/hackage-server/issues/568 > > Thanks again for the report! > > —Gershom > > > On January 24, 2017 at 3:00:45 AM, Harendra Kumar ( > harendra.kumar at gmail.com) wrote: > > It did build candidate documentation earlier for me. Not sure if > something > > changed recently. I always uploaded candidates, and when the > documentation > > was generated, I reviewed it and then published the candidate. > > > > -harendra > > > > On 24 January 2017 at 12:43, Gershom B wrote: > > > > > Good question! > > > > > > The current incarnation of the builder doesn’t build candidate > > > documentation — this is something we should change/implement. (Not > > > sure if it ever built candidate documentation, actually?) > > > > > > The builder itself (I just checked) is running just fine and > > > generating documentation for fully released packages. > > > > > > Best, > > > Gershom > > > > > > On January 24, 2017 at 1:22:05 AM, Harendra Kumar > > > (harendra.kumar at gmail.com) wrote: > > > > I am not sure if the problem has been resolved or if it has > resurfaced > > > > again after getting resolved. I uploaded a package recently and the > docs > > > > have not been generated even after a day. Here is the link to the > package > > > > candidate that I uploaded: > > > > > > > > https://hackage.haskell.org/package/unicode-transforms-0. > 2.1/candidate > > > > > > > > Is there a place where I can see any debug logs or diagnostic > messages to > > > > figure out what went wrong? > > > > > > > > -harendra > > > > > > > > On 16 November 2016 at 23:31, Gershom B wrote: > > > > > > > > > As an update -- the builder had a few other issues besides > disk-space > > > > > in terms of getting a better retry policy in place, and properly > > > > > prioritizing new over older packages, etc. I think as of this > morning > > > > > they're finally all worked through and it seems to be slowly > chugging > > > > > through the backlog in a reasonable order, prioritizing new > > > > > uploads.I'll be checking in on the logs daily for the time being to > > > > > make sure it does't seem to be getting stuck. > > > > > > > > > > If your docs haven't built and you're impatient (understandably > so!), > > > > > please don't bump your package version to kick the priority -- > that'll > > > > > just put more metadata on the server we don't need. Instead, you > can > > > > > build and upload your own docs as in this sample shell script: > > > > > > > > > > https://github.com/ekmett/lens/blob/master/scripts/hackage-docs.sh > > > > > > > > > > Best, > > > > > Gershom > > > > > > > > > > > > > > > On Fri, Nov 11, 2016 at 11:43 AM, Gershom B wrote: > > > > > > Sorry — the builder for docs has been in rough shape and we’re > > > working > > > > > on it. In this case it got stuck due to disk space issues and > > > monitoring > > > > > didn’t catch it. Its now running again but doing some catching up. > (And > > > > > lots of stuff in the queue it failed to build due to other problems > > > needs > > > > > to be replaced there, which is a manual process at the moment if we > > > don’t > > > > > want the queue as a whole to just drown out any new things at all > with > > > > > backlog). It would be much better to expose more queues and have > better > > > > > monitoring (and real prioritization), and another volunteer to help > > > ben out > > > > > on this would be very welcome (please contact me if you’re > interested > > > — the > > > > > code lives at https://github.com/haskell/ > hackage-server/blob/master/ > > > > > BuildClient.hs and there’s some uncommitted work on queuing as > well). > > > > > > > > > > > > —gerhsom > > > > > > > > > > > > On November 8, 2016 at 8:37:19 PM, Patrick Pelletier ( > > > > > code at funwithsoftware.org) wrote: > > > > > >> This is only my second time uploading a package to Hackage, so I > > > don't > > > > > >> yet have a feel for how it's supposed to go. I uploaded > > > > > >> normalization-insensitive-2.0.0.1 about 24 hours ago: > > > > > >> > > > > > >> https://hackage.haskell.org/package/normalization- > > > insensitive-2.0.0.1 > > > > > >> > > > > > >> Under "Status", it says "Docs pending". (And the module names > are > > > all > > > > > >> non-clickable.) Is it normal to take this long to build the > docs? Is > > > > > >> there some way to find out where in the queue my job is? Is > this an > > > > > >> indication that something has gone wrong? How do I fix it? > > > > > >> > > > > > >> Thanks, > > > > > >> > > > > > >> --Patrick > > > > > >> > > > > > >> _______________________________________________ > > > > > >> Haskell-Cafe mailing list > > > > > >> To (un)subscribe, modify options or view archives go to: > > > > > >> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > > > > > >> Only members subscribed via the mailman list are allowed to > post. > > > > > > > > > > > _______________________________________________ > > > > > Haskell-Cafe mailing list > > > > > To (un)subscribe, modify options or view archives go to: > > > > > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > > > > > Only members subscribed via the mailman list are allowed to post. > > > > > > > > > > > > > > _______________________________________________ > > Haskell-Cafe mailing list > > To (un)subscribe, modify options or view archives go to: > > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > > Only members subscribed via the mailman list are allowed to post. > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From tobias.grosser at inf.ethz.ch Tue Jan 24 09:36:01 2017 From: tobias.grosser at inf.ethz.ch (Tobias Grosser) Date: Tue, 24 Jan 2017 10:36:01 +0100 Subject: [Haskell-cafe] PLDI workshop and proposal deadline - Jan 30 Message-ID: <1485250561.1979829.857605104.1C8CE794@webmail.messagingengine.com> Reminder! The final deadline for PLDI W&T proposals is coming up on January 30. Please see the PLDI website for more information. http://conf.researchr.org/track/pldi-2017/pldi-2017-workshops-and-tutorials. Tobias Grosser PLDI Publicity Chair From polux2001 at gmail.com Tue Jan 24 10:04:01 2017 From: polux2001 at gmail.com (Paul Brauner) Date: Tue, 24 Jan 2017 10:04:01 +0000 Subject: [Haskell-cafe] Datomic-like db for Haskell? In-Reply-To: References: <867f6qekd1.fsf@posteo.de> <861swyecy0.fsf@posteo.de> Message-ID: Would you mind sharing the result of your research with the mailing list once you're done? On Sat, Dec 24, 2016 at 4:50 PM Ovidiu Deac wrote: > I'll do some research to evaluate my options. So far I have: > > Homegrown implementation on top of some DB (Riak/Postgres/Mongo...) > https://github.com/agentm/project-m36 > https://hackage.haskell.org/package/filestore > > Thanks for the answers! > > > On Fri, Dec 23, 2016 at 8:07 PM, Ertugrul Söylemez wrote: > > >> * Another option is to run an insertion-only relational model on > >> really any database system you want like PostgreSQL. There is > >> nothing about preserving history that needs special handling to be > >> efficient. > > > > I assume that some sort of structural sharing is needed once the > > collections grow above a certain size. Also some support for caching > > would be nice. > > Yeah, sharing could improve disk usage and cache utilisation. I'm not > aware of any DBMS-side sharing features in systems I have used > (PostgreSQL and SQLite mainly). The usual way to get sharing in > relational systems is to normalise the schema. That also allows you to > use domain-specific knowledge to get even better sharing. > > Caching is of course supported, at least by PostgreSQL. It aims to keep > as much of the database in memory as possible (or as you tell it to). > > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. -------------- next part -------------- An HTML attachment was scrubbed... URL: From merijn at inconsistent.nl Tue Jan 24 10:15:55 2017 From: merijn at inconsistent.nl (Merijn Verstraaten) Date: Tue, 24 Jan 2017 11:15:55 +0100 Subject: [Haskell-cafe] Bug-free, leak-free, battle-tested library for broadcast channels? In-Reply-To: References: Message-ID: <539991FF-F43D-4380-8610-962FA786D2C2@inconsistent.nl> I don't know about split-channel, which seems to try and have a lot of functionality, but broadcast-chan is literally (and I mean the "copy+paste" kind of literally) the exact same implementation as Control.Concurrent.Chan. The only difference is that, with Control.Concurrent.Chan each Chan always has access to both the read and write end of the Chan. This read end will keep data inside that Chan alive (and thus in memory!) indefinitely, if no one reads from that Chan. If you use dupChan this will create a new read end that tracks data in the Chan separately from the original one. This means that if you have a worker that only ever writes into a Chan, this read end is basically keeping everything you write into the Chan alive forever. broadcast-chan does the exact same thing as 'newBroadcastTChan' from Control.Concurrent.STM.TChan, that is your original Chan contains a "write" end only, and not a read end, the end result of that is: If you create a new write channel any message you write into it will, if there are no listeners, be immediately dropped and GCed. If you create "read" ends, then each read end will receive every message written into the write end, as long as the read end is active. So if you create 5 workers with a new read end each, then every message written after those have been created will be seen by all workers. So, if your problem is "I want to broadcast messages, but messages that are sent when there are no listeners should be dropped and forgotten", then use broadcast-chan. The package itself isn't "battle-tested", but since it's basically a copy+paste of Control.Concurrent.Chan with a trivial wrapper, I feel fairly confident that it doesn't have any major problems. Cheers, Merijn > On 23 Jan 2017, at 11:52, Saurabh Nanda wrote: > > (cross-posted from Reddit because I'm not sure of the audience overlap between haskell-cafe & reddit) > > I want to broadcast some instrumentation data from deep within my Haskell app. This data will have listeners in some environments (say, debug), but not others (say, production). Which library should I be using? A little searching threw two possible candidates: > > * http://hackage.haskell.org/package/split-channel > * https://hackage.haskell.org/package/broadcast-chan > > But, I'm not sure if these are battle-tested. Any help would be appreciated. > > -- Saurabh. > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 842 bytes Desc: Message signed with OpenPGP using GPGMail URL: From monnier at iro.umontreal.ca Tue Jan 24 13:41:37 2017 From: monnier at iro.umontreal.ca (Stefan Monnier) Date: Tue, 24 Jan 2017 08:41:37 -0500 Subject: [Haskell-cafe] Using stringize and string concatenation in ghc preprocessing References: Message-ID: > middle of it and containing a decent summary) indicated that a significant > number of high profile Haskell users would be forced to drop Haskell if > cpphs went into ghc, because they'd have to face the uphill battle of > getting corporate lawyers to okay it again. Self-censorship based on fear. The power of FUD. Stefan From monnier at iro.umontreal.ca Tue Jan 24 13:44:40 2017 From: monnier at iro.umontreal.ca (Stefan Monnier) Date: Tue, 24 Jan 2017 08:44:40 -0500 Subject: [Haskell-cafe] Using stringize and string concatenation in ghc preprocessing References: Message-ID: > I note that a company I worked for refused to have any GPL software > on their machines, even GCC, due to legal advice. That was a couple > of revisions of the GPL ago, but some scars last. By "some scars last", do you mean "I'll stay away from that company"? Stefan From audunskaugen at gmail.com Tue Jan 24 15:24:57 2017 From: audunskaugen at gmail.com (Audun Skaugen) Date: Tue, 24 Jan 2017 16:24:57 +0100 Subject: [Haskell-cafe] Using stringize and string concatenation in ghc preprocessing In-Reply-To: References: Message-ID: <1485271497.5757.5.camel@gmail.com> ma., 23.01.2017 kl. 20.55 +0100, skrev Ben Franksen: > Do you have any evidence to support this statement? I ask because if > what you say is true, most companies willfully and severely restrict > their options. For instance, a company that employs lawyers who > "won't > touch GPL3 or even LGPL3 with a ten foot pole" could not use Linux in > any way (the kernel is GPL licensed), nor e.g. Android (based on > Linux > kernel). > > I have no data on how many companies in the world use Linux. What I > do > know is that many companies, even big corporations, actually support > the > Linux kernel with code (e.g. drivers), thus triggering the most > restricting clauses in the GPL. For instance, Volkswagen AG has > contributed socketcan to the kernel. Actually, the Linux kernel is GPLv2 licenced[1]. I believe companies are more comfortable with version 2 than version 3. [1]: https://www.kernel.org/category/faq.html From acowley at seas.upenn.edu Tue Jan 24 16:07:38 2017 From: acowley at seas.upenn.edu (Anthony Cowley) Date: Tue, 24 Jan 2017 11:07:38 -0500 Subject: [Haskell-cafe] Using stringize and string concatenation in ghc preprocessing In-Reply-To: References: Message-ID: > On Jan 24, 2017, at 3:11 AM, Andrew Butterfield wrote: > > Why not write a new Haskell version of CPP with a more corporate-friendly OS license? > > (HPP ?) I already wrote hpp, and it's been on hackage for a while now. Its test suite puts it through the spec conformance portion of the mcpp test suite, so one can be somewhat confident that it does the fiddly things correctly. That said, I did find and fix bugs when running it over lens (a sigil-rich environment, to be sure) during testing, so there may yet be Haskell code it doesn't play well with. It is fairly fast, memory-efficient, written entirely in Haskell, on GitHub, and BSD-licensed. Anthony > >> On 23 Jan 2017, at 23:43, Ben Franksen wrote: >> >> Am 23.01.2017 um 23:25 schrieb Sven Panne: >>> 2017-01-23 22:42 GMT+01:00 Ben Franksen : >>> We could talk endlessly about this >> >> Right. I am tired of it, too. I am ready to concede that there are >> /enough/ of these people around that it is a real problem for some >> Haskell users. >> >> For me things are exactly the opposite: as a Haskell preprocessor, using >> cpphs is the much safer option compared to CPP. History has shown that >> e.g. the gcc developers change cpp's behaviour in ways that are >> incompatible with using cpp for anything other than C or C++, even if >> that means interpreting the C standard in quite a liberal way. >> >> I would very much like to be able to use cpphs as a drop-in replacement >> for cpp and to be able to change the default cpp in a ghc configuration >> file, rather than at compile time (so I can still use a ghc packaged for >> my distro). >> >> Cheers >> Ben >> -- >> "Make it so they have to reboot after every typo." ― Scott Adams >> >> _______________________________________________ >> Haskell-Cafe mailing list >> To (un)subscribe, modify options or view archives go to: >> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe >> Only members subscribed via the mailman list are allowed to post. > > Andrew Butterfield > School of Computer Science & Statistics > Trinity College > Dublin 2, Ireland > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. From ben.franksen at online.de Tue Jan 24 20:06:12 2017 From: ben.franksen at online.de (Ben Franksen) Date: Tue, 24 Jan 2017 21:06:12 +0100 Subject: [Haskell-cafe] Using stringize and string concatenation in ghc preprocessing In-Reply-To: References: Message-ID: Am 24.01.2017 um 17:07 schrieb Anthony Cowley: >> On Jan 24, 2017, at 3:11 AM, Andrew Butterfield wrote: >> >> Why not write a new Haskell version of CPP with a more corporate-friendly OS license? >> >> (HPP ?) > > I already wrote hpp, and it's been on hackage for a while now. Its test suite puts it through the spec conformance portion of the mcpp test suite, so one can be somewhat confident that it does the fiddly things correctly. That said, I did find and fix bugs when running it over lens (a sigil-rich environment, to be sure) during testing, so there may yet be Haskell code it doesn't play well with. > > It is fairly fast, memory-efficient, written entirely in Haskell, on GitHub, and BSD-licensed. That's like music (progressive rock, to be specific) in my ears! Cheers Ben -- "Make it so they have to reboot after every typo." ― Scott Adams From ben.franksen at online.de Tue Jan 24 20:20:32 2017 From: ben.franksen at online.de (Ben Franksen) Date: Tue, 24 Jan 2017 21:20:32 +0100 Subject: [Haskell-cafe] Using stringize and string concatenation in ghc preprocessing In-Reply-To: <1485271497.5757.5.camel@gmail.com> References: <1485271497.5757.5.camel@gmail.com> Message-ID: Am 24.01.2017 um 16:24 schrieb Audun Skaugen: > ma., 23.01.2017 kl. 20.55 +0100, skrev Ben Franksen: >> Do you have any evidence to support this statement? I ask because if >> what you say is true, most companies willfully and severely restrict >> their options. For instance, a company that employs lawyers who >> "won't >> touch GPL3 or even LGPL3 with a ten foot pole" could not use Linux in >> any way (the kernel is GPL licensed), nor e.g. Android (based on >> Linux >> kernel). >> >> I have no data on how many companies in the world use Linux. What I >> do >> know is that many companies, even big corporations, actually support >> the >> Linux kernel with code (e.g. drivers), thus triggering the most >> restricting clauses in the GPL. For instance, Volkswagen AG has >> contributed socketcan to the kernel. > > Actually, the Linux kernel is GPLv2 licenced[1]. I believe companies > are more comfortable with version 2 than version 3. > > [1]: https://www.kernel.org/category/faq.html Same with cpphs: GPLv2 for the program, for the library it's LGPLv2, and there is also LICENCE-commercial which allows unrestricted distribution of the binary (w/o sources). Cheers Ben -- "Make it so they have to reboot after every typo." ― Scott Adams From hcc.olemiss at gmail.com Tue Jan 24 20:53:08 2017 From: hcc.olemiss at gmail.com (Conrad Cunningham) Date: Tue, 24 Jan 2017 14:53:08 -0600 Subject: [Haskell-cafe] Suggestions for "Advanced" Topics for Haskell-based Class Message-ID: I am teaching a class in Haskell-based functional programming for advanced undergraduates and beginning graduate students at my institution. None of the students have previously used Haskell and for most of my students functional programming is new. Because I am teaching this in a "multiparadigm programming" course, I want to expand beyond what I have usually covered in the Haskell-based "functional programming" course and cover a few topics in areas such as parallel, concurrent, distributed, reactive, or metaprogramming (domain-specific languages, Template Haskell, etc.). Assuming my course has more or less covered the topics in *Learn You a Haskell for Great Good *(with likely shallow coverage of monads) at that point, what would be good additional topics to cover, libraries to use, and tutorial or teaching resources to use? Although I have taught fundamental Haskell FP topics for many years, I have not delved into any of these "advanced" topics. Thanks, Conrad -- H. Conrad Cunningham, Professor Computer and Information Science University of Mississippi ​ (USA) ​ -------------- next part -------------- An HTML attachment was scrubbed... URL: From joehillen at gmail.com Tue Jan 24 21:15:15 2017 From: joehillen at gmail.com (Joe Hillenbrand) Date: Tue, 24 Jan 2017 21:15:15 +0000 Subject: [Haskell-cafe] Suggestions for "Advanced" Topics for Haskell-based Class In-Reply-To: References: Message-ID: <8xmdy0lh3jvmdg4tze9ozbavz-0@mailer.nylas.com> I _personally_ don't like LYAH, but I highly recommend Parallel and Concurrent Programming in Haskell[1] especially the second half. It's *required* reading for real world Haskelling. [1] http://chimera.labs.oreilly.com/books/1230000000929 On Jan 24 2017, at 12:55 pm, Conrad Cunningham wrote: > I am teaching a class in Haskell-based functional programming for advanced undergraduates and beginning graduate students at my institution. None of the students have previously used Haskell and for most of my students functional programming is new. > > > > Because I am teaching this in a "multiparadigm programming" course, I want to expand beyond what I have usually covered in the Haskell-based "functional programming" course and cover a few topics in areas such as parallel, concurrent, distributed, reactive, or metaprogramming (domain-specific languages, Template Haskell, etc.). > > > > Assuming my course has more or less covered the topics in _Learn You a Haskell for Great Good _(with likely shallow coverage of monads) at that point, what would be good additional topics to cover, libraries to use, and tutorial or teaching resources to use? Although I have taught fundamental Haskell FP topics for many years, I have not delved into any of these "advanced" topics. > > > > Thanks, > > Conrad > > > > \-- > > H. Conrad Cunningham, Professor > > Computer and Information Science > > University of Mississippi > > ​ (USA) > > ​ -------------- next part -------------- An HTML attachment was scrubbed... URL: From sivanov at colimite.fr Tue Jan 24 21:32:29 2017 From: sivanov at colimite.fr (Sergiu Ivanov) Date: Tue, 24 Jan 2017 22:32:29 +0100 Subject: [Haskell-cafe] Suggestions for "Advanced" Topics for Haskell-based Class In-Reply-To: References: Message-ID: <87inp4uosy.fsf@colimite.fr> Hello Conrad, Thus quoth Conrad Cunningham at 20:53 on Tue, Jan 24 2017: > > Because I am teaching this in a "multiparadigm programming" course, I want > to expand beyond what I have usually covered in the Haskell-based > "functional programming" course and cover a few topics in areas such as > parallel, concurrent, distributed, reactive, or metaprogramming > (domain-specific languages, Template Haskell, etc.). > > Assuming my course has more or less covered the topics in *Learn You a > Haskell for Great Good *(with likely shallow coverage of monads) at that > point, what would be good additional topics to cover, libraries to use, and > tutorial or teaching resources to use? I've been teaching Haskell for beginners for some (relatively short) time, and it seems to me that parallel and concurrent programming may be one very good additional topic. I particularly like Simon Marlow's tutorial "Parallel and Concurrent Programming in Haskell" [0]: it's very well written and gives some clear practical examples. -- Sergiu [0] http://community.haskell.org/~simonmar/par-tutorial.pdf -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 487 bytes Desc: not available URL: From will.yager at gmail.com Tue Jan 24 22:06:32 2017 From: will.yager at gmail.com (William Yager) Date: Tue, 24 Jan 2017 16:06:32 -0600 Subject: [Haskell-cafe] Suggestions for "Advanced" Topics for Haskell-based Class In-Reply-To: References: Message-ID: I would suggest looking into more advanced monadic concepts (including monad transformers, free monads, continuation monads, etc.), and perhaps Lenses. Will On Tue, Jan 24, 2017 at 2:53 PM, Conrad Cunningham wrote: > what would be good additional topics to cover ...? > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kc1956 at gmail.com Tue Jan 24 22:14:14 2017 From: kc1956 at gmail.com (KC) Date: Tue, 24 Jan 2017 14:14:14 -0800 Subject: [Haskell-cafe] Suggestions for "Advanced" Topics for Haskell-based Class In-Reply-To: References: Message-ID: I would encourage GUI development using GHCJS or FRP or ... :) On Tue, Jan 24, 2017 at 12:53 PM, Conrad Cunningham wrote: > I am teaching a class in Haskell-based functional programming for advanced > undergraduates and beginning graduate students at my institution. None of > the students have previously used Haskell and for most of my students > functional programming is new. > > Because I am teaching this in a "multiparadigm programming" course, I want > to expand beyond what I have usually covered in the Haskell-based > "functional programming" course and cover a few topics in areas such as > parallel, concurrent, distributed, reactive, or metaprogramming > (domain-specific languages, Template Haskell, etc.). > > Assuming my course has more or less covered the topics in *Learn You a > Haskell for Great Good *(with likely shallow coverage of monads) at that > point, what would be good additional topics to cover, libraries to use, and > tutorial or teaching resources to use? Although I have taught fundamental > Haskell FP topics for many years, I have not delved into any of these > "advanced" topics. > > Thanks, > Conrad > > -- > H. Conrad Cunningham, Professor > Computer and Information Science > University of Mississippi > ​ (USA) > ​ > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. > -- -- Sent from an expensive device which will be obsolete in a few months! :D Casey -------------- next part -------------- An HTML attachment was scrubbed... URL: From rae at cs.brynmawr.edu Tue Jan 24 22:16:39 2017 From: rae at cs.brynmawr.edu (Richard Eisenberg) Date: Tue, 24 Jan 2017 17:16:39 -0500 Subject: [Haskell-cafe] Early feedback on a GHC proposal In-Reply-To: References: Message-ID: <739268F9-4F76-4210-80A2-CAACA1153E0D@cs.brynmawr.edu> I like it. My use case for overloaded application is from singletons, where I want users to be able to apply something of type Sing (x :: k1 -> k2). Right now, they must call `applySing` to do the application. Thanks for writing it up! Richard > On Jan 24, 2017, at 3:07 AM, Chris Smith wrote: > > Anyone want to offer some early feedback on a GHC proposal I'm working on? It's called OverloadedApplication. Current version at https://github.com/cdsmith/ghc-proposals/blob/overloadedapplication/proposals/0000-overloaded-application.rst > > I am proposing something a bit more ambitious than what I need, because the proposal as written seems more likely to be broadly useful. The bit that I actually need is about desugaring of infix operators in the presence of RebindableSyntax. I'd love to get early thoughts from anyone who has a solid use case for the rest of the proposal. It feels like a thing that *ought* to be useful, but I'm drawing blanks at the moment. > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. -------------- next part -------------- An HTML attachment was scrubbed... URL: From dennis.raddle at gmail.com Tue Jan 24 22:33:40 2017 From: dennis.raddle at gmail.com (Dennis Raddle) Date: Tue, 24 Jan 2017 14:33:40 -0800 Subject: [Haskell-cafe] ghci, running :load on filename provided by variable Message-ID: How do I load a file in ghci where the filename comes from a variable? So like, let f = "myfile.hs" :load f D -------------- next part -------------- An HTML attachment was scrubbed... URL: From noonslists at gmail.com Tue Jan 24 22:58:14 2017 From: noonslists at gmail.com (Noon van der Silk) Date: Wed, 25 Jan 2017 09:58:14 +1100 Subject: [Haskell-cafe] Suggestions for "Advanced" Topics for Haskell-based Class In-Reply-To: References: Message-ID: I think something useful could be memory concerns: analysing space leaks, strictness, fusion, and related areas. -- Noon On Wed, Jan 25, 2017 at 9:14 AM, KC wrote: > I would encourage GUI development using GHCJS or FRP or ... :) > > On Tue, Jan 24, 2017 at 12:53 PM, Conrad Cunningham > wrote: > >> I am teaching a class in Haskell-based functional programming for >> advanced undergraduates and beginning graduate students at my institution. >> None of the students have previously used Haskell and for most of my >> students functional programming is new. >> >> Because I am teaching this in a "multiparadigm programming" course, I >> want to expand beyond what I have usually covered in the Haskell-based >> "functional programming" course and cover a few topics in areas such as >> parallel, concurrent, distributed, reactive, or metaprogramming >> (domain-specific languages, Template Haskell, etc.). >> >> Assuming my course has more or less covered the topics in *Learn You a >> Haskell for Great Good *(with likely shallow coverage of monads) at that >> point, what would be good additional topics to cover, libraries to use, and >> tutorial or teaching resources to use? Although I have taught fundamental >> Haskell FP topics for many years, I have not delved into any of these >> "advanced" topics. >> >> Thanks, >> Conrad >> >> -- >> H. Conrad Cunningham, Professor >> Computer and Information Science >> University of Mississippi >> ​ (USA) >> ​ >> >> _______________________________________________ >> Haskell-Cafe mailing list >> To (un)subscribe, modify options or view archives go to: >> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe >> Only members subscribed via the mailman list are allowed to post. >> > > > > -- > > -- > > Sent from an expensive device which will be obsolete in a few months! :D > Casey > > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. > -- Noon Silk, ن https://silky.github.io/ "Every morning when I wake up, I experience an exquisite joy — the joy of being this signature." -------------- next part -------------- An HTML attachment was scrubbed... URL: From ok at cs.otago.ac.nz Tue Jan 24 23:05:31 2017 From: ok at cs.otago.ac.nz (Richard A. O'Keefe) Date: Wed, 25 Jan 2017 12:05:31 +1300 Subject: [Haskell-cafe] Using stringize and string concatenation in ghc preprocessing In-Reply-To: References: Message-ID: On 25/01/17 2:44 AM, Stefan Monnier wrote: >> I note that a company I worked for refused to have any GPL software >> on their machines, even GCC, due to legal advice. That was a couple >> of revisions of the GPL ago, but some scars last. > > By "some scars last", do you mean "I'll stay away from that company"? No, of course not. The key point was that we were a small company and would not have survived a law suit, win or lose. That company no longer exists, in any case. The venture capitalists whose lawyers' advice we followed do exist, but I no longer work for a startup. From headprogrammingczar at gmail.com Wed Jan 25 01:25:25 2017 From: headprogrammingczar at gmail.com (Joe Quinn) Date: Tue, 24 Jan 2017 20:25:25 -0500 Subject: [Haskell-cafe] Suggestions for "Advanced" Topics for Haskell-based Class In-Reply-To: References: Message-ID: <853b690e-9896-ddd5-3095-e4d994cd6ef8@gmail.com> On 1/24/2017 5:58 PM, Noon van der Silk wrote: > I think something useful could be memory concerns: analysing space > leaks, strictness, fusion, and related areas. > > -- > Noon > > > On Wed, Jan 25, 2017 at 9:14 AM, KC > wrote: > > I would encourage GUI development using GHCJS or FRP or ... :) > > On Tue, Jan 24, 2017 at 12:53 PM, Conrad Cunningham > > wrote: > > I am teaching a class in Haskell-based functional programming > for advanced undergraduates and beginning graduate students at > my institution. None of the students have previously used > Haskell and for most of my students functional programming is new. > > Because I am teaching this in a "multiparadigm programming" > course, I want to expand beyond what I have usually covered in > the Haskell-based "functional programming" course and cover a > few topics in areas such as parallel, concurrent, distributed, > reactive, or metaprogramming (domain-specific languages, > Template Haskell, etc.). > > Assuming my course has more or less covered the topics in > /Learn You a Haskell for Great Good /(with likely shallow > coverage of monads) at that point, what would be good > additional topics to cover, libraries to use, and tutorial or > teaching resources to use? Although I have taught fundamental > Haskell FP topics for many years, I have not delved into any > of these "advanced" topics. > > Thanks, > Conrad > > -- > If you want to focus on math a bit, start with purity/parametricity/type safety, and then work up from there. You can lead into the Curry-Howard isomorphism and theorem proving languages like agda, or look in the direction of -XSafe, or the algebra of ADTs / free theorems / djinn. Both of these trains of thought eventually merge at the idea of automation acquiring knowledge from code and using it to write more code for you. -------------- next part -------------- An HTML attachment was scrubbed... URL: From stuart at cs.uchicago.edu Tue Jan 24 21:20:00 2017 From: stuart at cs.uchicago.edu (Stuart A. Kurtz) Date: Tue, 24 Jan 2017 15:20:00 -0600 Subject: [Haskell-cafe] Suggestions for "Advanced" Topics for Haskell-based Class In-Reply-To: References: Message-ID: <8FA774EE-6F97-4507-9E21-7D7FEDBFE2C8@cs.uchicago.edu> Dear Conrad, There have been several classes taught at Stanford along the lines you ask about: CS240h (2011) http://www.scs.stanford.edu/11au-cs240h/ CS240h (2014) http://www.scs.stanford.edu/14sp-cs240h/ under the title “Functional Systems in Haskell.” Jakub Tucholski and I taught a course inspired by these classes at Chicago in 2015 with the same title: CMSC 22311 (2015) http://cmsc-22311.cs.uchicago.edu/2015/ The material (in my class, at least) is a bit dated — Haskell evolves quickly, so the lectures suffer from inevitable entropy, but there’s a de facto syllabus there, and considerable supporting lecture material (this is true also of the original Stanford sites). Anyway, here’s what we did: • Introduction (a quick review of Haskell) • Typeclassopedia • Arrays and Mutability • QuickCheck • Seq and All That • IO • Pattern Guards • Template Haskell • Lenses • Zippers • Testing • GADTs • Parallel Haskell • Concurrency, Exceptions, and STM • Networking • Yesod Were I to do this again, I’d probably opt for Happstack over Yesod (if only because I can get Happstack to install on a Raspberry Pi, and so it’s what I’m playing with now). For a bit of variety, if you have time, you might want to throw in a bit of Elm (http://elm-lang.org), an eager language that is similar in syntax to Haskell, which compiles to JavaScript. It’s fun, and high leverage for people who already know Haskell. We’d hoped to do pipes, but ran out of time (quarters are short). Peace, Stu --------------- Stuart A. Kurtz Professor, Department of Computer Science and the College Director of Undergraduate Studies for Computer Science The University of Chicago From gregmainland at gmail.com Wed Jan 25 03:15:27 2017 From: gregmainland at gmail.com (Greg Horn) Date: Wed, 25 Jan 2017 03:15:27 +0000 Subject: [Haskell-cafe] Bug-free, leak-free, battle-tested library for broadcast channels? In-Reply-To: <539991FF-F43D-4380-8610-962FA786D2C2@inconsistent.nl> References: <539991FF-F43D-4380-8610-962FA786D2C2@inconsistent.nl> Message-ID: I'm not sure if it's exactly what you're looking for, but I've been using zeromq for this for a long time http://hackage.haskell.org/package/zeromq4-haskell. It's bindings to a C++ library, but that means that you can communicate with other languages which also have bindings. On Tue, Jan 24, 2017 at 2:18 AM Merijn Verstraaten wrote: > I don't know about split-channel, which seems to try and have a lot of > functionality, but broadcast-chan is literally (and I mean the "copy+paste" > kind of literally) the exact same implementation as Control.Concurrent.Chan. > > The only difference is that, with Control.Concurrent.Chan each Chan always > has access to both the read and write end of the Chan. This read end will > keep data inside that Chan alive (and thus in memory!) indefinitely, if no > one reads from that Chan. If you use dupChan this will create a new read > end that tracks data in the Chan separately from the original one. > > This means that if you have a worker that only ever writes into a Chan, > this read end is basically keeping everything you write into the Chan alive > forever. > > broadcast-chan does the exact same thing as 'newBroadcastTChan' from > Control.Concurrent.STM.TChan, that is your original Chan contains a "write" > end only, and not a read end, the end result of that is: If you create a > new write channel any message you write into it will, if there are no > listeners, be immediately dropped and GCed. If you create "read" ends, then > each read end will receive every message written into the write end, as > long as the read end is active. So if you create 5 workers with a new read > end each, then every message written after those have been created will be > seen by all workers. > > So, if your problem is "I want to broadcast messages, but messages that > are sent when there are no listeners should be dropped and forgotten", then > use broadcast-chan. > > The package itself isn't "battle-tested", but since it's basically a > copy+paste of Control.Concurrent.Chan with a trivial wrapper, I feel fairly > confident that it doesn't have any major problems. > > Cheers, > Merijn > > > > On 23 Jan 2017, at 11:52, Saurabh Nanda wrote: > > > > (cross-posted from Reddit because I'm not sure of the audience overlap > between haskell-cafe & reddit) > > > > I want to broadcast some instrumentation data from deep within my > Haskell app. This data will have listeners in some environments (say, > debug), but not others (say, production). Which library should I be using? > A little searching threw two possible candidates: > > > > * http://hackage.haskell.org/package/split-channel > > * https://hackage.haskell.org/package/broadcast-chan > > > > But, I'm not sure if these are battle-tested. Any help would be > appreciated. > > > > -- Saurabh. > > > > _______________________________________________ > > Haskell-Cafe mailing list > > To (un)subscribe, modify options or view archives go to: > > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > > Only members subscribed via the mailman list are allowed to post. > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. -------------- next part -------------- An HTML attachment was scrubbed... URL: From dct25-561bs at mythic-beasts.com Wed Jan 25 04:04:19 2017 From: dct25-561bs at mythic-beasts.com (David Turner) Date: Wed, 25 Jan 2017 04:04:19 +0000 Subject: [Haskell-cafe] Bug-free, leak-free, battle-tested library for broadcast channels? In-Reply-To: References: Message-ID: The implementation in STM works well and certainly ticks the battle-tested box: https://hackage.haskell.org/package/stm-2.4.4.1/docs/Control-Concurrent-STM-TChan.html#v:newBroadcastTChan Cheers, On 23 January 2017 at 10:52, Saurabh Nanda wrote: > (cross-posted from Reddit because I'm not sure of the audience overlap > between haskell-cafe & reddit) > > I want to broadcast some instrumentation data from deep within my Haskell > app. This data will have listeners in some environments (say, debug), but > not others (say, production). Which library should I be using? A little > searching threw two possible candidates: > > * http://hackage.haskell.org/package/split-channel > * https://hackage.haskell.org/package/broadcast-chan > > But, I'm not sure if these are battle-tested. Any help would be > appreciated. > > -- Saurabh. > > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From monnier at iro.umontreal.ca Wed Jan 25 04:36:35 2017 From: monnier at iro.umontreal.ca (Stefan Monnier) Date: Tue, 24 Jan 2017 23:36:35 -0500 Subject: [Haskell-cafe] Using stringize and string concatenation in ghc preprocessing References: Message-ID: >>> I note that a company I worked for refused to have any GPL software >>> on their machines, even GCC, due to legal advice. That was a couple >>> of revisions of the GPL ago, but some scars last. >> By "some scars last", do you mean "I'll stay away from that company"? > No, of course not. The key point was that we were a small company > and would not have survived a law suit, win or lose. I don't follow: the "keep away from GPL" stance seems to only make sense in the context of a very large corporation where the potential benefit of that one little tool (GHC) is dwarfed by the general risk of using things whose license can't be controlled via money. In the context of a small company, rather than a general stance, I'd expect it is worth looking at each specific case (since that one tool would likely represent a more significant portion of the overall set of tools in use), and drop the hysteria. Reality check: Has anyone ever heard of a company sued because they use a GPL'd tool? Ever? How 'bout in your wildest dream, maybe? Stefan From jo at durchholz.org Wed Jan 25 04:57:37 2017 From: jo at durchholz.org (Joachim Durchholz) Date: Wed, 25 Jan 2017 05:57:37 +0100 Subject: [Haskell-cafe] Suggestions for "Advanced" Topics for Haskell-based Class In-Reply-To: <8xmdy0lh3jvmdg4tze9ozbavz-0@mailer.nylas.com> References: <8xmdy0lh3jvmdg4tze9ozbavz-0@mailer.nylas.com> Message-ID: <69d3ebd3-5ce9-3550-ed32-0511c6ad26fa@durchholz.org> Am 24.01.2017 um 22:15 schrieb Joe Hillenbrand: > I _personally_ don't like LYAH, but I highly recommend Parallel and > Concurrent Programming in Haskell[1] especially the second half. It's > *required* reading for real world Haskelling. Can you expand on that? Both book title and synopsis seem to indicate that it is focused on parallel programming, which is important but certainly not the only thing you'd want to do in the real world. Also, not all real-world tasks involve parallelism, so the claim that parallelism is required reading requires substantiation. From joehillen at gmail.com Wed Jan 25 05:24:22 2017 From: joehillen at gmail.com (Joe Hillenbrand) Date: Wed, 25 Jan 2017 05:24:22 +0000 Subject: [Haskell-cafe] Suggestions for "Advanced" Topics for Haskell-based Class In-Reply-To: <69d3ebd3-5ce9-3550-ed32-0511c6ad26fa@durchholz.org> References: <8xmdy0lh3jvmdg4tze9ozbavz-0@mailer.nylas.com> <69d3ebd3-5ce9-3550-ed32-0511c6ad26fa@durchholz.org> Message-ID: <3wh35jqs11htg3zw0ol1grwz7-0@mailer.nylas.com> I think the concurrency half is most important. Any non trivial Haskell program should leverage concurrency, and Haskell's concurrency is amazing. Correct, it's not the only thing a person should know to write Haskell, but it is a required part of the curriculum. It also covers a lot of ground in demonstrating why Haskell is great. On Jan 24 2017, at 8:59 pm, Joachim Durchholz wrote: > Am 24.01.2017 um 22:15 schrieb Joe Hillenbrand: > I _personally_ don't like LYAH, but I highly recommend Parallel and > Concurrent Programming in Haskell[1] especially the second half. It's > *required* reading for real world Haskelling. > > Can you expand on that? Both book title and synopsis seem to indicate that it is focused on parallel programming, which is important but certainly not the only thing you'd want to do in the real world. Also, not all real-world tasks involve parallelism, so the claim that parallelism is required reading requires substantiation. _______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: Only members subscribed via the mailman list are allowed to post. -------------- next part -------------- An HTML attachment was scrubbed... URL: From saurabhnanda at gmail.com Wed Jan 25 05:39:32 2017 From: saurabhnanda at gmail.com (Saurabh Nanda) Date: Wed, 25 Jan 2017 11:09:32 +0530 Subject: [Haskell-cafe] Bug-free, leak-free, battle-tested library for broadcast channels? In-Reply-To: <539991FF-F43D-4380-8610-962FA786D2C2@inconsistent.nl> References: <539991FF-F43D-4380-8610-962FA786D2C2@inconsistent.nl> Message-ID: > > broadcast-chan does the exact same thing as 'newBroadcastTChan' from > Control.Concurrent.STM.TChan, that is your original Chan contains a "write" > end only, and not a read end, the end result of that is: If you create a > new write channel any message you write into it will, if there are no > listeners, be immediately dropped and GCed. If you create "read" ends, then > each read end will receive every message written into the write end, as > long as the read end is active. So if you create 5 workers with a new read > end each, then every message written after those have been created will be > seen by all workers. > If broadcast-chan does the exact same thing as broadcastTChan, why the need for a new library? This is what I'm trying to understand at the discussion on Reddit [1]. Would you prefer the mailing list or Reddit for the discussion? [1] https://www.reddit.com/r/haskell/comments/5pnd9i/bugfree_leakfree_battletested_library_for/dct14rx/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From saurabhnanda at gmail.com Wed Jan 25 05:41:18 2017 From: saurabhnanda at gmail.com (Saurabh Nanda) Date: Wed, 25 Jan 2017 11:11:18 +0530 Subject: [Haskell-cafe] Bug-free, leak-free, battle-tested library for broadcast channels? In-Reply-To: References: Message-ID: > > The implementation in STM works well and certainly ticks the battle-tested > box: > > https://hackage.haskell.org/package/stm-2.4.4.1/docs/ > Control-Concurrent-STM-TChan.html#v:newBroadcastTChan > What does the following comment in the documentation really mean (highlighted by >>><<<)? "Create a write-only TChan . >>> More precisely, readTChan will retry even after items have been written to the channel.<<< The only way to read a broadcast channel is to duplicate it with dupTChan ." -- Saurabh. -------------- next part -------------- An HTML attachment was scrubbed... URL: From saurabhnanda at gmail.com Wed Jan 25 07:54:18 2017 From: saurabhnanda at gmail.com (Saurabh Nanda) Date: Wed, 25 Jan 2017 13:24:18 +0530 Subject: [Haskell-cafe] Bug-free, leak-free, battle-tested library for broadcast channels? In-Reply-To: <539991FF-F43D-4380-8610-962FA786D2C2@inconsistent.nl> References: <539991FF-F43D-4380-8610-962FA786D2C2@inconsistent.nl> Message-ID: Am I using broadcastTChan & STM correctly here? https://gist.github.com/saurabhnanda/3cc39f1e0a646254dd8819b01cd04ac3 Is it acceptable to basically create a `broadcastTChan` and make it "escape" the STM monad? On Tue, Jan 24, 2017 at 3:45 PM, Merijn Verstraaten wrote: > I don't know about split-channel, which seems to try and have a lot of > functionality, but broadcast-chan is literally (and I mean the "copy+paste" > kind of literally) the exact same implementation as Control.Concurrent.Chan. > > The only difference is that, with Control.Concurrent.Chan each Chan always > has access to both the read and write end of the Chan. This read end will > keep data inside that Chan alive (and thus in memory!) indefinitely, if no > one reads from that Chan. If you use dupChan this will create a new read > end that tracks data in the Chan separately from the original one. > > This means that if you have a worker that only ever writes into a Chan, > this read end is basically keeping everything you write into the Chan alive > forever. > > broadcast-chan does the exact same thing as 'newBroadcastTChan' from > Control.Concurrent.STM.TChan, that is your original Chan contains a "write" > end only, and not a read end, the end result of that is: If you create a > new write channel any message you write into it will, if there are no > listeners, be immediately dropped and GCed. If you create "read" ends, then > each read end will receive every message written into the write end, as > long as the read end is active. So if you create 5 workers with a new read > end each, then every message written after those have been created will be > seen by all workers. > > So, if your problem is "I want to broadcast messages, but messages that > are sent when there are no listeners should be dropped and forgotten", then > use broadcast-chan. > > The package itself isn't "battle-tested", but since it's basically a > copy+paste of Control.Concurrent.Chan with a trivial wrapper, I feel fairly > confident that it doesn't have any major problems. > > Cheers, > Merijn > > > > On 23 Jan 2017, at 11:52, Saurabh Nanda wrote: > > > > (cross-posted from Reddit because I'm not sure of the audience overlap > between haskell-cafe & reddit) > > > > I want to broadcast some instrumentation data from deep within my > Haskell app. This data will have listeners in some environments (say, > debug), but not others (say, production). Which library should I be using? > A little searching threw two possible candidates: > > > > * http://hackage.haskell.org/package/split-channel > > * https://hackage.haskell.org/package/broadcast-chan > > > > But, I'm not sure if these are battle-tested. Any help would be > appreciated. > > > > -- Saurabh. > > > > _______________________________________________ > > Haskell-Cafe mailing list > > To (un)subscribe, modify options or view archives go to: > > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > > Only members subscribed via the mailman list are allowed to post. > > -- http://www.saurabhnanda.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From dct25-561bs at mythic-beasts.com Wed Jan 25 08:16:22 2017 From: dct25-561bs at mythic-beasts.com (David Turner) Date: Wed, 25 Jan 2017 08:16:22 +0000 Subject: [Haskell-cafe] Bug-free, leak-free, battle-tested library for broadcast channels? In-Reply-To: References: Message-ID: At a high level, it means it does what I think you're looking for: the "read end" of the channel created there isn't connected to anything, so there's no leak if there's no consumers. But duplicating it gives you a new "read end" that yields values as you would expect. Without going into too much detail about STM, everything runs in a transaction, and `retry` means to roll back any changes within the transaction and start again. An unconditional `retry` (including unconditionally reading from a channel created with `newBroadcastTChan`) is a deadlock and therefore probably a mistake. So don't do that! On 25 Jan 2017 05:41, "Saurabh Nanda" wrote: The implementation in STM works well and certainly ticks the battle-tested > box: > > https://hackage.haskell.org/package/stm-2.4.4.1/docs/Control > -Concurrent-STM-TChan.html#v:newBroadcastTChan > What does the following comment in the documentation really mean (highlighted by >>><<<)? "Create a write-only TChan . >>> More precisely, readTChan will retry even after items have been written to the channel.<<< The only way to read a broadcast channel is to duplicate it with dupTChan ." -- Saurabh. -------------- next part -------------- An HTML attachment was scrubbed... URL: From dct25-561bs at mythic-beasts.com Wed Jan 25 08:19:42 2017 From: dct25-561bs at mythic-beasts.com (David Turner) Date: Wed, 25 Jan 2017 08:19:42 +0000 Subject: [Haskell-cafe] Bug-free, leak-free, battle-tested library for broadcast channels? In-Reply-To: References: <539991FF-F43D-4380-8610-962FA786D2C2@inconsistent.nl> Message-ID: Looks good to me. In particular, creating things in one transaction and using them in another is normal for STM. If you're creating the channel in a transaction on its own you might prefer to call this: https://hackage.haskell.org/package/stm-2.4.4.1/docs/Control-Concurrent-STM-TChan.html#v:newBroadcastTChanIO On 25 Jan 2017 07:55, "Saurabh Nanda" wrote: > Am I using broadcastTChan & STM correctly here? https://gist.github.com/ > saurabhnanda/3cc39f1e0a646254dd8819b01cd04ac3 Is it acceptable to > basically create a `broadcastTChan` and make it "escape" the STM monad? > > > > On Tue, Jan 24, 2017 at 3:45 PM, Merijn Verstraaten < > merijn at inconsistent.nl> wrote: > >> I don't know about split-channel, which seems to try and have a lot of >> functionality, but broadcast-chan is literally (and I mean the "copy+paste" >> kind of literally) the exact same implementation as Control.Concurrent.Chan. >> >> The only difference is that, with Control.Concurrent.Chan each Chan >> always has access to both the read and write end of the Chan. This read end >> will keep data inside that Chan alive (and thus in memory!) indefinitely, >> if no one reads from that Chan. If you use dupChan this will create a new >> read end that tracks data in the Chan separately from the original one. >> >> This means that if you have a worker that only ever writes into a Chan, >> this read end is basically keeping everything you write into the Chan alive >> forever. >> >> broadcast-chan does the exact same thing as 'newBroadcastTChan' from >> Control.Concurrent.STM.TChan, that is your original Chan contains a "write" >> end only, and not a read end, the end result of that is: If you create a >> new write channel any message you write into it will, if there are no >> listeners, be immediately dropped and GCed. If you create "read" ends, then >> each read end will receive every message written into the write end, as >> long as the read end is active. So if you create 5 workers with a new read >> end each, then every message written after those have been created will be >> seen by all workers. >> >> So, if your problem is "I want to broadcast messages, but messages that >> are sent when there are no listeners should be dropped and forgotten", then >> use broadcast-chan. >> >> The package itself isn't "battle-tested", but since it's basically a >> copy+paste of Control.Concurrent.Chan with a trivial wrapper, I feel fairly >> confident that it doesn't have any major problems. >> >> Cheers, >> Merijn >> >> >> > On 23 Jan 2017, at 11:52, Saurabh Nanda wrote: >> > >> > (cross-posted from Reddit because I'm not sure of the audience overlap >> between haskell-cafe & reddit) >> > >> > I want to broadcast some instrumentation data from deep within my >> Haskell app. This data will have listeners in some environments (say, >> debug), but not others (say, production). Which library should I be using? >> A little searching threw two possible candidates: >> > >> > * http://hackage.haskell.org/package/split-channel >> > * https://hackage.haskell.org/package/broadcast-chan >> > >> > But, I'm not sure if these are battle-tested. Any help would be >> appreciated. >> > >> > -- Saurabh. >> > >> > _______________________________________________ >> > Haskell-Cafe mailing list >> > To (un)subscribe, modify options or view archives go to: >> > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe >> > Only members subscribed via the mailman list are allowed to post. >> >> > > > -- > http://www.saurabhnanda.com > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dct25-561bs at mythic-beasts.com Wed Jan 25 08:47:35 2017 From: dct25-561bs at mythic-beasts.com (David Turner) Date: Wed, 25 Jan 2017 08:47:35 +0000 Subject: [Haskell-cafe] Bug-free, leak-free, battle-tested library for broadcast channels? In-Reply-To: References: <539991FF-F43D-4380-8610-962FA786D2C2@inconsistent.nl> Message-ID: On an unrelated note, are you sure about using `getCurrentTime` to measure the start and end times of your process? If you want to report on the duration of the process, it can be better to use the monotonic clock from here: https://hackage.haskell.org/package/clock-0.7.2/docs/System-Clock.html The trouble with the real-time clock is that it can change discontinuously, even backwards, and it is hard to account for things like leap seconds with it, so durations calculated by subtracting two UTCTimes are a little unreliable. OTOH you might well want to know the real start and end times of your process instead/as well - it depends on your application. Hope that helps, David On 25 Jan 2017 08:19, "David Turner" wrote: Looks good to me. In particular, creating things in one transaction and using them in another is normal for STM. If you're creating the channel in a transaction on its own you might prefer to call this: https://hackage.haskell.org/package/stm-2.4.4.1/docs/Control -Concurrent-STM-TChan.html#v:newBroadcastTChanIO On 25 Jan 2017 07:55, "Saurabh Nanda" wrote: > Am I using broadcastTChan & STM correctly here? https://gist.github.com/ > saurabhnanda/3cc39f1e0a646254dd8819b01cd04ac3 Is it acceptable to > basically create a `broadcastTChan` and make it "escape" the STM monad? > > > > On Tue, Jan 24, 2017 at 3:45 PM, Merijn Verstraaten < > merijn at inconsistent.nl> wrote: > >> I don't know about split-channel, which seems to try and have a lot of >> functionality, but broadcast-chan is literally (and I mean the "copy+paste" >> kind of literally) the exact same implementation as Control.Concurrent.Chan. >> >> The only difference is that, with Control.Concurrent.Chan each Chan >> always has access to both the read and write end of the Chan. This read end >> will keep data inside that Chan alive (and thus in memory!) indefinitely, >> if no one reads from that Chan. If you use dupChan this will create a new >> read end that tracks data in the Chan separately from the original one. >> >> This means that if you have a worker that only ever writes into a Chan, >> this read end is basically keeping everything you write into the Chan alive >> forever. >> >> broadcast-chan does the exact same thing as 'newBroadcastTChan' from >> Control.Concurrent.STM.TChan, that is your original Chan contains a "write" >> end only, and not a read end, the end result of that is: If you create a >> new write channel any message you write into it will, if there are no >> listeners, be immediately dropped and GCed. If you create "read" ends, then >> each read end will receive every message written into the write end, as >> long as the read end is active. So if you create 5 workers with a new read >> end each, then every message written after those have been created will be >> seen by all workers. >> >> So, if your problem is "I want to broadcast messages, but messages that >> are sent when there are no listeners should be dropped and forgotten", then >> use broadcast-chan. >> >> The package itself isn't "battle-tested", but since it's basically a >> copy+paste of Control.Concurrent.Chan with a trivial wrapper, I feel fairly >> confident that it doesn't have any major problems. >> >> Cheers, >> Merijn >> >> >> > On 23 Jan 2017, at 11:52, Saurabh Nanda wrote: >> > >> > (cross-posted from Reddit because I'm not sure of the audience overlap >> between haskell-cafe & reddit) >> > >> > I want to broadcast some instrumentation data from deep within my >> Haskell app. This data will have listeners in some environments (say, >> debug), but not others (say, production). Which library should I be using? >> A little searching threw two possible candidates: >> > >> > * http://hackage.haskell.org/package/split-channel >> > * https://hackage.haskell.org/package/broadcast-chan >> > >> > But, I'm not sure if these are battle-tested. Any help would be >> appreciated. >> > >> > -- Saurabh. >> > >> > _______________________________________________ >> > Haskell-Cafe mailing list >> > To (un)subscribe, modify options or view archives go to: >> > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe >> > Only members subscribed via the mailman list are allowed to post. >> >> > > > -- > http://www.saurabhnanda.com > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From saurabhnanda at gmail.com Wed Jan 25 09:51:03 2017 From: saurabhnanda at gmail.com (Saurabh Nanda) Date: Wed, 25 Jan 2017 15:21:03 +0530 Subject: [Haskell-cafe] Bug-free, leak-free, battle-tested library for broadcast channels? In-Reply-To: References: <539991FF-F43D-4380-8610-962FA786D2C2@inconsistent.nl> Message-ID: > > The trouble with the real-time clock is that it can change > discontinuously, even backwards, and it is hard to account for things like > leap seconds with it, so durations calculated by subtracting two UTCTimes > are a little unreliable. > Thanks for pointing that out. Didn't realize this subtlety. -- Saurabh. -------------- next part -------------- An HTML attachment was scrubbed... URL: From lukewm at riseup.net Wed Jan 25 14:25:55 2017 From: lukewm at riseup.net (Luke Murphy) Date: Wed, 25 Jan 2017 14:25:55 +0000 Subject: [Haskell-cafe] GHC 8.0.2 Stackage LTS8 plan Message-ID: <7e592fd2-0060-ce53-8947-26aa22a73149@riseup.net> Hi folks, Please see the following brief write up regarding what the Stackage curator team have planned for a smooth transition to GHC 8.0.2 on LTS builds. http://lwm.github.io/stackage-8.0.2/ Best, Luke -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: OpenPGP digital signature URL: From david.feuer at gmail.com Wed Jan 25 14:59:05 2017 From: david.feuer at gmail.com (David Feuer) Date: Wed, 25 Jan 2017 09:59:05 -0500 Subject: [Haskell-cafe] A proof that the list monad is not a free monad In-Reply-To: References: Message-ID: The ConstraintKinds extension just lets you deal with kinds involving constraints. Turn it on, import the Constraint kind from somewhere (I know it's exported from GHC.Exts and also from Data.Constraint in the constraints package; I don't know if it has a nice home in base). Then you can write things like class C f a where p :: f a => proxy f -> a -> Int etc. On Jan 23, 2017 4:19 PM, "Olaf Klinke" wrote: On a mostly unrelated note, Dan Doel elaborated [1] that the list monad is not the monad of free monoids either, even though mathematically the free monoid over x is the set of words of finite length with alphabet x. Briefly, the reason is that Haskell types are domains, not sets. Below is a proof that the free monad is not the free algebra. One approximant to free algebraic structures is to look at the free F-algebra for a functor F. This approach does not take into account any equations between the algebraic operations. {-# LANGUAGE Rank2Types,MultiParamTypeClasses,FlexibleInstances,FlexibleContexts #-} module FreeFAlg where import Control.Applicative import Control.Monad -- F-algebras (sans laws). class Functor f => Alg f a where alg :: f a -> a -- The free F-algebra over x, following Dan Doel's ideas, -- with the universal property baked in. newtype FreeAlg f x = FreeAlg (forall a. Alg f a => (x -> a) -> a) runFree :: Alg f a => FreeAlg f x -> (x -> a) -> a runFree (FreeAlg f) = f universal :: Alg f a => (x -> a) -> FreeAlg f x -> a universal = flip runFree instance Functor f => Alg f (FreeAlg f x) where alg ff = FreeAlg (\f -> alg (fmap (($f).runFree) ff)) instance Functor (FreeAlg f) where fmap h (FreeAlg fx) = FreeAlg (\f -> fx (f.h)) instance Monad (FreeAlg f) where return x = FreeAlg ($x) (FreeAlg fx) >>= k = FreeAlg (\f -> fx (\x -> runFree (k x) f)) instance Applicative (FreeAlg f) where pure = return (<*>) = ap data FreeMonad f x = Pure x | Roll (f (FreeMonad f x)) instance Functor f => Alg f (FreeMonad f x) where alg = Roll -- This looks like the same universal property... universal' :: Alg f a => (x -> a) -> FreeMonad f x -> a universal' f (Pure x) = f x universal' f (Roll ffree) = alg (fmap (universal' f) ffree) freeAlg2freeMonad :: Functor f => FreeAlg f x -> FreeMonad f x freeAlg2freeMonad = universal Pure freeMonad2freeAlg :: Functor f => FreeMonad f x -> FreeAlg f x freeMonad2freeAlg = universal' return The free monad is not the free F-algebra, because uniqueness fails. Consider the constant functor data Point a = Point instance Functor Point where fmap f Point = Point -- universal' f (Pure x) = f x -- universal' f (Roll Point) = alg Point -- but we have another function with the same type as universal': notUnique :: Alg Point a => (x -> a) -> FreeMonad Point x -> a notUnique f = const (alg Point) For classes like Monoid, which have equations between the algebraic operations (such as mappend mempty = id), we'd need the language extension that allows constraints as type parameters. I'd like to write Free Monoid x = Free (forall a. Monid a => (x -> a) -> a) but I am not experienced with the ConstraintKinds extension. Anyone help? Olaf [1] http://comonad.com/reader/2015/free-monoids-in-haskell/ _______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post. -------------- next part -------------- An HTML attachment was scrubbed... URL: From mblazevic at stilo.com Wed Jan 25 15:46:08 2017 From: mblazevic at stilo.com (=?UTF-8?Q?Mario_Bla=c5=beevi=c4=87?=) Date: Wed, 25 Jan 2017 10:46:08 -0500 Subject: [Haskell-cafe] Early feedback on a GHC proposal In-Reply-To: References: Message-ID: <0b04c78e-fcc8-7486-7b8d-e6e096a0e0d4@stilo.com> On 2017-01-24 03:07 AM, Chris Smith wrote: > Anyone want to offer some early feedback on a GHC proposal I'm working > on? It's called OverloadedApplication. Current version > at https://github.com/cdsmith/ghc-proposals/blob/overloadedapplication/proposals/0000-overloaded-application.rst I like the proposal overall. One question you haven't addressed is whether the backtick syntax `f` should apply to all IsFunction instances, or only to functions like now. You should also explain what you expect to happen if the {-# LANGUAGE OverloadedApplication #-} pragma is plunked on top of an existing module and some IsFunction instances imported. Do you expect any Haskell2010 module to remain completely unaffected? If so, I presume there must be some defaulting rules to prefer the plain old function application. > I'd love to get early thoughts from anyone who has a solid use case > for the rest of the proposal. It feels like a thing that *ought* to > be useful, but I'm drawing blanks at the moment. I haven't looked into it deeply, but it may be possible to re-implement something like the idiom brackets (for a particular Applicative instance) using this proposal. From b at chreekat.net Wed Jan 25 17:09:20 2017 From: b at chreekat.net (Bryan Richter) Date: Wed, 25 Jan 2017 09:09:20 -0800 Subject: [Haskell-cafe] Using stringize and string concatenation in ghc preprocessing In-Reply-To: References: Message-ID: <20170125170920.GA32099@fuzzbomb> On Tue, Jan 24, 2017 at 11:36:35PM -0500, Stefan Monnier wrote: > >>> I note that a company I worked for refused to have any GPL > >>> software on their machines, even GCC, due to legal advice. That > >>> was a couple of revisions of the GPL ago, but some scars last. > >> By "some scars last", do you mean "I'll stay away from that > >> company"? > > No, of course not. The key point was that we were a small company > > and would not have survived a law suit, win or lose. > > I don't follow: the "keep away from GPL" stance seems to only make > sense in the context of a very large corporation where the potential > benefit of that one little tool (GHC) is dwarfed by the general risk > of using things whose license can't be controlled via money. In general, it has nothing to do with controlling the software. In the American legal system (which inherits from the British system), the rules are defined based on previously-established rules ("precedent"). This contrasts it with, say, the discipline of physics, which continuously tries to discover first principles. Law just keeps accreting its principles. One effect of this is that it is easy to tell if you are on safe ground. Are you doing something that is exactly like something else that has already been decided on? Then you can be pretty certain you will know the legal results of your actions. You can know if it's "safe" or "risky". Some issue that has not been explored in much detail is decidedly risky. The act of creating new legal principles is long, very costly, and entirely uncertain. The act alone will kill most small organizations, whether or not the result is in their favor. The GPL still has a very sparse legal history. Lawyers are rationally conservative. They will warn their clients of the sparse legal history of the GPL. Thus, if using GPL'd software is not related to a company's mission, the smart executive will avoid it. Why open yourself to unnecessary risk? Why not simply using one of the dozens of other solutions that have less uncertainty? This is *especially* true for smaller companies! Please note I'm playing Devil's advocate here. I use the GPL myself, and think highly of it. I simply understand that antagonizing people who rationally avoid it will get us nowhere. > Reality check: Has anyone ever heard of a company sued because they > use a GPL'd tool? Ever? How 'bout in your wildest dream, maybe? I can list a few, mostly involving Linux. But only a few. That's the problem. Here's a FAQ about one such case: https://sfconservancy.org/copyleft-compliance/vmware-lawsuit-faq.html Note that the SFC very carefully chose the venue for this case: Germany, which apparently does not have a precedent-based legal system. The SFC are trying to build a base of legal history for the GPL in the safest, most conservative manner possible. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 801 bytes Desc: Digital signature URL: From mail at joachim-breitner.de Wed Jan 25 17:44:04 2017 From: mail at joachim-breitner.de (Joachim Breitner) Date: Wed, 25 Jan 2017 12:44:04 -0500 Subject: [Haskell-cafe] Early feedback on a GHC proposal In-Reply-To: References: Message-ID: <1485366244.1305.3.camel@joachim-breitner.de> Hi, Am Dienstag, den 24.01.2017, 00:07 -0800 schrieb Chris Smith: > Anyone want to offer some early feedback on a GHC proposal I'm > working on?  It's called OverloadedApplication.  Current version at h > ttps://github.com/cdsmith/ghc- > proposals/blob/overloadedapplication/proposals/0000-overloaded- > application.rst > > I am proposing something a bit more ambitious than what I need, > because the proposal as written seems more likely to be broadly > useful.  The bit that I actually need is about desugaring of infix > operators in the presence of RebindableSyntax.  I'd love to get early > thoughts from anyone who has a solid use case for the rest of the > proposal.  It feels like a thing that *ought* to be useful, but I'm > drawing blanks at the moment. bold! For your use-case (presenting a world view where only curried functions are allowed), the proposal https://github.com/ghc-proposals/ghc-proposals/pull/23 might be useful (but in its current form it has now way of influencing another module, which you’d probably need to remove boiler-plate code from the student’s modules). Greetings, Joachim -- Joachim “nomeata” Breitner   mail at joachim-breitner.de • https://www.joachim-breitner.de/   XMPP: nomeata at joachim-breitner.de • OpenPGP-Key: 0xF0FBF51F   Debian Developer: nomeata at debian.org -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: This is a digitally signed message part URL: From greg at gregorycollins.net Wed Jan 25 19:00:02 2017 From: greg at gregorycollins.net (Gregory Collins) Date: Wed, 25 Jan 2017 11:00:02 -0800 Subject: [Haskell-cafe] Bug-free, leak-free, battle-tested library for broadcast channels? In-Reply-To: References: Message-ID: Try "unagi-chan", it's supposed to be much faster than Control.Concurrent.Chan, and comes with bounded channels out of the box. Greg On Mon, Jan 23, 2017 at 2:52 AM, Saurabh Nanda wrote: > (cross-posted from Reddit because I'm not sure of the audience overlap > between haskell-cafe & reddit) > > I want to broadcast some instrumentation data from deep within my Haskell > app. This data will have listeners in some environments (say, debug), but > not others (say, production). Which library should I be using? A little > searching threw two possible candidates: > > * http://hackage.haskell.org/package/split-channel > * https://hackage.haskell.org/package/broadcast-chan > > But, I'm not sure if these are battle-tested. Any help would be > appreciated. > > -- Saurabh. > > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. > -- Gregory Collins -------------- next part -------------- An HTML attachment was scrubbed... URL: From jo at durchholz.org Wed Jan 25 20:57:37 2017 From: jo at durchholz.org (Joachim Durchholz) Date: Wed, 25 Jan 2017 21:57:37 +0100 Subject: [Haskell-cafe] Bug-free, leak-free, battle-tested library for broadcast channels? In-Reply-To: References: <539991FF-F43D-4380-8610-962FA786D2C2@inconsistent.nl> Message-ID: <0b16639a-5539-f149-15fd-86320118a884@durchholz.org> Am 25.01.2017 um 09:47 schrieb David Turner: > The trouble with the real-time clock is that it can change > discontinuously, even backwards, and it is hard to account for things > like leap seconds with it, so durations calculated by subtracting two > UTCTimes are a little unreliable. > > OTOH you might well want to know the real start and end times of your > process instead/as well - it depends on your application. You use the proper tool for the job. Monotonic clock for measuring durations, UTC for reporting approximate points in time. I.e. something like 2017-01-12 10:43: benchmark #3 started 2017-01-12 10:43: benchmark #3 took 3.472 ms to complete Mixing the monotonic durations and UTC is a path to madness, and nothing good can come from it. (SCNR the hyperbole.) From antoine.rimlet at gmail.com Thu Jan 26 10:26:53 2017 From: antoine.rimlet at gmail.com (Antoine Rimlet) Date: Thu, 26 Jan 2017 11:26:53 +0100 Subject: [Haskell-cafe] Question about STRef Message-ID: Hi list, I try to get the following little program (a slightly modified "Man or boy", it prints -14254067) work "as expected", that is, without consuming lots of memory: import Control.Monad.ST import Data.STRef a k x1 x2 x3 x4 x5 = do kk <- newSTRef k let b = do k <- modifySTRef kk pred >> readSTRef kk; a k b x1 x2 x3 x4 if k <= 0 then do x3' <- x3; x4' <- x4; return (x3' + x4') else do x5' <- x5; b' <- b; return (x5' + b') main = print (runST (a 22 (return 1) (return (-1)) (return (-1)) (return 1) (return 0))) I use GHC 7.8.4, and executing this program uses about 2.5 GB of memory (or about 3.5 GB with runghc). However, the "equivalent" program in OCaml only needs 4 MB (or 9 MB with the interpreter): let rec a k x1 x2 x3 x4 x5 = let kk = ref k in let rec b () = begin decr kk; a !kk b x1 x2 x3 x4 end in if k <= 0 then let v = x3 () in v + x4 () else let v = x5 () in v + b ();; print_int (a 22 (fun () -> 1) (fun () -> -1) (fun () -> -1) (fun () -> 1) (fun () -> 0));; print_newline ();; Therefore I suspect I'm doing something wrong, but I can't see what. I did try to use the strict version modifySTRef' as indicated in the manual, but with no visible improvement. Thanks, Antoine -------------- next part -------------- An HTML attachment was scrubbed... URL: From johannes.waldmann at htwk-leipzig.de Thu Jan 26 11:42:06 2017 From: johannes.waldmann at htwk-leipzig.de (Johannes Waldmann) Date: Thu, 26 Jan 2017 12:42:06 +0100 Subject: [Haskell-cafe] Question about STRef Message-ID: Thanks for pointing out this (Knuth's) nice test case. I should use this as an exam question ... Allocation and run-time can be reduced by replacing return (x3' + x4') with let x = (x3' + x4') in x `seq` return x And, modifySTRef' *does* help. I *do* notice a regression (for the seq-ed and primed version) ghc-8.0.2 : 2.6 GB alloc, 2.3 sec ghc-6.10.4: 2.0 GB alloc, 1.7 sec (measured on X5365 @ 3.00GHz ) Numbers are for total allocation, residency is small (it runs with +RTS -H10k -A10k but then the number of GCs goes up) - J. From palotai.robin at gmail.com Thu Jan 26 12:03:19 2017 From: palotai.robin at gmail.com (Robin Palotai) Date: Thu, 26 Jan 2017 13:03:19 +0100 Subject: [Haskell-cafe] Question about STRef In-Reply-To: References: Message-ID: Alternatively, just use "return $! ", which has the same effect as seq-ing, and is generally a good practice (unless you want to be explicitly lazy). See http://johantibell.com/files/haskell-performance-patterns.html. the-thing +RTS -s (with GHC 8) 3,965,758,088 bytes allocated in the heap 46,006,592 bytes copied during GC 207,792 bytes maximum residency (5 sample(s)) <---- down to 200K from 1.5G 182,864 bytes maximum slop 8 MB total memory in use (0 MB lost due to fragmentation) Robin 2017-01-26 12:42 GMT+01:00 Johannes Waldmann < johannes.waldmann at htwk-leipzig.de>: > Thanks for pointing out this (Knuth's) nice test case. > I should use this as an exam question ... > > Allocation and run-time can be reduced > by replacing return (x3' + x4') > with let x = (x3' + x4') in x `seq` return x > And, modifySTRef' *does* help. > > I *do* notice a regression > (for the seq-ed and primed version) > > ghc-8.0.2 : 2.6 GB alloc, 2.3 sec > ghc-6.10.4: 2.0 GB alloc, 1.7 sec > > (measured on X5365 @ 3.00GHz ) > > Numbers are for total allocation, > residency is small (it runs with +RTS -H10k -A10k > but then the number of GCs goes up) > > - J. > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. -------------- next part -------------- An HTML attachment was scrubbed... URL: From johannes.waldmann at htwk-leipzig.de Thu Jan 26 12:05:30 2017 From: johannes.waldmann at htwk-leipzig.de (Johannes Waldmann) Date: Thu, 26 Jan 2017 13:05:30 +0100 Subject: [Haskell-cafe] Question about STRef In-Reply-To: References: Message-ID: Yes. Here's a table with runtime performance by ghc version: http://www.imn.htwk-leipzig.de/~waldmann/etc/mob/ The winner is 6.12.3 (1.56 sec) (where 8.0.2 : 2.30 sec) - J. From michael at snoyman.com Thu Jan 26 12:05:54 2017 From: michael at snoyman.com (Michael Snoyman) Date: Thu, 26 Jan 2017 14:05:54 +0200 Subject: [Haskell-cafe] Question about STRef In-Reply-To: References: Message-ID: I made a few modifications to your code, and found that replacing `return (x3' + x4')` with `return $! x3' + x4'` reduced maximum residency down to 64kb. This forces evaluation earlier. You can see the progression here: https://gist.github.com/snoyberg/6a48876aedb9b19c808a0c53e86109ac I took it one step further, and used the mutable-containers package to use an unboxed reference instead of the boxed STRef type. In other words: it avoids allocating a heap object. Here's that version of the code: #!/usr/bin/env stack -- stack --resolver lts-7.14 --install-ghc exec --package mutable-containers -- ghc -O2 -with-rtsopts=-s import Control.Monad.ST import Data.Mutable a :: Int -> ST s Int -> ST s Int -> ST s Int -> ST s Int -> ST s Int -> ST s Int a k x1 x2 x3 x4 x5 = do kk <- fmap asURef $ newRef k let b = do k0 <- readRef kk let k1 = k0 - 1 writeRef kk k1 a k1 b x1 x2 x3 x4 if k <= 0 then do x3' <- x3; x4' <- x4; return $! x3' + x4' else do x5' <- x5; b' <- b; return $! x5' + b' main = print (runST (a 22 (return 1) (return (-1)) (return (-1)) (return 1) (return 0))) It knocked down total allocations from 2.7GB to 1.8GB, which is an improvement, but I think there's still some more low hanging fruit here. On Thu, Jan 26, 2017 at 12:26 PM, Antoine Rimlet wrote: > Hi list, > > I try to get the following little program (a slightly modified "Man or > boy", it prints -14254067) work "as expected", that is, without consuming > lots of memory: > > import Control.Monad.ST > import Data.STRef > a k x1 x2 x3 x4 x5 = > do kk <- newSTRef k > let b = do k <- modifySTRef kk pred >> readSTRef kk; a k b x1 x2 x3 > x4 > if k <= 0 then do x3' <- x3; x4' <- x4; return (x3' + x4') > else do x5' <- x5; b' <- b; return (x5' + b') > main = print (runST (a 22 (return 1) (return (-1)) (return (-1)) (return > 1) (return 0))) > > I use GHC 7.8.4, and executing this program uses about 2.5 GB of memory > (or about 3.5 GB with runghc). However, the "equivalent" program in OCaml > only needs 4 MB (or 9 MB with the interpreter): > > let rec a k x1 x2 x3 x4 x5 = > let kk = ref k in let rec b () = begin decr kk; a !kk b x1 x2 x3 x4 end > in if k <= 0 then let v = x3 () in v + x4 () else let v = x5 () in v + b > ();; > print_int (a 22 (fun () -> 1) (fun () -> -1) (fun () -> -1) (fun () -> 1) > (fun () -> 0));; print_newline ();; > > Therefore I suspect I'm doing something wrong, but I can't see what. I > did try to use the strict version modifySTRef' as indicated in the manual, > but with no visible improvement. > > Thanks, > > Antoine > > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From johannes.waldmann at htwk-leipzig.de Thu Jan 26 13:05:52 2017 From: johannes.waldmann at htwk-leipzig.de (Johannes Waldmann) Date: Thu, 26 Jan 2017 14:05:52 +0100 Subject: [Haskell-cafe] Question about STRef Message-ID: What Michael did not mention in the mail, but it's in his code: numerals defaulted to Integer, and the story changes (somewhat) if we force Int. I updated my measurements: http://www.imn.htwk-leipzig.de/~waldmann/etc/mob/ and ghc-8 looks better now - but not quite wins. > there's still some more low hanging fruit here ... for whom? What could we reasonably expect of the compiler here? It could do the strictification? the unboxing? It certainly could not replace Integer by Int, since the range of numerical values has no obvious bound. But then, all these Integers are small, but we pay quite an overhead (for represeting Int as Integer) which has increased for current ghcs? - J. From michael at snoyman.com Thu Jan 26 13:15:44 2017 From: michael at snoyman.com (Michael Snoyman) Date: Thu, 26 Jan 2017 15:15:44 +0200 Subject: [Haskell-cafe] Question about STRef In-Reply-To: References: Message-ID: On Thu, Jan 26, 2017 at 3:05 PM, Johannes Waldmann < johannes.waldmann at htwk-leipzig.de> wrote: > What Michael did not mention in the mail, but it's in his code: > numerals defaulted to Integer, and the story changes (somewhat) > if we force Int. > > I updated my measurements: > http://www.imn.htwk-leipzig.de/~waldmann/etc/mob/ > and ghc-8 looks better now - but not quite wins. > > > there's still some more low hanging fruit here > > ... for whom? What could we reasonably expect of the compiler here? > It could do the strictification? the unboxing? > > It certainly could not replace Integer by Int, > since the range of numerical values has no obvious bound. > > But then, all these Integers are small, but we pay quite an overhead > (for represeting Int as Integer) which has increased for current ghcs? > > I meant that, if someone wanted to bring down allocations significantly, I would think there's still room for optimization. I was not commenting on what GHC should or shouldn't be capable of doing here. It would certainly be nice, for example, if it was capable of noticing the strictness involved and automatically unbox the STRefs, but that would be quite a feat. I didn't investigate further myself, so I could be mistaken about the possibility to further reduce allocations. It was just a guess (thus the "I think"). Michael -------------- next part -------------- An HTML attachment was scrubbed... URL: From blamario at ciktel.net Thu Jan 26 13:22:24 2017 From: blamario at ciktel.net (=?UTF-8?Q?Mario_Bla=c5=beevi=c4=87?=) Date: Thu, 26 Jan 2017 08:22:24 -0500 Subject: [Haskell-cafe] Request for feedback on two GHC proposals Message-ID: <514fc4de-e54d-0499-3b8a-4836d65d65a7@ciktel.net> The time is nigh for closing the discussion on the Eval class proposal for GHC, so please pipe in if you have any interest in it, either on the practical (what's the point of this terrible idea!?) or the theoretical side (I can finally get those free theorems and I'd love unlifted products!). https://github.com/ghc-proposals/ghc-proposals/pull/27 I would also appreciate feedback on a tangentially related and wholly practical INCOMPLETE_CONTEXTS pragma proposal at https://github.com/ghc-proposals/ghc-proposals/pull/34 Thank you. From michael at snoyman.com Thu Jan 26 13:22:08 2017 From: michael at snoyman.com (Michael Snoyman) Date: Thu, 26 Jan 2017 15:22:08 +0200 Subject: [Haskell-cafe] Question about STRef In-Reply-To: References: Message-ID: On Thu, Jan 26, 2017 at 3:15 PM, Michael Snoyman wrote: > > > On Thu, Jan 26, 2017 at 3:05 PM, Johannes Waldmann < > johannes.waldmann at htwk-leipzig.de> wrote: > >> What Michael did not mention in the mail, but it's in his code: >> numerals defaulted to Integer, and the story changes (somewhat) >> if we force Int. >> >> I updated my measurements: >> http://www.imn.htwk-leipzig.de/~waldmann/etc/mob/ >> and ghc-8 looks better now - but not quite wins. >> >> > there's still some more low hanging fruit here >> >> ... for whom? What could we reasonably expect of the compiler here? >> It could do the strictification? the unboxing? >> >> It certainly could not replace Integer by Int, >> since the range of numerical values has no obvious bound. >> >> But then, all these Integers are small, but we pay quite an overhead >> (for represeting Int as Integer) which has increased for current ghcs? >> >> > I meant that, if someone wanted to bring down allocations significantly, I > would think there's still room for optimization. I was not commenting on > what GHC should or shouldn't be capable of doing here. It would certainly > be nice, for example, if it was capable of noticing the strictness involved > and automatically unbox the STRefs, but that would be quite a feat. > > I didn't investigate further myself, so I could be mistaken about the > possibility to further reduce allocations. It was just a guess (thus the "I > think"). > > Michael > As an example, upon reviewing the code I realized it was unnecessarily allocating a reference in the case of `k <= 0`. Fixing that reduces allocations to 800MB (from 1.9GB). This was a pretty easy change to make. A more involved change would be to share a mutable vector of larger size instead of allocating a new reference each time. I'm now intrigued enough by the problem that I'll probably do that next :) #!/usr/bin/env stack -- stack --resolver lts-7.14 --install-ghc exec --package mutable-containers -- ghc -O2 -with-rtsopts=-s import Control.Monad.ST import Data.Mutable a :: Int -> ST s Int -> ST s Int -> ST s Int -> ST s Int -> ST s Int -> ST s Int a k x1 x2 x3 x4 x5 | k <= 0 = do x3' <- x3 x4' <- x4 return $! x3' + x4' | otherwise = do kRef <- fmap asURef $ newRef k let b = do k0 <- readRef kRef let k1 = k0 - 1 writeRef kRef k1 a k1 b x1 x2 x3 x4 x5' <- x5 b' <- b return $! x5' + b' main = print $ runST $ a 22 (return 1) (return (-1)) (return (-1)) (return 1) (return 0) -------------- next part -------------- An HTML attachment was scrubbed... URL: From frank at fstaals.net Thu Jan 26 13:32:48 2017 From: frank at fstaals.net (Frank Staals) Date: Thu, 26 Jan 2017 14:32:48 +0100 Subject: [Haskell-cafe] Question about STRef In-Reply-To: (Antoine Rimlet's message of "Thu, 26 Jan 2017 11:26:53 +0100") References: Message-ID: <87d1faeykf.fsf@work.fstaals.net> Antoine Rimlet writes: > Hi list, > > I try to get the following little program (a slightly modified "Man or > boy", it prints -14254067) work "as expected", that is, without consuming > lots of memory Are you sure "-14254067" is correct for k=22? Wikipedia [1] and RosettaCode [2] both seem to suggest that -865 609 is the right answer. Similarly, for k=10 it is supposed to return -67 rather than -577. [1] https://en.wikipedia.org/wiki/Man_or_boy_test [2] http://rosettacode.org/wiki/Man_or_boy_test -- - Frank From antoine.rimlet at gmail.com Thu Jan 26 13:56:29 2017 From: antoine.rimlet at gmail.com (Antoine Rimlet) Date: Thu, 26 Jan 2017 14:56:29 +0100 Subject: [Haskell-cafe] Question about STRef In-Reply-To: <87d1faeykf.fsf@work.fstaals.net> References: <87d1faeykf.fsf@work.fstaals.net> Message-ID: Thanks to all for your answers! With "return $!" the program now works "as expected". Forcing Int, and moving the "let b" in the "else" part, also brings some (but comparatively far less) improvement. Note that, as indicated in my initial post, this program is a *modified* version of "Man or boy", and therefore it does not return the same values. Best, Antoine 2017-01-26 14:32 GMT+01:00 Frank Staals : > Antoine Rimlet writes: > > > Hi list, > > > > I try to get the following little program (a slightly modified "Man or > > boy", it prints -14254067) work "as expected", that is, without consuming > > lots of memory > > Are you sure "-14254067" is correct for k=22? Wikipedia [1] and > RosettaCode [2] both seem to suggest that -865 609 is the right > answer. Similarly, for k=10 it is supposed to return -67 rather than -577. > > [1] https://en.wikipedia.org/wiki/Man_or_boy_test > [2] http://rosettacode.org/wiki/Man_or_boy_test > > -- > > - Frank > -------------- next part -------------- An HTML attachment was scrubbed... URL: From monnier at iro.umontreal.ca Thu Jan 26 23:25:58 2017 From: monnier at iro.umontreal.ca (Stefan Monnier) Date: Thu, 26 Jan 2017 18:25:58 -0500 Subject: [Haskell-cafe] Using stringize and string concatenation in ghc preprocessing References: <20170125170920.GA32099@fuzzbomb> Message-ID: >> Reality check: Has anyone ever heard of a company sued because they >> use a GPL'd tool? Ever? How 'bout in your wildest dream, maybe? > I can list a few, mostly involving Linux. Notice I said "use a GPL'd tool". The cases such as VMware or Linksys/Cisco are quite different from using GHC for development. Stefan From fa-ml at ariis.it Fri Jan 27 01:32:36 2017 From: fa-ml at ariis.it (Francesco Ariis) Date: Fri, 27 Jan 2017 02:32:36 +0100 Subject: [Haskell-cafe] Desugaring ArrowLoop notation Message-ID: <20170127013236.GA10254@casa.casa> Hello cafe, I was reading Stephen's Arrow Tutorial [1], where (among other things), a way to compute the running mean of a stream of integers using circular programming (ArrowLoop) is shown: mean5 :: Fractional a => Circuit a a mean5 = proc value -> do rec (lastTot, lastN) <- delay (0,0) -< (tot, n) let (tot, n) = (lastTot + value, lastN + 1) let mean = tot / n returnA -< mean To understand the example better I tried to convert the `rec do` notation to plain loop/(>>>) one (i.e. without syntactic sugar), but failed. So I ask: what's the sour version of `mean5`? -F [1] https://en.wikibooks.org/wiki/Haskell/Arrow_tutorial From joehillen at gmail.com Fri Jan 27 05:13:28 2017 From: joehillen at gmail.com (Joe Hillenbrand) Date: Thu, 26 Jan 2017 21:13:28 -0800 Subject: [Haskell-cafe] Using stringize and string concatenation in ghc preprocessing In-Reply-To: References: <20170125170920.GA32099@fuzzbomb> Message-ID: All these companies that have lawyers that say "avoid GPL" are using Linux, gcc, Emacs, and many other GPL tools, even if they don't realize it, including Apple and Microsoft. This whole argument is dangerous FUD. On Thu, Jan 26, 2017 at 3:25 PM, Stefan Monnier wrote: >>> Reality check: Has anyone ever heard of a company sued because they >>> use a GPL'd tool? Ever? How 'bout in your wildest dream, maybe? >> I can list a few, mostly involving Linux. > > Notice I said "use a GPL'd tool". The cases such as VMware or > Linksys/Cisco are quite different from using GHC for development. > > > Stefan > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. From dennis.raddle at gmail.com Fri Jan 27 05:18:13 2017 From: dennis.raddle at gmail.com (Dennis Raddle) Date: Thu, 26 Jan 2017 21:18:13 -0800 Subject: [Haskell-cafe] hash tables Message-ID: I want to build a hash table and then freeze it and use it for fast lookup later. Is there a way to build it in IO or ST but freeze it and use it in transparent code later? D -------------- next part -------------- An HTML attachment was scrubbed... URL: From saurabhnanda at gmail.com Fri Jan 27 05:19:43 2017 From: saurabhnanda at gmail.com (Saurabh Nanda) Date: Fri, 27 Jan 2017 10:49:43 +0530 Subject: [Haskell-cafe] Instrumentation without requiring code-level changes? Message-ID: (another cross post from Reddit - https://www.reddit.com/r/haskell/comments/5qfd36/instrumentation_without_required_application/ ) Is it possible to collect instrumentation data from a Hakell application without requiring the core application to change code? Here are some examples of instrumentation data: * Time taken to serve an HTTP request (not average time, but individual times, for individual requests) along with the incoming request params+headers and outgoing response length. * Time taken to make an SQL query along with the actual query (again, not average times, but individual times, for individual queries) * Time taken to fetch data from Redis along with the Redis command * Time taken to render an HTML page along with path to the HTML file Most dynamic languages (like Ruby) allow monkey-patching OR "decorating" existing functions during runtime. Most instrumentation agents (like Skylight, Newrelic), simply monkey-patch the API surfaces of known libraries to collect this data. Therefore, using these instrumentation agents is a one line code change (just include the gem, or drop the JAR, or whatever). What is the equivalent of this in Haskell? Here's what I've tried so far [1] , but it has the following disadvantages: * Requires changes to the application's cabal file to replace the non-instrumented versions of the libraries with the instrumented version (replace scotty with instrumentedscotty, in my example) * Requires the application to explicitly import the instrumented versions of the libraries (replace import Scotty with import InstrumentedScotty, in my example) * Forces all the code interacting with instrumented APIs to be run in a MonadIO environment - because of the underlying calls to getCurrentTime I'm sure there's a better way, but I couldn't get my hands on it! [1] https://gist.github.com/saurabhnanda/27592da0269bc35569ec6239e1a91b75 -- Saurabh. -------------- next part -------------- An HTML attachment was scrubbed... URL: From jo at durchholz.org Fri Jan 27 05:32:35 2017 From: jo at durchholz.org (Joachim Durchholz) Date: Fri, 27 Jan 2017 06:32:35 +0100 Subject: [Haskell-cafe] Suggestions for "Advanced" Topics for Haskell-based Class In-Reply-To: <3wh35jqs11htg3zw0ol1grwz7-0@mailer.nylas.com> References: <8xmdy0lh3jvmdg4tze9ozbavz-0@mailer.nylas.com> <69d3ebd3-5ce9-3550-ed32-0511c6ad26fa@durchholz.org> <3wh35jqs11htg3zw0ol1grwz7-0@mailer.nylas.com> Message-ID: <29fcb711-2ee1-7812-fadd-cbe8275c979b@durchholz.org> Am 25.01.2017 um 06:24 schrieb Joe Hillenbrand: > Correct, it's not the only thing a person should know to write Haskell, > but it is a required part of the curriculum. Ah, so I understood "real world Haskelling" as "doing a specific real-world Haskell project" (which may or may not require parallelism) while you meant "having the competence to work in *any* real-world Haskell project" (some of which will certainly require parallelism). From saurabhnanda at gmail.com Fri Jan 27 07:15:37 2017 From: saurabhnanda at gmail.com (Saurabh Nanda) Date: Fri, 27 Jan 2017 12:45:37 +0530 Subject: [Haskell-cafe] Instrumentation without requiring code-level changes? In-Reply-To: References: Message-ID: (copying the mailing list -- I don't think your intention was to keep this off the mailing list) I've looked at middleware for Scotty (or any WAI application), but it has limitations. I want deeper insights about how much time is being spent where, when serving a web request -- which is why the need to instrument SQL, Redis, and HTML rendering. One example that doesn't necessarily need to be in the IO monad is HTML rendering using Lucid, where the data is being passed separately to it (standard Controller <> View separation). Also, if everything needs to be run in MonadIO, what does that do to fine-grained effect tracking? I wanted to have HasDb, HasRedis, HasEmail kind of monads (or type-classes) that give me some guarantees about the **type** of IO interactions a particular function call can do. If I instrument them and add an additional MonadIO constraint, does it mean any IO can be lifted into such monads? It's unfortunate to know that the RTS doesn't have these kind of instrumentation capabilities built-in. Is it absolutely not possible to do this at an RTS level? -- Saurabh. On Fri, Jan 27, 2017 at 12:32 PM, David Turner < dct25-561bs at mythic-beasts.com> wrote: > Hi Saurabh, > > There's no direct equivalent to monkey-patching in Haskell (AFAIK (*)). > Why not instrument things always? The performance impact is usually quite > negligible, and the ability to switch instrumentation on at runtime in > production is sometimes invaluable. > > For instrumenting Scotty (in particular) or WAI-based apps (in general) > you can instrument things simply by inserting an appropriate `Middleware`, > a decision that can be deferred until service-startup time, and which > involves no change to the Scotty-side code. > > There's no equivalent to WAI for database access so I don't have a general > answer in that case, but typically database APIs have only a few core > `execute` or `query` functions that are quite straightforward to wrap with > instrumentation if needs be. > > This all kinda _has_ to be in IO anyway, as you're trying to measure a > real-world activity. Certainly there's no problem with either Scotty or > databases in this regard, as they're running in IO. Do you have an example > where you need instrumentation of a pure (i.e. non-IO) computation? In such > a case you could use the `unsafePerformIO` escape hatch (like `Debug.Trace` > does) but you'll have to be very careful to measure what you think you're > measuring: the language is quite free to reorder computations and avoid > repeating duplicated computations via referential transparency etc. > > (*) I mean, you could do something with dynamic libs and LD_PRELOAD (the > original monkey-patching) but please don't! > > Hope that helps, > > David > > On 27 Jan 2017 05:21, "Saurabh Nanda" wrote: > >> (another cross post from Reddit - https://www.reddit.com/r/haske >> ll/comments/5qfd36/instrumentation_without_required_application/) >> >> Is it possible to collect instrumentation data from a Hakell application >> without requiring the core application to change code? Here are some >> examples of instrumentation data: >> >> * Time taken to serve an HTTP request (not average time, but individual >> times, for individual requests) along with the incoming request >> params+headers and outgoing response length. >> * Time taken to make an SQL query along with the actual query (again, not >> average times, but individual times, for individual queries) >> * Time taken to fetch data from Redis along with the Redis command >> * Time taken to render an HTML page along with path to the HTML file >> >> Most dynamic languages (like Ruby) allow monkey-patching OR "decorating" >> existing functions during runtime. Most instrumentation agents (like >> Skylight, Newrelic), simply monkey-patch the API surfaces of known >> libraries to collect this data. Therefore, using these instrumentation >> agents is a one line code change (just include the gem, or drop the JAR, or >> whatever). >> >> What is the equivalent of this in Haskell? >> >> Here's what I've tried so far [1] , but it has the following >> disadvantages: >> >> * Requires changes to the application's cabal file to replace the >> non-instrumented versions of the libraries with the instrumented version >> (replace scotty with instrumentedscotty, in my example) >> * Requires the application to explicitly import the instrumented versions >> of the libraries (replace import Scotty with import InstrumentedScotty, in >> my example) >> * Forces all the code interacting with instrumented APIs to be run in a >> MonadIO environment - because of the underlying calls to getCurrentTime >> >> I'm sure there's a better way, but I couldn't get my hands on it! >> >> [1] https://gist.github.com/saurabhnanda/27592da0269bc35569ec6239e1a91b75 >> >> -- Saurabh. >> >> _______________________________________________ >> Haskell-Cafe mailing list >> To (un)subscribe, modify options or view archives go to: >> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe >> Only members subscribed via the mailman list are allowed to post. >> > -- http://www.saurabhnanda.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From dct25-561bs at mythic-beasts.com Fri Jan 27 07:41:16 2017 From: dct25-561bs at mythic-beasts.com (David Turner) Date: Fri, 27 Jan 2017 07:41:16 +0000 Subject: [Haskell-cafe] hash tables In-Reply-To: References: Message-ID: Hi Dennis, Data.HashMap [1] is my preferred way to do this, which avoids any mucking around in IO at all. If that doesn't work for you, funnily enough the function you're looking for may well be called `freeze` [2] [1] https://hackage.haskell.org/package/unordered-containers-0.2.7.2/docs/Data-HashMap-Strict.html [2] https://hackage.haskell.org/package/vector-0.12.0.0/docs/Data-Vector.html#v:freeze On 27 Jan 2017 05:18, "Dennis Raddle" wrote: I want to build a hash table and then freeze it and use it for fast lookup later. Is there a way to build it in IO or ST but freeze it and use it in transparent code later? D _______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post. -------------- next part -------------- An HTML attachment was scrubbed... URL: From saurabhnanda at gmail.com Fri Jan 27 08:14:24 2017 From: saurabhnanda at gmail.com (Saurabh Nanda) Date: Fri, 27 Jan 2017 13:44:24 +0530 Subject: [Haskell-cafe] Instrumentation without requiring code-level changes? In-Reply-To: References: Message-ID: Another thought: is it possible to "shadow" all the module names exported by a package? eg. can I simply change 'scotty' to 'instrumentedscotty' in the cabal file, where 'instrumentedscotty' also exports a module called 'Scotty', but internally depends on the 'scotty' package and imports the real 'Scotty' module? -- Saurabh. -------------- next part -------------- An HTML attachment was scrubbed... URL: From dct25-561bs at mythic-beasts.com Fri Jan 27 08:17:09 2017 From: dct25-561bs at mythic-beasts.com (David Turner) Date: Fri, 27 Jan 2017 08:17:09 +0000 Subject: [Haskell-cafe] Instrumentation without requiring code-level changes? In-Reply-To: References: Message-ID: On 27 Jan 2017 07:16, "Saurabh Nanda" wrote: (copying the mailing list -- I don't think your intention was to keep this off the mailing list) Apologies, yes, I failed to CC the mailing list. Thanks. Double checked that this one is addressed properly. I've looked at middleware for Scotty (or any WAI application), but it has limitations. I want deeper insights about how much time is being spent where, when serving a web request -- which is why the need to instrument SQL, Redis, and HTML rendering. One example that doesn't necessarily need to be in the IO monad is HTML rendering using Lucid, where the data is being passed separately to it (standard Controller <> View separation). Ok, this is definitely something that's hard to define, let alone measure: Lucid's rendering uses Bytestring.Builder to interleave the rendering and the transmission of traffic over the network, so a simple endTime-minus-startTime calculation doesn't work. You'd have to do something within ByteString.Builder itself to count the time spent filling each buffer vs the time spent sending it. I don't know of an existing implementation, but I can see how you'd do it (and it's worth noting that the relevant code is in IO, hidden behind a call to `unsafePerformIO` or similar): https://hackage.haskell.org/package/bytestring-0.10.8.1/docs/Data-ByteString-Builder-Extra.html#v:runBuilder Also, if everything needs to be run in MonadIO, what does that do to fine-grained effect tracking? I wanted to have HasDb, HasRedis, HasEmail kind of monads (or type-classes) that give me some guarantees about the **type** of IO interactions a particular function call can do. If I instrument them and add an additional MonadIO constraint, does it mean any IO can be lifted into such monads? Your type classes can avoid mentioning IO, it's the instance definitions that would want to contain the instrumentation code. But they need IO anyway so that's no big deal. It's unfortunate to know that the RTS doesn't have these kind of instrumentation capabilities built-in. Is it absolutely not possible to do this at an RTS level? Ah, actually, there's the RTS event log: https://ghc.haskell.org/trac/ghc/wiki/EventLog and https://hackage.haskell.org/package/base-4.9.1.0/docs/Debug-Trace.html#g:2 But it emits a _lot_ of events from the RTS if you switch it on. Cheers, David -- Saurabh. On Fri, Jan 27, 2017 at 12:32 PM, David Turner < dct25-561bs at mythic-beasts.com> wrote: > Hi Saurabh, > > There's no direct equivalent to monkey-patching in Haskell (AFAIK (*)). > Why not instrument things always? The performance impact is usually quite > negligible, and the ability to switch instrumentation on at runtime in > production is sometimes invaluable. > > For instrumenting Scotty (in particular) or WAI-based apps (in general) > you can instrument things simply by inserting an appropriate `Middleware`, > a decision that can be deferred until service-startup time, and which > involves no change to the Scotty-side code. > > There's no equivalent to WAI for database access so I don't have a general > answer in that case, but typically database APIs have only a few core > `execute` or `query` functions that are quite straightforward to wrap with > instrumentation if needs be. > > This all kinda _has_ to be in IO anyway, as you're trying to measure a > real-world activity. Certainly there's no problem with either Scotty or > databases in this regard, as they're running in IO. Do you have an example > where you need instrumentation of a pure (i.e. non-IO) computation? In such > a case you could use the `unsafePerformIO` escape hatch (like `Debug.Trace` > does) but you'll have to be very careful to measure what you think you're > measuring: the language is quite free to reorder computations and avoid > repeating duplicated computations via referential transparency etc. > > (*) I mean, you could do something with dynamic libs and LD_PRELOAD (the > original monkey-patching) but please don't! > > Hope that helps, > > David > > On 27 Jan 2017 05:21, "Saurabh Nanda" wrote: > >> (another cross post from Reddit - https://www.reddit.com/r/haske >> ll/comments/5qfd36/instrumentation_without_required_application/) >> >> Is it possible to collect instrumentation data from a Hakell application >> without requiring the core application to change code? Here are some >> examples of instrumentation data: >> >> * Time taken to serve an HTTP request (not average time, but individual >> times, for individual requests) along with the incoming request >> params+headers and outgoing response length. >> * Time taken to make an SQL query along with the actual query (again, not >> average times, but individual times, for individual queries) >> * Time taken to fetch data from Redis along with the Redis command >> * Time taken to render an HTML page along with path to the HTML file >> >> Most dynamic languages (like Ruby) allow monkey-patching OR "decorating" >> existing functions during runtime. Most instrumentation agents (like >> Skylight, Newrelic), simply monkey-patch the API surfaces of known >> libraries to collect this data. Therefore, using these instrumentation >> agents is a one line code change (just include the gem, or drop the JAR, or >> whatever). >> >> What is the equivalent of this in Haskell? >> >> Here's what I've tried so far [1] , but it has the following >> disadvantages: >> >> * Requires changes to the application's cabal file to replace the >> non-instrumented versions of the libraries with the instrumented version >> (replace scotty with instrumentedscotty, in my example) >> * Requires the application to explicitly import the instrumented versions >> of the libraries (replace import Scotty with import InstrumentedScotty, in >> my example) >> * Forces all the code interacting with instrumented APIs to be run in a >> MonadIO environment - because of the underlying calls to getCurrentTime >> >> I'm sure there's a better way, but I couldn't get my hands on it! >> >> [1] https://gist.github.com/saurabhnanda/27592da0269bc35569ec6239e1a91b75 >> >> -- Saurabh. >> >> _______________________________________________ >> Haskell-Cafe mailing list >> To (un)subscribe, modify options or view archives go to: >> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe >> Only members subscribed via the mailman list are allowed to post. >> > -- http://www.saurabhnanda.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From saurabhnanda at gmail.com Fri Jan 27 08:30:12 2017 From: saurabhnanda at gmail.com (Saurabh Nanda) Date: Fri, 27 Jan 2017 14:00:12 +0530 Subject: [Haskell-cafe] Instrumentation without requiring code-level changes? In-Reply-To: References: Message-ID: > > Yes, I think so, with the PackageImports extension. > > https://downloads.haskell.org/~ghc/7.8.2/docs/html/users_ > guide/syntax-extns.html#package-imports > Thank you for this. If this works, it makes using instrumentedscotty & instrumentedopaleye easier to use.. Btw, there's a note in the docs: [...] Note: you probably don't need to use this feature, it was added mainly so that we can build backwards-compatible versions of packages when APIs change. It can lead to fragile dependencies in the common case: modules occasionally move from one package to another, rendering any package-qualified imports broken. [...] I hope GHC doesn't plan to remove this extension any time soon. -- Saurabh. -------------- next part -------------- An HTML attachment was scrubbed... URL: From dct25-561bs at mythic-beasts.com Fri Jan 27 08:38:25 2017 From: dct25-561bs at mythic-beasts.com (David Turner) Date: Fri, 27 Jan 2017 08:38:25 +0000 Subject: [Haskell-cafe] Instrumentation without requiring code-level changes? In-Reply-To: References: Message-ID: I doubt it'll be removed, it's occasionally useful and I don't think it costs much to maintain. The note does indicate that your proposed usage isn't exactly recommended, and I agree: I would instrument everything all the time, to avoid all the problems associated with monkey-patching and having two different sets of performance characteristics to worry about, but it is at least possible to do what you're trying to do with this method. Cheers, On 27 Jan 2017 08:30, "Saurabh Nanda" wrote: Yes, I think so, with the PackageImports extension. > > https://downloads.haskell.org/~ghc/7.8.2/docs/html/users_gui > de/syntax-extns.html#package-imports > Thank you for this. If this works, it makes using instrumentedscotty & instrumentedopaleye easier to use.. Btw, there's a note in the docs: [...] Note: you probably don't need to use this feature, it was added mainly so that we can build backwards-compatible versions of packages when APIs change. It can lead to fragile dependencies in the common case: modules occasionally move from one package to another, rendering any package-qualified imports broken. [...] I hope GHC doesn't plan to remove this extension any time soon. -- Saurabh. -------------- next part -------------- An HTML attachment was scrubbed... URL: From saurabhnanda at gmail.com Fri Jan 27 09:00:03 2017 From: saurabhnanda at gmail.com (Saurabh Nanda) Date: Fri, 27 Jan 2017 14:30:03 +0530 Subject: [Haskell-cafe] Instrumentation without requiring code-level changes? In-Reply-To: References: Message-ID: The PackageImports hack doesn't seem to be working. Is this a peculiarity of the extension, or of GHCi, or have I gotten the imports/exports wrong -- https://gist.github.com/saurabhnanda/cab87791d38cca3bfe2cce66cead9080 Note: The package-qualified import and my package name are the **same** On Fri, Jan 27, 2017 at 2:08 PM, David Turner wrote: > I doubt it'll be removed, it's occasionally useful and I don't think it > costs much to maintain. > > The note does indicate that your proposed usage isn't exactly recommended, > and I agree: I would instrument everything all the time, to avoid all the > problems associated with monkey-patching and having two different sets of > performance characteristics to worry about, but it is at least possible to > do what you're trying to do with this method. > > Cheers, > > > > On 27 Jan 2017 08:30, "Saurabh Nanda" wrote: > > Yes, I think so, with the PackageImports extension. >> >> https://downloads.haskell.org/~ghc/7.8.2/docs/html/users_gui >> de/syntax-extns.html#package-imports >> > > Thank you for this. If this works, it makes using instrumentedscotty & > instrumentedopaleye easier to use.. Btw, there's a note in the docs: > > [...] Note: you probably don't need to use this feature, it was added > mainly so that we can build backwards-compatible versions of packages when > APIs change. It can lead to fragile dependencies in the common case: > modules occasionally move from one package to another, rendering any > package-qualified imports broken. [...] > > I hope GHC doesn't plan to remove this extension any time soon. > > -- Saurabh. > > > > -- http://www.saurabhnanda.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From frank at fstaals.net Fri Jan 27 09:12:30 2017 From: frank at fstaals.net (Frank Staals) Date: Fri, 27 Jan 2017 10:12:30 +0100 Subject: [Haskell-cafe] hash tables In-Reply-To: (David Turner's message of "Fri, 27 Jan 2017 07:41:16 +0000") References: Message-ID: <877f5gg935.fsf@work.fstaals.net> David Turner writes: > Hi Dennis, > > Data.HashMap [1] is my preferred way to do this, which avoids any mucking > around in IO at all. > > If that doesn't work for you, funnily enough the function you're looking > for may well be called `freeze` [2] > > [1] > https://hackage.haskell.org/package/unordered-containers-0.2.7.2/docs/Data-HashMap-Strict.html > > [2] > https://hackage.haskell.org/package/vector-0.12.0.0/docs/Data-Vector.html#v:freeze > > On 27 Jan 2017 05:18, "Dennis Raddle" wrote: > > I want to build a hash table and then freeze it and use it for fast lookup > later. Is there a way to build it in IO or ST but freeze it and use it in > transparent code later? > D I've actually wanted this type of operations a few times as well, but never really found a solution so far. The problem with just using Data.HashMap is that it does not guarantee the desired query times (although I'm guessing it would "work well in practice"). It would be awesome if there was some sort of cuckoo-hashing implementation that you could build in ST (in expected O(n) time or so), and then freeze as to get O(1) worst case (guaranteed) lookups in pure code. -- - Frank From jmartty at hotmail.com Fri Jan 27 10:01:19 2017 From: jmartty at hotmail.com (Juan Luis Martty) Date: Fri, 27 Jan 2017 10:01:19 +0000 Subject: [Haskell-cafe] Problem using external package from git with stack Message-ID: Hello, I am trying to use binary-serialise-cbor in my project. Since it's not on hackage I followed the docs and added the following to stack.yaml: packages: - '.' - location: git: https://github.com/well-typed/binary-serialise-cbor.git commit: 1e11ea5cc7810d241b2fe1bca0ed435baa4d4371 extra-dep: true flags: binary-serialise-cbor: newtime15: true And in my .cabal file I have: build-depends: base >= 4.7 && < 5, network-simple, time, binary-serialize-cbor, bytestring When I do stack build the package is downloaded and built but then I get the following error: Error: While constructing the build plan, the following exceptions were encountered: In the dependencies for hcopia-0.1.0.0: binary-serialize-cbor must match -any, but the stack configuration has no specified version I attached both files just in case. Regards, Juan -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: hcopia.cabal Type: application/octet-stream Size: 1190 bytes Desc: hcopia.cabal URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: stack.yaml Type: application/x-yaml Size: 2364 bytes Desc: stack.yaml URL: From michael at snoyman.com Fri Jan 27 10:08:53 2017 From: michael at snoyman.com (Michael Snoyman) Date: Fri, 27 Jan 2017 12:08:53 +0200 Subject: [Haskell-cafe] Problem using external package from git with stack In-Reply-To: References: Message-ID: It's because you're an American. Replace binary-serialize-cbor with binary-serialise-cbor in your cabal file :) On Fri, Jan 27, 2017 at 12:01 PM, Juan Luis Martty wrote: > Hello, I am trying to use binary-serialise-cbor in my project. Since it's > not on hackage I followed the docs and added the following to stack.yaml: > > packages: > - '.' > - location: > git: https://github.com/well-typed/binary-serialise-cbor.git > commit: 1e11ea5cc7810d241b2fe1bca0ed435baa4d4371 > extra-dep: true > > flags: > binary-serialise-cbor: > newtime15: true > > > And in my .cabal file I have: > > build-depends: base >= 4.7 && < 5, > network-simple, > time, > binary-serialize-cbor, > bytestring > > > When I do stack build the package is downloaded and built but then I get > the following error: > > Error: While constructing the build plan, the following exceptions were > encountered: > > In the dependencies for hcopia-0.1.0.0: > binary-serialize-cbor must match -any, but the stack configuration has > no specified version > > > I attached both files just in case. > > Regards, > > Juan > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From michael at snoyman.com Fri Jan 27 10:10:23 2017 From: michael at snoyman.com (Michael Snoyman) Date: Fri, 27 Jan 2017 12:10:23 +0200 Subject: [Haskell-cafe] Problem using external package from git with stack In-Reply-To: References: Message-ID: Sorry, I should have said "you're using American spelling." On Fri, Jan 27, 2017 at 12:08 PM, Michael Snoyman wrote: > It's because you're an American. > > Replace binary-serialize-cbor with binary-serialise-cbor in your cabal > file :) > > On Fri, Jan 27, 2017 at 12:01 PM, Juan Luis Martty > wrote: > >> Hello, I am trying to use binary-serialise-cbor in my project. Since it's >> not on hackage I followed the docs and added the following to stack.yaml: >> >> packages: >> - '.' >> - location: >> git: https://github.com/well-typed/binary-serialise-cbor.git >> commit: 1e11ea5cc7810d241b2fe1bca0ed435baa4d4371 >> extra-dep: true >> >> flags: >> binary-serialise-cbor: >> newtime15: true >> >> >> And in my .cabal file I have: >> >> build-depends: base >= 4.7 && < 5, >> network-simple, >> time, >> binary-serialize-cbor, >> bytestring >> >> >> When I do stack build the package is downloaded and built but then I get >> the following error: >> >> Error: While constructing the build plan, the following exceptions were >> encountered: >> >> In the dependencies for hcopia-0.1.0.0: >> binary-serialize-cbor must match -any, but the stack configuration >> has no specified version >> >> >> I attached both files just in case. >> >> Regards, >> >> Juan >> >> _______________________________________________ >> Haskell-Cafe mailing list >> To (un)subscribe, modify options or view archives go to: >> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe >> Only members subscribed via the mailman list are allowed to post. >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jmartty at hotmail.com Fri Jan 27 10:11:56 2017 From: jmartty at hotmail.com (Juan Luis Martty) Date: Fri, 27 Jan 2017 10:11:56 +0000 Subject: [Haskell-cafe] Problem using external package from git with stack In-Reply-To: References: , Message-ID: Thanks for the quick response, that did it! I feel dumb now, I guess the error message tripped me up Cheers ________________________________ From: michael.snoyman at gmail.com on behalf of Michael Snoyman Sent: Friday, January 27, 2017 7:08 AM To: Juan Luis Martty Cc: haskell-cafe at haskell.org Subject: Re: [Haskell-cafe] Problem using external package from git with stack It's because you're an American. Replace binary-serialize-cbor with binary-serialise-cbor in your cabal file :) On Fri, Jan 27, 2017 at 12:01 PM, Juan Luis Martty > wrote: Hello, I am trying to use binary-serialise-cbor in my project. Since it's not on hackage I followed the docs and added the following to stack.yaml: packages: - '.' - location: git: https://github.com/well-typed/binary-serialise-cbor.git commit: 1e11ea5cc7810d241b2fe1bca0ed435baa4d4371 extra-dep: true flags: binary-serialise-cbor: newtime15: true And in my .cabal file I have: build-depends: base >= 4.7 && < 5, network-simple, time, binary-serialize-cbor, bytestring When I do stack build the package is downloaded and built but then I get the following error: Error: While constructing the build plan, the following exceptions were encountered: In the dependencies for hcopia-0.1.0.0: binary-serialize-cbor must match -any, but the stack configuration has no specified version I attached both files just in case. Regards, Juan _______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post. -------------- next part -------------- An HTML attachment was scrubbed... URL: From michael at snoyman.com Fri Jan 27 10:22:30 2017 From: michael at snoyman.com (Michael Snoyman) Date: Fri, 27 Jan 2017 10:22:30 +0000 Subject: [Haskell-cafe] Problem using external package from git with stack In-Reply-To: References: Message-ID: No problem, I've tripped over those kinds of misspellings enough myself in the past. On Fri, Jan 27, 2017, 12:21 PM Juan Luis Martty wrote: > Thanks for the quick response, that did it! I feel dumb now, I guess the > error message tripped me up > > Cheers > > ------------------------------ > *From:* michael.snoyman at gmail.com on behalf > of Michael Snoyman > *Sent:* Friday, January 27, 2017 7:08 AM > *To:* Juan Luis Martty > *Cc:* haskell-cafe at haskell.org > *Subject:* Re: [Haskell-cafe] Problem using external package from git > with stack > > It's because you're an American. > > Replace binary-serialize-cbor with binary-serialise-cbor in your cabal > file :) > > On Fri, Jan 27, 2017 at 12:01 PM, Juan Luis Martty > wrote: > > Hello, I am trying to use binary-serialise-cbor in my project. Since it's > not on hackage I followed the docs and added the following to stack.yaml: > > packages: > - '.' > - location: > git: https://github.com/well-typed/binary-serialise-cbor.git > commit: 1e11ea5cc7810d241b2fe1bca0ed435baa4d4371 > extra-dep: true > > flags: > binary-serialise-cbor: > newtime15: true > > > And in my .cabal file I have: > > build-depends: base >= 4.7 && < 5, > network-simple, > time, > binary-serialize-cbor, > bytestring > > > When I do stack build the package is downloaded and built but then I get > the following error: > > Error: While constructing the build plan, the following exceptions were > encountered: > > In the dependencies for hcopia-0.1.0.0: > binary-serialize-cbor must match -any, but the stack configuration has > no specified version > > > I attached both files just in case. > > Regards, > > Juan > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. > > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. -------------- next part -------------- An HTML attachment was scrubbed... URL: From toad3k at gmail.com Fri Jan 27 13:29:04 2017 From: toad3k at gmail.com (David McBride) Date: Fri, 27 Jan 2017 08:29:04 -0500 Subject: [Haskell-cafe] Problem using external package from git with stack In-Reply-To: References: Message-ID: I spent an hour one day with this problem when I had haskell-mysql instead of mysql-haskell. I can't really fault stack, nor can I think of any way to make it better. On Fri, Jan 27, 2017 at 5:22 AM, Michael Snoyman wrote: > No problem, I've tripped over those kinds of misspellings enough myself in > the past. > > > On Fri, Jan 27, 2017, 12:21 PM Juan Luis Martty wrote: >> >> Thanks for the quick response, that did it! I feel dumb now, I guess the >> error message tripped me up >> >> Cheers >> >> >> ________________________________ >> From: michael.snoyman at gmail.com on behalf of >> Michael Snoyman >> Sent: Friday, January 27, 2017 7:08 AM >> To: Juan Luis Martty >> Cc: haskell-cafe at haskell.org >> Subject: Re: [Haskell-cafe] Problem using external package from git with >> stack >> >> It's because you're an American. >> >> Replace binary-serialize-cbor with binary-serialise-cbor in your cabal >> file :) >> >> On Fri, Jan 27, 2017 at 12:01 PM, Juan Luis Martty >> wrote: >>> >>> Hello, I am trying to use binary-serialise-cbor in my project. Since it's >>> not on hackage I followed the docs and added the following to stack.yaml: >>> >>> packages: >>> - '.' >>> - location: >>> git: https://github.com/well-typed/binary-serialise-cbor.git >>> commit: 1e11ea5cc7810d241b2fe1bca0ed435baa4d4371 >>> extra-dep: true >>> >>> flags: >>> binary-serialise-cbor: >>> newtime15: true >>> >>> >>> And in my .cabal file I have: >>> >>> build-depends: base >= 4.7 && < 5, >>> network-simple, >>> time, >>> binary-serialize-cbor, >>> bytestring >>> >>> >>> When I do stack build the package is downloaded and built but then I get >>> the following error: >>> >>> Error: While constructing the build plan, the following exceptions were >>> encountered: >>> >>> In the dependencies for hcopia-0.1.0.0: >>> binary-serialize-cbor must match -any, but the stack configuration >>> has no specified version >>> >>> >>> I attached both files just in case. >>> >>> Regards, >>> >>> Juan >>> >>> >>> _______________________________________________ >>> Haskell-Cafe mailing list >>> To (un)subscribe, modify options or view archives go to: >>> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe >>> Only members subscribed via the mailman list are allowed to post. >> >> >> _______________________________________________ >> Haskell-Cafe mailing list >> To (un)subscribe, modify options or view archives go to: >> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe >> Only members subscribed via the mailman list are allowed to post. > > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. From tomas.carnecky at gmail.com Fri Jan 27 13:49:14 2017 From: tomas.carnecky at gmail.com (Tomas Carnecky) Date: Fri, 27 Jan 2017 13:49:14 +0000 Subject: [Haskell-cafe] Problem using external package from git with stack In-Reply-To: References: Message-ID: > nor can I think of any way to make it better. I can. It's easy to detect permutations of words (levenshtein distance) and let the user know. Permutations of words should also be fairly easy to detect, there aren't that many packages in the stackage snapshot. See git for example: $ git comit -m ... git: 'comit' is not a git command. See 'git --help'. Did you mean this? commit On Fri, Jan 27, 2017 at 2:42 PM David McBride wrote: > I spent an hour one day with this problem when I had haskell-mysql > instead of mysql-haskell. I can't really fault stack, nor can I think > of any way to make it better. > > On Fri, Jan 27, 2017 at 5:22 AM, Michael Snoyman > wrote: > > No problem, I've tripped over those kinds of misspellings enough myself > in > > the past. > > > > > > On Fri, Jan 27, 2017, 12:21 PM Juan Luis Martty > wrote: > >> > >> Thanks for the quick response, that did it! I feel dumb now, I guess the > >> error message tripped me up > >> > >> Cheers > >> > >> > >> ________________________________ > >> From: michael.snoyman at gmail.com on behalf > of > >> Michael Snoyman > >> Sent: Friday, January 27, 2017 7:08 AM > >> To: Juan Luis Martty > >> Cc: haskell-cafe at haskell.org > >> Subject: Re: [Haskell-cafe] Problem using external package from git with > >> stack > >> > >> It's because you're an American. > >> > >> Replace binary-serialize-cbor with binary-serialise-cbor in your cabal > >> file :) > >> > >> On Fri, Jan 27, 2017 at 12:01 PM, Juan Luis Martty > > >> wrote: > >>> > >>> Hello, I am trying to use binary-serialise-cbor in my project. Since > it's > >>> not on hackage I followed the docs and added the following to > stack.yaml: > >>> > >>> packages: > >>> - '.' > >>> - location: > >>> git: https://github.com/well-typed/binary-serialise-cbor.git > >>> commit: 1e11ea5cc7810d241b2fe1bca0ed435baa4d4371 > >>> extra-dep: true > >>> > >>> flags: > >>> binary-serialise-cbor: > >>> newtime15: true > >>> > >>> > >>> And in my .cabal file I have: > >>> > >>> build-depends: base >= 4.7 && < 5, > >>> network-simple, > >>> time, > >>> binary-serialize-cbor, > >>> bytestring > >>> > >>> > >>> When I do stack build the package is downloaded and built but then I > get > >>> the following error: > >>> > >>> Error: While constructing the build plan, the following exceptions were > >>> encountered: > >>> > >>> In the dependencies for hcopia-0.1.0.0: > >>> binary-serialize-cbor must match -any, but the stack configuration > >>> has no specified version > >>> > >>> > >>> I attached both files just in case. > >>> > >>> Regards, > >>> > >>> Juan > >>> > >>> > >>> _______________________________________________ > >>> Haskell-Cafe mailing list > >>> To (un)subscribe, modify options or view archives go to: > >>> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > >>> Only members subscribed via the mailman list are allowed to post. > >> > >> > >> _______________________________________________ > >> Haskell-Cafe mailing list > >> To (un)subscribe, modify options or view archives go to: > >> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > >> Only members subscribed via the mailman list are allowed to post. > > > > > > _______________________________________________ > > Haskell-Cafe mailing list > > To (un)subscribe, modify options or view archives go to: > > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > > Only members subscribed via the mailman list are allowed to post. > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. -------------- next part -------------- An HTML attachment was scrubbed... URL: From saurabhnanda at gmail.com Fri Jan 27 14:25:51 2017 From: saurabhnanda at gmail.com (Saurabh Nanda) Date: Fri, 27 Jan 2017 19:55:51 +0530 Subject: [Haskell-cafe] Instrumentation without requiring code-level changes? In-Reply-To: References: Message-ID: > > The PackageImports hack doesn't seem to be working. Is this a peculiarity > of the extension, or of GHCi, or have I gotten the imports/exports wrong -- > https://gist.github.com/saurabhnanda/cab87791d38cca3bfe2cce66cead9080 > > Note: The package-qualified import and my package name are the **same** > Have put this question upon on StackOverflow for greater visibility -- http://stackoverflow.com/questions/41896211/how-to-use-packageimports-extension-to-shadow-a-module -- Saurabh. -------------- next part -------------- An HTML attachment was scrubbed... URL: From monnier at iro.umontreal.ca Fri Jan 27 14:47:28 2017 From: monnier at iro.umontreal.ca (Stefan Monnier) Date: Fri, 27 Jan 2017 09:47:28 -0500 Subject: [Haskell-cafe] Using stringize and string concatenation in ghc preprocessing References: <20170125170920.GA32099@fuzzbomb> Message-ID: >>> Reality check: Has anyone ever heard of a company sued because they >>> use a GPL'd tool? Ever? How 'bout in your wildest dream, maybe? >> I can list a few, mostly involving Linux. One more thing: in your list, please include the number of years of negotiation before the lawsuit was filed. Stefan From greg at gregorycollins.net Fri Jan 27 17:44:17 2017 From: greg at gregorycollins.net (Gregory Collins) Date: Fri, 27 Jan 2017 09:44:17 -0800 Subject: [Haskell-cafe] hash tables In-Reply-To: <877f5gg935.fsf@work.fstaals.net> References: <877f5gg935.fsf@work.fstaals.net> Message-ID: On Fri, Jan 27, 2017 at 1:12 AM, Frank Staals wrote: > It would be awesome if there was some sort of cuckoo-hashing > implementation that you could build in ST (in expected O(n) time or so), > and then freeze as to get O(1) worst case (guaranteed) lookups in pure > code. > There is a version of cuckoo hashing in the hashtables library that is in ST, but it doesn't do freeze, sorry. I decided not to add freeze -- it would have more than doubled the API footprint for very little benefit. G -- Gregory Collins -------------- next part -------------- An HTML attachment was scrubbed... URL: From twhitehead at gmail.com Fri Jan 27 20:39:52 2017 From: twhitehead at gmail.com (Tyson Whitehead) Date: Fri, 27 Jan 2017 15:39:52 -0500 Subject: [Haskell-cafe] Sequence of lifting transformation operators Message-ID: A couple of times I find myself wishing for an easy way to transform a function by picking and choosing which of its operators are lifted. For example, consider f <$> x1 <*> pure x2 <*> x3 <*> pure x4 we can put all the details of this into f itself f' x1 x2 x3 x4 = f <$> x1 <*> pure x2 <*> x3 <*> pure x4 and then just write f' x1 x2 x3 x4 I think it might be nice to have a series of transformation functions that made this easy to write. Something like a series of operator like so f' = f <$_$_> where it would be read that f' is a lifted f such that the first argument is lifted, the second is not, the third is, and the fourth is not (this is consistent with f <$> returning a being a lifted f with first argument being lifted). This would make code such as the following flip (go finalX finalY) y `liftM` mx = go <__$_> finalX finalY mx y https://github.com/snoyberg/conduit/blob/be803218b5b2acaad2eb720ca3a27a4d0734fba8/conduit/Data/Conduit/Internal/Conduit.hs#L543 much more robust to write (how it gets written now depends very much on the number of arguments, their order, which ones are lifted, etc.), a whole lot easier to read, and don't even get me started on the points free use (go <__$_>)! A library could easily provide the first six or so variants (2^6 = 64 functions). If they were really useful the compiler could provide the rest. <$> :: (a -> b) -> f a -> f b <$$> :: (a -> b -> c) -> f a -> f b -> f c <$_> :: (a -> b -> c) -> f a -> b -> f c <_$> :: (a -> b -> c) -> a -> f b -> f c ... Cheers! -Tyson PS: It would be nice to also have ones that work with f being lifted. That is like how we have <$> for an unlifted f and <*> for a lifted f. <*> :: f (a -> b) -> f a -> f b <**> :: f (a -> b -> c) -> f a -> f b -> f c <*_> :: f (a -> b -> c) -> f a -> b -> f c <_*> :: f (a -> b -> c) -> a -> f b -> f c ... A bit of a pain here is that <**> is actually already taken as <*> with reversed arguments. Possibly this would call for something like this instead <$^> :: (a -> b) -> f a -> f b <$^^> :: (a -> b -> c) -> f a -> f b -> f c <$^_> :: (a -> b -> c) -> f a -> b -> f c <$_^> :: (a -> b -> c) -> a -> f b -> f c ... and <*^> :: f (a -> b) -> f a -> f b <*^^> :: f (a -> b -> c) -> f a -> f b -> f c <*^_> :: f (a -> b -> c) -> f a -> b -> f c <*_^> :: f (a -> b -> c) -> a -> f b -> f c ... where they are prefixed by $ or * to indicate what type f is and then _ encodes an unlifted argument position and ^ a lifted argument position. From mle+hs at mega-nerd.com Fri Jan 27 22:33:42 2017 From: mle+hs at mega-nerd.com (Erik de Castro Lopo) Date: Sat, 28 Jan 2017 09:33:42 +1100 Subject: [Haskell-cafe] Sequence of lifting transformation operators In-Reply-To: References: Message-ID: <20170128093342.42447c4a5d4881089124f4f0@mega-nerd.com> Tyson Whitehead wrote: > <$$> :: (a -> b -> c) -> f a -> f b -> f c I'd just like to point out that this operator is often used by as the oeprator for fmap2: (<$$>) :: (Functor f1, Functor f) => (a -> b) -> f (f1 a) -> f (f1 b) (<$$>) = fmap . fmap Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/ From saurabhnanda at gmail.com Sat Jan 28 05:03:11 2017 From: saurabhnanda at gmail.com (Saurabh Nanda) Date: Sat, 28 Jan 2017 10:33:11 +0530 Subject: [Haskell-cafe] Instrumentation without requiring code-level changes? In-Reply-To: References: Message-ID: > > The PackageImports hack doesn't seem to be working. Is this a peculiarity >> of the extension, or of GHCi, or have I gotten the imports/exports wrong -- >> https://gist.github.com/saurabhnanda/cab87791d38cca3bfe2cce66cead9080 >> >> Note: The package-qualified import and my package name are the **same** >> > > > Have put this question upon on StackOverflow for greater visibility -- > http://stackoverflow.com/questions/41896211/how-to-use- > packageimports-extension-to-shadow-a-module > And I managed to find a solution after scratching my head around yet another Haskell limitation related to modules! http://stackoverflow.com/a/41906492/534481 -- http://www.saurabhnanda.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From esz at posteo.de Sat Jan 28 14:07:48 2017 From: esz at posteo.de (Ertugrul =?utf-8?Q?S=C3=B6ylemez?=) Date: Sat, 28 Jan 2017 15:07:48 +0100 Subject: [Haskell-cafe] Desugaring ArrowLoop notation In-Reply-To: <20170127013236.GA10254@casa.casa> References: <20170127013236.GA10254@casa.casa> Message-ID: <86wpdf9t1n.fsf@posteo.de> > mean5 :: Fractional a => Circuit a a > mean5 = proc value -> do > rec > (lastTot, lastN) <- delay (0,0) -< (tot, n) > let (tot, n) = (lastTot + value, lastN + 1) > let mean = tot / n > returnA -< mean > > So I ask: what's the sour version of `mean5`? The translation is very similar to the one for 'mfix', except that you need to account for the side channel in the input: mean5 = loop $ proc (value, ~(tot', n')) -> do (lastTot, lastN) <- delay (0,0) -< (tot', n') let (tot, n) = (lastTot + value, lastN + 1) id -< (tot / n, (tot, n)) You need the values 'tot' and 'n' to be in scope as input to the 'delay' action. To achieve that you literally just return them as the second output component, and 'loop' will feed them back as the second input component. That's how they get in scope for 'delay's input. This is not the exact way it's desugared (which is probably a lot uglier), but it's equivalent and should give you an intuition for how 'loop' works. I'm not entirely sure the lazy pattern is necessary or even possible. If it's possible, it's probably also necessary. Greets ertes -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 487 bytes Desc: not available URL: From fa-ml at ariis.it Sat Jan 28 14:42:07 2017 From: fa-ml at ariis.it (Francesco Ariis) Date: Sat, 28 Jan 2017 15:42:07 +0100 Subject: [Haskell-cafe] Desugaring ArrowLoop notation In-Reply-To: <86wpdf9t1n.fsf@posteo.de> References: <20170127013236.GA10254@casa.casa> <86wpdf9t1n.fsf@posteo.de> Message-ID: <20170128144207.GA14442@casa.casa> On Sat, Jan 28, 2017 at 03:07:48PM +0100, Ertugrul Söylemez wrote: > > mean5 :: Fractional a => Circuit a a > > mean5 = proc value -> do > > rec > > (lastTot, lastN) <- delay (0,0) -< (tot, n) > > let (tot, n) = (lastTot + value, lastN + 1) > > let mean = tot / n > > returnA -< mean > > > > So I ask: what's the sour version of `mean5`? > > The translation is very similar to the one for 'mfix', except that you > need to account for the side channel in the input: > > mean5 = > loop $ proc (value, ~(tot', n')) -> do > (lastTot, lastN) <- delay (0,0) -< (tot', n') > let (tot, n) = (lastTot + value, lastN + 1) > id -< (tot / n, (tot, n)) Thank you, loop machinery is much more clearer now! From chneukirchen at gmail.com Sat Jan 28 17:17:54 2017 From: chneukirchen at gmail.com (Christian Neukirchen) Date: Sat, 28 Jan 2017 18:17:54 +0100 Subject: [Haskell-cafe] Munich Haskell Meeting, 2017-01-30 @ 19:30 Message-ID: <877f5fhznh.fsf@gmail.com> Dear all, Next week, our monthly Munich Haskell Meeting will take place again on Monday, January 28 at Augustiner-Gaststätte Rumpler at 19h30. For details see here: http://muenchen.haskell.bayern/dates.html If you plan to join, please add yourself to this dudle so we can reserve enough seats! It is OK to add yourself to the dudle anonymously or pseudonymously. https://dudle.inf.tu-dresden.de/haskell-munich-jan-2017/ Everybody is welcome! cu, -- Christian Neukirchen http://chneukirchen.org From chneukirchen at gmail.com Sat Jan 28 17:22:35 2017 From: chneukirchen at gmail.com (Christian Neukirchen) Date: Sat, 28 Jan 2017 18:22:35 +0100 Subject: [Haskell-cafe] Correction: Munich Haskell Meeting, 2017-01-30 @ 19:30 In-Reply-To: <877f5fhznh.fsf@gmail.com> Message-ID: <8760kzhzfo.fsf@gmail.com> > Next week, our monthly Munich Haskell Meeting will take place again on > Monday, January 28 at Augustiner-Gaststätte Rumpler at 19h30. For > details see here: Of course, Monday is January 30. Good morning everyone. ;) cu, -- Christian Neukirchen http://chneukirchen.org From vieira.ufpi at gmail.com Sat Jan 28 18:16:27 2017 From: vieira.ufpi at gmail.com (Francisco Vieira de Souza) Date: Sat, 28 Jan 2017 15:16:27 -0300 Subject: [Haskell-cafe] Munich Haskell Meeting, 2017-01-30 @ 19:30 In-Reply-To: <877f5fhznh.fsf@gmail.com> References: <877f5fhznh.fsf@gmail.com> Message-ID: Escuse me, but I think there is something wrong. January, 28 on Monday? 2017-01-28 14:17 GMT-03:00 Christian Neukirchen : > Dear all, > > Next week, our monthly Munich Haskell Meeting will take place again on > Monday, January 28 at Augustiner-Gaststätte Rumpler at 19h30. For > details see here: > > http://muenchen.haskell.bayern/dates.html > > If you plan to join, please add yourself to this dudle so we can > reserve enough seats! It is OK to add yourself to the dudle > anonymously or pseudonymously. > > https://dudle.inf.tu-dresden.de/haskell-munich-jan-2017/ > > Everybody is welcome! > > cu, > -- > Christian Neukirchen http://chneukirchen.org > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. -- "Embora ninguém possa voltar atrás e fazer um novo começo, qualquer um pode começar agora e fazer um novo fim". (Chico Xavier) -------------- next part -------------- An HTML attachment was scrubbed... URL: From david.feuer at gmail.com Sun Jan 29 07:22:06 2017 From: david.feuer at gmail.com (David Feuer) Date: Sun, 29 Jan 2017 02:22:06 -0500 Subject: [Haskell-cafe] Lazy ST test code In-Reply-To: References: Message-ID: I've come up with what might be a fix for a major thread safety bug in lazy ST. Fixing it involved making multiple non-trivial changes to a number of basic functions. Unfortunately, the GHC test suite barely touches lazy ST. Does anyone out there have some code that uses lazy ST in interesting ways but that only relies on the libraries that ship with GHC? -------------- next part -------------- An HTML attachment was scrubbed... URL: From saurabhnanda at gmail.com Sun Jan 29 07:26:31 2017 From: saurabhnanda at gmail.com (Saurabh Nanda) Date: Sun, 29 Jan 2017 12:56:31 +0530 Subject: [Haskell-cafe] Monad transformer performance - Request to review benchmarking code + results Message-ID: Hi, I was noticing severe drop in performance when Lucid's HtmlT was being combined with Scotty's ActionT. I've tried putting together a minimal repro at https://github.com/vacationlabs/monad-transformer-benchmark Request someone with better knowledge of benchmarking to check if the benchmarking methodology is correct. Is my reading of 200ms performance penalty correct? -- Saurabh. -------------- next part -------------- An HTML attachment was scrubbed... URL: From dct25-561bs at mythic-beasts.com Sun Jan 29 09:35:38 2017 From: dct25-561bs at mythic-beasts.com (David Turner) Date: Sun, 29 Jan 2017 09:35:38 +0000 Subject: [Haskell-cafe] Monad transformer performance - Request to review benchmarking code + results In-Reply-To: References: Message-ID: The methodology does look reasonable, although I think you should wait for all the scotty threads to start before starting the benchmarks, as I see this interleaved output: Setting phasers to stun... (port 3002) (ctrl-c to quit) Setting phasers to stun... (port 3003) (ctrl-c to quit) Setting phasers to stun... (port 3001) (ctrl-c to quit) benchmarking bareScotty Setting phasers to stun... (port 3000) (ctrl-c to quit) Your numbers are wayyy slower than the ones I see on my dev machine: benchmarking bareScotty Setting phasers to stun... (port 3000) (ctrl-c to quit) time 10.94 ms (10.36 ms .. 11.52 ms) 0.979 R² (0.961 R² .. 0.989 R²) mean 12.53 ms (11.98 ms .. 13.28 ms) std dev 1.702 ms (1.187 ms .. 2.589 ms) variance introduced by outliers: 66% (severely inflated) benchmarking bareScottyBareLucid time 12.95 ms (12.28 ms .. 13.95 ms) 0.972 R² (0.951 R² .. 0.989 R²) mean 12.20 ms (11.75 ms .. 12.69 ms) std dev 1.236 ms (991.3 μs .. 1.601 ms) variance introduced by outliers: 50% (severely inflated) benchmarking transScottyBareLucid time 12.05 ms (11.70 ms .. 12.39 ms) 0.992 R² (0.982 R² .. 0.996 R²) mean 12.43 ms (12.06 ms .. 13.01 ms) std dev 1.320 ms (880.5 μs .. 2.071 ms) variance introduced by outliers: 54% (severely inflated) benchmarking transScottyTransLucid time 39.73 ms (32.16 ms .. 49.45 ms) 0.668 R² (0.303 R² .. 0.969 R²) mean 42.59 ms (36.69 ms .. 54.38 ms) std dev 16.52 ms (8.456 ms .. 25.96 ms) variance introduced by outliers: 92% (severely inflated) benchmarking bareScotty time 11.46 ms (10.89 ms .. 12.07 ms) 0.986 R² (0.975 R² .. 0.994 R²) mean 11.73 ms (11.45 ms .. 12.07 ms) std dev 800.6 μs (636.8 μs .. 975.3 μs) variance introduced by outliers: 34% (moderately inflated) but nonetheless I do also see the one using renderTextT to be substantially slower than the one without. I've sent you a PR [1] that isolates Lucid from Scotty and shows that renderTextT is twice as slow over IO than it is over Identity, and it's ~10% slower over Reader too: benchmarking renderText time 5.529 ms (5.328 ms .. 5.709 ms) 0.990 R² (0.983 R² .. 0.995 R²) mean 5.645 ms (5.472 ms .. 5.888 ms) std dev 593.0 μs (352.5 μs .. 908.2 μs) variance introduced by outliers: 63% (severely inflated) benchmarking renderTextT Id time 5.439 ms (5.243 ms .. 5.640 ms) 0.991 R² (0.985 R² .. 0.996 R²) mean 5.498 ms (5.367 ms .. 5.631 ms) std dev 408.8 μs (323.8 μs .. 552.9 μs) variance introduced by outliers: 45% (moderately inflated) benchmarking renderTextT Rd time 6.173 ms (5.983 ms .. 6.396 ms) 0.990 R² (0.983 R² .. 0.995 R²) mean 6.284 ms (6.127 ms .. 6.527 ms) std dev 581.6 μs (422.9 μs .. 773.0 μs) variance introduced by outliers: 55% (severely inflated) benchmarking renderTextT IO time 12.35 ms (11.84 ms .. 12.84 ms) 0.989 R² (0.982 R² .. 0.995 R²) mean 12.22 ms (11.85 ms .. 12.76 ms) std dev 1.159 ms (729.5 μs .. 1.683 ms) variance introduced by outliers: 50% (severely inflated) I tried replacing forM [1..10000] (\_ -> div_ "hello world!") with replicateM_ 10000 (div_ "hello world!") which discards the list of 10,000 () values that the forM thing generates, but this made very little difference. Hope this helps, David [1] https://github.com/vacationlabs/monad-transformer-benchmark/pull/2 On 29 January 2017 at 07:26, Saurabh Nanda wrote: > Hi, > > I was noticing severe drop in performance when Lucid's HtmlT was being > combined with Scotty's ActionT. I've tried putting together a minimal repro > at https://github.com/vacationlabs/monad-transformer-benchmark Request > someone with better knowledge of benchmarking to check if the benchmarking > methodology is correct. > > Is my reading of 200ms performance penalty correct? > > -- Saurabh. > > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From saurabhnanda at gmail.com Sun Jan 29 10:26:46 2017 From: saurabhnanda at gmail.com (Saurabh Nanda) Date: Sun, 29 Jan 2017 15:56:46 +0530 Subject: [Haskell-cafe] Monad transformer performance - Request to review benchmarking code + results In-Reply-To: References: Message-ID: Thank you for the PR. Does your research suggest something is wrong with HtmlT when combined with any MonadIO, not necessarily ActionT? Is this an mtl issue or a lucid issue in that case? Curiously, what's your machine config? I'm on a late 2011 macbook pro with 10G ram and some old i5. -- Saurabh. On 29 Jan 2017 3:05 pm, "David Turner" wrote: The methodology does look reasonable, although I think you should wait for all the scotty threads to start before starting the benchmarks, as I see this interleaved output: Setting phasers to stun... (port 3002) (ctrl-c to quit) Setting phasers to stun... (port 3003) (ctrl-c to quit) Setting phasers to stun... (port 3001) (ctrl-c to quit) benchmarking bareScotty Setting phasers to stun... (port 3000) (ctrl-c to quit) Your numbers are wayyy slower than the ones I see on my dev machine: benchmarking bareScotty Setting phasers to stun... (port 3000) (ctrl-c to quit) time 10.94 ms (10.36 ms .. 11.52 ms) 0.979 R² (0.961 R² .. 0.989 R²) mean 12.53 ms (11.98 ms .. 13.28 ms) std dev 1.702 ms (1.187 ms .. 2.589 ms) variance introduced by outliers: 66% (severely inflated) benchmarking bareScottyBareLucid time 12.95 ms (12.28 ms .. 13.95 ms) 0.972 R² (0.951 R² .. 0.989 R²) mean 12.20 ms (11.75 ms .. 12.69 ms) std dev 1.236 ms (991.3 μs .. 1.601 ms) variance introduced by outliers: 50% (severely inflated) benchmarking transScottyBareLucid time 12.05 ms (11.70 ms .. 12.39 ms) 0.992 R² (0.982 R² .. 0.996 R²) mean 12.43 ms (12.06 ms .. 13.01 ms) std dev 1.320 ms (880.5 μs .. 2.071 ms) variance introduced by outliers: 54% (severely inflated) benchmarking transScottyTransLucid time 39.73 ms (32.16 ms .. 49.45 ms) 0.668 R² (0.303 R² .. 0.969 R²) mean 42.59 ms (36.69 ms .. 54.38 ms) std dev 16.52 ms (8.456 ms .. 25.96 ms) variance introduced by outliers: 92% (severely inflated) benchmarking bareScotty time 11.46 ms (10.89 ms .. 12.07 ms) 0.986 R² (0.975 R² .. 0.994 R²) mean 11.73 ms (11.45 ms .. 12.07 ms) std dev 800.6 μs (636.8 μs .. 975.3 μs) variance introduced by outliers: 34% (moderately inflated) but nonetheless I do also see the one using renderTextT to be substantially slower than the one without. I've sent you a PR [1] that isolates Lucid from Scotty and shows that renderTextT is twice as slow over IO than it is over Identity, and it's ~10% slower over Reader too: benchmarking renderText time 5.529 ms (5.328 ms .. 5.709 ms) 0.990 R² (0.983 R² .. 0.995 R²) mean 5.645 ms (5.472 ms .. 5.888 ms) std dev 593.0 μs (352.5 μs .. 908.2 μs) variance introduced by outliers: 63% (severely inflated) benchmarking renderTextT Id time 5.439 ms (5.243 ms .. 5.640 ms) 0.991 R² (0.985 R² .. 0.996 R²) mean 5.498 ms (5.367 ms .. 5.631 ms) std dev 408.8 μs (323.8 μs .. 552.9 μs) variance introduced by outliers: 45% (moderately inflated) benchmarking renderTextT Rd time 6.173 ms (5.983 ms .. 6.396 ms) 0.990 R² (0.983 R² .. 0.995 R²) mean 6.284 ms (6.127 ms .. 6.527 ms) std dev 581.6 μs (422.9 μs .. 773.0 μs) variance introduced by outliers: 55% (severely inflated) benchmarking renderTextT IO time 12.35 ms (11.84 ms .. 12.84 ms) 0.989 R² (0.982 R² .. 0.995 R²) mean 12.22 ms (11.85 ms .. 12.76 ms) std dev 1.159 ms (729.5 μs .. 1.683 ms) variance introduced by outliers: 50% (severely inflated) I tried replacing forM [1..10000] (\_ -> div_ "hello world!") with replicateM_ 10000 (div_ "hello world!") which discards the list of 10,000 () values that the forM thing generates, but this made very little difference. Hope this helps, David [1] https://github.com/vacationlabs/monad-transformer-benchmark/pull/2 On 29 January 2017 at 07:26, Saurabh Nanda wrote: > Hi, > > I was noticing severe drop in performance when Lucid's HtmlT was being > combined with Scotty's ActionT. I've tried putting together a minimal repro > at https://github.com/vacationlabs/monad-transformer-benchmark Request > someone with better knowledge of benchmarking to check if the benchmarking > methodology is correct. > > Is my reading of 200ms performance penalty correct? > > -- Saurabh. > > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dct25-561bs at mythic-beasts.com Sun Jan 29 11:11:45 2017 From: dct25-561bs at mythic-beasts.com (David Turner) Date: Sun, 29 Jan 2017 11:11:45 +0000 Subject: [Haskell-cafe] Monad transformer performance - Request to review benchmarking code + results In-Reply-To: References: Message-ID: I would guess that the issue lies within HtmlT, which looks vaguely similar to a WriterT transformer but without much in the way of optimisation (e.g. INLINE pragmas). But that's just a guess after about 30 sec of glancing at https://hackage.haskell.org/package/lucid-2.9.7/docs/src/Lucid-Base.html so don't take it as gospel. My machine is apparently an i7-4770 of a similar vintage to yours, running Ubuntu in a VirtualBox VM hosted on Windows. 4GB of RAM in the VM, 16 in the host FWIW. On 29 Jan 2017 10:26, "Saurabh Nanda" wrote: Thank you for the PR. Does your research suggest something is wrong with HtmlT when combined with any MonadIO, not necessarily ActionT? Is this an mtl issue or a lucid issue in that case? Curiously, what's your machine config? I'm on a late 2011 macbook pro with 10G ram and some old i5. -- Saurabh. On 29 Jan 2017 3:05 pm, "David Turner" wrote: The methodology does look reasonable, although I think you should wait for all the scotty threads to start before starting the benchmarks, as I see this interleaved output: Setting phasers to stun... (port 3002) (ctrl-c to quit) Setting phasers to stun... (port 3003) (ctrl-c to quit) Setting phasers to stun... (port 3001) (ctrl-c to quit) benchmarking bareScotty Setting phasers to stun... (port 3000) (ctrl-c to quit) Your numbers are wayyy slower than the ones I see on my dev machine: benchmarking bareScotty Setting phasers to stun... (port 3000) (ctrl-c to quit) time 10.94 ms (10.36 ms .. 11.52 ms) 0.979 R² (0.961 R² .. 0.989 R²) mean 12.53 ms (11.98 ms .. 13.28 ms) std dev 1.702 ms (1.187 ms .. 2.589 ms) variance introduced by outliers: 66% (severely inflated) benchmarking bareScottyBareLucid time 12.95 ms (12.28 ms .. 13.95 ms) 0.972 R² (0.951 R² .. 0.989 R²) mean 12.20 ms (11.75 ms .. 12.69 ms) std dev 1.236 ms (991.3 μs .. 1.601 ms) variance introduced by outliers: 50% (severely inflated) benchmarking transScottyBareLucid time 12.05 ms (11.70 ms .. 12.39 ms) 0.992 R² (0.982 R² .. 0.996 R²) mean 12.43 ms (12.06 ms .. 13.01 ms) std dev 1.320 ms (880.5 μs .. 2.071 ms) variance introduced by outliers: 54% (severely inflated) benchmarking transScottyTransLucid time 39.73 ms (32.16 ms .. 49.45 ms) 0.668 R² (0.303 R² .. 0.969 R²) mean 42.59 ms (36.69 ms .. 54.38 ms) std dev 16.52 ms (8.456 ms .. 25.96 ms) variance introduced by outliers: 92% (severely inflated) benchmarking bareScotty time 11.46 ms (10.89 ms .. 12.07 ms) 0.986 R² (0.975 R² .. 0.994 R²) mean 11.73 ms (11.45 ms .. 12.07 ms) std dev 800.6 μs (636.8 μs .. 975.3 μs) variance introduced by outliers: 34% (moderately inflated) but nonetheless I do also see the one using renderTextT to be substantially slower than the one without. I've sent you a PR [1] that isolates Lucid from Scotty and shows that renderTextT is twice as slow over IO than it is over Identity, and it's ~10% slower over Reader too: benchmarking renderText time 5.529 ms (5.328 ms .. 5.709 ms) 0.990 R² (0.983 R² .. 0.995 R²) mean 5.645 ms (5.472 ms .. 5.888 ms) std dev 593.0 μs (352.5 μs .. 908.2 μs) variance introduced by outliers: 63% (severely inflated) benchmarking renderTextT Id time 5.439 ms (5.243 ms .. 5.640 ms) 0.991 R² (0.985 R² .. 0.996 R²) mean 5.498 ms (5.367 ms .. 5.631 ms) std dev 408.8 μs (323.8 μs .. 552.9 μs) variance introduced by outliers: 45% (moderately inflated) benchmarking renderTextT Rd time 6.173 ms (5.983 ms .. 6.396 ms) 0.990 R² (0.983 R² .. 0.995 R²) mean 6.284 ms (6.127 ms .. 6.527 ms) std dev 581.6 μs (422.9 μs .. 773.0 μs) variance introduced by outliers: 55% (severely inflated) benchmarking renderTextT IO time 12.35 ms (11.84 ms .. 12.84 ms) 0.989 R² (0.982 R² .. 0.995 R²) mean 12.22 ms (11.85 ms .. 12.76 ms) std dev 1.159 ms (729.5 μs .. 1.683 ms) variance introduced by outliers: 50% (severely inflated) I tried replacing forM [1..10000] (\_ -> div_ "hello world!") with replicateM_ 10000 (div_ "hello world!") which discards the list of 10,000 () values that the forM thing generates, but this made very little difference. Hope this helps, David [1] https://github.com/vacationlabs/monad-transformer-benchmark/pull/2 On 29 January 2017 at 07:26, Saurabh Nanda wrote: > Hi, > > I was noticing severe drop in performance when Lucid's HtmlT was being > combined with Scotty's ActionT. I've tried putting together a minimal repro > at https://github.com/vacationlabs/monad-transformer-benchmark Request > someone with better knowledge of benchmarking to check if the benchmarking > methodology is correct. > > Is my reading of 200ms performance penalty correct? > > -- Saurabh. > > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ollie at ocharles.org.uk Sun Jan 29 14:20:35 2017 From: ollie at ocharles.org.uk (Oliver Charles) Date: Sun, 29 Jan 2017 14:20:35 +0000 Subject: [Haskell-cafe] Monad transformer performance - Request to review benchmarking code + results In-Reply-To: References: Message-ID: I would wager a guess that this can be solved with INLINE pragmas. We recently added INLINE to just about everything in transformers and got a significant speed up. On Sun, 29 Jan 2017, 11:18 am David Turner, wrote: > I would guess that the issue lies within HtmlT, which looks vaguely > similar to a WriterT transformer but without much in the way of > optimisation (e.g. INLINE pragmas). But that's just a guess after about 30 > sec of glancing at > https://hackage.haskell.org/package/lucid-2.9.7/docs/src/Lucid-Base.html > so don't take it as gospel. > > My machine is apparently an i7-4770 of a similar vintage to yours, running > Ubuntu in a VirtualBox VM hosted on Windows. 4GB of RAM in the VM, 16 in > the host FWIW. > > > On 29 Jan 2017 10:26, "Saurabh Nanda" wrote: > > Thank you for the PR. Does your research suggest something is wrong with > HtmlT when combined with any MonadIO, not necessarily ActionT? Is this an > mtl issue or a lucid issue in that case? > > Curiously, what's your machine config? I'm on a late 2011 macbook pro with > 10G ram and some old i5. > > -- Saurabh. > > On 29 Jan 2017 3:05 pm, "David Turner" > wrote: > > The methodology does look reasonable, although I think you should wait for > all the scotty threads to start before starting the benchmarks, as I see > this interleaved output: > > Setting phasers to stun... (port 3002) (ctrl-c to quit) > Setting phasers to stun... (port 3003) (ctrl-c to quit) > Setting phasers to stun... (port 3001) (ctrl-c to quit) > benchmarking bareScotty > Setting phasers to stun... (port 3000) (ctrl-c to quit) > > Your numbers are wayyy slower than the ones I see on my dev machine: > > benchmarking bareScotty > Setting phasers to stun... (port 3000) (ctrl-c to quit) > time 10.94 ms (10.36 ms .. 11.52 ms) > 0.979 R² (0.961 R² .. 0.989 R²) > mean 12.53 ms (11.98 ms .. 13.28 ms) > std dev 1.702 ms (1.187 ms .. 2.589 ms) > variance introduced by outliers: 66% (severely inflated) > > benchmarking bareScottyBareLucid > time 12.95 ms (12.28 ms .. 13.95 ms) > 0.972 R² (0.951 R² .. 0.989 R²) > mean 12.20 ms (11.75 ms .. 12.69 ms) > std dev 1.236 ms (991.3 μs .. 1.601 ms) > variance introduced by outliers: 50% (severely inflated) > > benchmarking transScottyBareLucid > time 12.05 ms (11.70 ms .. 12.39 ms) > 0.992 R² (0.982 R² .. 0.996 R²) > mean 12.43 ms (12.06 ms .. 13.01 ms) > std dev 1.320 ms (880.5 μs .. 2.071 ms) > variance introduced by outliers: 54% (severely inflated) > > benchmarking transScottyTransLucid > time 39.73 ms (32.16 ms .. 49.45 ms) > 0.668 R² (0.303 R² .. 0.969 R²) > mean 42.59 ms (36.69 ms .. 54.38 ms) > std dev 16.52 ms (8.456 ms .. 25.96 ms) > variance introduced by outliers: 92% (severely inflated) > > benchmarking bareScotty > time 11.46 ms (10.89 ms .. 12.07 ms) > 0.986 R² (0.975 R² .. 0.994 R²) > mean 11.73 ms (11.45 ms .. 12.07 ms) > std dev 800.6 μs (636.8 μs .. 975.3 μs) > variance introduced by outliers: 34% (moderately inflated) > > but nonetheless I do also see the one using renderTextT to be > substantially slower than the one without. > > I've sent you a PR [1] that isolates Lucid from Scotty and shows that > renderTextT is twice as slow over IO than it is over Identity, and it's > ~10% slower over Reader too: > > benchmarking renderText > time 5.529 ms (5.328 ms .. 5.709 ms) > 0.990 R² (0.983 R² .. 0.995 R²) > mean 5.645 ms (5.472 ms .. 5.888 ms) > std dev 593.0 μs (352.5 μs .. 908.2 μs) > variance introduced by outliers: 63% (severely inflated) > > benchmarking renderTextT Id > time 5.439 ms (5.243 ms .. 5.640 ms) > 0.991 R² (0.985 R² .. 0.996 R²) > mean 5.498 ms (5.367 ms .. 5.631 ms) > std dev 408.8 μs (323.8 μs .. 552.9 μs) > variance introduced by outliers: 45% (moderately inflated) > > benchmarking renderTextT Rd > time 6.173 ms (5.983 ms .. 6.396 ms) > 0.990 R² (0.983 R² .. 0.995 R²) > mean 6.284 ms (6.127 ms .. 6.527 ms) > std dev 581.6 μs (422.9 μs .. 773.0 μs) > variance introduced by outliers: 55% (severely inflated) > > benchmarking renderTextT IO > time 12.35 ms (11.84 ms .. 12.84 ms) > 0.989 R² (0.982 R² .. 0.995 R²) > mean 12.22 ms (11.85 ms .. 12.76 ms) > std dev 1.159 ms (729.5 μs .. 1.683 ms) > variance introduced by outliers: 50% (severely inflated) > > I tried replacing > > forM [1..10000] (\_ -> div_ "hello world!") > > with > > replicateM_ 10000 (div_ "hello world!") > > which discards the list of 10,000 () values that the forM thing generates, > but this made very little difference. > > Hope this helps, > > David > > > [1] https://github.com/vacationlabs/monad-transformer-benchmark/pull/2 > > > > On 29 January 2017 at 07:26, Saurabh Nanda wrote: > > Hi, > > I was noticing severe drop in performance when Lucid's HtmlT was being > combined with Scotty's ActionT. I've tried putting together a minimal repro > at https://github.com/vacationlabs/monad-transformer-benchmark Request > someone with better knowledge of benchmarking to check if the benchmarking > methodology is correct. > > Is my reading of 200ms performance penalty correct? > > -- Saurabh. > > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. > > > > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. -------------- next part -------------- An HTML attachment was scrubbed... URL: From saurabhnanda at gmail.com Sun Jan 29 15:32:07 2017 From: saurabhnanda at gmail.com (Saurabh Nanda) Date: Sun, 29 Jan 2017 21:02:07 +0530 Subject: [Haskell-cafe] Monad transformer performance - Request to review benchmarking code + results In-Reply-To: References: Message-ID: Please tell me what to INLINE. I'll update the benchmarks. Also, shouldn't this be treated as a GHC bug then? Using monad transformers as intended should not result in a severe performance penalty! Either monad transformers themselves are a problem or GHC is not doing the right thing. -- Saurabh. On 29 Jan 2017 7:50 pm, "Oliver Charles" wrote: I would wager a guess that this can be solved with INLINE pragmas. We recently added INLINE to just about everything in transformers and got a significant speed up. On Sun, 29 Jan 2017, 11:18 am David Turner, wrote: > I would guess that the issue lies within HtmlT, which looks vaguely > similar to a WriterT transformer but without much in the way of > optimisation (e.g. INLINE pragmas). But that's just a guess after about 30 > sec of glancing at https://hackage.haskell.org/package/lucid-2.9.7/docs/ > src/Lucid-Base.html so don't take it as gospel. > > My machine is apparently an i7-4770 of a similar vintage to yours, running > Ubuntu in a VirtualBox VM hosted on Windows. 4GB of RAM in the VM, 16 in > the host FWIW. > > > On 29 Jan 2017 10:26, "Saurabh Nanda" wrote: > > Thank you for the PR. Does your research suggest something is wrong with > HtmlT when combined with any MonadIO, not necessarily ActionT? Is this an > mtl issue or a lucid issue in that case? > > Curiously, what's your machine config? I'm on a late 2011 macbook pro with > 10G ram and some old i5. > > -- Saurabh. > > On 29 Jan 2017 3:05 pm, "David Turner" > wrote: > > The methodology does look reasonable, although I think you should wait for > all the scotty threads to start before starting the benchmarks, as I see > this interleaved output: > > Setting phasers to stun... (port 3002) (ctrl-c to quit) > Setting phasers to stun... (port 3003) (ctrl-c to quit) > Setting phasers to stun... (port 3001) (ctrl-c to quit) > benchmarking bareScotty > Setting phasers to stun... (port 3000) (ctrl-c to quit) > > Your numbers are wayyy slower than the ones I see on my dev machine: > > benchmarking bareScotty > Setting phasers to stun... (port 3000) (ctrl-c to quit) > time 10.94 ms (10.36 ms .. 11.52 ms) > 0.979 R² (0.961 R² .. 0.989 R²) > mean 12.53 ms (11.98 ms .. 13.28 ms) > std dev 1.702 ms (1.187 ms .. 2.589 ms) > variance introduced by outliers: 66% (severely inflated) > > benchmarking bareScottyBareLucid > time 12.95 ms (12.28 ms .. 13.95 ms) > 0.972 R² (0.951 R² .. 0.989 R²) > mean 12.20 ms (11.75 ms .. 12.69 ms) > std dev 1.236 ms (991.3 μs .. 1.601 ms) > variance introduced by outliers: 50% (severely inflated) > > benchmarking transScottyBareLucid > time 12.05 ms (11.70 ms .. 12.39 ms) > 0.992 R² (0.982 R² .. 0.996 R²) > mean 12.43 ms (12.06 ms .. 13.01 ms) > std dev 1.320 ms (880.5 μs .. 2.071 ms) > variance introduced by outliers: 54% (severely inflated) > > benchmarking transScottyTransLucid > time 39.73 ms (32.16 ms .. 49.45 ms) > 0.668 R² (0.303 R² .. 0.969 R²) > mean 42.59 ms (36.69 ms .. 54.38 ms) > std dev 16.52 ms (8.456 ms .. 25.96 ms) > variance introduced by outliers: 92% (severely inflated) > > benchmarking bareScotty > time 11.46 ms (10.89 ms .. 12.07 ms) > 0.986 R² (0.975 R² .. 0.994 R²) > mean 11.73 ms (11.45 ms .. 12.07 ms) > std dev 800.6 μs (636.8 μs .. 975.3 μs) > variance introduced by outliers: 34% (moderately inflated) > > but nonetheless I do also see the one using renderTextT to be > substantially slower than the one without. > > I've sent you a PR [1] that isolates Lucid from Scotty and shows that > renderTextT is twice as slow over IO than it is over Identity, and it's > ~10% slower over Reader too: > > benchmarking renderText > time 5.529 ms (5.328 ms .. 5.709 ms) > 0.990 R² (0.983 R² .. 0.995 R²) > mean 5.645 ms (5.472 ms .. 5.888 ms) > std dev 593.0 μs (352.5 μs .. 908.2 μs) > variance introduced by outliers: 63% (severely inflated) > > benchmarking renderTextT Id > time 5.439 ms (5.243 ms .. 5.640 ms) > 0.991 R² (0.985 R² .. 0.996 R²) > mean 5.498 ms (5.367 ms .. 5.631 ms) > std dev 408.8 μs (323.8 μs .. 552.9 μs) > variance introduced by outliers: 45% (moderately inflated) > > benchmarking renderTextT Rd > time 6.173 ms (5.983 ms .. 6.396 ms) > 0.990 R² (0.983 R² .. 0.995 R²) > mean 6.284 ms (6.127 ms .. 6.527 ms) > std dev 581.6 μs (422.9 μs .. 773.0 μs) > variance introduced by outliers: 55% (severely inflated) > > benchmarking renderTextT IO > time 12.35 ms (11.84 ms .. 12.84 ms) > 0.989 R² (0.982 R² .. 0.995 R²) > mean 12.22 ms (11.85 ms .. 12.76 ms) > std dev 1.159 ms (729.5 μs .. 1.683 ms) > variance introduced by outliers: 50% (severely inflated) > > I tried replacing > > forM [1..10000] (\_ -> div_ "hello world!") > > with > > replicateM_ 10000 (div_ "hello world!") > > which discards the list of 10,000 () values that the forM thing generates, > but this made very little difference. > > Hope this helps, > > David > > > [1] https://github.com/vacationlabs/monad-transformer-benchmark/pull/2 > > > > On 29 January 2017 at 07:26, Saurabh Nanda wrote: > > Hi, > > I was noticing severe drop in performance when Lucid's HtmlT was being > combined with Scotty's ActionT. I've tried putting together a minimal repro > at https://github.com/vacationlabs/monad-transformer-benchmark Request > someone with better knowledge of benchmarking to check if the benchmarking > methodology is correct. > > Is my reading of 200ms performance penalty correct? > > -- Saurabh. > > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. > > > > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. -------------- next part -------------- An HTML attachment was scrubbed... URL: From ollie at ocharles.org.uk Sun Jan 29 15:45:31 2017 From: ollie at ocharles.org.uk (Oliver Charles) Date: Sun, 29 Jan 2017 15:45:31 +0000 Subject: [Haskell-cafe] Monad transformer performance - Request to review benchmarking code + results In-Reply-To: References: Message-ID: I would start by inlining operations in the Functor, Applicative and Monad classes for your monad and all the layers in the stack (such as HtmlT). An un-inlining monadic bind can end up allocating a lot (as it's such a common operation) On Sun, 29 Jan 2017, 3:32 pm Saurabh Nanda, wrote: > Please tell me what to INLINE. I'll update the benchmarks. > > Also, shouldn't this be treated as a GHC bug then? Using monad > transformers as intended should not result in a severe performance penalty! > Either monad transformers themselves are a problem or GHC is not doing the > right thing. > > -- Saurabh. > > On 29 Jan 2017 7:50 pm, "Oliver Charles" wrote: > > I would wager a guess that this can be solved with INLINE pragmas. We > recently added INLINE to just about everything in transformers and got a > significant speed up. > > On Sun, 29 Jan 2017, 11:18 am David Turner, > wrote: > > I would guess that the issue lies within HtmlT, which looks vaguely > similar to a WriterT transformer but without much in the way of > optimisation (e.g. INLINE pragmas). But that's just a guess after about 30 > sec of glancing at > https://hackage.haskell.org/package/lucid-2.9.7/docs/src/Lucid-Base.html > so don't take it as gospel. > > My machine is apparently an i7-4770 of a similar vintage to yours, running > Ubuntu in a VirtualBox VM hosted on Windows. 4GB of RAM in the VM, 16 in > the host FWIW. > > > On 29 Jan 2017 10:26, "Saurabh Nanda" wrote: > > Thank you for the PR. Does your research suggest something is wrong with > HtmlT when combined with any MonadIO, not necessarily ActionT? Is this an > mtl issue or a lucid issue in that case? > > Curiously, what's your machine config? I'm on a late 2011 macbook pro with > 10G ram and some old i5. > > -- Saurabh. > > On 29 Jan 2017 3:05 pm, "David Turner" > wrote: > > The methodology does look reasonable, although I think you should wait for > all the scotty threads to start before starting the benchmarks, as I see > this interleaved output: > > Setting phasers to stun... (port 3002) (ctrl-c to quit) > Setting phasers to stun... (port 3003) (ctrl-c to quit) > Setting phasers to stun... (port 3001) (ctrl-c to quit) > benchmarking bareScotty > Setting phasers to stun... (port 3000) (ctrl-c to quit) > > Your numbers are wayyy slower than the ones I see on my dev machine: > > benchmarking bareScotty > Setting phasers to stun... (port 3000) (ctrl-c to quit) > time 10.94 ms (10.36 ms .. 11.52 ms) > 0.979 R² (0.961 R² .. 0.989 R²) > mean 12.53 ms (11.98 ms .. 13.28 ms) > std dev 1.702 ms (1.187 ms .. 2.589 ms) > variance introduced by outliers: 66% (severely inflated) > > benchmarking bareScottyBareLucid > time 12.95 ms (12.28 ms .. 13.95 ms) > 0.972 R² (0.951 R² .. 0.989 R²) > mean 12.20 ms (11.75 ms .. 12.69 ms) > std dev 1.236 ms (991.3 μs .. 1.601 ms) > variance introduced by outliers: 50% (severely inflated) > > benchmarking transScottyBareLucid > time 12.05 ms (11.70 ms .. 12.39 ms) > 0.992 R² (0.982 R² .. 0.996 R²) > mean 12.43 ms (12.06 ms .. 13.01 ms) > std dev 1.320 ms (880.5 μs .. 2.071 ms) > variance introduced by outliers: 54% (severely inflated) > > benchmarking transScottyTransLucid > time 39.73 ms (32.16 ms .. 49.45 ms) > 0.668 R² (0.303 R² .. 0.969 R²) > mean 42.59 ms (36.69 ms .. 54.38 ms) > std dev 16.52 ms (8.456 ms .. 25.96 ms) > variance introduced by outliers: 92% (severely inflated) > > benchmarking bareScotty > time 11.46 ms (10.89 ms .. 12.07 ms) > 0.986 R² (0.975 R² .. 0.994 R²) > mean 11.73 ms (11.45 ms .. 12.07 ms) > std dev 800.6 μs (636.8 μs .. 975.3 μs) > variance introduced by outliers: 34% (moderately inflated) > > but nonetheless I do also see the one using renderTextT to be > substantially slower than the one without. > > I've sent you a PR [1] that isolates Lucid from Scotty and shows that > renderTextT is twice as slow over IO than it is over Identity, and it's > ~10% slower over Reader too: > > benchmarking renderText > time 5.529 ms (5.328 ms .. 5.709 ms) > 0.990 R² (0.983 R² .. 0.995 R²) > mean 5.645 ms (5.472 ms .. 5.888 ms) > std dev 593.0 μs (352.5 μs .. 908.2 μs) > variance introduced by outliers: 63% (severely inflated) > > benchmarking renderTextT Id > time 5.439 ms (5.243 ms .. 5.640 ms) > 0.991 R² (0.985 R² .. 0.996 R²) > mean 5.498 ms (5.367 ms .. 5.631 ms) > std dev 408.8 μs (323.8 μs .. 552.9 μs) > variance introduced by outliers: 45% (moderately inflated) > > benchmarking renderTextT Rd > time 6.173 ms (5.983 ms .. 6.396 ms) > 0.990 R² (0.983 R² .. 0.995 R²) > mean 6.284 ms (6.127 ms .. 6.527 ms) > std dev 581.6 μs (422.9 μs .. 773.0 μs) > variance introduced by outliers: 55% (severely inflated) > > benchmarking renderTextT IO > time 12.35 ms (11.84 ms .. 12.84 ms) > 0.989 R² (0.982 R² .. 0.995 R²) > mean 12.22 ms (11.85 ms .. 12.76 ms) > std dev 1.159 ms (729.5 μs .. 1.683 ms) > variance introduced by outliers: 50% (severely inflated) > > I tried replacing > > forM [1..10000] (\_ -> div_ "hello world!") > > with > > replicateM_ 10000 (div_ "hello world!") > > which discards the list of 10,000 () values that the forM thing generates, > but this made very little difference. > > Hope this helps, > > David > > > [1] https://github.com/vacationlabs/monad-transformer-benchmark/pull/2 > > > > On 29 January 2017 at 07:26, Saurabh Nanda wrote: > > Hi, > > I was noticing severe drop in performance when Lucid's HtmlT was being > combined with Scotty's ActionT. I've tried putting together a minimal repro > at https://github.com/vacationlabs/monad-transformer-benchmark Request > someone with better knowledge of benchmarking to check if the benchmarking > methodology is correct. > > Is my reading of 200ms performance penalty correct? > > -- Saurabh. > > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. > > > > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dct25-561bs at mythic-beasts.com Sun Jan 29 16:11:59 2017 From: dct25-561bs at mythic-beasts.com (David Turner) Date: Sun, 29 Jan 2017 16:11:59 +0000 Subject: [Haskell-cafe] Monad transformer performance - Request to review benchmarking code + results In-Reply-To: References: Message-ID: Here's the profiling summary that I got: COST CENTRE MODULE %time %alloc getOverhead Criterion.Monad 41.3 0.0 >>= Lucid.Base 19.2 41.6 makeElement.\.\ Lucid.Base 11.4 23.4 fromHtmlEscapedString Blaze.ByteString.Builder.Html.Utf8 7.9 14.9 >>= Data.Vector.Fusion.Util 2.3 1.7 return Lucid.Base 1.4 2.1 runBenchmark.loop Criterion.Measurement 1.2 0.0 with.\ Lucid.Base 1.0 2.1 foldlMapWithKey Lucid.Base 0.5 2.6 streamDecodeUtf8With.decodeChunk Data.Text.Encoding 0.0 1.7 As expected, HtmlT's bind is the expensive bit. However I've been unable to encourage it to go away using INLINE pragmas. On 29 January 2017 at 15:45, Oliver Charles wrote: > I would start by inlining operations in the Functor, Applicative and Monad > classes for your monad and all the layers in the stack (such as HtmlT). An > un-inlining monadic bind can end up allocating a lot (as it's such a common > operation) > > On Sun, 29 Jan 2017, 3:32 pm Saurabh Nanda, > wrote: > >> Please tell me what to INLINE. I'll update the benchmarks. >> >> Also, shouldn't this be treated as a GHC bug then? Using monad >> transformers as intended should not result in a severe performance penalty! >> Either monad transformers themselves are a problem or GHC is not doing the >> right thing. >> >> -- Saurabh. >> >> On 29 Jan 2017 7:50 pm, "Oliver Charles" wrote: >> >> I would wager a guess that this can be solved with INLINE pragmas. We >> recently added INLINE to just about everything in transformers and got a >> significant speed up. >> >> On Sun, 29 Jan 2017, 11:18 am David Turner, < >> dct25-561bs at mythic-beasts.com> wrote: >> >> I would guess that the issue lies within HtmlT, which looks vaguely >> similar to a WriterT transformer but without much in the way of >> optimisation (e.g. INLINE pragmas). But that's just a guess after about 30 >> sec of glancing at https://hackage.haskell.org/package/lucid-2.9.7/docs/ >> src/Lucid-Base.html so don't take it as gospel. >> >> My machine is apparently an i7-4770 of a similar vintage to yours, >> running Ubuntu in a VirtualBox VM hosted on Windows. 4GB of RAM in the VM, >> 16 in the host FWIW. >> >> >> On 29 Jan 2017 10:26, "Saurabh Nanda" wrote: >> >> Thank you for the PR. Does your research suggest something is wrong with >> HtmlT when combined with any MonadIO, not necessarily ActionT? Is this an >> mtl issue or a lucid issue in that case? >> >> Curiously, what's your machine config? I'm on a late 2011 macbook pro >> with 10G ram and some old i5. >> >> -- Saurabh. >> >> On 29 Jan 2017 3:05 pm, "David Turner" >> wrote: >> >> The methodology does look reasonable, although I think you should wait >> for all the scotty threads to start before starting the benchmarks, as I >> see this interleaved output: >> >> Setting phasers to stun... (port 3002) (ctrl-c to quit) >> Setting phasers to stun... (port 3003) (ctrl-c to quit) >> Setting phasers to stun... (port 3001) (ctrl-c to quit) >> benchmarking bareScotty >> Setting phasers to stun... (port 3000) (ctrl-c to quit) >> >> Your numbers are wayyy slower than the ones I see on my dev machine: >> >> benchmarking bareScotty >> Setting phasers to stun... (port 3000) (ctrl-c to quit) >> time 10.94 ms (10.36 ms .. 11.52 ms) >> 0.979 R² (0.961 R² .. 0.989 R²) >> mean 12.53 ms (11.98 ms .. 13.28 ms) >> std dev 1.702 ms (1.187 ms .. 2.589 ms) >> variance introduced by outliers: 66% (severely inflated) >> >> benchmarking bareScottyBareLucid >> time 12.95 ms (12.28 ms .. 13.95 ms) >> 0.972 R² (0.951 R² .. 0.989 R²) >> mean 12.20 ms (11.75 ms .. 12.69 ms) >> std dev 1.236 ms (991.3 μs .. 1.601 ms) >> variance introduced by outliers: 50% (severely inflated) >> >> benchmarking transScottyBareLucid >> time 12.05 ms (11.70 ms .. 12.39 ms) >> 0.992 R² (0.982 R² .. 0.996 R²) >> mean 12.43 ms (12.06 ms .. 13.01 ms) >> std dev 1.320 ms (880.5 μs .. 2.071 ms) >> variance introduced by outliers: 54% (severely inflated) >> >> benchmarking transScottyTransLucid >> time 39.73 ms (32.16 ms .. 49.45 ms) >> 0.668 R² (0.303 R² .. 0.969 R²) >> mean 42.59 ms (36.69 ms .. 54.38 ms) >> std dev 16.52 ms (8.456 ms .. 25.96 ms) >> variance introduced by outliers: 92% (severely inflated) >> >> benchmarking bareScotty >> time 11.46 ms (10.89 ms .. 12.07 ms) >> 0.986 R² (0.975 R² .. 0.994 R²) >> mean 11.73 ms (11.45 ms .. 12.07 ms) >> std dev 800.6 μs (636.8 μs .. 975.3 μs) >> variance introduced by outliers: 34% (moderately inflated) >> >> but nonetheless I do also see the one using renderTextT to be >> substantially slower than the one without. >> >> I've sent you a PR [1] that isolates Lucid from Scotty and shows that >> renderTextT is twice as slow over IO than it is over Identity, and it's >> ~10% slower over Reader too: >> >> benchmarking renderText >> time 5.529 ms (5.328 ms .. 5.709 ms) >> 0.990 R² (0.983 R² .. 0.995 R²) >> mean 5.645 ms (5.472 ms .. 5.888 ms) >> std dev 593.0 μs (352.5 μs .. 908.2 μs) >> variance introduced by outliers: 63% (severely inflated) >> >> benchmarking renderTextT Id >> time 5.439 ms (5.243 ms .. 5.640 ms) >> 0.991 R² (0.985 R² .. 0.996 R²) >> mean 5.498 ms (5.367 ms .. 5.631 ms) >> std dev 408.8 μs (323.8 μs .. 552.9 μs) >> variance introduced by outliers: 45% (moderately inflated) >> >> benchmarking renderTextT Rd >> time 6.173 ms (5.983 ms .. 6.396 ms) >> 0.990 R² (0.983 R² .. 0.995 R²) >> mean 6.284 ms (6.127 ms .. 6.527 ms) >> std dev 581.6 μs (422.9 μs .. 773.0 μs) >> variance introduced by outliers: 55% (severely inflated) >> >> benchmarking renderTextT IO >> time 12.35 ms (11.84 ms .. 12.84 ms) >> 0.989 R² (0.982 R² .. 0.995 R²) >> mean 12.22 ms (11.85 ms .. 12.76 ms) >> std dev 1.159 ms (729.5 μs .. 1.683 ms) >> variance introduced by outliers: 50% (severely inflated) >> >> I tried replacing >> >> forM [1..10000] (\_ -> div_ "hello world!") >> >> with >> >> replicateM_ 10000 (div_ "hello world!") >> >> which discards the list of 10,000 () values that the forM thing >> generates, but this made very little difference. >> >> Hope this helps, >> >> David >> >> >> [1] https://github.com/vacationlabs/monad-transformer-benchmark/pull/2 >> >> >> >> On 29 January 2017 at 07:26, Saurabh Nanda >> wrote: >> >> Hi, >> >> I was noticing severe drop in performance when Lucid's HtmlT was being >> combined with Scotty's ActionT. I've tried putting together a minimal repro >> at https://github.com/vacationlabs/monad-transformer-benchmark Request >> someone with better knowledge of benchmarking to check if the benchmarking >> methodology is correct. >> >> Is my reading of 200ms performance penalty correct? >> >> -- Saurabh. >> >> >> _______________________________________________ >> Haskell-Cafe mailing list >> To (un)subscribe, modify options or view archives go to: >> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe >> Only members subscribed via the mailman list are allowed to post. >> >> >> >> >> _______________________________________________ >> Haskell-Cafe mailing list >> To (un)subscribe, modify options or view archives go to: >> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe >> Only members subscribed via the mailman list are allowed to post. >> >> >> -------------- next part -------------- An HTML attachment was scrubbed... URL: From saurabhnanda at gmail.com Sun Jan 29 16:59:29 2017 From: saurabhnanda at gmail.com (Saurabh Nanda) Date: Sun, 29 Jan 2017 22:29:29 +0530 Subject: [Haskell-cafe] Monad transformer performance - Request to review benchmarking code + results In-Reply-To: References: Message-ID: Thanks for digging deeper, David. What exactly did you inline? Also, am I the only one losing my mind over this? It's such a straightforward use of available code structuring tools in Haskell. How come the compiler is not being smart about this OOB? -- Saurabh. On 29 Jan 2017 9:42 pm, "David Turner" wrote: Here's the profiling summary that I got: COST CENTRE MODULE %time %alloc getOverhead Criterion.Monad 41.3 0.0 >>= Lucid.Base 19.2 41.6 makeElement.\.\ Lucid.Base 11.4 23.4 fromHtmlEscapedString Blaze.ByteString.Builder.Html.Utf8 7.9 14.9 >>= Data.Vector.Fusion.Util 2.3 1.7 return Lucid.Base 1.4 2.1 runBenchmark.loop Criterion.Measurement 1.2 0.0 with.\ Lucid.Base 1.0 2.1 foldlMapWithKey Lucid.Base 0.5 2.6 streamDecodeUtf8With.decodeChunk Data.Text.Encoding 0.0 1.7 As expected, HtmlT's bind is the expensive bit. However I've been unable to encourage it to go away using INLINE pragmas. On 29 January 2017 at 15:45, Oliver Charles wrote: > I would start by inlining operations in the Functor, Applicative and Monad > classes for your monad and all the layers in the stack (such as HtmlT). An > un-inlining monadic bind can end up allocating a lot (as it's such a common > operation) > > On Sun, 29 Jan 2017, 3:32 pm Saurabh Nanda, > wrote: > >> Please tell me what to INLINE. I'll update the benchmarks. >> >> Also, shouldn't this be treated as a GHC bug then? Using monad >> transformers as intended should not result in a severe performance penalty! >> Either monad transformers themselves are a problem or GHC is not doing the >> right thing. >> >> -- Saurabh. >> >> On 29 Jan 2017 7:50 pm, "Oliver Charles" wrote: >> >> I would wager a guess that this can be solved with INLINE pragmas. We >> recently added INLINE to just about everything in transformers and got a >> significant speed up. >> >> On Sun, 29 Jan 2017, 11:18 am David Turner, < >> dct25-561bs at mythic-beasts.com> wrote: >> >> I would guess that the issue lies within HtmlT, which looks vaguely >> similar to a WriterT transformer but without much in the way of >> optimisation (e.g. INLINE pragmas). But that's just a guess after about 30 >> sec of glancing at https://hackage.haskell.org >> /package/lucid-2.9.7/docs/src/Lucid-Base.html so don't take it as gospel. >> >> My machine is apparently an i7-4770 of a similar vintage to yours, >> running Ubuntu in a VirtualBox VM hosted on Windows. 4GB of RAM in the VM, >> 16 in the host FWIW. >> >> >> On 29 Jan 2017 10:26, "Saurabh Nanda" wrote: >> >> Thank you for the PR. Does your research suggest something is wrong with >> HtmlT when combined with any MonadIO, not necessarily ActionT? Is this an >> mtl issue or a lucid issue in that case? >> >> Curiously, what's your machine config? I'm on a late 2011 macbook pro >> with 10G ram and some old i5. >> >> -- Saurabh. >> >> On 29 Jan 2017 3:05 pm, "David Turner" >> wrote: >> >> The methodology does look reasonable, although I think you should wait >> for all the scotty threads to start before starting the benchmarks, as I >> see this interleaved output: >> >> Setting phasers to stun... (port 3002) (ctrl-c to quit) >> Setting phasers to stun... (port 3003) (ctrl-c to quit) >> Setting phasers to stun... (port 3001) (ctrl-c to quit) >> benchmarking bareScotty >> Setting phasers to stun... (port 3000) (ctrl-c to quit) >> >> Your numbers are wayyy slower than the ones I see on my dev machine: >> >> benchmarking bareScotty >> Setting phasers to stun... (port 3000) (ctrl-c to quit) >> time 10.94 ms (10.36 ms .. 11.52 ms) >> 0.979 R² (0.961 R² .. 0.989 R²) >> mean 12.53 ms (11.98 ms .. 13.28 ms) >> std dev 1.702 ms (1.187 ms .. 2.589 ms) >> variance introduced by outliers: 66% (severely inflated) >> >> benchmarking bareScottyBareLucid >> time 12.95 ms (12.28 ms .. 13.95 ms) >> 0.972 R² (0.951 R² .. 0.989 R²) >> mean 12.20 ms (11.75 ms .. 12.69 ms) >> std dev 1.236 ms (991.3 μs .. 1.601 ms) >> variance introduced by outliers: 50% (severely inflated) >> >> benchmarking transScottyBareLucid >> time 12.05 ms (11.70 ms .. 12.39 ms) >> 0.992 R² (0.982 R² .. 0.996 R²) >> mean 12.43 ms (12.06 ms .. 13.01 ms) >> std dev 1.320 ms (880.5 μs .. 2.071 ms) >> variance introduced by outliers: 54% (severely inflated) >> >> benchmarking transScottyTransLucid >> time 39.73 ms (32.16 ms .. 49.45 ms) >> 0.668 R² (0.303 R² .. 0.969 R²) >> mean 42.59 ms (36.69 ms .. 54.38 ms) >> std dev 16.52 ms (8.456 ms .. 25.96 ms) >> variance introduced by outliers: 92% (severely inflated) >> >> benchmarking bareScotty >> time 11.46 ms (10.89 ms .. 12.07 ms) >> 0.986 R² (0.975 R² .. 0.994 R²) >> mean 11.73 ms (11.45 ms .. 12.07 ms) >> std dev 800.6 μs (636.8 μs .. 975.3 μs) >> variance introduced by outliers: 34% (moderately inflated) >> >> but nonetheless I do also see the one using renderTextT to be >> substantially slower than the one without. >> >> I've sent you a PR [1] that isolates Lucid from Scotty and shows that >> renderTextT is twice as slow over IO than it is over Identity, and it's >> ~10% slower over Reader too: >> >> benchmarking renderText >> time 5.529 ms (5.328 ms .. 5.709 ms) >> 0.990 R² (0.983 R² .. 0.995 R²) >> mean 5.645 ms (5.472 ms .. 5.888 ms) >> std dev 593.0 μs (352.5 μs .. 908.2 μs) >> variance introduced by outliers: 63% (severely inflated) >> >> benchmarking renderTextT Id >> time 5.439 ms (5.243 ms .. 5.640 ms) >> 0.991 R² (0.985 R² .. 0.996 R²) >> mean 5.498 ms (5.367 ms .. 5.631 ms) >> std dev 408.8 μs (323.8 μs .. 552.9 μs) >> variance introduced by outliers: 45% (moderately inflated) >> >> benchmarking renderTextT Rd >> time 6.173 ms (5.983 ms .. 6.396 ms) >> 0.990 R² (0.983 R² .. 0.995 R²) >> mean 6.284 ms (6.127 ms .. 6.527 ms) >> std dev 581.6 μs (422.9 μs .. 773.0 μs) >> variance introduced by outliers: 55% (severely inflated) >> >> benchmarking renderTextT IO >> time 12.35 ms (11.84 ms .. 12.84 ms) >> 0.989 R² (0.982 R² .. 0.995 R²) >> mean 12.22 ms (11.85 ms .. 12.76 ms) >> std dev 1.159 ms (729.5 μs .. 1.683 ms) >> variance introduced by outliers: 50% (severely inflated) >> >> I tried replacing >> >> forM [1..10000] (\_ -> div_ "hello world!") >> >> with >> >> replicateM_ 10000 (div_ "hello world!") >> >> which discards the list of 10,000 () values that the forM thing >> generates, but this made very little difference. >> >> Hope this helps, >> >> David >> >> >> [1] https://github.com/vacationlabs/monad-transformer-benchmark/pull/2 >> >> >> >> On 29 January 2017 at 07:26, Saurabh Nanda >> wrote: >> >> Hi, >> >> I was noticing severe drop in performance when Lucid's HtmlT was being >> combined with Scotty's ActionT. I've tried putting together a minimal repro >> at https://github.com/vacationlabs/monad-transformer-benchmark Request >> someone with better knowledge of benchmarking to check if the benchmarking >> methodology is correct. >> >> Is my reading of 200ms performance penalty correct? >> >> -- Saurabh. >> >> >> _______________________________________________ >> Haskell-Cafe mailing list >> To (un)subscribe, modify options or view archives go to: >> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe >> Only members subscribed via the mailman list are allowed to post. >> >> >> >> >> _______________________________________________ >> Haskell-Cafe mailing list >> To (un)subscribe, modify options or view archives go to: >> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe >> Only members subscribed via the mailman list are allowed to post. >> >> >> -------------- next part -------------- An HTML attachment was scrubbed... URL: From ollie at ocharles.org.uk Sun Jan 29 17:51:52 2017 From: ollie at ocharles.org.uk (Oliver Charles) Date: Sun, 29 Jan 2017 17:51:52 +0000 Subject: [Haskell-cafe] Monad transformer performance - Request to review benchmarking code + results In-Reply-To: References: Message-ID: Why do you keep expecting the compiler to "be smart"? It's just shuffling data around, any type of magic efficiency with Monadic computations requires specific knowledge about monads, which is not something we encode into the compiler. just saying "this should be obvious" is not very productive. On Sun, 29 Jan 2017, 4:59 pm Saurabh Nanda, wrote: > Thanks for digging deeper, David. What exactly did you inline? > > Also, am I the only one losing my mind over this? It's such a > straightforward use of available code structuring tools in Haskell. How > come the compiler is not being smart about this OOB? > > -- Saurabh. > > On 29 Jan 2017 9:42 pm, "David Turner" > wrote: > > Here's the profiling summary that I got: > > COST CENTRE MODULE %time > %alloc > > getOverhead Criterion.Monad 41.3 > 0.0 > >>= Lucid.Base 19.2 > 41.6 > makeElement.\.\ Lucid.Base 11.4 > 23.4 > fromHtmlEscapedString Blaze.ByteString.Builder.Html.Utf8 7.9 > 14.9 > >>= Data.Vector.Fusion.Util 2.3 > 1.7 > return Lucid.Base 1.4 > 2.1 > runBenchmark.loop Criterion.Measurement 1.2 > 0.0 > with.\ Lucid.Base 1.0 > 2.1 > foldlMapWithKey Lucid.Base 0.5 > 2.6 > streamDecodeUtf8With.decodeChunk Data.Text.Encoding 0.0 > 1.7 > > As expected, HtmlT's bind is the expensive bit. However I've been unable > to encourage it to go away using INLINE pragmas. > > > > > On 29 January 2017 at 15:45, Oliver Charles wrote: > > I would start by inlining operations in the Functor, Applicative and Monad > classes for your monad and all the layers in the stack (such as HtmlT). An > un-inlining monadic bind can end up allocating a lot (as it's such a common > operation) > > On Sun, 29 Jan 2017, 3:32 pm Saurabh Nanda, > wrote: > > Please tell me what to INLINE. I'll update the benchmarks. > > Also, shouldn't this be treated as a GHC bug then? Using monad > transformers as intended should not result in a severe performance penalty! > Either monad transformers themselves are a problem or GHC is not doing the > right thing. > > -- Saurabh. > > On 29 Jan 2017 7:50 pm, "Oliver Charles" wrote: > > I would wager a guess that this can be solved with INLINE pragmas. We > recently added INLINE to just about everything in transformers and got a > significant speed up. > > On Sun, 29 Jan 2017, 11:18 am David Turner, > wrote: > > I would guess that the issue lies within HtmlT, which looks vaguely > similar to a WriterT transformer but without much in the way of > optimisation (e.g. INLINE pragmas). But that's just a guess after about 30 > sec of glancing at > https://hackage.haskell.org/package/lucid-2.9.7/docs/src/Lucid-Base.html > so don't take it as gospel. > > My machine is apparently an i7-4770 of a similar vintage to yours, running > Ubuntu in a VirtualBox VM hosted on Windows. 4GB of RAM in the VM, 16 in > the host FWIW. > > > On 29 Jan 2017 10:26, "Saurabh Nanda" wrote: > > Thank you for the PR. Does your research suggest something is wrong with > HtmlT when combined with any MonadIO, not necessarily ActionT? Is this an > mtl issue or a lucid issue in that case? > > Curiously, what's your machine config? I'm on a late 2011 macbook pro with > 10G ram and some old i5. > > -- Saurabh. > > On 29 Jan 2017 3:05 pm, "David Turner" > wrote: > > The methodology does look reasonable, although I think you should wait for > all the scotty threads to start before starting the benchmarks, as I see > this interleaved output: > > Setting phasers to stun... (port 3002) (ctrl-c to quit) > Setting phasers to stun... (port 3003) (ctrl-c to quit) > Setting phasers to stun... (port 3001) (ctrl-c to quit) > benchmarking bareScotty > Setting phasers to stun... (port 3000) (ctrl-c to quit) > > Your numbers are wayyy slower than the ones I see on my dev machine: > > benchmarking bareScotty > Setting phasers to stun... (port 3000) (ctrl-c to quit) > time 10.94 ms (10.36 ms .. 11.52 ms) > 0.979 R² (0.961 R² .. 0.989 R²) > mean 12.53 ms (11.98 ms .. 13.28 ms) > std dev 1.702 ms (1.187 ms .. 2.589 ms) > variance introduced by outliers: 66% (severely inflated) > > benchmarking bareScottyBareLucid > time 12.95 ms (12.28 ms .. 13.95 ms) > 0.972 R² (0.951 R² .. 0.989 R²) > mean 12.20 ms (11.75 ms .. 12.69 ms) > std dev 1.236 ms (991.3 μs .. 1.601 ms) > variance introduced by outliers: 50% (severely inflated) > > benchmarking transScottyBareLucid > time 12.05 ms (11.70 ms .. 12.39 ms) > 0.992 R² (0.982 R² .. 0.996 R²) > mean 12.43 ms (12.06 ms .. 13.01 ms) > std dev 1.320 ms (880.5 μs .. 2.071 ms) > variance introduced by outliers: 54% (severely inflated) > > benchmarking transScottyTransLucid > time 39.73 ms (32.16 ms .. 49.45 ms) > 0.668 R² (0.303 R² .. 0.969 R²) > mean 42.59 ms (36.69 ms .. 54.38 ms) > std dev 16.52 ms (8.456 ms .. 25.96 ms) > variance introduced by outliers: 92% (severely inflated) > > benchmarking bareScotty > time 11.46 ms (10.89 ms .. 12.07 ms) > 0.986 R² (0.975 R² .. 0.994 R²) > mean 11.73 ms (11.45 ms .. 12.07 ms) > std dev 800.6 μs (636.8 μs .. 975.3 μs) > variance introduced by outliers: 34% (moderately inflated) > > but nonetheless I do also see the one using renderTextT to be > substantially slower than the one without. > > I've sent you a PR [1] that isolates Lucid from Scotty and shows that > renderTextT is twice as slow over IO than it is over Identity, and it's > ~10% slower over Reader too: > > benchmarking renderText > time 5.529 ms (5.328 ms .. 5.709 ms) > 0.990 R² (0.983 R² .. 0.995 R²) > mean 5.645 ms (5.472 ms .. 5.888 ms) > std dev 593.0 μs (352.5 μs .. 908.2 μs) > variance introduced by outliers: 63% (severely inflated) > > benchmarking renderTextT Id > time 5.439 ms (5.243 ms .. 5.640 ms) > 0.991 R² (0.985 R² .. 0.996 R²) > mean 5.498 ms (5.367 ms .. 5.631 ms) > std dev 408.8 μs (323.8 μs .. 552.9 μs) > variance introduced by outliers: 45% (moderately inflated) > > benchmarking renderTextT Rd > time 6.173 ms (5.983 ms .. 6.396 ms) > 0.990 R² (0.983 R² .. 0.995 R²) > mean 6.284 ms (6.127 ms .. 6.527 ms) > std dev 581.6 μs (422.9 μs .. 773.0 μs) > variance introduced by outliers: 55% (severely inflated) > > benchmarking renderTextT IO > time 12.35 ms (11.84 ms .. 12.84 ms) > 0.989 R² (0.982 R² .. 0.995 R²) > mean 12.22 ms (11.85 ms .. 12.76 ms) > std dev 1.159 ms (729.5 μs .. 1.683 ms) > variance introduced by outliers: 50% (severely inflated) > > I tried replacing > > forM [1..10000] (\_ -> div_ "hello world!") > > with > > replicateM_ 10000 (div_ "hello world!") > > which discards the list of 10,000 () values that the forM thing generates, > but this made very little difference. > > Hope this helps, > > David > > > [1] https://github.com/vacationlabs/monad-transformer-benchmark/pull/2 > > > > On 29 January 2017 at 07:26, Saurabh Nanda wrote: > > Hi, > > I was noticing severe drop in performance when Lucid's HtmlT was being > combined with Scotty's ActionT. I've tried putting together a minimal repro > at https://github.com/vacationlabs/monad-transformer-benchmark Request > someone with better knowledge of benchmarking to check if the benchmarking > methodology is correct. > > Is my reading of 200ms performance penalty correct? > > -- Saurabh. > > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. > > > > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dct25-561bs at mythic-beasts.com Sun Jan 29 19:27:17 2017 From: dct25-561bs at mythic-beasts.com (David Turner) Date: Sun, 29 Jan 2017 19:27:17 +0000 Subject: [Haskell-cafe] Monad transformer performance - Request to review benchmarking code + results In-Reply-To: References: Message-ID: Because, I guess, nobody has put the time and effort into optimising this particular benchmark. Lucid's fast enough that there are normally other more pressing bottlenecks in a real application. The compiler has no relevant smarts here, it's the library code to look at. There's something funny going on on your system that I can't help with, since I'm seeing rendering and serving the 230kB HTML page in a reasonably punchy 10-20ms range, an order of magnitude less than your numbers. Nonetheless, here is a fork of Lucid which performs substantially better running renderTextT over the IO monad on the benchmarks I sent earlier, thanks to a sprinkling of inlining: https://github.com/chrisdone/lucid/compare/master...DaveCTurner:98d69d0457034390d596eb40113368b24504dd6c benchmarking renderText time 4.900 ms (4.577 ms .. 5.218 ms) 0.895 R² (0.749 R² .. 0.988 R²) mean 5.560 ms (5.189 ms .. 6.461 ms) std dev 1.717 ms (510.4 μs .. 3.380 ms) variance introduced by outliers: 95% (severely inflated) benchmarking renderTextT Id time 4.879 ms (4.755 ms .. 5.036 ms) 0.989 R² (0.979 R² .. 0.997 R²) mean 5.057 ms (4.946 ms .. 5.219 ms) std dev 373.7 μs (285.5 μs .. 483.4 μs) variance introduced by outliers: 47% (moderately inflated) benchmarking renderTextT Rd time 5.034 ms (4.916 ms .. 5.152 ms) 0.994 R² (0.989 R² .. 0.997 R²) mean 5.226 ms (5.090 ms .. 5.772 ms) std dev 713.8 μs (261.3 μs .. 1.417 ms) variance introduced by outliers: 74% (severely inflated) benchmarking renderTextT IO time 7.168 ms (6.694 ms .. 7.557 ms) 0.969 R² (0.946 R² .. 0.982 R²) mean 8.388 ms (8.014 ms .. 8.880 ms) std dev 1.132 ms (932.1 μs .. 1.397 ms) variance introduced by outliers: 71% (severely inflated) and here is all the things I tried on it: https://github.com/chrisdone/lucid/compare/master...DaveCTurner:inline-the-things Hope that helps, David On 29 January 2017 at 16:59, Saurabh Nanda wrote: > Thanks for digging deeper, David. What exactly did you inline? > > Also, am I the only one losing my mind over this? It's such a > straightforward use of available code structuring tools in Haskell. How > come the compiler is not being smart about this OOB? > > -- Saurabh. > > On 29 Jan 2017 9:42 pm, "David Turner" > wrote: > > Here's the profiling summary that I got: > > COST CENTRE MODULE %time > %alloc > > getOverhead Criterion.Monad 41.3 > 0.0 > >>= Lucid.Base 19.2 > 41.6 > makeElement.\.\ Lucid.Base 11.4 > 23.4 > fromHtmlEscapedString Blaze.ByteString.Builder.Html.Utf8 > 7.9 14.9 > >>= Data.Vector.Fusion.Util 2.3 > 1.7 > return Lucid.Base 1.4 > 2.1 > runBenchmark.loop Criterion.Measurement 1.2 > 0.0 > with.\ Lucid.Base 1.0 > 2.1 > foldlMapWithKey Lucid.Base 0.5 > 2.6 > streamDecodeUtf8With.decodeChunk Data.Text.Encoding > 0.0 1.7 > > As expected, HtmlT's bind is the expensive bit. However I've been unable > to encourage it to go away using INLINE pragmas. > > > > > On 29 January 2017 at 15:45, Oliver Charles wrote: > >> I would start by inlining operations in the Functor, Applicative and >> Monad classes for your monad and all the layers in the stack (such as >> HtmlT). An un-inlining monadic bind can end up allocating a lot (as it's >> such a common operation) >> >> On Sun, 29 Jan 2017, 3:32 pm Saurabh Nanda, >> wrote: >> >>> Please tell me what to INLINE. I'll update the benchmarks. >>> >>> Also, shouldn't this be treated as a GHC bug then? Using monad >>> transformers as intended should not result in a severe performance penalty! >>> Either monad transformers themselves are a problem or GHC is not doing the >>> right thing. >>> >>> -- Saurabh. >>> >>> On 29 Jan 2017 7:50 pm, "Oliver Charles" wrote: >>> >>> I would wager a guess that this can be solved with INLINE pragmas. We >>> recently added INLINE to just about everything in transformers and got a >>> significant speed up. >>> >>> On Sun, 29 Jan 2017, 11:18 am David Turner, < >>> dct25-561bs at mythic-beasts.com> wrote: >>> >>> I would guess that the issue lies within HtmlT, which looks vaguely >>> similar to a WriterT transformer but without much in the way of >>> optimisation (e.g. INLINE pragmas). But that's just a guess after about 30 >>> sec of glancing at https://hackage.haskell.org >>> /package/lucid-2.9.7/docs/src/Lucid-Base.html so don't take it as >>> gospel. >>> >>> My machine is apparently an i7-4770 of a similar vintage to yours, >>> running Ubuntu in a VirtualBox VM hosted on Windows. 4GB of RAM in the VM, >>> 16 in the host FWIW. >>> >>> >>> On 29 Jan 2017 10:26, "Saurabh Nanda" wrote: >>> >>> Thank you for the PR. Does your research suggest something is wrong with >>> HtmlT when combined with any MonadIO, not necessarily ActionT? Is this an >>> mtl issue or a lucid issue in that case? >>> >>> Curiously, what's your machine config? I'm on a late 2011 macbook pro >>> with 10G ram and some old i5. >>> >>> -- Saurabh. >>> >>> On 29 Jan 2017 3:05 pm, "David Turner" >>> wrote: >>> >>> The methodology does look reasonable, although I think you should wait >>> for all the scotty threads to start before starting the benchmarks, as I >>> see this interleaved output: >>> >>> Setting phasers to stun... (port 3002) (ctrl-c to quit) >>> Setting phasers to stun... (port 3003) (ctrl-c to quit) >>> Setting phasers to stun... (port 3001) (ctrl-c to quit) >>> benchmarking bareScotty >>> Setting phasers to stun... (port 3000) (ctrl-c to quit) >>> >>> Your numbers are wayyy slower than the ones I see on my dev machine: >>> >>> benchmarking bareScotty >>> Setting phasers to stun... (port 3000) (ctrl-c to quit) >>> time 10.94 ms (10.36 ms .. 11.52 ms) >>> 0.979 R² (0.961 R² .. 0.989 R²) >>> mean 12.53 ms (11.98 ms .. 13.28 ms) >>> std dev 1.702 ms (1.187 ms .. 2.589 ms) >>> variance introduced by outliers: 66% (severely inflated) >>> >>> benchmarking bareScottyBareLucid >>> time 12.95 ms (12.28 ms .. 13.95 ms) >>> 0.972 R² (0.951 R² .. 0.989 R²) >>> mean 12.20 ms (11.75 ms .. 12.69 ms) >>> std dev 1.236 ms (991.3 μs .. 1.601 ms) >>> variance introduced by outliers: 50% (severely inflated) >>> >>> benchmarking transScottyBareLucid >>> time 12.05 ms (11.70 ms .. 12.39 ms) >>> 0.992 R² (0.982 R² .. 0.996 R²) >>> mean 12.43 ms (12.06 ms .. 13.01 ms) >>> std dev 1.320 ms (880.5 μs .. 2.071 ms) >>> variance introduced by outliers: 54% (severely inflated) >>> >>> benchmarking transScottyTransLucid >>> time 39.73 ms (32.16 ms .. 49.45 ms) >>> 0.668 R² (0.303 R² .. 0.969 R²) >>> mean 42.59 ms (36.69 ms .. 54.38 ms) >>> std dev 16.52 ms (8.456 ms .. 25.96 ms) >>> variance introduced by outliers: 92% (severely inflated) >>> >>> benchmarking bareScotty >>> time 11.46 ms (10.89 ms .. 12.07 ms) >>> 0.986 R² (0.975 R² .. 0.994 R²) >>> mean 11.73 ms (11.45 ms .. 12.07 ms) >>> std dev 800.6 μs (636.8 μs .. 975.3 μs) >>> variance introduced by outliers: 34% (moderately inflated) >>> >>> but nonetheless I do also see the one using renderTextT to be >>> substantially slower than the one without. >>> >>> I've sent you a PR [1] that isolates Lucid from Scotty and shows that >>> renderTextT is twice as slow over IO than it is over Identity, and it's >>> ~10% slower over Reader too: >>> >>> benchmarking renderText >>> time 5.529 ms (5.328 ms .. 5.709 ms) >>> 0.990 R² (0.983 R² .. 0.995 R²) >>> mean 5.645 ms (5.472 ms .. 5.888 ms) >>> std dev 593.0 μs (352.5 μs .. 908.2 μs) >>> variance introduced by outliers: 63% (severely inflated) >>> >>> benchmarking renderTextT Id >>> time 5.439 ms (5.243 ms .. 5.640 ms) >>> 0.991 R² (0.985 R² .. 0.996 R²) >>> mean 5.498 ms (5.367 ms .. 5.631 ms) >>> std dev 408.8 μs (323.8 μs .. 552.9 μs) >>> variance introduced by outliers: 45% (moderately inflated) >>> >>> benchmarking renderTextT Rd >>> time 6.173 ms (5.983 ms .. 6.396 ms) >>> 0.990 R² (0.983 R² .. 0.995 R²) >>> mean 6.284 ms (6.127 ms .. 6.527 ms) >>> std dev 581.6 μs (422.9 μs .. 773.0 μs) >>> variance introduced by outliers: 55% (severely inflated) >>> >>> benchmarking renderTextT IO >>> time 12.35 ms (11.84 ms .. 12.84 ms) >>> 0.989 R² (0.982 R² .. 0.995 R²) >>> mean 12.22 ms (11.85 ms .. 12.76 ms) >>> std dev 1.159 ms (729.5 μs .. 1.683 ms) >>> variance introduced by outliers: 50% (severely inflated) >>> >>> I tried replacing >>> >>> forM [1..10000] (\_ -> div_ "hello world!") >>> >>> with >>> >>> replicateM_ 10000 (div_ "hello world!") >>> >>> which discards the list of 10,000 () values that the forM thing >>> generates, but this made very little difference. >>> >>> Hope this helps, >>> >>> David >>> >>> >>> [1] https://github.com/vacationlabs/monad-transformer-benchmark/pull/2 >>> >>> >>> >>> On 29 January 2017 at 07:26, Saurabh Nanda >>> wrote: >>> >>> Hi, >>> >>> I was noticing severe drop in performance when Lucid's HtmlT was being >>> combined with Scotty's ActionT. I've tried putting together a minimal repro >>> at https://github.com/vacationlabs/monad-transformer-benchmark Request >>> someone with better knowledge of benchmarking to check if the benchmarking >>> methodology is correct. >>> >>> Is my reading of 200ms performance penalty correct? >>> >>> -- Saurabh. >>> >>> >>> _______________________________________________ >>> Haskell-Cafe mailing list >>> To (un)subscribe, modify options or view archives go to: >>> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe >>> Only members subscribed via the mailman list are allowed to post. >>> >>> >>> >>> >>> _______________________________________________ >>> Haskell-Cafe mailing list >>> To (un)subscribe, modify options or view archives go to: >>> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe >>> Only members subscribed via the mailman list are allowed to post. >>> >>> >>> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From saurabhnanda at gmail.com Mon Jan 30 04:57:43 2017 From: saurabhnanda at gmail.com (Saurabh Nanda) Date: Mon, 30 Jan 2017 10:27:43 +0530 Subject: [Haskell-cafe] Monad transformer performance - Request to review benchmarking code + results In-Reply-To: References: Message-ID: > > Why do you keep expecting the compiler to "be smart"? It's just shuffling > data around, any type of magic efficiency with Monadic computations > requires specific knowledge about monads, which is not something we encode > into the compiler. just saying "this should be obvious" is not very > productive. > Two reasons: * If inlining certain functions can give a boost to the performance, then is it unreasonable to expect the compiler to have better heuristics about when commonly occurring code patterns should be inlined? In this case monads and mtl being the commonly occurring code patterns. * At a broader level, the promise of writing pure functions was to be able to talk about 'intent', not 'implementation' -- the classic `map` vs `for loop` example. Additionally, pure functions give the compiler enough opportunity to optimise code. Both these higher level promises are being broken by this experience. Hence, I'm feeling "cheated" -- Saurabh. -------------- next part -------------- An HTML attachment was scrubbed... URL: From guthrie at mum.edu Mon Jan 30 14:53:20 2017 From: guthrie at mum.edu (Gregory Guthrie) Date: Mon, 30 Jan 2017 08:53:20 -0600 Subject: [Haskell-cafe] Haskell IDEs Message-ID: <08EF9DA445C4B5439C4733E1F35705BA065BF53866BA@MAIL.cs.mum.edu> The Wiki on Haskell IDEs seems to be out of date. It mentions KDevelop, which no longer has any references to Haskell on its site, and to FPeclipse which was orphaned in 2015. I find Leksah rather cumbersome to use/learn (for students), and it is still a bit hard to convince them after Netbeans & Eclipse to fall back to Vi and DOS command windows. :) -------------- next part -------------- An HTML attachment was scrubbed... URL: From saurabhnanda at gmail.com Mon Jan 30 17:25:41 2017 From: saurabhnanda at gmail.com (Saurabh Nanda) Date: Mon, 30 Jan 2017 22:55:41 +0530 Subject: [Haskell-cafe] Monad transformer performance - Request to review benchmarking code + results In-Reply-To: References: Message-ID: Was going through https://downloads.haskell.org/~ghc/7.0.3/docs/html/users_guide/pragmas.html and came across the SPECIALIZE pragma. Is it possible to write it in a way that it specializes a complete monad transformer stack to given concrete stack? -- Saurabh. On 30 Jan 2017 10:27 am, "Saurabh Nanda" wrote: > Why do you keep expecting the compiler to "be smart"? It's just shuffling >> data around, any type of magic efficiency with Monadic computations >> requires specific knowledge about monads, which is not something we encode >> into the compiler. just saying "this should be obvious" is not very >> productive. >> > > Two reasons: > > * If inlining certain functions can give a boost to the performance, then > is it unreasonable to expect the compiler to have better heuristics about > when commonly occurring code patterns should be inlined? In this case > monads and mtl being the commonly occurring code patterns. > > * At a broader level, the promise of writing pure functions was to be able > to talk about 'intent', not 'implementation' -- the classic `map` vs `for > loop` example. Additionally, pure functions give the compiler enough > opportunity to optimise code. Both these higher level promises are being > broken by this experience. Hence, I'm feeling "cheated" > > -- Saurabh. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From trebla at vex.net Mon Jan 30 19:28:13 2017 From: trebla at vex.net (Albert Y. C. Lai) Date: Mon, 30 Jan 2017 14:28:13 -0500 Subject: [Haskell-cafe] Lazy ST test code In-Reply-To: References: Message-ID: <21e88a6f-4803-ab9d-8ae6-88a9d730c95b@vex.net> On 2017-01-29 02:22 AM, David Feuer wrote: > I've come up with what might be a fix for a major thread safety bug in > lazy ST. Fixing it involved making multiple non-trivial changes to a > number of basic functions. Unfortunately, the GHC test suite barely > touches lazy ST. Does anyone out there have some code that uses lazy ST > in interesting ways but that only relies on the libraries that ship with > GHC? I don't normally use lazy ST, but I have some toy examples at http://lpaste.net/63925 . You may like the fact that I got strictToLazyST involved. From trebla at vex.net Mon Jan 30 19:35:39 2017 From: trebla at vex.net (Albert Y. C. Lai) Date: Mon, 30 Jan 2017 14:35:39 -0500 Subject: [Haskell-cafe] Haskell IDEs In-Reply-To: <08EF9DA445C4B5439C4733E1F35705BA065BF53866BA@MAIL.cs.mum.edu> References: <08EF9DA445C4B5439C4733E1F35705BA065BF53866BA@MAIL.cs.mum.edu> Message-ID: <8dba5425-0b61-8a85-31b9-7650c503fed5@vex.net> On 2017-01-30 09:53 AM, Gregory Guthrie wrote: > The Wiki on Haskell IDEs seems to be out of date. The sad state is that updating it means deleting a lot of obsolete entries but there is no new entry to add (apart from Haskell for Mac, http://haskellformac.com/ ) The silver lining is that you are not missing out on any recent development. If you have heard of Leksah and Haskell for Mac, you have already known it all. (Wouldn't it be nice if Apple permitted us to run MacOS in VirtualBox on Windows and Linux?) From saurabhnanda at gmail.com Tue Jan 31 02:47:44 2017 From: saurabhnanda at gmail.com (Saurabh Nanda) Date: Tue, 31 Jan 2017 08:17:44 +0530 Subject: [Haskell-cafe] Ensuring all values of an ADT are explicitly handled OR finding all occurrences of type X in my app In-Reply-To: References: Message-ID: Hi, If I have the following ADT data BookingState = Confirmed | Cancelled which had a very high chance of being expanded in the future to have more values. How do I ensure that every pattern match on BookingState matches each value explicitly. Basically prevent the '_' matcher ? If that is not possible, is the following possible instead: evolve BookingState and then find all possible occurrences of values of BookingState throughout my app? I'm basically trying to make sure that any a newly added state, which may require special-case handling is not automatically handled by the '_' branch. -- Saurabh. -------------- next part -------------- An HTML attachment was scrubbed... URL: From michael at orlitzky.com Tue Jan 31 04:19:57 2017 From: michael at orlitzky.com (Michael Orlitzky) Date: Mon, 30 Jan 2017 23:19:57 -0500 Subject: [Haskell-cafe] Ensuring all values of an ADT are explicitly handled OR finding all occurrences of type X in my app In-Reply-To: References: Message-ID: <9750a089-55aa-1e1f-8868-a0c0da0bf9b3@orlitzky.com> On 01/30/2017 09:47 PM, Saurabh Nanda wrote: > Hi, > > If I have the following ADT > > data BookingState = Confirmed | Cancelled > > which had a very high chance of being expanded in the future to have more > values. How do I ensure that every pattern match on BookingState matches > each value explicitly. Basically prevent the '_' matcher ? > Don't write the "_" case? GHC will warn you about any pattern matches you've missed. From taeer at necsi.edu Tue Jan 31 04:37:25 2017 From: taeer at necsi.edu (Taeer Bar-Yam) Date: Tue, 31 Jan 2017 04:37:25 +0000 Subject: [Haskell-cafe] Sequence of lifting transformation operators In-Reply-To: <20170128093342.42447c4a5d4881089124f4f0@mega-nerd.com> References: <20170128093342.42447c4a5d4881089124f4f0@mega-nerd.com> Message-ID: <1485837279-astroid-0-sd6adh0nmr-7966@rebel> This is (IMO) very similar in use-case to Idris' bang-notation. I'll give a brief summary of what that is and then explain the pros/cons that I see between them. In Idris the do notation has the added notation that do return $ !a + !b would desugar to do a' <- a b' <- b return $ a' + b' So !a unwraps a higher up and then uses the unwrapped version. Thus if you want to apply a function to apply a function to some wrapped and some unwrapped values: do return $ f !a b !c !d Pros/Cons: - Idris notation is (IMO) more visually appealing. - In particular, it puts the information about which arguments are lifted next to the arguments themselves, which matches our intuition about what's going on - While it matches our intuition, it does *not* match what's actually going on, so that's a con. - Idris notation can lift things more than once: do return $ f !!a !b !!!!c - Idris notation is syntactic sugar, not a first-class operator - So that means no currying, no passing it in as an argument, etc. (though with lambdas this is not as bad as it otherwise would be) - Idris notation is for monads, so it would not work for things that are applicative but not monads (though I'm not entirely sure what falls into this category) What do you y'all think? Do they operate in different enough spaces that they should both exist (like applicatives and moands), or is one clearly better? --Taeer From saurabhnanda at gmail.com Tue Jan 31 04:59:56 2017 From: saurabhnanda at gmail.com (Saurabh Nanda) Date: Tue, 31 Jan 2017 10:29:56 +0530 Subject: [Haskell-cafe] Ensuring all values of an ADT are explicitly handled OR finding all occurrences of type X in my app In-Reply-To: <9750a089-55aa-1e1f-8868-a0c0da0bf9b3@orlitzky.com> References: <9750a089-55aa-1e1f-8868-a0c0da0bf9b3@orlitzky.com> Message-ID: I would want the compiler (or linter) to help me here. Think if a mid-to-large team where everyone may not know (or remember) what the current best practices are. On 31 Jan 2017 9:51 am, "Michael Orlitzky" wrote: > On 01/30/2017 09:47 PM, Saurabh Nanda wrote: > > Hi, > > > > If I have the following ADT > > > > data BookingState = Confirmed | Cancelled > > > > which had a very high chance of being expanded in the future to have more > > values. How do I ensure that every pattern match on BookingState matches > > each value explicitly. Basically prevent the '_' matcher ? > > > > Don't write the "_" case? GHC will warn you about any pattern matches > you've missed. > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. -------------- next part -------------- An HTML attachment was scrubbed... URL: From branimir.maksimovic at gmail.com Tue Jan 31 05:10:56 2017 From: branimir.maksimovic at gmail.com (Branimir Maksimovic) Date: Tue, 31 Jan 2017 06:10:56 +0100 Subject: [Haskell-cafe] Ensuring all values of an ADT are explicitly handled OR finding all occurrences of type X in my app In-Reply-To: References: <9750a089-55aa-1e1f-8868-a0c0da0bf9b3@orlitzky.com> Message-ID: Actually in team, one who writes `_` match, is very useful as that prevents breaking code when adding new value... I can't really see any problem here. There is real world use case when member of team don't need to cover all cases therefore `_`. On 01/31/2017 05:59 AM, Saurabh Nanda wrote: > I would want the compiler (or linter) to help me here. Think if a > mid-to-large team where everyone may not know (or remember) what the > current best practices are. > > On 31 Jan 2017 9:51 am, "Michael Orlitzky" > wrote: > > On 01/30/2017 09:47 PM, Saurabh Nanda wrote: > > Hi, > > > > If I have the following ADT > > > > data BookingState = Confirmed | Cancelled > > > > which had a very high chance of being expanded in the future to > have more > > values. How do I ensure that every pattern match on BookingState > matches > > each value explicitly. Basically prevent the '_' matcher ? > > > > Don't write the "_" case? GHC will warn you about any pattern matches > you've missed. > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > > Only members subscribed via the mailman list are allowed to post. > > > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. -------------- next part -------------- An HTML attachment was scrubbed... URL: From b at chreekat.net Tue Jan 31 05:25:30 2017 From: b at chreekat.net (Bryan Richter) Date: Mon, 30 Jan 2017 21:25:30 -0800 Subject: [Haskell-cafe] Ensuring all values of an ADT are explicitly handled OR finding all occurrences of type X in my app In-Reply-To: References: <9750a089-55aa-1e1f-8868-a0c0da0bf9b3@orlitzky.com> Message-ID: On Jan 30, 2017 21:00, "Saurabh Nanda" wrote: I would want the compiler (or linter) to help me here. Think if a mid-to-large team where everyone may not know (or remember) what the current best practices are. I believe you are asking, "Is there an option to emit warnings when the underscore pattern is used?" I further believe the answer to that question is no. I can appreciate your use case, however. On 31 Jan 2017 9:51 am, "Michael Orlitzky" wrote: > On 01/30/2017 09:47 PM, Saurabh Nanda wrote: > > Hi, > > > > If I have the following ADT > > > > data BookingState = Confirmed | Cancelled > > > > which had a very high chance of being expanded in the future to have more > > values. How do I ensure that every pattern match on BookingState matches > > each value explicitly. Basically prevent the '_' matcher ? > > > > Don't write the "_" case? GHC will warn you about any pattern matches > you've missed. > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. _______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post. -------------- next part -------------- An HTML attachment was scrubbed... URL: From saurabhnanda at gmail.com Tue Jan 31 05:41:57 2017 From: saurabhnanda at gmail.com (Saurabh Nanda) Date: Tue, 31 Jan 2017 11:11:57 +0530 Subject: [Haskell-cafe] Ensuring all values of an ADT are explicitly handled OR finding all occurrences of type X in my app In-Reply-To: References: <9750a089-55aa-1e1f-8868-a0c0da0bf9b3@orlitzky.com> Message-ID: > > Actually in team, one who writes `_` match, is very useful as that > prevents breaking code when adding new value...I can't really see any > problem here. There is real world use case when member of team don't need > to cover all cases therefore `_`. > I **want** code to break when I add a new value to an ADT. I want the programmer to go through all the sites where a pattern match was done on a particular ADT and explicitly consider the impact of the new value on these sites. Actual use-case -- we start with the following ADT definition and call-sites: data BookingStatus = Confirmed | Cancelled | Abandoned > computeRemainingSeats :: BookingStatus -> (...) > computeBilling :: BookingStatus -> (...) Now, assume that within `computeAvailability` only `Confirmed` is explicitly matched to result in a reduction of available seats, everything else is matched by `_` and results in a no-op. What happens when `BookingStatus` evolves to have a new value of `ManualReview`? We want to reduce the number of seats till the manual-review of the booking is complete. However, the compiler will not force us to look at this particular call-site to evaluate this impact. Another one: assume that within `computeBilling` only `Confirmed is explicitly matched to trigger an invoicing action, others are matched via `_` to a no-op. What happens when `BookingStatus` evolves to have a new value of `Refunded`, which should trigger a credit-note action? Again, the compiler is not going to help us here. One may reason that this is conflation of concerns; that this should be split into **three** ADTs -- one for BookingStatus, one for AvailabilityStatus and one for BillingStatus. And pedantically this might be right. But all of these learnings evolve over time and one may not make the right decisions when writing v1 of the system. Under such circumstances, can Haskell still help in helping the programmer ensure correctness? -- Saurabh. -------------- next part -------------- An HTML attachment was scrubbed... URL: From david.feuer at gmail.com Tue Jan 31 05:48:11 2017 From: david.feuer at gmail.com (David Feuer) Date: Tue, 31 Jan 2017 00:48:11 -0500 Subject: [Haskell-cafe] Lazy ST test code In-Reply-To: <21e88a6f-4803-ab9d-8ae6-88a9d730c95b@vex.net> References: <21e88a6f-4803-ab9d-8ae6-88a9d730c95b@vex.net> Message-ID: Thanks! I'll include these in my proposed additions to the GHC test suite, with your permission (releasing them under GHC's license terms). On Jan 30, 2017 2:28 PM, "Albert Y. C. Lai" wrote: > On 2017-01-29 02:22 AM, David Feuer wrote: > >> I've come up with what might be a fix for a major thread safety bug in >> lazy ST. Fixing it involved making multiple non-trivial changes to a >> number of basic functions. Unfortunately, the GHC test suite barely >> touches lazy ST. Does anyone out there have some code that uses lazy ST >> in interesting ways but that only relies on the libraries that ship with >> GHC? >> > > I don't normally use lazy ST, but I have some toy examples at > http://lpaste.net/63925 . You may like the fact that I got strictToLazyST > involved. > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. -------------- next part -------------- An HTML attachment was scrubbed... URL: From vagarenko at gmail.com Tue Jan 31 05:56:11 2017 From: vagarenko at gmail.com (Alexey Vagarenko) Date: Tue, 31 Jan 2017 10:56:11 +0500 Subject: [Haskell-cafe] Sequence of lifting transformation operators In-Reply-To: <1485837279-astroid-0-sd6adh0nmr-7966@rebel> References: <20170128093342.42447c4a5d4881089124f4f0@mega-nerd.com> <1485837279-astroid-0-sd6adh0nmr-7966@rebel> Message-ID: What is the order of unwrapping? `return $ !a + !b` doesn't equals `return $ !b + !a` right? 2017-01-31 9:37 GMT+05:00 Taeer Bar-Yam : > This is (IMO) very similar in use-case to Idris' bang-notation. I'll give > a brief > summary of what that is and then explain the pros/cons that I see between > them. > > In Idris the do notation has the added notation that > do return $ !a + !b > would desugar to > do > a' <- a > b' <- b > return $ a' + b' > > So !a unwraps a higher up and then uses the unwrapped version. > Thus if you want to apply a function to apply a function to some wrapped > and > some unwrapped values: > do return $ f !a b !c !d > > > Pros/Cons: > - Idris notation is (IMO) more visually appealing. > - In particular, it puts the information about which arguments are lifted > next > to the arguments themselves, which matches our intuition about what's > going on > - While it matches our intuition, it does *not* match what's actually > going on, > so that's a con. > - Idris notation can lift things more than once: > do return $ f !!a !b !!!!c > - Idris notation is syntactic sugar, not a first-class operator > - So that means no currying, no passing it in as an argument, etc. (though > with lambdas this is not as bad as it otherwise would be) > - Idris notation is for monads, so it would not work for things that are > applicative but not monads (though I'm not entirely sure what falls into > this > category) > > What do you y'all think? Do they operate in different enough spaces that > they > should both exist (like applicatives and moands), or is one clearly better? > > --Taeer > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From vagarenko at gmail.com Tue Jan 31 06:00:03 2017 From: vagarenko at gmail.com (Alexey Vagarenko) Date: Tue, 31 Jan 2017 11:00:03 +0500 Subject: [Haskell-cafe] Ensuring all values of an ADT are explicitly handled OR finding all occurrences of type X in my app In-Reply-To: References: <9750a089-55aa-1e1f-8868-a0c0da0bf9b3@orlitzky.com> Message-ID: There is a proposal about that https://github.com/ghc-proposals/ghc-proposals/pull/43 2017-01-31 10:41 GMT+05:00 Saurabh Nanda : > Actually in team, one who writes `_` match, is very useful as that >> prevents breaking code when adding new value...I can't really see any >> problem here. There is real world use case when member of team don't need >> to cover all cases therefore `_`. >> > I **want** code to break when I add a new value to an ADT. I want the > programmer to go through all the sites where a pattern match was done on a > particular ADT and explicitly consider the impact of the new value on these > sites. > > Actual use-case -- we start with the following ADT definition and > call-sites: > > data BookingStatus = Confirmed | Cancelled | Abandoned >> computeRemainingSeats :: BookingStatus -> (...) >> computeBilling :: BookingStatus -> (...) > > > Now, assume that within `computeAvailability` only `Confirmed` is > explicitly matched to result in a reduction of available seats, everything > else is matched by `_` and results in a no-op. What happens when > `BookingStatus` evolves to have a new value of `ManualReview`? We want to > reduce the number of seats till the manual-review of the booking is > complete. However, the compiler will not force us to look at this > particular call-site to evaluate this impact. > > Another one: assume that within `computeBilling` only `Confirmed is > explicitly matched to trigger an invoicing action, others are matched via > `_` to a no-op. What happens when `BookingStatus` evolves to have a new > value of `Refunded`, which should trigger a credit-note action? Again, the > compiler is not going to help us here. > > One may reason that this is conflation of concerns; that this should be > split into **three** ADTs -- one for BookingStatus, one for > AvailabilityStatus and one for BillingStatus. And pedantically this might > be right. But all of these learnings evolve over time and one may not make > the right decisions when writing v1 of the system. Under such > circumstances, can Haskell still help in helping the programmer ensure > correctness? > > -- Saurabh. > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From saurabhnanda at gmail.com Tue Jan 31 06:11:11 2017 From: saurabhnanda at gmail.com (Saurabh Nanda) Date: Tue, 31 Jan 2017 11:41:11 +0530 Subject: [Haskell-cafe] Ensuring all values of an ADT are explicitly handled OR finding all occurrences of type X in my app In-Reply-To: References: <9750a089-55aa-1e1f-8868-a0c0da0bf9b3@orlitzky.com> Message-ID: > > There is a proposal about that https://github.com/ghc- > proposals/ghc-proposals/pull/43 > Thanks for the link. Added my 2 cents there: https://github.com/ghc-proposals/ghc-proposals/pull/43#issuecomment-276283404 While this is being considered for inclusion in core GHC, can a linter help, in the meantime? -- Saurabh. -------------- next part -------------- An HTML attachment was scrubbed... URL: From cma at bitemyapp.com Tue Jan 31 06:38:19 2017 From: cma at bitemyapp.com (Christopher Allen) Date: Tue, 31 Jan 2017 00:38:19 -0600 Subject: [Haskell-cafe] Ensuring all values of an ADT are explicitly handled OR finding all occurrences of type X in my app In-Reply-To: References: <9750a089-55aa-1e1f-8868-a0c0da0bf9b3@orlitzky.com> Message-ID: We want this at my company too, so we don't write fall-through cases. On Mon, Jan 30, 2017 at 11:41 PM, Saurabh Nanda wrote: >> Actually in team, one who writes `_` match, is very useful as that >> prevents breaking code when adding new value...I can't really see any >> problem here. There is real world use case when member of team don't need to >> cover all cases therefore `_`. > > I **want** code to break when I add a new value to an ADT. I want the > programmer to go through all the sites where a pattern match was done on a > particular ADT and explicitly consider the impact of the new value on these > sites. > > Actual use-case -- we start with the following ADT definition and > call-sites: > >> data BookingStatus = Confirmed | Cancelled | Abandoned >> computeRemainingSeats :: BookingStatus -> (...) >> computeBilling :: BookingStatus -> (...) > > > Now, assume that within `computeAvailability` only `Confirmed` is explicitly > matched to result in a reduction of available seats, everything else is > matched by `_` and results in a no-op. What happens when `BookingStatus` > evolves to have a new value of `ManualReview`? We want to reduce the number > of seats till the manual-review of the booking is complete. However, the > compiler will not force us to look at this particular call-site to evaluate > this impact. > > Another one: assume that within `computeBilling` only `Confirmed is > explicitly matched to trigger an invoicing action, others are matched via > `_` to a no-op. What happens when `BookingStatus` evolves to have a new > value of `Refunded`, which should trigger a credit-note action? Again, the > compiler is not going to help us here. > > One may reason that this is conflation of concerns; that this should be > split into **three** ADTs -- one for BookingStatus, one for > AvailabilityStatus and one for BillingStatus. And pedantically this might be > right. But all of these learnings evolve over time and one may not make the > right decisions when writing v1 of the system. Under such circumstances, can > Haskell still help in helping the programmer ensure correctness? > > -- Saurabh. > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. -- Chris Allen Currently working on http://haskellbook.com From saurabhnanda at gmail.com Tue Jan 31 06:45:13 2017 From: saurabhnanda at gmail.com (Saurabh Nanda) Date: Tue, 31 Jan 2017 12:15:13 +0530 Subject: [Haskell-cafe] Ensuring all values of an ADT are explicitly handled OR finding all occurrences of type X in my app In-Reply-To: References: <9750a089-55aa-1e1f-8868-a0c0da0bf9b3@orlitzky.com> Message-ID: > > We want this at my company too, so we don't write fall-through cases. > That's a short-term workaround, yes. However it doesn't fit into Haskell's overall story of language-enforced correctness. -- Saurabh. -------------- next part -------------- An HTML attachment was scrubbed... URL: From saurabhnanda at gmail.com Tue Jan 31 06:45:52 2017 From: saurabhnanda at gmail.com (Saurabh Nanda) Date: Tue, 31 Jan 2017 12:15:52 +0530 Subject: [Haskell-cafe] Ensuring all values of an ADT are explicitly handled OR finding all occurrences of type X in my app In-Reply-To: References: <9750a089-55aa-1e1f-8868-a0c0da0bf9b3@orlitzky.com> Message-ID: Btw, what about the other approach -- listing all possible occurrences of type X throughout the app? -- Saurabh. On Tue, Jan 31, 2017 at 12:15 PM, Saurabh Nanda wrote: > We want this at my company too, so we don't write fall-through cases. >> > > That's a short-term workaround, yes. However it doesn't fit into Haskell's > overall story of language-enforced correctness. > > -- Saurabh. > -- http://www.saurabhnanda.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From mle+hs at mega-nerd.com Tue Jan 31 07:34:04 2017 From: mle+hs at mega-nerd.com (Erik de Castro Lopo) Date: Tue, 31 Jan 2017 18:34:04 +1100 Subject: [Haskell-cafe] Ensuring all values of an ADT are explicitly handled OR finding all occurrences of type X in my app In-Reply-To: References: <9750a089-55aa-1e1f-8868-a0c0da0bf9b3@orlitzky.com> Message-ID: <20170131183404.c35f1d4d14ed6f0ceb8baee4@mega-nerd.com> Branimir Maksimovic wrote: > Actually in team, one who writes `_` match, is very useful as that > prevents breaking code when adding new value... I write Haskell code in a team of 15 engineers and wild card pattern matches are considered a bad idea exactly *because* we want compiler errors when a sum type is extended with a new constructor. Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/ From taeer at necsi.edu Tue Jan 31 07:34:00 2017 From: taeer at necsi.edu (Taeer Bar-Yam) Date: Tue, 31 Jan 2017 07:34:00 +0000 Subject: [Haskell-cafe] Sequence of lifting transformation operators In-Reply-To: References: <20170128093342.42447c4a5d4881089124f4f0@mega-nerd.com> <1485837279-astroid-0-sd6adh0nmr-7966@rebel> Message-ID: <1485847598-astroid-1-adinahpp9a-7966@rebel> In general no. IMO this is better used with commutative monads (is that the right term?) such as [] or Maybe, rather than monads such as IO. However, there is a well-defined order, that I presume is inner-to-outer left-to-right, but I don't actually have experience programming in Idris. Reference: http://docs.idris-lang.org/en/latest/tutorial/interfaces.html#notation Excerpts from Alexey Vagarenko's message of January 31, 2017 12:56 am: > What is the order of unwrapping? > `return $ !a + !b` doesn't equals `return $ !b + !a` right? --Taeer From saurabhnanda at gmail.com Tue Jan 31 07:38:56 2017 From: saurabhnanda at gmail.com (Saurabh Nanda) Date: Tue, 31 Jan 2017 13:08:56 +0530 Subject: [Haskell-cafe] Ensuring all values of an ADT are explicitly handled OR finding all occurrences of type X in my app In-Reply-To: <20170131183404.c35f1d4d14ed6f0ceb8baee4@mega-nerd.com> References: <9750a089-55aa-1e1f-8868-a0c0da0bf9b3@orlitzky.com> <20170131183404.c35f1d4d14ed6f0ceb8baee4@mega-nerd.com> Message-ID: > > I write Haskell code in a team of 15 engineers and wild card pattern > matches are considered a bad idea exactly *because* we want compiler > errors when a sum type is extended with a new constructor > How would you respond to this comment: https://github.com/ghc-proposals/ghc-proposals/pull/43#issuecomment-276292037 -- Saurabh. -------------- next part -------------- An HTML attachment was scrubbed... URL: From svenpanne at gmail.com Tue Jan 31 07:43:31 2017 From: svenpanne at gmail.com (Sven Panne) Date: Tue, 31 Jan 2017 08:43:31 +0100 Subject: [Haskell-cafe] Ensuring all values of an ADT are explicitly handled OR finding all occurrences of type X in my app In-Reply-To: References: <9750a089-55aa-1e1f-8868-a0c0da0bf9b3@orlitzky.com> Message-ID: 2017-01-31 7:45 GMT+01:00 Saurabh Nanda : > We want this at my company too, so we don't write fall-through cases. >> > > That's a short-term workaround, yes. However it doesn't fit into Haskell's > overall story of language-enforced correctness. > I don't see this as a workaround, this is *the* way to go IMHO. Using '_' is saying: "I know what I'm doing here, for all eternity, trust me...", so you get what you ask for. Unless you don't care about an argument at all, using '_' is counterproductive for maintenance. But that's the usual tension between being able to write something down quickly which works *now* and writing something which will be maintained for a long time by lots of people. So '_' itself is fine, but you should be aware of what kind of SW you are writing. Implicitness will always hurt you sooner or later, it is only a matter of time, and '_' has a very implicit flavor. For exactly this reason, using C++'s "default" case was banned in the last 2 companies I've worked for, and this turned out to be very beneficial: Finding all the places where a "default" was not really the default anymore hit us several times and resulted in actual bugs in released SW. Banning '_', just like Christopher mentioned, seems to be a sensible approach. -------------- next part -------------- An HTML attachment was scrubbed... URL: From dct25-561bs at mythic-beasts.com Tue Jan 31 08:11:07 2017 From: dct25-561bs at mythic-beasts.com (David Turner) Date: Tue, 31 Jan 2017 08:11:07 +0000 Subject: [Haskell-cafe] Ensuring all values of an ADT are explicitly handled OR finding all occurrences of type X in my app In-Reply-To: References: <9750a089-55aa-1e1f-8868-a0c0da0bf9b3@orlitzky.com> Message-ID: I've done exactly this a number of times. The approach I generally take is to define a completely new ADT, mark the old one as deprecated, and then simply plough through the compiler warnings and errors, which is a mostly mechanical process. On occasion I've written a (temporary) injection from the old datatype into the new one which lets you make the changes piecemeal (by topologically sorting the usages) which is nice as if there's any risk of making a mistake then tools like `git bisect` can help you find the slip in the sea of otherwise identical changes. Doesn't always work smoothly but it's often ok. This also has the advantage that you don't have to fix all the usages in third-party code or dependent libraries straight away. The deprecation step need not be immediate, depending on how stable your API is supposed to be. Cheers, David On 31 Jan 2017 06:48, "Saurabh Nanda" wrote: > Btw, what about the other approach -- listing all possible occurrences of > type X throughout the app? > > -- Saurabh. > > On Tue, Jan 31, 2017 at 12:15 PM, Saurabh Nanda > wrote: > >> We want this at my company too, so we don't write fall-through cases. >>> >> >> That's a short-term workaround, yes. However it doesn't fit into >> Haskell's overall story of language-enforced correctness. >> >> -- Saurabh. >> > > > > -- > http://www.saurabhnanda.com > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From alan.zimm at gmail.com Tue Jan 31 08:41:23 2017 From: alan.zimm at gmail.com (Alan & Kim Zimmerman) Date: Tue, 31 Jan 2017 10:41:23 +0200 Subject: [Haskell-cafe] Ensuring all values of an ADT are explicitly handled OR finding all occurrences of type X in my app In-Reply-To: References: <9750a089-55aa-1e1f-8868-a0c0da0bf9b3@orlitzky.com> Message-ID: I can envisage some sort of tooling to fill in all the unmatched cases, based on the GHC warnings. Which can make the editing process trivial, for the "make it work quickly" case. On 31 January 2017 at 10:11, David Turner wrote: > I've done exactly this a number of times. The approach I generally take is > to define a completely new ADT, mark the old one as deprecated, and then > simply plough through the compiler warnings and errors, which is a mostly > mechanical process. > > On occasion I've written a (temporary) injection from the old datatype > into the new one which lets you make the changes piecemeal (by > topologically sorting the usages) which is nice as if there's any risk of > making a mistake then tools like `git bisect` can help you find the slip in > the sea of otherwise identical changes. Doesn't always work smoothly but > it's often ok. > > This also has the advantage that you don't have to fix all the usages in > third-party code or dependent libraries straight away. The deprecation step > need not be immediate, depending on how stable your API is supposed to be. > > Cheers, > > David > > On 31 Jan 2017 06:48, "Saurabh Nanda" wrote: > >> Btw, what about the other approach -- listing all possible occurrences of >> type X throughout the app? >> >> -- Saurabh. >> >> On Tue, Jan 31, 2017 at 12:15 PM, Saurabh Nanda >> wrote: >> >>> We want this at my company too, so we don't write fall-through cases. >>>> >>> >>> That's a short-term workaround, yes. However it doesn't fit into >>> Haskell's overall story of language-enforced correctness. >>> >>> -- Saurabh. >>> >> >> >> >> -- >> http://www.saurabhnanda.com >> >> _______________________________________________ >> Haskell-Cafe mailing list >> To (un)subscribe, modify options or view archives go to: >> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe >> Only members subscribed via the mailman list are allowed to post. >> > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From marian.jancar at gmx.com Tue Jan 31 10:44:45 2017 From: marian.jancar at gmx.com (Marian Jancar) Date: Tue, 31 Jan 2017 11:44:45 +0100 Subject: [Haskell-cafe] Haskell IDEs Message-ID: An HTML attachment was scrubbed... URL: From agocorona at gmail.com Tue Jan 31 10:58:26 2017 From: agocorona at gmail.com (Alberto G. Corona ) Date: Tue, 31 Jan 2017 11:58:26 +0100 Subject: [Haskell-cafe] Haskell IDEs In-Reply-To: <08EF9DA445C4B5439C4733E1F35705BA065BF53866BA@MAIL.cs.mum.edu> References: <08EF9DA445C4B5439C4733E1F35705BA065BF53866BA@MAIL.cs.mum.edu> Message-ID: If you are a Teacher, give Leksah a second opportunity. It is the only IDE AFAIK that integrates the Haskell debugger. It is invaluable for teaching how expressions are executed lazily. You can observer graphically how the execution goes back and forth executing lazily at the finest level 2017-01-30 15:53 GMT+01:00 Gregory Guthrie : > The Wiki on Haskell IDEs seems to be out of date. > > > > It mentions KDevelop, which no longer has any references to Haskell on its > site, and to FPeclipse which was orphaned in 2015. > > > > I find Leksah rather cumbersome to use/learn (for students), and it is > still a bit hard to convince them after Netbeans & Eclipse to fall back to > Vi and DOS command windows. J > > > > > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. > -- Alberto. -------------- next part -------------- An HTML attachment was scrubbed... URL: From eric at seidel.io Tue Jan 31 15:52:18 2017 From: eric at seidel.io (Eric Seidel) Date: Tue, 31 Jan 2017 07:52:18 -0800 Subject: [Haskell-cafe] Ensuring all values of an ADT are explicitly handled OR finding all occurrences of type X in my app In-Reply-To: References: <9750a089-55aa-1e1f-8868-a0c0da0bf9b3@orlitzky.com> Message-ID: I think the best solution here would be a new warning, say -fwarn-wildcard-patterns. This would be a simple syntactic check for a wildcard pattern anywhere in the module. Combined with -Werror you would be prevented from compiling programs with wildcards. I think this would be quite valuable given the rest of the comments in the thread, and probably a simple addition to GHC. Eric > On Jan 30, 2017, at 20:59, Saurabh Nanda wrote: > > I would want the compiler (or linter) to help me here. Think if a mid-to-large team where everyone may not know (or remember) what the current best practices are. > > On 31 Jan 2017 9:51 am, "Michael Orlitzky" wrote: > On 01/30/2017 09:47 PM, Saurabh Nanda wrote: > > Hi, > > > > If I have the following ADT > > > > data BookingState = Confirmed | Cancelled > > > > which had a very high chance of being expanded in the future to have more > > values. How do I ensure that every pattern match on BookingState matches > > each value explicitly. Basically prevent the '_' matcher ? > > > > Don't write the "_" case? GHC will warn you about any pattern matches > you've missed. > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. From monnier at iro.umontreal.ca Tue Jan 31 17:11:50 2017 From: monnier at iro.umontreal.ca (Stefan Monnier) Date: Tue, 31 Jan 2017 12:11:50 -0500 Subject: [Haskell-cafe] Ensuring all values of an ADT are explicitly handled OR finding all occurrences of type X in my app References: <9750a089-55aa-1e1f-8868-a0c0da0bf9b3@orlitzky.com> Message-ID: > I think the best solution here would be a new warning, > say -fwarn-wildcard-patterns. This would be a simple syntactic check > for a wildcard pattern anywhere in the module. Note that case | [] -> ... | (_ : xs) -> ... also contains a wildcard-pattern. So emitting a warning for every use of wildcard patterns would likely lead to a lot of pain. You'd instead want to warn about "default branch", e.g. case | [] -> ... | (1 : xs) -> ... | (_ : xs) -> ... here the wildcard pattern does correspond to a "default branch" and might hence deserve a warning. Stefan From eric at seidel.io Tue Jan 31 17:31:13 2017 From: eric at seidel.io (Eric Seidel) Date: Tue, 31 Jan 2017 09:31:13 -0800 Subject: [Haskell-cafe] Ensuring all values of an ADT are explicitly handled OR finding all occurrences of type X in my app In-Reply-To: References: <9750a089-55aa-1e1f-8868-a0c0da0bf9b3@orlitzky.com> Message-ID: <7FDB999E-5342-466B-BD6F-BDEE2DF3328B@seidel.io> > Note that > > case > | [] -> ... > | (_ : xs) -> ... > > also contains a wildcard-pattern. So emitting a warning for every use > of wildcard patterns would likely lead to a lot of pain. Yes, good point, that would be too restrictive. When I said wildcard-pattern I was thinking specifically of a top-level wildcard, so your example would be accepted, but e.g. case ... of [] -> ... _ -> ... would be rejected. > You'd instead want to warn about "default branch", e.g. > > case > | [] -> ... > | (1 : xs) -> ... > | (_ : xs) -> ... > > here the wildcard pattern does correspond to a "default branch" and > might hence deserve a warning. This sounds promising, but how would you define “default branch”? Seems like it could be an involved definition, which could make the warning unpredictable for users. From trebla at vex.net Tue Jan 31 17:35:37 2017 From: trebla at vex.net (Albert Y. C. Lai) Date: Tue, 31 Jan 2017 12:35:37 -0500 Subject: [Haskell-cafe] Lazy ST test code In-Reply-To: References: <21e88a6f-4803-ab9d-8ae6-88a9d730c95b@vex.net> Message-ID: OK yes, this is my message of explicit consent (in case it is needed). On 2017-01-31 12:48 AM, David Feuer wrote: > Thanks! I'll include these in my proposed additions to the GHC test > suite, with your permission (releasing them under GHC's license terms). > > On Jan 30, 2017 2:28 PM, "Albert Y. C. Lai" > wrote: > > On 2017-01-29 02:22 AM, David Feuer wrote: > > I've come up with what might be a fix for a major thread safety > bug in > lazy ST. Fixing it involved making multiple non-trivial changes to a > number of basic functions. Unfortunately, the GHC test suite barely > touches lazy ST. Does anyone out there have some code that uses > lazy ST > in interesting ways but that only relies on the libraries that > ship with > GHC? > > > I don't normally use lazy ST, but I have some toy examples at > http://lpaste.net/63925 . You may like the fact that I got > strictToLazyST involved. > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > > Only members subscribed via the mailman list are allowed to post. > > > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. > From iavor.diatchki at gmail.com Tue Jan 31 18:03:10 2017 From: iavor.diatchki at gmail.com (Iavor Diatchki) Date: Tue, 31 Jan 2017 10:03:10 -0800 Subject: [Haskell-cafe] Galois is hiring again! Message-ID: Hello, We have more openings at Galois, for a variety of positions, including researchers, principle investigators, software engineers, project leads, and some others. The full list is available at: http://galois.com/careers/#careers-list We are looking for people with strong background in one or more of the following areas: functional programming, formal methods, machine learning, embedded systems, computer security, and networking. Galois has two offices, one on the west coast of the US, in Portland, Oregon, and one on the east coast, in Arlington, Virginia. There are positions available at both offices. Generally, we are looking for candidates who are allowed to work in the US, and are interested in working locally at one of the two offices. If this sounds exciting, please consider sending us your resume. The descriptions of the positions each contains an application link. Cheers, -Iavor -------------- next part -------------- An HTML attachment was scrubbed... URL: From hesselink at gmail.com Tue Jan 31 19:31:43 2017 From: hesselink at gmail.com (Erik Hesselink) Date: Tue, 31 Jan 2017 20:31:43 +0100 Subject: [Haskell-cafe] Ensuring all values of an ADT are explicitly handled OR finding all occurrences of type X in my app In-Reply-To: <7FDB999E-5342-466B-BD6F-BDEE2DF3328B@seidel.io> References: <9750a089-55aa-1e1f-8868-a0c0da0bf9b3@orlitzky.com> <7FDB999E-5342-466B-BD6F-BDEE2DF3328B@seidel.io> Message-ID: I feel like there's no good technical solution here. For example, this is potentially dangerous in the face of a changing data type, but presumably wouldn't fall under the definition of a "default branch": data T = A | B -- Later, C could be added which might need special handling case ... of [] -> ... (A : xs) -> ... (_ : xs) -> ... On the other hand, this would presumably be a "default branch" but I challenge you to replace the wildcard pattern with an exhaustive list of pattern matches: case ... of 0 -> ... 1 -> ... _ -> ... Of course this is a special case, but there are many data types in the wild with a large number of constructors: think of generated enumerations, for example. I'd say education is the best option here. I thought wildcards were convenient, until I realized their effect on maintainability in the face of future data type changes. Erik On 31 January 2017 at 18:31, Eric Seidel wrote: > > > Note that > > > > case > > | [] -> ... > > | (_ : xs) -> ... > > > > also contains a wildcard-pattern. So emitting a warning for every use > > of wildcard patterns would likely lead to a lot of pain. > > Yes, good point, that would be too restrictive. When I said > wildcard-pattern I was thinking specifically of a top-level wildcard, so > your example would be accepted, but e.g. > > case ... of > [] -> ... > _ -> ... > > would be rejected. > > > You'd instead want to warn about "default branch", e.g. > > > > case > > | [] -> ... > > | (1 : xs) -> ... > > | (_ : xs) -> ... > > > > here the wildcard pattern does correspond to a "default branch" and > > might hence deserve a warning. > > This sounds promising, but how would you define “default branch”? Seems > like it could be an involved definition, which could make the warning > unpredictable for users. > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at joachim-breitner.de Tue Jan 31 20:22:35 2017 From: mail at joachim-breitner.de (Joachim Breitner) Date: Tue, 31 Jan 2017 15:22:35 -0500 Subject: [Haskell-cafe] What is this applicative functor? Message-ID: <1485894155.1237.7.camel@joachim-breitner.de> Hi, I recently wrote this applicative functor: data OneStep a = OneStep a [a] instance Functor OneStep where     fmap f (OneStep o s) = OneStep (f o) (map f s) instance Applicative OneStep where     pure x = OneStep x []     OneStep f fs <*> OneStep x xs = OneStep (f x) (map ($x) fs ++ map f xs) takeOneStep :: OneStep t -> [t] takeOneStep (OneStep _ xs) = xs This was useful in the context of writing a shrink for QuickCheck, as discussed at http://stackoverflow.com/a/41944525/946226. Now I wonder: Does this functor have a proper name? Does it already exist in the libraries somewhere? Should it? Greetings, Joachim -- Joachim “nomeata” Breitner   mail at joachim-breitner.de • https://www.joachim-breitner.de/   XMPP: nomeata at joachim-breitner.de • OpenPGP-Key: 0xF0FBF51F   Debian Developer: nomeata at debian.org -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: This is a digitally signed message part URL: From cma at bitemyapp.com Tue Jan 31 20:24:31 2017 From: cma at bitemyapp.com (Christopher Allen) Date: Tue, 31 Jan 2017 14:24:31 -0600 Subject: [Haskell-cafe] What is this applicative functor? In-Reply-To: <1485894155.1237.7.camel@joachim-breitner.de> References: <1485894155.1237.7.camel@joachim-breitner.de> Message-ID: NonEmpty? On Tue, Jan 31, 2017 at 2:22 PM, Joachim Breitner wrote: > Hi, > > I recently wrote this applicative functor: > > data OneStep a = OneStep a [a] > > instance Functor OneStep where > fmap f (OneStep o s) = OneStep (f o) (map f s) > > instance Applicative OneStep where > pure x = OneStep x [] > OneStep f fs <*> OneStep x xs = OneStep (f x) (map ($x) fs ++ map f xs) > > takeOneStep :: OneStep t -> [t] > takeOneStep (OneStep _ xs) = xs > > This was useful in the context of writing a shrink for QuickCheck, as > discussed at http://stackoverflow.com/a/41944525/946226. > > Now I wonder: Does this functor have a proper name? Does it already > exist in the libraries somewhere? Should it? > > Greetings, > Joachim > > -- > Joachim “nomeata” Breitner > mail at joachim-breitner.de • https://www.joachim-breitner.de/ > XMPP: nomeata at joachim-breitner.de • OpenPGP-Key: 0xF0FBF51F > Debian Developer: nomeata at debian.org > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. -- Chris Allen Currently working on http://haskellbook.com From mail at joachim-breitner.de Tue Jan 31 20:36:00 2017 From: mail at joachim-breitner.de (Joachim Breitner) Date: Tue, 31 Jan 2017 15:36:00 -0500 Subject: [Haskell-cafe] What is this applicative functor? In-Reply-To: References: <1485894155.1237.7.camel@joachim-breitner.de> Message-ID: <1485894960.1237.9.camel@joachim-breitner.de> Hi, good idea, but no. The datatypes are superficially equivalent, but the Applicative instance differs: With NonEmpty’s instance: > (,) <$> 0 :| [1,2] <*> 3 :| [4,5] (0,3) :| [(0,4),(0,5),(1,3),(1,4),(1,5),(2,3),(2,4),(2,5)] with my instance: > (,) <$> 0 :| [1,2] <*> 3 :| [4,5] (0,3) :| [(1,3),(2,3),(0,4),(0,5)] Greetings, Joachim Am Dienstag, den 31.01.2017, 14:24 -0600 schrieb Christopher Allen: > NonEmpty? > > On Tue, Jan 31, 2017 at 2:22 PM, Joachim Breitner > wrote: > > Hi, > > > > I recently wrote this applicative functor: > > > >     data OneStep a = OneStep a [a] > > > >     instance Functor OneStep where > >         fmap f (OneStep o s) = OneStep (f o) (map f s) > > > >     instance Applicative OneStep where > >         pure x = OneStep x [] > >         OneStep f fs <*> OneStep x xs = OneStep (f x) (map ($x) fs > > ++ map f xs) > > > >     takeOneStep :: OneStep t -> [t] > >     takeOneStep (OneStep _ xs) = xs > > > > This was useful in the context of writing a shrink for QuickCheck, > > as > > discussed at http://stackoverflow.com/a/41944525/946226. > > > > Now I wonder: Does this functor have a proper name? Does it already > > exist in the libraries somewhere? Should it? > > > > Greetings, > > Joachim > > > > -- > > Joachim “nomeata” Breitner > >   mail at joachim-breitner.de • https://www.joachim-breitner.de/ > >   XMPP: nomeata at joachim-breitner.de • OpenPGP-Key: 0xF0FBF51F > >   Debian Developer: nomeata at debian.org > > _______________________________________________ > > Haskell-Cafe mailing list > > To (un)subscribe, modify options or view archives go to: > > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > > Only members subscribed via the mailman list are allowed to post. > > > -- Joachim “nomeata” Breitner   mail at joachim-breitner.de • https://www.joachim-breitner.de/   XMPP: nomeata at joachim-breitner.de • OpenPGP-Key: 0xF0FBF51F   Debian Developer: nomeata at debian.org -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: This is a digitally signed message part URL: From cma at bitemyapp.com Tue Jan 31 20:41:43 2017 From: cma at bitemyapp.com (Christopher Allen) Date: Tue, 31 Jan 2017 14:41:43 -0600 Subject: [Haskell-cafe] What is this applicative functor? In-Reply-To: <1485894960.1237.9.camel@joachim-breitner.de> References: <1485894155.1237.7.camel@joachim-breitner.de> <1485894960.1237.9.camel@joachim-breitner.de> Message-ID: Ah right, I didn't stare hard enough at the Applicative. If I squint a bit at the results of your Applicative instance it seems similar to the difference between []'s Applicative and the ZipList Applicative, except a little crossed up. Sure you already identified that, sorry I don't have more to offer here. On Tue, Jan 31, 2017 at 2:36 PM, Joachim Breitner wrote: > Hi, > > good idea, but no. The datatypes are superficially equivalent, but the > Applicative instance differs: > > With NonEmpty’s instance: > >> (,) <$> 0 :| [1,2] <*> 3 :| [4,5] > (0,3) :| [(0,4),(0,5),(1,3),(1,4),(1,5),(2,3),(2,4),(2,5)] > > with my instance: > >> (,) <$> 0 :| [1,2] <*> 3 :| [4,5] > (0,3) :| [(1,3),(2,3),(0,4),(0,5)] > > Greetings, > Joachim > > Am Dienstag, den 31.01.2017, 14:24 -0600 schrieb Christopher Allen: >> NonEmpty? >> >> On Tue, Jan 31, 2017 at 2:22 PM, Joachim Breitner >> wrote: >> > Hi, >> > >> > I recently wrote this applicative functor: >> > >> > data OneStep a = OneStep a [a] >> > >> > instance Functor OneStep where >> > fmap f (OneStep o s) = OneStep (f o) (map f s) >> > >> > instance Applicative OneStep where >> > pure x = OneStep x [] >> > OneStep f fs <*> OneStep x xs = OneStep (f x) (map ($x) fs >> > ++ map f xs) >> > >> > takeOneStep :: OneStep t -> [t] >> > takeOneStep (OneStep _ xs) = xs >> > >> > This was useful in the context of writing a shrink for QuickCheck, >> > as >> > discussed at http://stackoverflow.com/a/41944525/946226. >> > >> > Now I wonder: Does this functor have a proper name? Does it already >> > exist in the libraries somewhere? Should it? >> > >> > Greetings, >> > Joachim >> > >> > -- >> > Joachim “nomeata” Breitner >> > mail at joachim-breitner.de • https://www.joachim-breitner.de/ >> > XMPP: nomeata at joachim-breitner.de • OpenPGP-Key: 0xF0FBF51F >> > Debian Developer: nomeata at debian.org >> > _______________________________________________ >> > Haskell-Cafe mailing list >> > To (un)subscribe, modify options or view archives go to: >> > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe >> > Only members subscribed via the mailman list are allowed to post. >> >> >> > -- > Joachim “nomeata” Breitner > mail at joachim-breitner.de • https://www.joachim-breitner.de/ > XMPP: nomeata at joachim-breitner.de • OpenPGP-Key: 0xF0FBF51F > Debian Developer: nomeata at debian.org > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. -- Chris Allen Currently working on http://haskellbook.com From parsonsmatt at gmail.com Tue Jan 31 21:25:58 2017 From: parsonsmatt at gmail.com (Matt) Date: Tue, 31 Jan 2017 16:25:58 -0500 Subject: [Haskell-cafe] What is this applicative functor? In-Reply-To: References: <1485894155.1237.7.camel@joachim-breitner.de> <1485894960.1237.9.camel@joachim-breitner.de> Message-ID: Interestingly, neither NEL nor OneStep behave the same as `Product Identity []`: λ> let a = Pair (Identity 0) [1,2] λ> let b = Pair (Identity 3) [4,5] λ> (,) <$> a <*> b Pair (Identity (0,3)) [(1,4),(1,5),(2,4),(2,5)] So many applicatives! Matt Parsons On Tue, Jan 31, 2017 at 3:41 PM, Christopher Allen wrote: > Ah right, I didn't stare hard enough at the Applicative. > > If I squint a bit at the results of your Applicative instance it seems > similar to the difference between []'s Applicative and the ZipList > Applicative, except a little crossed up. Sure you already identified > that, sorry I don't have more to offer here. > > On Tue, Jan 31, 2017 at 2:36 PM, Joachim Breitner > wrote: > > Hi, > > > > good idea, but no. The datatypes are superficially equivalent, but the > > Applicative instance differs: > > > > With NonEmpty’s instance: > > > >> (,) <$> 0 :| [1,2] <*> 3 :| [4,5] > > (0,3) :| [(0,4),(0,5),(1,3),(1,4),(1,5),(2,3),(2,4),(2,5)] > > > > with my instance: > > > >> (,) <$> 0 :| [1,2] <*> 3 :| [4,5] > > (0,3) :| [(1,3),(2,3),(0,4),(0,5)] > > > > Greetings, > > Joachim > > > > Am Dienstag, den 31.01.2017, 14:24 -0600 schrieb Christopher Allen: > >> NonEmpty? > >> > >> On Tue, Jan 31, 2017 at 2:22 PM, Joachim Breitner > >> wrote: > >> > Hi, > >> > > >> > I recently wrote this applicative functor: > >> > > >> > data OneStep a = OneStep a [a] > >> > > >> > instance Functor OneStep where > >> > fmap f (OneStep o s) = OneStep (f o) (map f s) > >> > > >> > instance Applicative OneStep where > >> > pure x = OneStep x [] > >> > OneStep f fs <*> OneStep x xs = OneStep (f x) (map ($x) fs > >> > ++ map f xs) > >> > > >> > takeOneStep :: OneStep t -> [t] > >> > takeOneStep (OneStep _ xs) = xs > >> > > >> > This was useful in the context of writing a shrink for QuickCheck, > >> > as > >> > discussed at http://stackoverflow.com/a/41944525/946226. > >> > > >> > Now I wonder: Does this functor have a proper name? Does it already > >> > exist in the libraries somewhere? Should it? > >> > > >> > Greetings, > >> > Joachim > >> > > >> > -- > >> > Joachim “nomeata” Breitner > >> > mail at joachim-breitner.de • https://www.joachim-breitner.de/ > >> > XMPP: nomeata at joachim-breitner.de • OpenPGP-Key: 0xF0FBF51F > >> > Debian Developer: nomeata at debian.org > >> > _______________________________________________ > >> > Haskell-Cafe mailing list > >> > To (un)subscribe, modify options or view archives go to: > >> > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > >> > Only members subscribed via the mailman list are allowed to post. > >> > >> > >> > > -- > > Joachim “nomeata” Breitner > > mail at joachim-breitner.de • https://www.joachim-breitner.de/ > > XMPP: nomeata at joachim-breitner.de • OpenPGP-Key: 0xF0FBF51F > > Debian Developer: nomeata at debian.org > > > > _______________________________________________ > > Haskell-Cafe mailing list > > To (un)subscribe, modify options or view archives go to: > > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > > Only members subscribed via the mailman list are allowed to post. > > > > -- > Chris Allen > Currently working on http://haskellbook.com > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From cma at bitemyapp.com Tue Jan 31 21:32:16 2017 From: cma at bitemyapp.com (Christopher Allen) Date: Tue, 31 Jan 2017 15:32:16 -0600 Subject: [Haskell-cafe] What is this applicative functor? In-Reply-To: References: <1485894155.1237.7.camel@joachim-breitner.de> <1485894960.1237.9.camel@joachim-breitner.de> Message-ID: I must confess, this one's behavior makes more sense to me. It's the product of the guaranteed values and the cartesian product. On Tue, Jan 31, 2017 at 3:25 PM, Matt wrote: > Interestingly, neither NEL nor OneStep behave the same as `Product Identity > []`: > > λ> let a = Pair (Identity 0) [1,2] > λ> let b = Pair (Identity 3) [4,5] > λ> (,) <$> a <*> b > Pair (Identity (0,3)) [(1,4),(1,5),(2,4),(2,5)] > > So many applicatives! > > Matt Parsons > > On Tue, Jan 31, 2017 at 3:41 PM, Christopher Allen > wrote: >> >> Ah right, I didn't stare hard enough at the Applicative. >> >> If I squint a bit at the results of your Applicative instance it seems >> similar to the difference between []'s Applicative and the ZipList >> Applicative, except a little crossed up. Sure you already identified >> that, sorry I don't have more to offer here. >> >> On Tue, Jan 31, 2017 at 2:36 PM, Joachim Breitner >> wrote: >> > Hi, >> > >> > good idea, but no. The datatypes are superficially equivalent, but the >> > Applicative instance differs: >> > >> > With NonEmpty’s instance: >> > >> >> (,) <$> 0 :| [1,2] <*> 3 :| [4,5] >> > (0,3) :| [(0,4),(0,5),(1,3),(1,4),(1,5),(2,3),(2,4),(2,5)] >> > >> > with my instance: >> > >> >> (,) <$> 0 :| [1,2] <*> 3 :| [4,5] >> > (0,3) :| [(1,3),(2,3),(0,4),(0,5)] >> > >> > Greetings, >> > Joachim >> > >> > Am Dienstag, den 31.01.2017, 14:24 -0600 schrieb Christopher Allen: >> >> NonEmpty? >> >> >> >> On Tue, Jan 31, 2017 at 2:22 PM, Joachim Breitner >> >> wrote: >> >> > Hi, >> >> > >> >> > I recently wrote this applicative functor: >> >> > >> >> > data OneStep a = OneStep a [a] >> >> > >> >> > instance Functor OneStep where >> >> > fmap f (OneStep o s) = OneStep (f o) (map f s) >> >> > >> >> > instance Applicative OneStep where >> >> > pure x = OneStep x [] >> >> > OneStep f fs <*> OneStep x xs = OneStep (f x) (map ($x) fs >> >> > ++ map f xs) >> >> > >> >> > takeOneStep :: OneStep t -> [t] >> >> > takeOneStep (OneStep _ xs) = xs >> >> > >> >> > This was useful in the context of writing a shrink for QuickCheck, >> >> > as >> >> > discussed at http://stackoverflow.com/a/41944525/946226. >> >> > >> >> > Now I wonder: Does this functor have a proper name? Does it already >> >> > exist in the libraries somewhere? Should it? >> >> > >> >> > Greetings, >> >> > Joachim >> >> > >> >> > -- >> >> > Joachim “nomeata” Breitner >> >> > mail at joachim-breitner.de • https://www.joachim-breitner.de/ >> >> > XMPP: nomeata at joachim-breitner.de • OpenPGP-Key: 0xF0FBF51F >> >> > Debian Developer: nomeata at debian.org >> >> > _______________________________________________ >> >> > Haskell-Cafe mailing list >> >> > To (un)subscribe, modify options or view archives go to: >> >> > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe >> >> > Only members subscribed via the mailman list are allowed to post. >> >> >> >> >> >> >> > -- >> > Joachim “nomeata” Breitner >> > mail at joachim-breitner.de • https://www.joachim-breitner.de/ >> > XMPP: nomeata at joachim-breitner.de • OpenPGP-Key: 0xF0FBF51F >> > Debian Developer: nomeata at debian.org >> > >> > _______________________________________________ >> > Haskell-Cafe mailing list >> > To (un)subscribe, modify options or view archives go to: >> > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe >> > Only members subscribed via the mailman list are allowed to post. >> >> >> >> -- >> Chris Allen >> Currently working on http://haskellbook.com >> _______________________________________________ >> Haskell-Cafe mailing list >> To (un)subscribe, modify options or view archives go to: >> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe >> Only members subscribed via the mailman list are allowed to post. > > -- Chris Allen Currently working on http://haskellbook.com From li-yao.xia at ens.fr Tue Jan 31 18:56:04 2017 From: li-yao.xia at ens.fr (Li-yao Xia) Date: Tue, 31 Jan 2017 19:56:04 +0100 Subject: [Haskell-cafe] Ensuring all values of an ADT are explicitly handled OR finding all occurrences of type X in my app In-Reply-To: <7FDB999E-5342-466B-BD6F-BDEE2DF3328B@seidel.io> References: <9750a089-55aa-1e1f-8868-a0c0da0bf9b3@orlitzky.com> <7FDB999E-5342-466B-BD6F-BDEE2DF3328B@seidel.io> Message-ID: <37f5d585-2a12-7989-9a98-a24c9f8d3412@ens.fr> >> You'd instead want to warn about "default branch", e.g. >> >> case >> | [] -> ... >> | (1 : xs) -> ... >> | (_ : xs) -> ... >> >> here the wildcard pattern does correspond to a "default branch" and >> might hence deserve a warning. > > This sounds promising, but how would you define “default branch”? Seems like it could be an involved definition, which could make the warning unpredictable for users. A "default branch" seems to correspond to a wildcard overlapping a previous pattern. This would be a warning symmetrical to -Woverlapping-patterns. - A wildcard which overlaps with a pattern below it makes the latter unreachable, which is certainly not intentional. This is caught by -Woverlapping-patterns. case x of _ -> y C -> z - A wildcard which overlaps with a pattern above it has the risk mentionned in this thread, that it will catch any new constructor added to the corresponding ADT, and thus the programmer may forget to update some case expressions when the new constructor is to be handled differently. case x of C -> y _ -> z Li-yao