From will.yager at gmail.com Sat Jul 1 01:43:57 2017 From: will.yager at gmail.com (Will Yager) Date: Sat, 1 Jul 2017 08:43:57 +0700 Subject: [Haskell-cafe] Nice clean code example? In-Reply-To: References: Message-ID: <09BB0430-A343-4C8F-B333-4DDEEEC084B1@gmail.com> I wrote this specifically to be easy to read despite using some cool features (green threads, STM, etc.): https://github.com/wyager/Neks Will > On Jul 1, 2017, at 1:33 AM, Han Joosten wrote: > > I'd like to showoff some nice Haskell code to a CTO with no experience with FP. I promised to send him a small piece of Haskell so he could get an idea. The code should be easy to read, without obscure looking operators (so sorry, no lens, arrows stuff like that), optionally even do something interesting. > Who has the nicest example laying around? > > (and yes, I need it by yesterday ;-) ) > > Thanks! > _______________________________________________ > 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 han.joosten.han at gmail.com Sat Jul 1 10:08:59 2017 From: han.joosten.han at gmail.com (Han Joosten) Date: Sat, 1 Jul 2017 12:08:59 +0200 Subject: [Haskell-cafe] Nice clean code example? In-Reply-To: <09BB0430-A343-4C8F-B333-4DDEEEC084B1@gmail.com> References: <09BB0430-A343-4C8F-B333-4DDEEEC084B1@gmail.com> Message-ID: Thanks everyone for the awsome examples. I really enjoy the deversity of them. This tops my expectations 8-) 2017-07-01 3:43 GMT+02:00 Will Yager : > I wrote this specifically to be easy to read despite using some cool > features (green threads, STM, etc.): > > https://github.com/wyager/Neks > > Will > > > On Jul 1, 2017, at 1:33 AM, Han Joosten wrote: > > I'd like to showoff some nice Haskell code to a CTO with no experience > with FP. I promised to send him a small piece of Haskell so he could get an > idea. The code should be easy to read, without obscure looking operators > (so sorry, no lens, arrows stuff like that), optionally even do something > interesting. > Who has the nicest example laying around? > > (and yes, I need it by yesterday ;-) ) > > Thanks! > > _______________________________________________ > 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 imantc at gmail.com Sat Jul 1 10:23:38 2017 From: imantc at gmail.com (Imants Cekusins) Date: Sat, 1 Jul 2017 13:23:38 +0300 Subject: [Haskell-cafe] Nice clean code example? In-Reply-To: References: <09BB0430-A343-4C8F-B333-4DDEEEC084B1@gmail.com> Message-ID: This online book shows clear working examples in a variety of contexts : http://book.realworldhaskell.org/read Visitor is literally 2 clicks away from code examples in areas of interest to them. On 1 July 2017 at 13:08, Han Joosten wrote: > Thanks everyone for the awsome examples. I really enjoy the deversity of > them. This tops my expectations 8-) > > 2017-07-01 3:43 GMT+02:00 Will Yager : > >> I wrote this specifically to be easy to read despite using some cool >> features (green threads, STM, etc.): >> >> https://github.com/wyager/Neks >> >> Will >> >> >> On Jul 1, 2017, at 1:33 AM, Han Joosten >> wrote: >> >> I'd like to showoff some nice Haskell code to a CTO with no experience >> with FP. I promised to send him a small piece of Haskell so he could get an >> idea. The code should be easy to read, without obscure looking operators >> (so sorry, no lens, arrows stuff like that), optionally even do something >> interesting. >> Who has the nicest example laying around? >> >> (and yes, I need it by yesterday ;-) ) >> >> Thanks! >> >> _______________________________________________ >> 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 qdunkan at gmail.com Sat Jul 1 15:10:38 2017 From: qdunkan at gmail.com (Evan Laforge) Date: Sat, 1 Jul 2017 08:10:38 -0700 Subject: [Haskell-cafe] install haddock only with cabal? Message-ID: It's pretty common to wind up with a package installed, but not its haddock. Pretty much any time you install the traditional way via runhaskell Setup.hs you can forget to run haddock, since it doesn't use ~/.cabal/config. And even if you do, it doesn't update the haddock html index. But it seems like cabal install wants to install all targets in the cabal file, which means it wants to reinstall, which is no good for e.g. 'stm'. In fact I can't tell any way to address individual targets (e.g. if I just want to install the executable), and haddock doesn't seem to be a proper target at all, and I can't find any documentation about it. I can run 'haddock' and manually copy dist/doc/html to ~/.cabal/share/doc/$arch/$package/, but shouldn't cabal be able to do that? Also, it looks like regenerateHaddockIndex is hardcoded into the postInstallActions, and there's no way to run it independently, so it seems if you missed documentation on some package, you have to reinstall everything from scratch to fix it. Is there a way to install just haddock without going through all that? And shouldn't cabal-install/bootstrap.sh make the haddock index? Otherwise, you're guaranteed to be missing links for a bunch of fundamental packages. Or maybe it could default to using its (undocumented?) --sandbox flag to install just the binary, and not the various libraries (which are also likely to be missing desired flags, like --enable-profiling, since ~/.cabal/config is not available yet). From simon at joyful.com Sat Jul 1 17:52:37 2017 From: simon at joyful.com (Simon Michael) Date: Sat, 1 Jul 2017 18:52:37 +0100 Subject: [Haskell-cafe] ANN: hledger 1.3 Message-ID: <3A5EB146-F2E3-4013-BBAC-25804BFD83BA@joyful.com> I'm pleased to announce hledger 1.3, released yesterday. Thank you release contributors: Mykola Orliuk, Christian G. Warden, Dmitry Astapov, Justin Le, Joe Horsnell, Nicolas Wavrant, afarrow, Carel Fellinger, flip111, David Reaver, Felix Yan, Nissar Chababy, and Jan Zerebecki. Notable user-visible changes in this release: terminology/UI improvements for the status field, selection/scrolling/movement improvements in hledger-ui, negative amounts shown in red, bugfixes. Full release notes are at http://hledger.org/release-notes#hledger-1.3 The next major release is scheduled for September 30. 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. It is a haskell reimplementation of Ledger, provides command-line, curses and web interfaces, and aims to be a robust, practical tool for daily use. To get started, install the stack tool, eg by downloading from http://haskell-lang.org/get-started. Then install hledger (and optionally the alternate UIs): $ stack install hledger-lib-1.3 hledger-1.3 [hledger-ui-1.3] [hledger-web-1.3] [hledger-api-1.3] (cabal experts can use that instead. See http://hledger.org/download for more install options.) Ensure $HOME/.local/bin is in your $PATH, and try some commands: $ hledger # list commands $ hledger -h # quick help $ hledger --man # man page for the hledger CLI tool $ hledger info journal # info manual for the journal format etc. Our IRC channel is #hledger on Freenode, and you can find out more at http://hledger.org. If you have benefitted from hledger, please give back and make it stronger! Donate using one of the funding links on the home page, give feedback, report bugs, send pull requests, write about it, or help in some other way. Thanks for your support; I hope you enjoy hledger and that it helps you achieve your goals. -Simon From dct25-561bs at mythic-beasts.com Sat Jul 1 19:07:46 2017 From: dct25-561bs at mythic-beasts.com (David Turner) Date: Sat, 1 Jul 2017 20:07:46 +0100 Subject: [Haskell-cafe] Fast JSON validation - reducing allocations In-Reply-To: <87shkaf563.fsf@ben-laptop.smart-cactus.org> References: <87bmqzgru9.fsf@ben-laptop.smart-cactus.org> <874lwqgr0l.fsf@ben-laptop.smart-cactus.org> <87shkaf563.fsf@ben-laptop.smart-cactus.org> Message-ID: Just thought I'd follow up now that we've upgraded from GHC 7.10 to GHC 8.0.2 (not 8.2 yet) and are now seeing this code validate the 900-byte sample document in <8us with <220 bytes of allocation. This is awesome. I'm not sure what we did to get 8.0.2 to realise it could make the loop this tight, and I'll look into it some more if I have the time and the inclination. There's been various changes since my OP, although nothing fundamental: a bug fix, support for insignificant whitespace, and removal of bounds checks on the arrays. We now pass the test suite from the appendix of http://seriot.ch/parsing_json.php (except for the ones for bare values - we only want arrays or objects). Thanks again for everyone's help. Cheers, David On 12 May 2017 at 16:47, Ben Gamari wrote: > Mikolaj Konarski writes: > > > Truly impressive. Amazing. > > > > I wonder what style of coding of inner loops > > leads to such good results in 8.2. Is it easy to describe? > > Or is the answer "any" or "simplest" or "natural"? If not, > > can it be captured as some recursion combinators perhaps? > > > My fairly unhelpful description would be that carefully-written programs > that look like they shouldn't allocate will be helped most. Previously > these program (e.g. probably the one here) would allocate closures due > to GHC's failure to identify some types of join points. In 8.2 our > treatment of join points is more robust and consequently this > unnecessary allocation will be more reliably eliminated. > > Cheers, > > - Ben > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From olf at aatal-apotheke.de Sun Jul 2 20:02:09 2017 From: olf at aatal-apotheke.de (Olaf Klinke) Date: Sun, 2 Jul 2017 22:02:09 +0200 Subject: [Haskell-cafe] Master programme with Haskell prospects Message-ID: <3A3DBAFF-55A6-471F-A024-170032AA26A3@aatal-apotheke.de> Please follow Abhiroop's advice. The English midlands is a great region for functional minds. There is not only Nottingham: There is Leeds, Birmingham, Leicester and Swansea nearby, all of which have CS departments with very experienced scientists in that area. The midlands have the midlands graduate school [1]! I did my degree at the University of Birmingham, whose CS department is, as I dare say, run by a bunch of mathematicians. You can find any level of abstractness there, ranging from compiling ML to hardware up to topos theory. It was there I decided to learn Haskell. Recently they had a graduate whose entire dissertation [2] has an Agda version [3] so you can not only read it, but also execute. Olaf [1] http://www.cs.nott.ac.uk/MGS/ [2] http://etheses.bham.ac.uk/5967/ [3] http://www.cs.bham.ac.uk/~mhe/continuity-false/ From doug at cs.dartmouth.edu Mon Jul 3 17:25:21 2017 From: doug at cs.dartmouth.edu (Doug McIlroy) Date: Mon, 03 Jul 2017 13:25:21 -0400 Subject: [Haskell-cafe] type (++) = (<>) Message-ID: <201707031725.v63HPL0d001962@coolidge.cs.Dartmouth.EDU> > What do you think of making (++) the same as (<>) Before Haskell 98, ++ was an overloadable operator associated with class MonadPlus. Why was that arrangement abolished? Doug From doug at cs.dartmouth.edu Mon Jul 3 17:29:17 2017 From: doug at cs.dartmouth.edu (Doug McIlroy) Date: Mon, 03 Jul 2017 13:29:17 -0400 Subject: [Haskell-cafe] type (++) = (<>) Message-ID: <201707031729.v63HTHu5001972@coolidge.cs.Dartmouth.EDU> > What do you think of making (++) the same as (<>) This seems to be a call for returning to the old situation in which (++) was an operator of class MonadPlus. Why was that abolished in Haskell 98? Doug From olf at aatal-apotheke.de Mon Jul 3 21:14:23 2017 From: olf at aatal-apotheke.de (Olaf Klinke) Date: Mon, 3 Jul 2017 23:14:23 +0200 Subject: [Haskell-cafe] representations of probability distributions Message-ID: <61E88050-B9D2-4956-B21D-E943E46E3F72@aatal-apotheke.de> Dear cafe, following up the announcement of bali-phy and the discussion that ensued, I'd like ask the cafe for an overview of representations of probability distributions as data types. It seems that all packages mentioned to far use some flavour of Markov chain. Why? What else is there? Can someone recommend a survey publication/book/talk? Explicitly I am interested in: - the data type, as in Haskell's type system - how an element of the data type relates to the distribution it describes - how the monad instance works (if there is one) - how to compute conditionals (if computable) - how to compute integrals (if computable) - what base types are supported (finite types, reals, products ...) Below is an incomplete, and possibly oversimplified (or even wrong), list of my own. Additions and corrections welcome. -- Olaf 1. Markov chains - uses a random number generator - type is something like Markov a = a -> IO a - repeated execution produces an infinite trace xs :: [a] where for each predicate p :: a -> Bool, the limit of (length (filter p (take n xs))) % n as n tends to infinity approaches the probability of p under the distribution modeled. - monad instance? - conditionals? - integrals? - supported base types a in Markov a? 2. Riesz functionals: possibly the most functional representation - representation as linear functionals Riesz a = (a -> R) -> R for a suitable real number type R - embed predicates in the type (a -> R) via characteristic functions characteristic p = \a -> if p a then 1 else 0 Then for a functional phi :: Riesz a and p :: a -> Bool, phi (characteristic p) is the probability of p. - Monad instance is the same as for the continuation monad - conditionals? - integration is trivial: evaluation - arbitrary base types - but how would you even declare a uniform distribution in this type? 3. Density functions - represent a distribution on the reals as density function w.r.t. the Lebesgue measure - limited to reals (and products thereof) - data type possibly holds only parameters of parametric families (gaussian, beta, gamma, ...) - computing conditionals only for matching pairs of prior and sampling function (conjugate priors), analytically - integration analytically - no monad instance because no arbitrary base type 4. Finite distributions - type Dist a = [(a,R)] for suitable real number type R - optimizations use search trees instead of flat lists - basically composition of list and writer monads, where R is regarded as monoid under multiplication - represents a distribution of finite support. If phi :: Dist a, then probability p = sum $ map snd $ filter (p.fst) phi - conditioning possible if base type is of Eq class and R supports division - gets unwieldy without Ord instance of base type to keep the list small 5. Valuations - type Val a = (a -> Bool) -> R for suitable real number type R - models mathematical definition closely - monad bind is integration: requires exact reals R due to limit process - conditioning possible if R supports division From dennis.raddle at gmail.com Tue Jul 4 02:09:25 2017 From: dennis.raddle at gmail.com (Dennis Raddle) Date: Mon, 3 Jul 2017 19:09:25 -0700 Subject: [Haskell-cafe] speed of hashing Message-ID: Hello, I have an application which could benefit from caching certain computations. For instance, I might have a function: listToWord :: [Int] -> Word16 which takes an integer X in the input as referring to bit X in the output word, and sets the bits. I have to run this computation many times within the inner loop. So I thought I could cache it. The only trouble is that it may not be any less expensive to convert the [Int] into a hash value, or use it as a key to look up a binary Map. What do you think? Does Haskell hashing use some kind of optimized computation that's faster than me writing a loop by hand? D -------------- next part -------------- An HTML attachment was scrubbed... URL: From michael at snoyman.com Tue Jul 4 02:22:39 2017 From: michael at snoyman.com (Michael Snoyman) Date: Tue, 4 Jul 2017 05:22:39 +0300 Subject: [Haskell-cafe] speed of hashing In-Reply-To: References: Message-ID: The real answer here is to benchmark; there's no way to know for certain what will be faster in the abstract, especially without seeing your implementation. That said: in order for a caching algorithm to work, you're going to have to traverse your entire input list to perform a lookup. Meaning: I'd be surprised if caching sped up this case. But again, that's just a guess, benchmarking would be the only true answer. Algorithms like this can often be significantly faster if you used an unboxed vector[1] to hold the Ints instead of a list, so if you're benchmarking, I'd recommend throwing that into the mix as well. Finally: what were you considering using as a data structure to hold the cache? I would imagine that using a HashMap would sort of defeat the purpose in this case :) Michael [1] https://www.stackage.org/haddock/lts-8.21/vector-0.11.0.0/Data-Vector-Unboxed.html On Tue, Jul 4, 2017 at 5:09 AM, Dennis Raddle wrote: > Hello, I have an application which could benefit from caching certain > computations. For instance, I might have a function: > > listToWord :: [Int] -> Word16 > > which takes an integer X in the input as referring to bit X in the output > word, and sets the bits. > > I have to run this computation many times within the inner loop. So I > thought I could cache it. The only trouble is that it may not be any less > expensive to convert the [Int] into a hash value, or use it as a key to > look up a binary Map. > > What do you think? Does Haskell hashing use some kind of optimized > computation that's faster than me writing a loop by hand? > > 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 dennis.raddle at gmail.com Tue Jul 4 09:21:38 2017 From: dennis.raddle at gmail.com (Dennis Raddle) Date: Tue, 4 Jul 2017 02:21:38 -0700 Subject: [Haskell-cafe] speed of hashing In-Reply-To: References: Message-ID: Thanks, I suspect you are right that caching wouldn't help. However, there are several places that unboxed vectors might help me, so thanks for that tip. D On Mon, Jul 3, 2017 at 7:22 PM, Michael Snoyman wrote: > The real answer here is to benchmark; there's no way to know for certain > what will be faster in the abstract, especially without seeing your > implementation. That said: in order for a caching algorithm to work, you're > going to have to traverse your entire input list to perform a lookup. > Meaning: I'd be surprised if caching sped up this case. But again, that's > just a guess, benchmarking would be the only true answer. > > Algorithms like this can often be significantly faster if you used an > unboxed vector[1] to hold the Ints instead of a list, so if you're > benchmarking, I'd recommend throwing that into the mix as well. > > Finally: what were you considering using as a data structure to hold the > cache? I would imagine that using a HashMap would sort of defeat the > purpose in this case :) > > Michael > > [1] https://www.stackage.org/haddock/lts-8.21/vector-0.11. > 0.0/Data-Vector-Unboxed.html > > On Tue, Jul 4, 2017 at 5:09 AM, Dennis Raddle > wrote: > >> Hello, I have an application which could benefit from caching certain >> computations. For instance, I might have a function: >> >> listToWord :: [Int] -> Word16 >> >> which takes an integer X in the input as referring to bit X in the output >> word, and sets the bits. >> >> I have to run this computation many times within the inner loop. So I >> thought I could cache it. The only trouble is that it may not be any less >> expensive to convert the [Int] into a hash value, or use it as a key to >> look up a binary Map. >> >> What do you think? Does Haskell hashing use some kind of optimized >> computation that's faster than me writing a loop by hand? >> >> 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 lanablack at amok.cc Tue Jul 4 11:05:00 2017 From: lanablack at amok.cc (Lana Black) Date: Tue, 4 Jul 2017 11:05:00 +0000 Subject: [Haskell-cafe] type (++) = (<>) In-Reply-To: <201707031729.v63HTHu5001972@coolidge.cs.Dartmouth.EDU> References: <201707031729.v63HTHu5001972@coolidge.cs.Dartmouth.EDU> Message-ID: <8312ded4-afd5-1250-0a40-f173b43e700b@amok.cc> On 03/07/17 17:29, Doug McIlroy wrote: >> What do you think of making (++) the same as (<>) > > This seems to be a call for returning to the old situation in > which (++) was an operator of class MonadPlus. Why was that > abolished in Haskell 98? > > Doug Using MonadPlus in this case is not the best idea. There are types that can implement (++) but aren't a Monad. Data.Set is one example. From rae at cs.brynmawr.edu Tue Jul 4 13:57:27 2017 From: rae at cs.brynmawr.edu (Richard Eisenberg) Date: Tue, 4 Jul 2017 09:57:27 -0400 Subject: [Haskell-cafe] Deadline in 2 days: Haskell Implementors' Workshop Call for Talks In-Reply-To: <89244F5C-058B-426D-84A4-4A4D62C2E880@cs.brynmawr.edu> References: <89244F5C-058B-426D-84A4-4A4D62C2E880@cs.brynmawr.edu> Message-ID: <306EAE31-D51E-465A-A521-69946C7639CE@cs.brynmawr.edu> Call for Contributions ACM SIGPLAN Haskell Implementors' Workshop http://icfp17.sigplan.org/track/hiw-2017 Oxford, UK, 9 September, 2017 Co-located with ICFP 2017 http://www.icfpconference.org/icfp2017/ Important dates --------------- Proposal Deadline: Thursday, 6 July, 2017 Notification: Thursday, 20 July, 2017 Workshop: Saturday, 9 September, 2017 The 9th Haskell Implementors' Workshop is to be held alongside ICFP 2017 this year in Oxford. It is a forum for people involved in the design and development of Haskell implementations, tools, libraries, and supporting infrastructure, to share their work and discuss future directions and collaborations with others. Talks and/or demos are proposed by submitting an abstract, and selected by a small program committee. There will be no published proceedings. The workshop will be informal and interactive, with open spaces in the timetable and room for ad-hoc discussion, demos, and impromptu short talks. Scope and target audience ------------------------- It is important to distinguish the Haskell Implementors' Workshop from the Haskell Symposium which is also co-located with ICFP 2017. The Haskell Symposium is for the publication of Haskell-related research. In contrast, the Haskell Implementors' Workshop will have no proceedings -- although we will aim to make talk videos, slides and presented data available with the consent of the speakers. The Implementors' Workshop is an ideal place to describe a Haskell extension, describe works-in-progress, demo a new Haskell-related tool, or even propose future lines of Haskell development. Members of the wider Haskell community encouraged to attend the workshop -- we need your feedback to keep the Haskell ecosystem thriving. Students working with Haskell are specially encouraged to share their work. The scope covers any of the following topics. There may be some topics that people feel we've missed, so by all means submit a proposal even if it doesn't fit exactly into one of these buckets: * Compilation techniques * Language features and extensions * Type system implementation * Concurrency and parallelism: language design and implementation * Performance, optimisation and benchmarking * Virtual machines and run-time systems * Libraries and tools for development or deployment Talks ----- We invite proposals from potential speakers for talks and demonstrations. We are aiming for 20-minute talks with 5 minutes for questions and changeovers. We want to hear from people writing compilers, tools, or libraries, people with cool ideas for directions in which we should take the platform, proposals for new features to be implemented, and half-baked crazy ideas. Please submit a talk title and abstract of no more than 300 words. Submissions should be made via HotCRP. The website is: https://icfp-hiw17.hotcrp.com/ We will also have a lightning talks session which will be organised on the day. These talks will be 5-10 minutes, depending on available time. Suggested topics for lightning talks are to present a single idea, a work-in-progress project, a problem to intrigue and perplex Haskell implementors, or simply to ask for feedback and collaborators. Program Committee ----------------- * Richard A. Eisenberg -- chair (Bryn Mawr College) * Adam Gundry (Well-Typed) * Bartosz Nitka (Facebook) * Wren Romano (X, formerly Google[x]) * Alejandro Serrano Mena (Utrecht University) * Jan Stolarek (University of Edinburgh) Contact ------- * Richard A. Eisenberg _______________________________________________ Haskell mailing list Haskell at haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell From benjamin.redelings at gmail.com Tue Jul 4 14:24:13 2017 From: benjamin.redelings at gmail.com (Benjamin Redelings) Date: Tue, 4 Jul 2017 10:24:13 -0400 Subject: [Haskell-cafe] representations of probability distributions In-Reply-To: <61E88050-B9D2-4956-B21D-E943E46E3F72@aatal-apotheke.de> References: <61E88050-B9D2-4956-B21D-E943E46E3F72@aatal-apotheke.de> Message-ID: <373e69f0-8acd-ce20-195b-0d79ec34406f@gmail.com> Hi, On 07/03/2017 05:14 PM, Olaf Klinke wrote: > Dear cafe, > > following up the announcement of bali-phy and the discussion that ensued, I'd like ask the cafe for an overview of representations of probability distributions as data types. It seems that all packages mentioned to far use some flavour of Markov chain. Why? What else is there? Can someone recommend a survey publication/book/talk? One other class of inference strategies is Sequential Monte Carlo (aka Particle filters). Unlike MCMC, these methods run multiple points ("particles") in parallel, and the points can have unequal weights. The point cloud is incrementally updated as information is added, so these methods work well for online algorithms where you sequentially add data points. One idea in the probabilistic programming community is to separate the inference strategy from the inference problem, so that one could apply "pluggable" inference strategies. (See https://arxiv.org/abs/1404.0099). There are also "variational" methods, which I think restrict the posterior distribution to a particular analytic form, and use an iterative algorithm to find the parameter values of the restricted distribution that minimize the KL distance to the true posterior distribution. So, this is not a Monte Carlo method. > Explicitly I am interested in: > - the data type, as in Haskell's type system > - how an element of the data type relates to the distribution it describes > - how the monad instance works (if there is one) > - how to compute conditionals (if computable) > - how to compute integrals (if computable) > - what base types are supported (finite types, reals, products ...) > > Below is an incomplete, and possibly oversimplified (or even wrong), list of my own. > Additions and corrections welcome. > -- Olaf > > 1. Markov chains > - uses a random number generator > - type is something like > Markov a = a -> IO a > - repeated execution produces an infinite trace xs :: [a] > where for each predicate p :: a -> Bool, the limit of > (length (filter p (take n xs))) % n > as n tends to infinity approaches the probability of p > under the distribution modeled. > - monad instance? > - conditionals? > - integrals? > - supported base types a in Markov a? > > 2. Riesz functionals: possibly the most functional representation > - representation as linear functionals > Riesz a = (a -> R) -> R > for a suitable real number type R > - embed predicates in the type (a -> R) via characteristic functions > characteristic p = \a -> if p a then 1 else 0 > Then for a functional phi :: Riesz a and p :: a -> Bool, > phi (characteristic p) is the probability of p. > - Monad instance is the same as for the continuation monad > - conditionals? > - integration is trivial: evaluation > - arbitrary base types > - but how would you even declare a uniform distribution in this type? > > 3. Density functions > - represent a distribution on the reals as density function w.r.t. the Lebesgue measure > - limited to reals (and products thereof) > - data type possibly holds only parameters of parametric families (gaussian, beta, gamma, ...) > - computing conditionals only for matching pairs of prior and sampling function > (conjugate priors), analytically > - integration analytically > - no monad instance because no arbitrary base type > > 4. Finite distributions > - type Dist a = [(a,R)] for suitable real number type R > - optimizations use search trees instead of flat lists > - basically composition of list and writer monads, > where R is regarded as monoid under multiplication > - represents a distribution of finite support. > If phi :: Dist a, then > probability p = sum $ map snd $ filter (p.fst) phi > - conditioning possible if base type is of Eq class and R supports division > - gets unwieldy without Ord instance of base type to keep the list small > > 5. Valuations > - type Val a = (a -> Bool) -> R > for suitable real number type R > - models mathematical definition closely > - monad bind is integration: requires exact reals R due to limit process > - conditioning possible if R supports division > _______________________________________________ > 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 ruben.astud at gmail.com Tue Jul 4 18:44:08 2017 From: ruben.astud at gmail.com (Ruben Astudillo) Date: Tue, 4 Jul 2017 14:44:08 -0400 Subject: [Haskell-cafe] on the number of ghc_worker threads on executables Message-ID: Dear list I noticed that on -threaded programs, even with just 1 capability (+RTS -N1) the number of worker tasks is usually more than 3. Examples of this are glirc and taffybar. What factors determine the number of Tasks/worker Tasks (OS threads) on a program? -- -- Ruben Astudillo -- PGP: 4EE9 28F7 932E F4AD -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 488 bytes Desc: OpenPGP digital signature URL: From mail at nh2.me Tue Jul 4 20:43:21 2017 From: mail at nh2.me (=?UTF-8?Q?Niklas_Hamb=c3=bcchen?=) Date: Tue, 4 Jul 2017 22:43:21 +0200 Subject: [Haskell-cafe] on the number of ghc_worker threads on executables In-Reply-To: References: Message-ID: Others may have more insights, but with -threaded, `safe` FFI calls run in their own threads as to not block your Haskell thread. So even with -N1 you can have (arbitrarily?) many OS threads, depending on how many safe foreign calls you do. From anthony_clayden at clear.net.nz Wed Jul 5 11:40:40 2017 From: anthony_clayden at clear.net.nz (Anthony Clayden) Date: Wed, 05 Jul 2017 23:40:40 +1200 Subject: [Haskell-cafe] local instances / scoped instances Message-ID: <595cd038.25a.4d70.21887@clear.net.nz> Can anybody explain the idea of typeclass instances being declared with a scope? I’m not sure if these two terms mean the same. Perhaps the difference is: * ‘local instances’ are declared in the familiar let-style: `let in ` So the scope is the body of the `in` expr. * ‘scoped instances’ are declared as usual at the top level in a module. Scope is controlled by the export/import naming. (That is, there’s a way to name/identify instances for export/import. Note that currently you can’t control scope of instances; They’re imported to any module that (transitively) imports the module where an instance is declared.) (I'm doubtful that controlling scope of the name-for-instance would actually have the desired effect. Compare if I declare: > data T = MkT Int > f :: T -> String and export `f`, but not `T` nor `MkT`; nevertheless the type of `f` in some distant module is still `T -> String` (or `M.T -> String`). So detail of the type itself is exported. What are the use cases for instances being anything other than top-level/global scope? One seems to be so that a method can use a value/function declared in a surrounding scope, without needing an explicit parameter passed around the whole program. This is explored in [Kis04] (and linked references, esp. ‘Implicit configurations’), particularly for passing run-time parameters into methods. (What imperative programmers might do via global variables. In Haskell: nowadays Implicit Parameters.) [Kis04] (and especially the link to “The pioneering work” of Kaes) laments that Kaes’ original description of typeclasses/instances has never been delivered. I’m not convinced Kaes is actually describing local instances. He’s giving the formal semantics for instances using let-binding; because he’s using let as the standard way in Lambda Calculus to introduce any binding. Usual let-binding in LC provides a fresh name for each binding. That is, if that same name is in an outer scope, the outer binding is ‘shadowed’/unreachable within the scope of the fresh name. But instance binding is different: * There’s no fresh name: the class name is exactly the one already in scope. * There’s no ‘shadowing’: this instance is _in addition to_ those already in scope. — that’s what ‘overloading’ needs. Overloading a class method with two or more instances in the same scope means there’s no principal type for the method [W&B88 Appendix A.7]. That’s why in Haskell classes/instances/methods are at top level only. The methods then do have a most-general principal type `show :: (Show a) => a -> String`. This early work was of course before MPTCs, FunDeps, Overlaps, Flexible Instances/Contexts, constrained existentials, constrained GADTs. AFAICT it was expected there would be only one instance per type. So making instances global probably wasn’t too limiting. I’ve seen some later ideas (especially ‘scoped instances’ blocking the export of an instance) where the intent seems to be to have _different_ instances in different scopes for the same class/same type. For example (apparently) a ‘pretty print’ format for `show`. Or an alternative `Ord` for case-insensitive sorting of Chars/Strings. What are the use cases here? In particular, what’s wrong with either: * using a different class/method name for different behaviour (for example supplying a different comparison via `sortBy`); or * wrapping in a newtype and declaring an instance of `Show/Ord` on the different nominal type? I’m worried: classes come with laws. For example wrt case-insensitive `Ord`: `Eq` is a superclass. So if we get case-insensitive `‘A’ <= ‘a’` and `‘a’ <= ‘A’`, the laws expect ` ‘A’ == ‘a’ `. Specifically the base library `Data.Set` relies on those laws for `Ord` to build balanced trees. (There’s also a whole load of puzzlement to do with how the instance scoping rules work, as explored in [Kis04]. But I don’t want to worry about the implementation yet.) AntC [Kis04] Local instances: frequently still discussed and still not implemented, Kiselyov O. ??originally 2004, current version 2014 http://okmij.org/ftp/Haskell/TypeClass.html#local See also papers linked/referenced from that site. (Thank you Oleg for bringing out the issues.) [Kaes88] Parametric Overloading in Polymorphic Programming Languages, Kaes S. 1988 https://link.springer.com/content/pdf/10.1007%2F3-540-19027-9_9.pdf [W&B88] How to make ad-hoc Polymorphism less ad-hoc, Wadler P. & Blott S. 1988 https://people.csail.mit.edu/dnj/teaching/6898/papers/wadler88.pdf From saurabhnanda at gmail.com Wed Jul 5 12:56:45 2017 From: saurabhnanda at gmail.com (Saurabh Nanda) Date: Wed, 5 Jul 2017 18:26:45 +0530 Subject: [Haskell-cafe] Instantiating a typeclass based on a runtime value? Message-ID: Overall context: I'm trying to port the DelayedJob library from Ruby/Rails world to Haskell. The basic idea is to serialise a job and write it to the DB, deserialise it, and run the job using a job-runner function, which is determined by the job-type. I'm using a type-class to define the custom job-runner, something on the lines of: class (FromJSON j, ToJSON j) => DelayedJob j where runJob :: j -> AppM () data SyncContactsJob = SyncContactsJob { userId :: UserId } deriving (Eq, Show, Generic, FromJSON, ToJSON) instance DelayedJob SyncContactsJob where runJob job = do -- entire job execution logic comes here Is there **any** type-system hackery, that will let me take a runtime value, eg. "SyncContactsJob", "DoBackupJob", and use that to run the correct version of the `runJob` function? That is, how do I write the following function: invokeJob :: JobId -> AppM () invokeJob jid = do jobRow <- fetchJob jid let jtype = jobRow ^. jobtype -- this will have "SyncContactsJob" jvalue = jobRow ^. jobdata -- this will have a Data.Aeson.Value runJob (......) -- QUESTION: What do I write here to make this compile? -------------- next part -------------- An HTML attachment was scrubbed... URL: From parsonsmatt at gmail.com Wed Jul 5 17:08:25 2017 From: parsonsmatt at gmail.com (Matt) Date: Wed, 5 Jul 2017 11:08:25 -0600 Subject: [Haskell-cafe] Instantiating a typeclass based on a runtime value? In-Reply-To: References: Message-ID: You are asking GHC to select an instance of a type class (a compile-time operation) at run-time. I believe that this is possible with something like the exinst[1] package and runtime dictionaries with the constraints[2] package, but you're getting into some fairly hairy territory. I don't think that this would end up providing a nice UX for library consumers, either, as you end up needing user-defined singleton types to lift that information into the type level -- eg, a sum type of operations that the user supports, and then an open data family (or GADT) indexed by that sum type. In order for runJob to know about it, the class definition needs to know about that index, which kind of ruins the point of the class -- if you're going to keep a closed type of operations, you might as well just have: data Job = SyncContact SyncContactJob | ImportFoo ImportFooJob data SyncContactJob = SyncContactJob { userId :: UserId } data ImportFooJob = ImportFooJob { fooId :: FooId } runJob :: Job -> App () The main benefit to the existentialized approach, IMO, is when the actions are entirely derived from type class operations. Sandy Maguire gave a good talk on the approach at Lambdaconf [3]. Since much of the behavior here is ad hoc, then I think you'll get less utility out of the class. We have a similar sort of framework on our projects at work, but using Amazon SQS messages instead of a database. The function has a signature like: pollSqsFor :: FromJSON a => SqsQueue -> (a -> App b) -> App () This lets us write `pollSqsFor ImportThing (thingImporter :: ThingRequest -> App ())` for the workers that end up processing it, with the polling function handling stuff like delay time, error handling, keeping the message invisible, deleting it if successful, etc. This sort of thing would be easy to port to using a database, the only difference being loading only matching rows from the database for the given type. [1] exinst: https://hackage.haskell.org/package/exinst [2] contraints: http://haddock.stackage.org/lts-5.1/constraints-0.8/Data-Constraint.html [3] some1 like you: http://reasonablypolymorphic.com/some1-like-you/#/title Matt Parsons On Wed, Jul 5, 2017 at 6:56 AM, Saurabh Nanda wrote: > Overall context: I'm trying to port the DelayedJob library from > Ruby/Rails world to Haskell. The basic idea is to serialise a job and write > it to the DB, deserialise it, and run the job using a job-runner function, > which is determined by the job-type. > > I'm using a type-class to define the custom job-runner, something on the > lines of: > > class (FromJSON j, ToJSON j) => DelayedJob j where > runJob :: j -> AppM () > > data SyncContactsJob = SyncContactsJob { userId :: UserId } deriving > (Eq, Show, Generic, FromJSON, ToJSON) > > instance DelayedJob SyncContactsJob where > runJob job = do > -- entire job execution logic comes here > > Is there **any** type-system hackery, that will let me take a runtime > value, eg. "SyncContactsJob", "DoBackupJob", and use that to run the > correct version of the `runJob` function? That is, how do I write the > following function: > > invokeJob :: JobId -> AppM () > invokeJob jid = do > jobRow <- fetchJob jid > let jtype = jobRow ^. jobtype -- this will have "SyncContactsJob" > jvalue = jobRow ^. jobdata -- this will have a Data.Aeson.Value > runJob (......) -- QUESTION: What do I write here to make this > compile? > > _______________________________________________ > 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 rein.henrichs at gmail.com Wed Jul 5 17:52:08 2017 From: rein.henrichs at gmail.com (Rein Henrichs) Date: Wed, 05 Jul 2017 17:52:08 +0000 Subject: [Haskell-cafe] Instantiating a typeclass based on a runtime value? In-Reply-To: References: Message-ID: The job type is not a type in the Haskell sense. It is a just a value. Promoting it to a type just creates the problem you are trying to solve. The mechanism in Haskell that selects some value given another value is the function so why not write a function JobType -> Job -> App () that selects the right job running function for the given job type? On Wed, Jul 5, 2017 at 10:11 AM Matt wrote: > You are asking GHC to select an instance of a type class (a compile-time > operation) at run-time. I believe that this is possible with something like > the exinst[1] package and runtime dictionaries with the constraints[2] > package, but you're getting into some fairly hairy territory. I don't think > that this would end up providing a nice UX for library consumers, either, > as you end up needing user-defined singleton types to lift that information > into the type level -- eg, a sum type of operations that the user supports, > and then an open data family (or GADT) indexed by that sum type. In order > for runJob to know about it, the class definition needs to know about that > index, which kind of ruins the point of the class -- if you're going to > keep a closed type of operations, you might as well just have: > > data Job = SyncContact SyncContactJob | ImportFoo ImportFooJob > > data SyncContactJob = SyncContactJob { userId :: UserId } > data ImportFooJob = ImportFooJob { fooId :: FooId } > > runJob :: Job -> App () > > The main benefit to the existentialized approach, IMO, is when the actions > are entirely derived from type class operations. Sandy Maguire gave a good > talk on the approach at Lambdaconf [3]. Since much of the behavior here is > ad hoc, then I think you'll get less utility out of the class. > > We have a similar sort of framework on our projects at work, but using > Amazon SQS messages instead of a database. The function has a signature > like: > > pollSqsFor :: FromJSON a => SqsQueue -> (a -> App b) -> App () > > This lets us write `pollSqsFor ImportThing (thingImporter :: ThingRequest > -> App ())` for the workers that end up processing it, with the polling > function handling stuff like delay time, error handling, keeping the > message invisible, deleting it if successful, etc. This sort of thing would > be easy to port to using a database, the only difference being loading only > matching rows from the database for the given type. > > [1] exinst: https://hackage.haskell.org/package/exinst > [2] contraints: > http://haddock.stackage.org/lts-5.1/constraints-0.8/Data-Constraint.html > [3] some1 like you: > http://reasonablypolymorphic.com/some1-like-you/#/title > > Matt Parsons > > On Wed, Jul 5, 2017 at 6:56 AM, Saurabh Nanda > wrote: > >> Overall context: I'm trying to port the DelayedJob library from >> Ruby/Rails world to Haskell. The basic idea is to serialise a job and write >> it to the DB, deserialise it, and run the job using a job-runner function, >> which is determined by the job-type. >> >> I'm using a type-class to define the custom job-runner, something on the >> lines of: >> >> class (FromJSON j, ToJSON j) => DelayedJob j where >> runJob :: j -> AppM () >> >> data SyncContactsJob = SyncContactsJob { userId :: UserId } deriving >> (Eq, Show, Generic, FromJSON, ToJSON) >> >> instance DelayedJob SyncContactsJob where >> runJob job = do >> -- entire job execution logic comes here >> >> Is there **any** type-system hackery, that will let me take a runtime >> value, eg. "SyncContactsJob", "DoBackupJob", and use that to run the >> correct version of the `runJob` function? That is, how do I write the >> following function: >> >> invokeJob :: JobId -> AppM () >> invokeJob jid = do >> jobRow <- fetchJob jid >> let jtype = jobRow ^. jobtype -- this will have "SyncContactsJob" >> jvalue = jobRow ^. jobdata -- this will have a >> Data.Aeson.Value >> runJob (......) -- QUESTION: What do I write here to make this >> compile? >> >> _______________________________________________ >> 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 olf at aatal-apotheke.de Wed Jul 5 20:45:30 2017 From: olf at aatal-apotheke.de (Olaf Klinke) Date: Wed, 5 Jul 2017 22:45:30 +0200 Subject: [Haskell-cafe] representations of probability distributions Message-ID: <04A23730-FCE7-4FD0-89FD-88DCC319AAE3@aatal-apotheke.de> Thanks for the link, Benjamin. Can one give a Hasekll type to a particle filter? In the arxiv paper you linked, I found this quite unnerving sentence: "The divergence between the true conditioned distribution on execution traces and the distribution encoded by the program may depend strongly on what inference instructions are chosen and how they are interleaved with the incorporation of data." Does this mean: Here is a programming language that may or may not compute what you meant it to do? --Olaf From ivan.miljenovic at gmail.com Thu Jul 6 04:58:52 2017 From: ivan.miljenovic at gmail.com (Ivan Lazar Miljenovic) Date: Thu, 6 Jul 2017 14:58:52 +1000 Subject: [Haskell-cafe] Encrypting streamed data Message-ID: I have a use case for needing to use public key cryptography to encrypt a large amount of data in a streaming fashion (get it out of a DB, encrypt, put into an AWS S3 bucket). The command-line gpg tool seems to be able to encrypt/decrypt data from stdin to stdout in a streaming fashion, but in my attempts to use it it seems very file-based for things like the keys to use (whereas I would prefer to be able to pass the public key as an actual value rather than a file; if nothing else because this is for tools that don't have email addresses to use and base their keys on for addressing). Is there an existing library that can achieve this using conduit/pipes/whatever? cryptonite-conduit only covers hashing, hOpenPGP is poorly documented and I can't work out how to use it ("just follow the types" is difficult when Haddock docs don't link to the required types (seems to be because it uses the "import Module as X" trick for re-exporting everything but then everything from those modules isn't available). Can anyone recommend a solution? -- Ivan Lazar Miljenovic Ivan.Miljenovic at gmail.com http://IvanMiljenovic.wordpress.com From dct25-561bs at mythic-beasts.com Thu Jul 6 06:40:12 2017 From: dct25-561bs at mythic-beasts.com (David Turner) Date: Thu, 6 Jul 2017 07:40:12 +0100 Subject: [Haskell-cafe] Encrypting streamed data In-Reply-To: References: Message-ID: Hi, I do not know of a library to do this, sorry. Note that the way public-key crypto works in a streaming fashion is typically to use the public-key bit only to encrypt a key for a symmetric cipher and then use the (much-faster) symmetric encryption for the actual data. The symmetric bit could well be something like AES256-CBC or AES256-CTR. This means that the format of the resulting data is a bit implementation-defined as it has to include the asymetrically-encrypted data first, followed by the stream of symmetrically-encrypted data. GnuPG includes quite a bit of metadata in its files that describes the algorithms used and delimits the pieces, so if you want the resulting files to be GnuPG-compatible you'll need to take this into account. If it were me, I'd probably just shell out to `gpg`. It's fast and low-risk. Hope that helps, David On 6 Jul 2017 05:59, "Ivan Lazar Miljenovic" wrote: I have a use case for needing to use public key cryptography to encrypt a large amount of data in a streaming fashion (get it out of a DB, encrypt, put into an AWS S3 bucket). The command-line gpg tool seems to be able to encrypt/decrypt data from stdin to stdout in a streaming fashion, but in my attempts to use it it seems very file-based for things like the keys to use (whereas I would prefer to be able to pass the public key as an actual value rather than a file; if nothing else because this is for tools that don't have email addresses to use and base their keys on for addressing). Is there an existing library that can achieve this using conduit/pipes/whatever? cryptonite-conduit only covers hashing, hOpenPGP is poorly documented and I can't work out how to use it ("just follow the types" is difficult when Haddock docs don't link to the required types (seems to be because it uses the "import Module as X" trick for re-exporting everything but then everything from those modules isn't available). Can anyone recommend a solution? -- Ivan Lazar Miljenovic Ivan.Miljenovic at gmail.com http://IvanMiljenovic.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. -------------- next part -------------- An HTML attachment was scrubbed... URL: From dct25-561bs at mythic-beasts.com Thu Jul 6 07:23:44 2017 From: dct25-561bs at mythic-beasts.com (David Turner) Date: Thu, 6 Jul 2017 08:23:44 +0100 Subject: [Haskell-cafe] Encrypting streamed data In-Reply-To: References: Message-ID: Apologies, just seen the bit about wanting to pass the key in directly rather than using the GPG keyring because there are no email addresses attached to your various keys. Maybe a silly question, but can you give them email addresses to identify them in a GPG-compatible manner? They don't have to have associated mailboxes so the addresses can be totally made-up. If not, I'd probably start to look to something like openssl to do the symmetric encryption and manage the keys for that separately. It looks possible to build a streaming AES implementation using the nonstreaming functions in `cryptonite`, but the usual recommendation is that its far too risky to do any low-level crypto yourself so this seems like a bad idea. On 6 Jul 2017 07:40, "David Turner" wrote: > Hi, > > I do not know of a library to do this, sorry. Note that the way public-key > crypto works in a streaming fashion is typically to use the public-key bit > only to encrypt a key for a symmetric cipher and then use the (much-faster) > symmetric encryption for the actual data. The symmetric bit could well be > something like AES256-CBC or AES256-CTR. > > This means that the format of the resulting data is a bit > implementation-defined as it has to include the asymetrically-encrypted > data first, followed by the stream of symmetrically-encrypted data. GnuPG > includes quite a bit of metadata in its files that describes the algorithms > used and delimits the pieces, so if you want the resulting files to be > GnuPG-compatible you'll need to take this into account. > > If it were me, I'd probably just shell out to `gpg`. It's fast and > low-risk. > > Hope that helps, > > David > > > On 6 Jul 2017 05:59, "Ivan Lazar Miljenovic" > wrote: > > I have a use case for needing to use public key cryptography to > encrypt a large amount of data in a streaming fashion (get it out of a > DB, encrypt, put into an AWS S3 bucket). > > The command-line gpg tool seems to be able to encrypt/decrypt data > from stdin to stdout in a streaming fashion, but in my attempts to use > it it seems very file-based for things like the keys to use (whereas I > would prefer to be able to pass the public key as an actual value > rather than a file; if nothing else because this is for tools that > don't have email addresses to use and base their keys on for > addressing). > > Is there an existing library that can achieve this using > conduit/pipes/whatever? cryptonite-conduit only covers hashing, > hOpenPGP is poorly documented and I can't work out how to use it > ("just follow the types" is difficult when Haddock docs don't link to > the required types (seems to be because it uses the "import Module as > X" trick for re-exporting everything but then everything from those > modules isn't available). > > Can anyone recommend a solution? > > -- > Ivan Lazar Miljenovic > Ivan.Miljenovic at gmail.com > http://IvanMiljenovic.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. > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ivan.miljenovic at gmail.com Thu Jul 6 07:40:01 2017 From: ivan.miljenovic at gmail.com (Ivan Lazar Miljenovic) Date: Thu, 6 Jul 2017 17:40:01 +1000 Subject: [Haskell-cafe] Encrypting streamed data In-Reply-To: References: Message-ID: On 6 July 2017 at 17:23, David Turner wrote: > Apologies, just seen the bit about wanting to pass the key in directly > rather than using the GPG keyring because there are no email addresses > attached to your various keys. > > Maybe a silly question, but can you give them email addresses to identify > them in a GPG-compatible manner? They don't have to have associated > mailboxes so the addresses can be totally made-up. Yes, that's my fallback, since it's possible to tell gpg to use a different directory so I can provide a key externally with my transmission request, load it into a temporary store, grab the identity out and use that. It would just be more convenient to have a "here's a ByteString with the public key" option (which I can always implement as a wrapper function). > > If not, I'd probably start to look to something like openssl to do the > symmetric encryption and manage the keys for that separately. It looks > possible to build a streaming AES implementation using the nonstreaming > functions in `cryptonite`, but the usual recommendation is that its far too > risky to do any low-level crypto yourself so this seems like a bad idea. > > > On 6 Jul 2017 07:40, "David Turner" wrote: >> >> Hi, >> >> I do not know of a library to do this, sorry. Note that the way public-key >> crypto works in a streaming fashion is typically to use the public-key bit >> only to encrypt a key for a symmetric cipher and then use the (much-faster) >> symmetric encryption for the actual data. The symmetric bit could well be >> something like AES256-CBC or AES256-CTR. >> >> This means that the format of the resulting data is a bit >> implementation-defined as it has to include the asymetrically-encrypted data >> first, followed by the stream of symmetrically-encrypted data. GnuPG >> includes quite a bit of metadata in its files that describes the algorithms >> used and delimits the pieces, so if you want the resulting files to be >> GnuPG-compatible you'll need to take this into account. >> >> If it were me, I'd probably just shell out to `gpg`. It's fast and >> low-risk. >> >> Hope that helps, >> >> David >> >> >> On 6 Jul 2017 05:59, "Ivan Lazar Miljenovic" >> wrote: >> >> I have a use case for needing to use public key cryptography to >> encrypt a large amount of data in a streaming fashion (get it out of a >> DB, encrypt, put into an AWS S3 bucket). >> >> The command-line gpg tool seems to be able to encrypt/decrypt data >> from stdin to stdout in a streaming fashion, but in my attempts to use >> it it seems very file-based for things like the keys to use (whereas I >> would prefer to be able to pass the public key as an actual value >> rather than a file; if nothing else because this is for tools that >> don't have email addresses to use and base their keys on for >> addressing). >> >> Is there an existing library that can achieve this using >> conduit/pipes/whatever? cryptonite-conduit only covers hashing, >> hOpenPGP is poorly documented and I can't work out how to use it >> ("just follow the types" is difficult when Haddock docs don't link to >> the required types (seems to be because it uses the "import Module as >> X" trick for re-exporting everything but then everything from those >> modules isn't available). >> >> Can anyone recommend a solution? >> >> -- >> Ivan Lazar Miljenovic >> Ivan.Miljenovic at gmail.com >> http://IvanMiljenovic.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. >> >> > -- Ivan Lazar Miljenovic Ivan.Miljenovic at gmail.com http://IvanMiljenovic.wordpress.com From chpatrick at gmail.com Thu Jul 6 09:17:18 2017 From: chpatrick at gmail.com (Patrick Chilton) Date: Thu, 6 Jul 2017 11:17:18 +0200 Subject: [Haskell-cafe] Encrypting streamed data In-Reply-To: References: Message-ID: If your data fits in RAM maybe it's best to forget about the streaming and use the saltine library's Box module. Then you can't really go wrong on the crypto front. On Jul 6, 2017 09:41, "Ivan Lazar Miljenovic" wrote: > On 6 July 2017 at 17:23, David Turner > wrote: > > Apologies, just seen the bit about wanting to pass the key in directly > > rather than using the GPG keyring because there are no email addresses > > attached to your various keys. > > > > Maybe a silly question, but can you give them email addresses to identify > > them in a GPG-compatible manner? They don't have to have associated > > mailboxes so the addresses can be totally made-up. > > Yes, that's my fallback, since it's possible to tell gpg to use a > different directory so I can provide a key externally with my > transmission request, load it into a temporary store, grab the > identity out and use that. It would just be more convenient to have a > "here's a ByteString with the public key" option (which I can always > implement as a wrapper function). > > > > > If not, I'd probably start to look to something like openssl to do the > > symmetric encryption and manage the keys for that separately. It looks > > possible to build a streaming AES implementation using the nonstreaming > > functions in `cryptonite`, but the usual recommendation is that its far > too > > risky to do any low-level crypto yourself so this seems like a bad idea. > > > > > > On 6 Jul 2017 07:40, "David Turner" > wrote: > >> > >> Hi, > >> > >> I do not know of a library to do this, sorry. Note that the way > public-key > >> crypto works in a streaming fashion is typically to use the public-key > bit > >> only to encrypt a key for a symmetric cipher and then use the > (much-faster) > >> symmetric encryption for the actual data. The symmetric bit could well > be > >> something like AES256-CBC or AES256-CTR. > >> > >> This means that the format of the resulting data is a bit > >> implementation-defined as it has to include the asymetrically-encrypted > data > >> first, followed by the stream of symmetrically-encrypted data. GnuPG > >> includes quite a bit of metadata in its files that describes the > algorithms > >> used and delimits the pieces, so if you want the resulting files to be > >> GnuPG-compatible you'll need to take this into account. > >> > >> If it were me, I'd probably just shell out to `gpg`. It's fast and > >> low-risk. > >> > >> Hope that helps, > >> > >> David > >> > >> > >> On 6 Jul 2017 05:59, "Ivan Lazar Miljenovic" > > >> wrote: > >> > >> I have a use case for needing to use public key cryptography to > >> encrypt a large amount of data in a streaming fashion (get it out of a > >> DB, encrypt, put into an AWS S3 bucket). > >> > >> The command-line gpg tool seems to be able to encrypt/decrypt data > >> from stdin to stdout in a streaming fashion, but in my attempts to use > >> it it seems very file-based for things like the keys to use (whereas I > >> would prefer to be able to pass the public key as an actual value > >> rather than a file; if nothing else because this is for tools that > >> don't have email addresses to use and base their keys on for > >> addressing). > >> > >> Is there an existing library that can achieve this using > >> conduit/pipes/whatever? cryptonite-conduit only covers hashing, > >> hOpenPGP is poorly documented and I can't work out how to use it > >> ("just follow the types" is difficult when Haddock docs don't link to > >> the required types (seems to be because it uses the "import Module as > >> X" trick for re-exporting everything but then everything from those > >> modules isn't available). > >> > >> Can anyone recommend a solution? > >> > >> -- > >> Ivan Lazar Miljenovic > >> Ivan.Miljenovic at gmail.com > >> http://IvanMiljenovic.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. > >> > >> > > > > > > -- > Ivan Lazar Miljenovic > Ivan.Miljenovic at gmail.com > http://IvanMiljenovic.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. -------------- next part -------------- An HTML attachment was scrubbed... URL: From ivan.miljenovic at gmail.com Thu Jul 6 10:10:49 2017 From: ivan.miljenovic at gmail.com (Ivan Lazar Miljenovic) Date: Thu, 6 Jul 2017 20:10:49 +1000 Subject: [Haskell-cafe] Encrypting streamed data In-Reply-To: References: Message-ID: On 6 July 2017 at 19:17, Patrick Chilton wrote: > If your data fits in RAM maybe it's best to forget about the streaming and > use the saltine library's Box module. Then you can't really go wrong on the > crypto front. If that was the case, I wouldn't be asking ;-) > > On Jul 6, 2017 09:41, "Ivan Lazar Miljenovic" > wrote: >> >> On 6 July 2017 at 17:23, David Turner >> wrote: >> > Apologies, just seen the bit about wanting to pass the key in directly >> > rather than using the GPG keyring because there are no email addresses >> > attached to your various keys. >> > >> > Maybe a silly question, but can you give them email addresses to >> > identify >> > them in a GPG-compatible manner? They don't have to have associated >> > mailboxes so the addresses can be totally made-up. >> >> Yes, that's my fallback, since it's possible to tell gpg to use a >> different directory so I can provide a key externally with my >> transmission request, load it into a temporary store, grab the >> identity out and use that. It would just be more convenient to have a >> "here's a ByteString with the public key" option (which I can always >> implement as a wrapper function). >> >> > >> > If not, I'd probably start to look to something like openssl to do the >> > symmetric encryption and manage the keys for that separately. It looks >> > possible to build a streaming AES implementation using the nonstreaming >> > functions in `cryptonite`, but the usual recommendation is that its far >> > too >> > risky to do any low-level crypto yourself so this seems like a bad idea. >> > >> > >> > On 6 Jul 2017 07:40, "David Turner" >> > wrote: >> >> >> >> Hi, >> >> >> >> I do not know of a library to do this, sorry. Note that the way >> >> public-key >> >> crypto works in a streaming fashion is typically to use the public-key >> >> bit >> >> only to encrypt a key for a symmetric cipher and then use the >> >> (much-faster) >> >> symmetric encryption for the actual data. The symmetric bit could well >> >> be >> >> something like AES256-CBC or AES256-CTR. >> >> >> >> This means that the format of the resulting data is a bit >> >> implementation-defined as it has to include the asymetrically-encrypted >> >> data >> >> first, followed by the stream of symmetrically-encrypted data. GnuPG >> >> includes quite a bit of metadata in its files that describes the >> >> algorithms >> >> used and delimits the pieces, so if you want the resulting files to be >> >> GnuPG-compatible you'll need to take this into account. >> >> >> >> If it were me, I'd probably just shell out to `gpg`. It's fast and >> >> low-risk. >> >> >> >> Hope that helps, >> >> >> >> David >> >> >> >> >> >> On 6 Jul 2017 05:59, "Ivan Lazar Miljenovic" >> >> >> >> wrote: >> >> >> >> I have a use case for needing to use public key cryptography to >> >> encrypt a large amount of data in a streaming fashion (get it out of a >> >> DB, encrypt, put into an AWS S3 bucket). >> >> >> >> The command-line gpg tool seems to be able to encrypt/decrypt data >> >> from stdin to stdout in a streaming fashion, but in my attempts to use >> >> it it seems very file-based for things like the keys to use (whereas I >> >> would prefer to be able to pass the public key as an actual value >> >> rather than a file; if nothing else because this is for tools that >> >> don't have email addresses to use and base their keys on for >> >> addressing). >> >> >> >> Is there an existing library that can achieve this using >> >> conduit/pipes/whatever? cryptonite-conduit only covers hashing, >> >> hOpenPGP is poorly documented and I can't work out how to use it >> >> ("just follow the types" is difficult when Haddock docs don't link to >> >> the required types (seems to be because it uses the "import Module as >> >> X" trick for re-exporting everything but then everything from those >> >> modules isn't available). >> >> >> >> Can anyone recommend a solution? >> >> >> >> -- >> >> Ivan Lazar Miljenovic >> >> Ivan.Miljenovic at gmail.com >> >> http://IvanMiljenovic.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. >> >> >> >> >> > >> >> >> >> -- >> Ivan Lazar Miljenovic >> Ivan.Miljenovic at gmail.com >> http://IvanMiljenovic.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. -- Ivan Lazar Miljenovic Ivan.Miljenovic at gmail.com http://IvanMiljenovic.wordpress.com From michael at snoyman.com Thu Jul 6 12:19:37 2017 From: michael at snoyman.com (Michael Snoyman) Date: Thu, 6 Jul 2017 15:19:37 +0300 Subject: [Haskell-cafe] Encrypting streamed data In-Reply-To: References: Message-ID: This is something I've been interested in too, so with some guidance from Vincent I put together a short example of doing this: https://gist.github.com/snoyberg/20243aae347b38ad09daaf8b129e2efb It's got some magic values in a few places (especially that 65!), and the usage of leftovers/B.append is far from efficient. However, it should get the general idea across. On Thu, Jul 6, 2017 at 7:58 AM, Ivan Lazar Miljenovic < ivan.miljenovic at gmail.com> wrote: > I have a use case for needing to use public key cryptography to > encrypt a large amount of data in a streaming fashion (get it out of a > DB, encrypt, put into an AWS S3 bucket). > > The command-line gpg tool seems to be able to encrypt/decrypt data > from stdin to stdout in a streaming fashion, but in my attempts to use > it it seems very file-based for things like the keys to use (whereas I > would prefer to be able to pass the public key as an actual value > rather than a file; if nothing else because this is for tools that > don't have email addresses to use and base their keys on for > addressing). > > Is there an existing library that can achieve this using > conduit/pipes/whatever? cryptonite-conduit only covers hashing, > hOpenPGP is poorly documented and I can't work out how to use it > ("just follow the types" is difficult when Haddock docs don't link to > the required types (seems to be because it uses the "import Module as > X" trick for re-exporting everything but then everything from those > modules isn't available). > > Can anyone recommend a solution? > > -- > Ivan Lazar Miljenovic > Ivan.Miljenovic at gmail.com > http://IvanMiljenovic.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. -------------- next part -------------- An HTML attachment was scrubbed... URL: From monkleyon at gmail.com Thu Jul 6 13:09:17 2017 From: monkleyon at gmail.com (MarLinn) Date: Thu, 6 Jul 2017 15:09:17 +0200 Subject: [Haskell-cafe] Magic values, WAS: Encrypting streamed data In-Reply-To: References: Message-ID: > https://gist.github.com/snoyberg/20243aae347b38ad09daaf8b129e2efb > > It's got some magic values in a few places (especially that 65!) Off topic, but sometimes when I find myself using magic values I can't/won't get rid off, I'll just apply the good old habits learned in Java times. For example you might find a section at the top of a file with things like _DAYS_IN_A_WEEK_ , _KNOWN_SIZE_OF_POINT_ :: INT-- | Seems to be a good approximation for now _DAYS_IN_A_WEEK_ = 7 -- | When you ask "What's the point", this will not answer your question. _KNOWN_SIZE_OF_POINT_ = 65 Uppercase makes it easy to identify these as constants/magic values. The underscore in front works as an initial lowercase letter so they can be used as values despite uppercase. The goal is not necessarily to make these values easy to change, but to add documentation to usage sites. It's unnecessary In such a quick demonstration, but I wanted to take the opportunity to throw in my _VALUE_OF_CONTRIBUTION_IN_CENTS_ cents because I haven't seen others do something like this. Cheers, MarLinn PS: The underscore does introduce its own error message though. • Found hole: _VALUE_OF_CONTRIBUTION_IN_CENTS_ :: Double Or perhaps ‘_VALUE_OF_CONTRIBUTION_IN_CENTS_’ is mis-spelled, or not in scope -------------- next part -------------- An HTML attachment was scrubbed... URL: From capn.freako at gmail.com Thu Jul 6 13:35:07 2017 From: capn.freako at gmail.com (David Banas) Date: Thu, 6 Jul 2017 06:35:07 -0700 Subject: [Haskell-cafe] representations of probability distributions Message-ID: Hi Olaf, I can’t quite tell whether this is apropos to your request, but thought I’d mention it: https://wiki.haskell.org/Random_Processes -db -------------- next part -------------- An HTML attachment was scrubbed... URL: From ietf-dane at dukhovni.org Thu Jul 6 15:44:03 2017 From: ietf-dane at dukhovni.org (Viktor Dukhovni) Date: Thu, 6 Jul 2017 11:44:03 -0400 Subject: [Haskell-cafe] Encrypting streamed data In-Reply-To: References: Message-ID: <1E280315-0C09-4776-BE6B-3F135C543E05@dukhovni.org> > On Jul 6, 2017, at 12:58 AM, Ivan Lazar Miljenovic wrote: > > I have a use case for needing to use public key cryptography to > encrypt a large amount of data in a streaming fashion (get it out of a > DB, encrypt, put into an AWS S3 bucket). What are the data-format requirements? Do you need (binary) CMS output? GPG-compatible output? Or just roll your own? Integrity protection can be tricky with large data streams. Most data formats for enveloped data have a single MAC at the end, which means that the decoder has to consume all the data before it is known to be valid! So if you're in a position to avoid a standard all-in-one format, it makes sense to "packetize" the stream, with integrity protection for each "packet", and packet sequence numbers to preserve overall stream integrity. With vast amounts of data, you'll want to be careful with the symmetric cipher modes, AEAD (AES-GCM, for example) protects only a limited amount of data before you need to rekey. It may be simplest to just generate a new symmetric key for every N megabytes of data. With a careful design of the "packet" format, you can use in-memory crypto for each packet. Don't forget to include an "end-of-stream" packet to defeat truncation attacks. -- Viktor. From taylor at fausak.me Thu Jul 6 16:05:13 2017 From: taylor at fausak.me (Taylor Fausak) Date: Thu, 06 Jul 2017 11:05:13 -0500 Subject: [Haskell-cafe] Issue 61 :: Haskell Weekly Message-ID: <1499357113.3959696.1032493152.4B2A787B@webmail.messagingengine.com> \ Haskell Weekly \/\/ Issue 62 Welcome to another issue of Haskell Weekly! Haskell is a purely functional programming language that focuses on robustness, concision, and correctness. This is a weekly summary of what's going on in its community. ## Featured ## - YOW! Lambda Jam 2017 Videos of 23 talks by Edward Kmett, John Hughes, Conal Elliott, Brian McKenna, Bodil Stokke, and others. - Perhaps not the answer you were expecting but you asked for it A collection of Conor McBride's Stack Overflow answers. - Unit testing effectful Haskell with monad-mock > While monad-mock might not be anything drastically different from > existing testing techniques, my hope is that it can provide an > opinionated mechanism to make testing easy and accessible, even for > complex interactions with other services and systems. - Front Row is hiring a senior backend Haskell engineer (ad) > Come change how 6.5+ million K-12 US students learn Math, Language > Arts, Social Studies and more. Use data, advanced type systems, > great product design and deep pedagogy to change lives. - A major upgrade to Megaparsec: more speed, more power > The version 6 thus will aim to be not just a parser for human- > readable texts and source code, but "one size fits all" general > solution to parsing in Haskell, including low-level binary parsing. - Derive instances of representationally equal types > I made a way to get more free stuff and free stuff is good. - New version of FLTKHS with much better error messages and OpenGL integration > Happy to announce a new major version of FLTKHS, the Haskell > binding to the FLTK for easy native cross-platform GUI apps in > Haskell. - Notes on fusion > Fusion is one of those words that made me recoil for quite a few > years, since it sounds extremely complicated and arcane. A few > years into building applications in Haskell, I still hadn't forced > the thunk. - SuperRecord: Anonymous records for Haskell > A practical library for anonymous records that is both fast and has > an ergonomic interface for both using and extending it. - Typesafe modular arithmetic in Haskell > We would like to get a type error (at compile time) if we do a > operation involving two numbers with a different modulus. The role > of a type system is to represent the invariants and so it will be > great to encode as many invariants of a particular value into the > type. - Lessons learned building a toy compiler > We tend to think of compilers as big black boxes which transform > some high level language, let's say C into a binary in one big > step. I'd like to present it as a pipeline of languages and > transformations, each a bit simpler and slightly lower level than > the one before it. ## Package of the week ## This week's package of the week is Miso, a small isomorphic front-end framework. ## In brief ## - Diskhash: Disk-based, persistent hash tables - Graphing it out - highlight CLI application - Idris dependent typing challenge: Bowling kata - The Spiderman principle - What should a PostgreSQL migrator do? From dennis.raddle at gmail.com Thu Jul 6 16:53:34 2017 From: dennis.raddle at gmail.com (Dennis Raddle) Date: Thu, 6 Jul 2017 09:53:34 -0700 Subject: [Haskell-cafe] parallel Haskell Message-ID: I have a program which does backtracking search in a recursive function. I followed the chapter in "Real World Haskell" to parallelize it. Without Control.Parallel, it uses about 25% of the CPU, namely one core out of four. With the suggestions in RWH it runs faster but still uses only 35% of the CPU max. So I set about creating a MWE in order to experiment and reach out for help. For some reason, my stripped down program isn't working with parallelism at all! There's no effect from the R.W.H. ideas. Can I get some suggestions as to why? Here's the program: -------------------------------------------- import qualified Data.List as L import Text.Printf import System.CPUTime import Data.Function import Control.Parallel -- Run backtracking search for a list of doubles, optimizing a -- fitness function on the list, called 'evalFunc'. At each step, use 'stepFunc' -- to generate a list of possible next Doubles that can be added to the list. -- We are done when the list has 'finalSize' elements. search1_par :: Int -> ([Double] -> Double) -> ([Double] -> [Double]) -> [Double] -> (Double,[Double]) search1_par finalSize evalFunc stepFunc listIn | length listIn == finalSize = (evalFunc listIn,listIn) | otherwise = let steps = stepFunc listIn (steps1,steps2) = divideListInTwo steps f s = search1_par finalSize evalFunc stepFunc $ s:listIn results1 = map f steps1 results2 = map f steps2 results = force results1 `par` (force results2 `pseq` (results1++results2)) in L.maximumBy (compare `on` fst) results force :: [a] -> () force xs = go xs `pseq` () where go (_:xs) = go xs go [] = 1 divideListInTwo :: [a] -> ([a],[a]) divideListInTwo [] = ([],[]) divideListInTwo xs = (take l xs,drop l xs) where l = length xs `div` 2 --------------------------------------------- -- some sample evaluation (fitness) functions and step generation functions. eval1 :: [Double] -> Double eval1 xs = v1 - v2 + v3 where v1 = sum $ zipWith (*) (cycle [1]) xs v2 = sum . map (*2) $ zipWith (*) (cycle [1,0]) xs v3 = sum . map (*3) $ zipWith (*) (cycle [1,0,0]) xs step1 :: [Double] -> [Double] step1 xs | l == 0 = take 8 $ xs | l == 1 = take 8 $ map (/2) xs | l == 2 = take 8 $ map (*3) xs where l = length xs `mod` 3 -------------------------------------------------------------------------------- -- main main = do t1 <- getCPUTime let f :: Double -> String f x = printf "%5.1f" x (_,result) = search1_par 13 eval1 step1 [1,2,3] putStrLn $ concatMap f result t2 <- getCPUTime putStrLn $ printf "CPU time: %.3f" ((fromIntegral $ t2-t1) / 1000000000000 :: Double) -------------- next part -------------- An HTML attachment was scrubbed... URL: From dennis.raddle at gmail.com Thu Jul 6 16:55:18 2017 From: dennis.raddle at gmail.com (Dennis Raddle) Date: Thu, 6 Jul 2017 09:55:18 -0700 Subject: [Haskell-cafe] parallel Haskell In-Reply-To: References: Message-ID: Oh, I should clarify what I mean by "no effect from R.W.H. ideas." I wrote this first without parallelism and it took about 50 seconds to run and used about 20% of the CPU. After modifying it per the suggestions in R.W.H, it still takes about 50 seconds of wall clock time to run, and still uses no more than 20% CPU. -------------- next part -------------- An HTML attachment was scrubbed... URL: From claude at mathr.co.uk Thu Jul 6 17:16:30 2017 From: claude at mathr.co.uk (Claude Heiland-Allen) Date: Thu, 6 Jul 2017 18:16:30 +0100 Subject: [Haskell-cafe] parallel Haskell In-Reply-To: References: Message-ID: <2e1d0016-c4d5-0758-a498-a8182a8e44c4@mathr.co.uk> Hi Dennis, On 06/07/17 17:53, Dennis Raddle wrote: > I have a program which does backtracking search in a recursive > function. I followed the chapter in "Real World Haskell" to parallelize it. [snip] > There's no effect from the R.W.H. ideas. Can I get some suggestions as > to why? You can get timing and other useful diagnostics by compiling with -rtsopts and running with +RTS -s, no need to measure CPU time in your own program. > force :: [a] -> () > force xs = go xs `pseq` () > where go (_:xs) = go xs > go [] = 1 This force doesn't do enough, it just walks the spine. Try this, which forces the elements as well as the shape: force :: [a] -> () force xs = go xs `pseq` () where go (x:xs) = x `pseq` go xs go [] = 1 Thanks, Claude -- https://mathr.co.uk From rein.henrichs at gmail.com Thu Jul 6 17:34:02 2017 From: rein.henrichs at gmail.com (Rein Henrichs) Date: Thu, 06 Jul 2017 17:34:02 +0000 Subject: [Haskell-cafe] parallel Haskell In-Reply-To: <2e1d0016-c4d5-0758-a498-a8182a8e44c4@mathr.co.uk> References: <2e1d0016-c4d5-0758-a498-a8182a8e44c4@mathr.co.uk> Message-ID: Please take a look at Simon Marlow's free book, *Parallel and Concurrent Programming in Haskell* (http://chimera.labs.oreilly.com/books/1230000000929). It will teach you a lot about... the things in the title. On Thu, Jul 6, 2017 at 10:21 AM Claude Heiland-Allen wrote: > Hi Dennis, > > On 06/07/17 17:53, Dennis Raddle wrote: > > I have a program which does backtracking search in a recursive > > function. I followed the chapter in "Real World Haskell" to parallelize > it. > [snip] > > There's no effect from the R.W.H. ideas. Can I get some suggestions as > > to why? > > You can get timing and other useful diagnostics by compiling with > -rtsopts and running with +RTS -s, no need to measure CPU time in your > own program. > > > force :: [a] -> () > > force xs = go xs `pseq` () > > where go (_:xs) = go xs > > go [] = 1 > > This force doesn't do enough, it just walks the spine. Try this, which > forces the elements as well as the shape: > > force :: [a] -> () > force xs = go xs `pseq` () > where go (x:xs) = x `pseq` go xs > go [] = 1 > > Thanks, > > > Claude > -- > https://mathr.co.uk > _______________________________________________ > 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 ivan.miljenovic at gmail.com Thu Jul 6 22:29:01 2017 From: ivan.miljenovic at gmail.com (Ivan Lazar Miljenovic) Date: Fri, 7 Jul 2017 08:29:01 +1000 Subject: [Haskell-cafe] Encrypting streamed data In-Reply-To: <1E280315-0C09-4776-BE6B-3F135C543E05@dukhovni.org> References: <1E280315-0C09-4776-BE6B-3F135C543E05@dukhovni.org> Message-ID: On 7 July 2017 at 01:44, Viktor Dukhovni wrote: > >> On Jul 6, 2017, at 12:58 AM, Ivan Lazar Miljenovic wrote: >> >> I have a use case for needing to use public key cryptography to >> encrypt a large amount of data in a streaming fashion (get it out of a >> DB, encrypt, put into an AWS S3 bucket). > > What are the data-format requirements? Do you need (binary) CMS output? > GPG-compatible output? Or just roll your own? The intent is to be able to transfer data between two parties such that only the recipient is able to view it (hence the usage of public key cryptography). GPG/PGP compatability is preferable as it's common, but anything that is sufficiently standardised (as this will potentially be used by others that aren't me doing so with Haskell and thus can't just use a library to do so) will suffice. (The other advantage of GPG/PGP is that the security testing team is more familiar with it and thus likely to sign off on it.) > > Integrity protection can be tricky with large data streams. Most data > formats for enveloped data have a single MAC at the end, which means > that the decoder has to consume all the data before it is known to be > valid! > > So if you're in a position to avoid a standard all-in-one format, it > makes sense to "packetize" the stream, with integrity protection for > each "packet", and packet sequence numbers to preserve overall stream > integrity. With vast amounts of data, you'll want to be careful with > the symmetric cipher modes, AEAD (AES-GCM, for example) protects only > a limited amount of data before you need to rekey. It may be simplest > to just generate a new symmetric key for every N megabytes of data. > > With a careful design of the "packet" format, you can use in-memory > crypto for each packet. Don't forget to include an "end-of-stream" > packet to defeat truncation attacks. This sounds good in theory, but in practice I'm not versed enough in security to want to try and roll my own if I could avoid it, and trying to document such a format for others to use could be problematic.allowed to post. -- Ivan Lazar Miljenovic Ivan.Miljenovic at gmail.com http://IvanMiljenovic.wordpress.com From rein.henrichs at gmail.com Thu Jul 6 22:56:29 2017 From: rein.henrichs at gmail.com (Rein Henrichs) Date: Thu, 06 Jul 2017 22:56:29 +0000 Subject: [Haskell-cafe] Encrypting streamed data In-Reply-To: References: <1E280315-0C09-4776-BE6B-3F135C543E05@dukhovni.org> Message-ID: If you are not a security expert, I would strongly recommend against rolling your own encryption scheme. If you are a security expert, you would probably not be asking us for advice on how to roll your own encryption scheme. I would suggest that you find something off the rack that might meet your needs (whether it's written in Haskell or not) and make sure you understand how it works and what your threat model is well enough to decide whether it does, in fact, meet your needs. On Thu, Jul 6, 2017 at 3:29 PM Ivan Lazar Miljenovic < ivan.miljenovic at gmail.com> wrote: > On 7 July 2017 at 01:44, Viktor Dukhovni wrote: > > > >> On Jul 6, 2017, at 12:58 AM, Ivan Lazar Miljenovic < > ivan.miljenovic at gmail.com> wrote: > >> > >> I have a use case for needing to use public key cryptography to > >> encrypt a large amount of data in a streaming fashion (get it out of a > >> DB, encrypt, put into an AWS S3 bucket). > > > > What are the data-format requirements? Do you need (binary) CMS output? > > GPG-compatible output? Or just roll your own? > > The intent is to be able to transfer data between two parties such > that only the recipient is able to view it (hence the usage of public > key cryptography). GPG/PGP compatability is preferable as it's > common, but anything that is sufficiently standardised (as this will > potentially be used by others that aren't me doing so with Haskell and > thus can't just use a library to do so) will suffice. > > (The other advantage of GPG/PGP is that the security testing team is > more familiar with it and thus likely to sign off on it.) > > > > > Integrity protection can be tricky with large data streams. Most data > > formats for enveloped data have a single MAC at the end, which means > > that the decoder has to consume all the data before it is known to be > > valid! > > > > So if you're in a position to avoid a standard all-in-one format, it > > makes sense to "packetize" the stream, with integrity protection for > > each "packet", and packet sequence numbers to preserve overall stream > > integrity. With vast amounts of data, you'll want to be careful with > > the symmetric cipher modes, AEAD (AES-GCM, for example) protects only > > a limited amount of data before you need to rekey. It may be simplest > > to just generate a new symmetric key for every N megabytes of data. > > > > With a careful design of the "packet" format, you can use in-memory > > crypto for each packet. Don't forget to include an "end-of-stream" > > packet to defeat truncation attacks. > > This sounds good in theory, but in practice I'm not versed enough in > security to want to try and roll my own if I could avoid it, and > trying to document such a format for others to use could be > problematic.allowed to post. > > -- > Ivan Lazar Miljenovic > Ivan.Miljenovic at gmail.com > http://IvanMiljenovic.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. -------------- next part -------------- An HTML attachment was scrubbed... URL: From rein.henrichs at gmail.com Thu Jul 6 23:04:25 2017 From: rein.henrichs at gmail.com (Rein Henrichs) Date: Thu, 06 Jul 2017 23:04:25 +0000 Subject: [Haskell-cafe] Encrypting streamed data In-Reply-To: References: <1E280315-0C09-4776-BE6B-3F135C543E05@dukhovni.org> Message-ID: I'm also not sure what benefit you would get from rolling your own versus using AWS's server-side S3 bucket encryption[1], now that I think about it. [1] http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingServerSideEncryption.html On Thu, Jul 6, 2017 at 3:56 PM Rein Henrichs wrote: > If you are not a security expert, I would strongly recommend against > rolling your own encryption scheme. If you are a security expert, you would > probably not be asking us for advice on how to roll your own encryption > scheme. I would suggest that you find something off the rack that might > meet your needs (whether it's written in Haskell or not) and make sure you > understand how it works and what your threat model is well enough to decide > whether it does, in fact, meet your needs. > > On Thu, Jul 6, 2017 at 3:29 PM Ivan Lazar Miljenovic < > ivan.miljenovic at gmail.com> wrote: > >> On 7 July 2017 at 01:44, Viktor Dukhovni wrote: >> > >> >> On Jul 6, 2017, at 12:58 AM, Ivan Lazar Miljenovic < >> ivan.miljenovic at gmail.com> wrote: >> >> >> >> I have a use case for needing to use public key cryptography to >> >> encrypt a large amount of data in a streaming fashion (get it out of a >> >> DB, encrypt, put into an AWS S3 bucket). >> > >> > What are the data-format requirements? Do you need (binary) CMS output? >> > GPG-compatible output? Or just roll your own? >> >> The intent is to be able to transfer data between two parties such >> that only the recipient is able to view it (hence the usage of public >> key cryptography). GPG/PGP compatability is preferable as it's >> common, but anything that is sufficiently standardised (as this will >> potentially be used by others that aren't me doing so with Haskell and >> thus can't just use a library to do so) will suffice. >> >> (The other advantage of GPG/PGP is that the security testing team is >> more familiar with it and thus likely to sign off on it.) >> >> > >> > Integrity protection can be tricky with large data streams. Most data >> > formats for enveloped data have a single MAC at the end, which means >> > that the decoder has to consume all the data before it is known to be >> > valid! >> > >> > So if you're in a position to avoid a standard all-in-one format, it >> > makes sense to "packetize" the stream, with integrity protection for >> > each "packet", and packet sequence numbers to preserve overall stream >> > integrity. With vast amounts of data, you'll want to be careful with >> > the symmetric cipher modes, AEAD (AES-GCM, for example) protects only >> > a limited amount of data before you need to rekey. It may be simplest >> > to just generate a new symmetric key for every N megabytes of data. >> > >> > With a careful design of the "packet" format, you can use in-memory >> > crypto for each packet. Don't forget to include an "end-of-stream" >> > packet to defeat truncation attacks. >> >> This sounds good in theory, but in practice I'm not versed enough in >> security to want to try and roll my own if I could avoid it, and >> trying to document such a format for others to use could be >> problematic.allowed to post. >> >> -- >> Ivan Lazar Miljenovic >> Ivan.Miljenovic at gmail.com >> http://IvanMiljenovic.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. > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ivan.miljenovic at gmail.com Thu Jul 6 23:25:42 2017 From: ivan.miljenovic at gmail.com (Ivan Lazar Miljenovic) Date: Fri, 7 Jul 2017 09:25:42 +1000 Subject: [Haskell-cafe] Encrypting streamed data In-Reply-To: References: <1E280315-0C09-4776-BE6B-3F135C543E05@dukhovni.org> Message-ID: On 7 July 2017 at 09:04, Rein Henrichs wrote: > I'm also not sure what benefit you would get from rolling your own versus > using AWS's server-side S3 bucket encryption[1], now that I think about it. > > [1] > http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingServerSideEncryption.html Due to regulatory requirements, we can't rely upon that and need to ensure we never put any private data in AWS that even someone with login access to AWS can read. > > On Thu, Jul 6, 2017 at 3:56 PM Rein Henrichs > wrote: >> >> If you are not a security expert, I would strongly recommend against >> rolling your own encryption scheme. If you are a security expert, you would >> probably not be asking us for advice on how to roll your own encryption >> scheme. I would suggest that you find something off the rack that might meet >> your needs (whether it's written in Haskell or not) and make sure you >> understand how it works and what your threat model is well enough to decide >> whether it does, in fact, meet your needs. >> >> On Thu, Jul 6, 2017 at 3:29 PM Ivan Lazar Miljenovic >> wrote: >>> >>> On 7 July 2017 at 01:44, Viktor Dukhovni wrote: >>> > >>> >> On Jul 6, 2017, at 12:58 AM, Ivan Lazar Miljenovic >>> >> wrote: >>> >> >>> >> I have a use case for needing to use public key cryptography to >>> >> encrypt a large amount of data in a streaming fashion (get it out of a >>> >> DB, encrypt, put into an AWS S3 bucket). >>> > >>> > What are the data-format requirements? Do you need (binary) CMS >>> > output? >>> > GPG-compatible output? Or just roll your own? >>> >>> The intent is to be able to transfer data between two parties such >>> that only the recipient is able to view it (hence the usage of public >>> key cryptography). GPG/PGP compatability is preferable as it's >>> common, but anything that is sufficiently standardised (as this will >>> potentially be used by others that aren't me doing so with Haskell and >>> thus can't just use a library to do so) will suffice. >>> >>> (The other advantage of GPG/PGP is that the security testing team is >>> more familiar with it and thus likely to sign off on it.) >>> >>> > >>> > Integrity protection can be tricky with large data streams. Most data >>> > formats for enveloped data have a single MAC at the end, which means >>> > that the decoder has to consume all the data before it is known to be >>> > valid! >>> > >>> > So if you're in a position to avoid a standard all-in-one format, it >>> > makes sense to "packetize" the stream, with integrity protection for >>> > each "packet", and packet sequence numbers to preserve overall stream >>> > integrity. With vast amounts of data, you'll want to be careful with >>> > the symmetric cipher modes, AEAD (AES-GCM, for example) protects only >>> > a limited amount of data before you need to rekey. It may be simplest >>> > to just generate a new symmetric key for every N megabytes of data. >>> > >>> > With a careful design of the "packet" format, you can use in-memory >>> > crypto for each packet. Don't forget to include an "end-of-stream" >>> > packet to defeat truncation attacks. >>> >>> This sounds good in theory, but in practice I'm not versed enough in >>> security to want to try and roll my own if I could avoid it, and >>> trying to document such a format for others to use could be >>> problematic.allowed to post. >>> >>> -- >>> Ivan Lazar Miljenovic >>> Ivan.Miljenovic at gmail.com >>> http://IvanMiljenovic.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. -- Ivan Lazar Miljenovic Ivan.Miljenovic at gmail.com http://IvanMiljenovic.wordpress.com From rein.henrichs at gmail.com Thu Jul 6 23:27:17 2017 From: rein.henrichs at gmail.com (Rein Henrichs) Date: Thu, 06 Jul 2017 23:27:17 +0000 Subject: [Haskell-cafe] Encrypting streamed data In-Reply-To: References: <1E280315-0C09-4776-BE6B-3F135C543E05@dukhovni.org> Message-ID: Ah, yes. That would do it. On Thu, Jul 6, 2017 at 4:25 PM Ivan Lazar Miljenovic < ivan.miljenovic at gmail.com> wrote: > On 7 July 2017 at 09:04, Rein Henrichs wrote: > > I'm also not sure what benefit you would get from rolling your own versus > > using AWS's server-side S3 bucket encryption[1], now that I think about > it. > > > > [1] > > > http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingServerSideEncryption.html > > Due to regulatory requirements, we can't rely upon that and need to > ensure we never put any private data in AWS that even someone with > login access to AWS can read. > > > > > On Thu, Jul 6, 2017 at 3:56 PM Rein Henrichs > > wrote: > >> > >> If you are not a security expert, I would strongly recommend against > >> rolling your own encryption scheme. If you are a security expert, you > would > >> probably not be asking us for advice on how to roll your own encryption > >> scheme. I would suggest that you find something off the rack that might > meet > >> your needs (whether it's written in Haskell or not) and make sure you > >> understand how it works and what your threat model is well enough to > decide > >> whether it does, in fact, meet your needs. > >> > >> On Thu, Jul 6, 2017 at 3:29 PM Ivan Lazar Miljenovic > >> wrote: > >>> > >>> On 7 July 2017 at 01:44, Viktor Dukhovni > wrote: > >>> > > >>> >> On Jul 6, 2017, at 12:58 AM, Ivan Lazar Miljenovic > >>> >> wrote: > >>> >> > >>> >> I have a use case for needing to use public key cryptography to > >>> >> encrypt a large amount of data in a streaming fashion (get it out > of a > >>> >> DB, encrypt, put into an AWS S3 bucket). > >>> > > >>> > What are the data-format requirements? Do you need (binary) CMS > >>> > output? > >>> > GPG-compatible output? Or just roll your own? > >>> > >>> The intent is to be able to transfer data between two parties such > >>> that only the recipient is able to view it (hence the usage of public > >>> key cryptography). GPG/PGP compatability is preferable as it's > >>> common, but anything that is sufficiently standardised (as this will > >>> potentially be used by others that aren't me doing so with Haskell and > >>> thus can't just use a library to do so) will suffice. > >>> > >>> (The other advantage of GPG/PGP is that the security testing team is > >>> more familiar with it and thus likely to sign off on it.) > >>> > >>> > > >>> > Integrity protection can be tricky with large data streams. Most > data > >>> > formats for enveloped data have a single MAC at the end, which means > >>> > that the decoder has to consume all the data before it is known to be > >>> > valid! > >>> > > >>> > So if you're in a position to avoid a standard all-in-one format, it > >>> > makes sense to "packetize" the stream, with integrity protection for > >>> > each "packet", and packet sequence numbers to preserve overall stream > >>> > integrity. With vast amounts of data, you'll want to be careful with > >>> > the symmetric cipher modes, AEAD (AES-GCM, for example) protects only > >>> > a limited amount of data before you need to rekey. It may be > simplest > >>> > to just generate a new symmetric key for every N megabytes of data. > >>> > > >>> > With a careful design of the "packet" format, you can use in-memory > >>> > crypto for each packet. Don't forget to include an "end-of-stream" > >>> > packet to defeat truncation attacks. > >>> > >>> This sounds good in theory, but in practice I'm not versed enough in > >>> security to want to try and roll my own if I could avoid it, and > >>> trying to document such a format for others to use could be > >>> problematic.allowed to post. > >>> > >>> -- > >>> Ivan Lazar Miljenovic > >>> Ivan.Miljenovic at gmail.com > >>> http://IvanMiljenovic.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. > > > > -- > Ivan Lazar Miljenovic > Ivan.Miljenovic at gmail.com > http://IvanMiljenovic.wordpress.com > -------------- next part -------------- An HTML attachment was scrubbed... URL: From clintonmead at gmail.com Fri Jul 7 04:48:44 2017 From: clintonmead at gmail.com (Clinton Mead) Date: Fri, 7 Jul 2017 14:48:44 +1000 Subject: [Haskell-cafe] Higher order functor package? Message-ID: Consider the illustrative code below: {-# LANGUAGE GADTs #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE KindSignatures #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE PolyKinds #-} {-# LANGUAGE StandaloneDeriving #-} {-# LANGUAGE UndecidableInstances #-} data Param = Param1 | Param2 data T (p :: Param) where TInt :: Int -> T Param1 TInteger :: Integer -> T Param1 TBool :: Bool -> T Param2 data U (p :: Param) where UDouble :: Double -> U Param1 UString :: String -> U Param2 data F (t :: Param -> *) where F :: t Param1 -> t Param2 -> F t f :: T a -> U a f (TInt x) = UDouble (fromIntegral x) f (TInteger x) = UDouble (fromIntegral x) f (TBool x) = UString (show x) class MyFunctor f where myFmap :: (forall a. t a -> u a) -> f t -> f u instance MyFunctor F where myFmap f (F x1 x2) = F (f x1) (f x2) deriving instance Show (U a) deriving instance (Show (t Param1), Show (t Param2)) => Show (F t) main = print $ myFmap f (F (TInt 42) (TBool False)) Basically this is a sort of "higher order" functor, but I can't seem to fit it into an ordinary functor. But it seems like I'm reinventing the wheel, as my code is suspiciously like `Functor` but only slightly different. Has this sort of class already been created and if so what package is it in? -------------- next part -------------- An HTML attachment was scrubbed... URL: From ivan.miljenovic at gmail.com Fri Jul 7 05:00:46 2017 From: ivan.miljenovic at gmail.com (Ivan Lazar Miljenovic) Date: Fri, 7 Jul 2017 15:00:46 +1000 Subject: [Haskell-cafe] Higher order functor package? In-Reply-To: References: Message-ID: On 7 July 2017 at 14:48, Clinton Mead wrote: > Consider the illustrative code below: > > > {-# LANGUAGE GADTs #-} > {-# LANGUAGE DataKinds #-} > {-# LANGUAGE KindSignatures #-} > {-# LANGUAGE RankNTypes #-} > {-# LANGUAGE PolyKinds #-} > {-# LANGUAGE StandaloneDeriving #-} > {-# LANGUAGE UndecidableInstances #-} > > data Param = Param1 | Param2 > > data T (p :: Param) where > TInt :: Int -> T Param1 > TInteger :: Integer -> T Param1 > TBool :: Bool -> T Param2 > > data U (p :: Param) where > UDouble :: Double -> U Param1 > UString :: String -> U Param2 > > data F (t :: Param -> *) where > F :: t Param1 -> t Param2 -> F t > > f :: T a -> U a > f (TInt x) = UDouble (fromIntegral x) > f (TInteger x) = UDouble (fromIntegral x) > f (TBool x) = UString (show x) > > class MyFunctor f where > myFmap :: (forall a. t a -> u a) -> f t -> f u > > instance MyFunctor F where > myFmap f (F x1 x2) = F (f x1) (f x2) > > deriving instance Show (U a) > deriving instance (Show (t Param1), Show (t Param2)) => Show (F t) > > main = print $ myFmap f (F (TInt 42) (TBool False)) > > > Basically this is a sort of "higher order" functor, but I can't seem to fit > it into an ordinary functor. > > But it seems like I'm reinventing the wheel, as my code is suspiciously like > `Functor` but only slightly different. > > Has this sort of class already been created and if so what package is it in? The type signature of myFmap looks a bit like that for hoist: http://hackage.haskell.org/package/mmorph-1.1.0/docs/Control-Monad-Morph.html#v:hoist -- Ivan Lazar Miljenovic Ivan.Miljenovic at gmail.com http://IvanMiljenovic.wordpress.com From dennis.raddle at gmail.com Fri Jul 7 05:06:36 2017 From: dennis.raddle at gmail.com (Dennis Raddle) Date: Thu, 6 Jul 2017 22:06:36 -0700 Subject: [Haskell-cafe] parallel Haskell In-Reply-To: References: <2e1d0016-c4d5-0758-a498-a8182a8e44c4@mathr.co.uk> Message-ID: thanks for the tip, that book is great... I'm reading it now, and it's an easy read, very clear explanations of laziness. I never understood laziness all that well before. D On Thu, Jul 6, 2017 at 10:34 AM, Rein Henrichs wrote: > Please take a look at Simon Marlow's free book, *Parallel and Concurrent > Programming in Haskell* (http://chimera.labs.oreilly.com/books/ > 1230000000929). It will teach you a lot about... the things in the title. > > On Thu, Jul 6, 2017 at 10:21 AM Claude Heiland-Allen > wrote: > >> Hi Dennis, >> >> On 06/07/17 17:53, Dennis Raddle wrote: >> > I have a program which does backtracking search in a recursive >> > function. I followed the chapter in "Real World Haskell" to >> parallelize it. >> [snip] >> > There's no effect from the R.W.H. ideas. Can I get some suggestions as >> > to why? >> >> You can get timing and other useful diagnostics by compiling with >> -rtsopts and running with +RTS -s, no need to measure CPU time in your >> own program. >> >> > force :: [a] -> () >> > force xs = go xs `pseq` () >> > where go (_:xs) = go xs >> > go [] = 1 >> >> This force doesn't do enough, it just walks the spine. Try this, which >> forces the elements as well as the shape: >> >> force :: [a] -> () >> force xs = go xs `pseq` () >> where go (x:xs) = x `pseq` go xs >> go [] = 1 >> >> Thanks, >> >> >> Claude >> -- >> https://mathr.co.uk >> _______________________________________________ >> 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 olshanskydr at gmail.com Fri Jul 7 05:50:29 2017 From: olshanskydr at gmail.com (Dmitry Olshansky) Date: Fri, 7 Jul 2017 08:50:29 +0300 Subject: [Haskell-cafe] constraint inference Message-ID: Hello, cafe! If we have many constraints then compiling is sometimes too slow. Especially if there are some type calculations. And I don't know how to divide this time among different source files because all constraints are checked only when we call a function. I tried to add constraint info into argument definition instead of the function signature but this trick is not working (see below). Is it (at least theoretically) possible to infer the constraint inside a function from the type of function's argument? ------------------------------------ $ stack ghci ---- GHCi, version 8.0.2: Prelude> import Data.Proxy Prelude Data.Proxy> import GHC.TypeLits Prelude Data.Proxy GHC.TypeLits> :set -XRankNTypes Prelude Data.Proxy GHC.TypeLits> let { f :: (KnownSymbol n => Proxy n) -> String; f = symbolVal } :4:54: error: • No instance for (KnownSymbol n) arising from a use of ‘symbolVal’ Possible fix: add (KnownSymbol n) to the context of the type signature for: f :: (KnownSymbol n => Proxy n) -> String • In the expression: symbolVal In an equation for ‘f’: f = symbolVal ------------------------------------ Best regards, Dmitry -------------- next part -------------- An HTML attachment was scrubbed... URL: From ivan.miljenovic at gmail.com Fri Jul 7 06:11:23 2017 From: ivan.miljenovic at gmail.com (Ivan Lazar Miljenovic) Date: Fri, 7 Jul 2017 16:11:23 +1000 Subject: [Haskell-cafe] constraint inference In-Reply-To: References: Message-ID: You've specified RankNTypes but aren't using it; did you mean "(forall n. KnownSymbol n => Proxy n)" ? Typically in these situations you also can't partially apply it, so you might need to make it "f p = symbolVal p". On 7 July 2017 at 15:50, Dmitry Olshansky wrote: > Hello, cafe! > > If we have many constraints then compiling is sometimes too slow. Especially > if there are some type calculations. > And I don't know how to divide this time among different source files > because all constraints are checked only when we call a function. > > I tried to add constraint info into argument definition instead of the > function signature but this trick is not working (see below). > > Is it (at least theoretically) possible to infer the constraint inside a > function from the type of function's argument? > > ------------------------------------ > $ stack ghci > ---- GHCi, version 8.0.2: > Prelude> import Data.Proxy > Prelude Data.Proxy> import GHC.TypeLits > Prelude Data.Proxy GHC.TypeLits> :set -XRankNTypes > Prelude Data.Proxy GHC.TypeLits> let { f :: (KnownSymbol n => Proxy n) -> > String; f = symbolVal } > > :4:54: error: > • No instance for (KnownSymbol n) arising from a use of ‘symbolVal’ > Possible fix: > add (KnownSymbol n) to the context of > the type signature for: > f :: (KnownSymbol n => Proxy n) -> String > • In the expression: symbolVal > In an equation for ‘f’: f = symbolVal > ------------------------------------ > > Best regards, > Dmitry > > > _______________________________________________ > 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. -- Ivan Lazar Miljenovic Ivan.Miljenovic at gmail.com http://IvanMiljenovic.wordpress.com From hesselink at gmail.com Fri Jul 7 06:40:41 2017 From: hesselink at gmail.com (Erik Hesselink) Date: Fri, 7 Jul 2017 08:40:41 +0200 Subject: [Haskell-cafe] Higher order functor package? In-Reply-To: References: Message-ID: I think the keyword you're looking for might be 'indexed', although that also seems to be used for something different (two indices for pre and post conditions). Your functor seems to be in 'index-core' [0], and probably other places (it seems there was something in category-extras but it's unclear where it went). Regards, Erik [0] http://hackage.haskell.org/package/index-core-1.0.4/docs/Control-IMonad-Core.html On 7 July 2017 at 06:48, Clinton Mead wrote: > Consider the illustrative code below: > > > {-# LANGUAGE GADTs #-} > {-# LANGUAGE DataKinds #-} > {-# LANGUAGE KindSignatures #-} > {-# LANGUAGE RankNTypes #-} > {-# LANGUAGE PolyKinds #-} > {-# LANGUAGE StandaloneDeriving #-} > {-# LANGUAGE UndecidableInstances #-} > > data Param = Param1 | Param2 > > data T (p :: Param) where > TInt :: Int -> T Param1 > TInteger :: Integer -> T Param1 > TBool :: Bool -> T Param2 > > data U (p :: Param) where > UDouble :: Double -> U Param1 > UString :: String -> U Param2 > > data F (t :: Param -> *) where > F :: t Param1 -> t Param2 -> F t > > f :: T a -> U a > f (TInt x) = UDouble (fromIntegral x) > f (TInteger x) = UDouble (fromIntegral x) > f (TBool x) = UString (show x) > > class MyFunctor f where > myFmap :: (forall a. t a -> u a) -> f t -> f u > > instance MyFunctor F where > myFmap f (F x1 x2) = F (f x1) (f x2) > > deriving instance Show (U a) > deriving instance (Show (t Param1), Show (t Param2)) => Show (F t) > > main = print $ myFmap f (F (TInt 42) (TBool False)) > > > Basically this is a sort of "higher order" functor, but I can't seem to > fit it into an ordinary functor. > > But it seems like I'm reinventing the wheel, as my code is suspiciously > like `Functor` but only slightly different. > > Has this sort of class already been created and if so what package is it > in? > > > > _______________________________________________ > 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 olshanskydr at gmail.com Fri Jul 7 06:50:16 2017 From: olshanskydr at gmail.com (Dmitry Olshansky) Date: Fri, 7 Jul 2017 09:50:16 +0300 Subject: [Haskell-cafe] Fwd: constraint inference In-Reply-To: References: Message-ID: Sorry, I didn't copy to cafe... ---------- Forwarded message ---------- From: Dmitry Olshansky Date: 2017-07-07 9:24 GMT+03:00 Subject: Re: [Haskell-cafe] constraint inference To: Ivan Lazar Miljenovic I am not sure why but when I didn't set RankNTypes I got an appropriate error. So I specified it. But if I write let { f :: (forall n. KnownSymbol n => Proxy n) -> String; f p = symbolVal p } then nothing is changed. 2017-07-07 9:11 GMT+03:00 Ivan Lazar Miljenovic : > You've specified RankNTypes but aren't using it; did you mean "(forall > n. KnownSymbol n => Proxy n)" ? > > Typically in these situations you also can't partially apply it, so > you might need to make it "f p = symbolVal p". > > On 7 July 2017 at 15:50, Dmitry Olshansky wrote: > > Hello, cafe! > > > > If we have many constraints then compiling is sometimes too slow. > Especially > > if there are some type calculations. > > And I don't know how to divide this time among different source files > > because all constraints are checked only when we call a function. > > > > I tried to add constraint info into argument definition instead of the > > function signature but this trick is not working (see below). > > > > Is it (at least theoretically) possible to infer the constraint inside a > > function from the type of function's argument? > > > > ------------------------------------ > > $ stack ghci > > ---- GHCi, version 8.0.2: > > Prelude> import Data.Proxy > > Prelude Data.Proxy> import GHC.TypeLits > > Prelude Data.Proxy GHC.TypeLits> :set -XRankNTypes > > Prelude Data.Proxy GHC.TypeLits> let { f :: (KnownSymbol n => Proxy n) -> > > String; f = symbolVal } > > > > :4:54: error: > > • No instance for (KnownSymbol n) arising from a use of ‘symbolVal’ > > Possible fix: > > add (KnownSymbol n) to the context of > > the type signature for: > > f :: (KnownSymbol n => Proxy n) -> String > > • In the expression: symbolVal > > In an equation for ‘f’: f = symbolVal > > ------------------------------------ > > > > Best regards, > > Dmitry > > > > > > _______________________________________________ > > 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. > > > > -- > Ivan Lazar Miljenovic > Ivan.Miljenovic at gmail.com > http://IvanMiljenovic.wordpress.com > -------------- next part -------------- An HTML attachment was scrubbed... URL: From raabe at froglogic.com Fri Jul 7 07:11:53 2017 From: raabe at froglogic.com (Frerich Raabe) Date: Fri, 07 Jul 2017 09:11:53 +0200 Subject: [Haskell-cafe] Issue 61 :: Haskell Weekly In-Reply-To: <1499357113.3959696.1032493152.4B2A787B@webmail.messagingengine.com> References: <1499357113.3959696.1032493152.4B2A787B@webmail.messagingengine.com> Message-ID: On 2017-07-06 18:05, Taylor Fausak wrote: > \ Haskell Weekly > \/\/ Issue 62 > [..] > - Perhaps not the answer you were expecting but you asked for it > > A collection of Conor McBride's Stack Overflow answers. Despite the fact that this is just a loose collection of answers without a lot of context (e.g. the questions which were answered are missing), I very much enjoyed reading it. I like the way in which Conor manages to discuss beginner-level questions as well as more advanced topics using simple language but without sacrificing correctness. Maybe he could be bribed into writing a book in this theme, various assorted topics much as in the style of Scott Meyers' "Effective C++" books? I'd certainly benefit and buy it. :-) -- Frerich Raabe - raabe at froglogic.com www.froglogic.com - Multi-Platform GUI Testing From dennis.raddle at gmail.com Fri Jul 7 08:33:22 2017 From: dennis.raddle at gmail.com (Dennis Raddle) Date: Fri, 7 Jul 2017 01:33:22 -0700 Subject: [Haskell-cafe] parallel Haskell In-Reply-To: References: <2e1d0016-c4d5-0758-a498-a8182a8e44c4@mathr.co.uk> Message-ID: I'm looking into using rpar and rseq from Control.Parallel.Strategies. The issue is that most of my code executes in a monad stack including StateT and ExceptT. Can I use the Eval monad at the root of the stack safely? D On Thu, Jul 6, 2017 at 10:06 PM, Dennis Raddle wrote: > thanks for the tip, that book is great... I'm reading it now, and it's an > easy read, very clear explanations of laziness. I never understood laziness > all that well before. > > D > > On Thu, Jul 6, 2017 at 10:34 AM, Rein Henrichs > wrote: > >> Please take a look at Simon Marlow's free book, *Parallel and Concurrent >> Programming in Haskell* (http://chimera.labs.o >> reilly.com/books/1230000000929). It will teach you a lot about... the >> things in the title. >> >> On Thu, Jul 6, 2017 at 10:21 AM Claude Heiland-Allen >> wrote: >> >>> Hi Dennis, >>> >>> On 06/07/17 17:53, Dennis Raddle wrote: >>> > I have a program which does backtracking search in a recursive >>> > function. I followed the chapter in "Real World Haskell" to >>> parallelize it. >>> [snip] >>> > There's no effect from the R.W.H. ideas. Can I get some suggestions as >>> > to why? >>> >>> You can get timing and other useful diagnostics by compiling with >>> -rtsopts and running with +RTS -s, no need to measure CPU time in your >>> own program. >>> >>> > force :: [a] -> () >>> > force xs = go xs `pseq` () >>> > where go (_:xs) = go xs >>> > go [] = 1 >>> >>> This force doesn't do enough, it just walks the spine. Try this, which >>> forces the elements as well as the shape: >>> >>> force :: [a] -> () >>> force xs = go xs `pseq` () >>> where go (x:xs) = x `pseq` go xs >>> go [] = 1 >>> >>> Thanks, >>> >>> >>> Claude >>> -- >>> https://mathr.co.uk >>> _______________________________________________ >>> 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 dennis.raddle at gmail.com Fri Jul 7 08:50:32 2017 From: dennis.raddle at gmail.com (Dennis Raddle) Date: Fri, 7 Jul 2017 01:50:32 -0700 Subject: [Haskell-cafe] parallel Haskell In-Reply-To: References: <2e1d0016-c4d5-0758-a498-a8182a8e44c4@mathr.co.uk> Message-ID: Oh, I think I realized why that won't work. I think that a program in the State monad, for instance, must execute its computations sequentially. There is no way to "split" a State monad into separate lines of execution from within the monad. I think the answer is that I have to split my computation before my code enters into the State monad. So I need to call runState four times for four cores, or whatever. Something like that. D On Fri, Jul 7, 2017 at 1:33 AM, Dennis Raddle wrote: > I'm looking into using rpar and rseq from Control.Parallel.Strategies. The > issue is that most of my code executes in a monad stack including StateT > and ExceptT. Can I use the Eval monad at the root of the stack safely? > > D > > On Thu, Jul 6, 2017 at 10:06 PM, Dennis Raddle > wrote: > >> thanks for the tip, that book is great... I'm reading it now, and it's an >> easy read, very clear explanations of laziness. I never understood laziness >> all that well before. >> >> D >> >> On Thu, Jul 6, 2017 at 10:34 AM, Rein Henrichs >> wrote: >> >>> Please take a look at Simon Marlow's free book, *Parallel and >>> Concurrent Programming in Haskell* (http://chimera.labs.o >>> reilly.com/books/1230000000929). It will teach you a lot about... the >>> things in the title. >>> >>> On Thu, Jul 6, 2017 at 10:21 AM Claude Heiland-Allen >>> wrote: >>> >>>> Hi Dennis, >>>> >>>> On 06/07/17 17:53, Dennis Raddle wrote: >>>> > I have a program which does backtracking search in a recursive >>>> > function. I followed the chapter in "Real World Haskell" to >>>> parallelize it. >>>> [snip] >>>> > There's no effect from the R.W.H. ideas. Can I get some suggestions as >>>> > to why? >>>> >>>> You can get timing and other useful diagnostics by compiling with >>>> -rtsopts and running with +RTS -s, no need to measure CPU time in your >>>> own program. >>>> >>>> > force :: [a] -> () >>>> > force xs = go xs `pseq` () >>>> > where go (_:xs) = go xs >>>> > go [] = 1 >>>> >>>> This force doesn't do enough, it just walks the spine. Try this, which >>>> forces the elements as well as the shape: >>>> >>>> force :: [a] -> () >>>> force xs = go xs `pseq` () >>>> where go (x:xs) = x `pseq` go xs >>>> go [] = 1 >>>> >>>> Thanks, >>>> >>>> >>>> Claude >>>> -- >>>> https://mathr.co.uk >>>> _______________________________________________ >>>> 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 code at funwithsoftware.org Fri Jul 7 13:12:11 2017 From: code at funwithsoftware.org (Patrick Pelletier) Date: Fri, 7 Jul 2017 06:12:11 -0700 Subject: [Haskell-cafe] "stack script" and extra-deps Message-ID: When I use "stack script", how can I specify a package which is not in Stackage? When using a stack.yaml, I can just specify such a package in extra-deps, but I'm not clear how to translate this to "stack script". Thanks, --Patrick From clintonmead at gmail.com Fri Jul 7 18:44:14 2017 From: clintonmead at gmail.com (Clinton Mead) Date: Sat, 8 Jul 2017 04:44:14 +1000 Subject: [Haskell-cafe] Higher order functor package? In-Reply-To: References: Message-ID: Hi Erik and All I don't think "indexed-core" is what I'm looking for. "indexed-code" refers to the following type: > (a :-> b) -> f a :-> f b Where: > type (:->) a b = forall i. a i -> b i This effectively makes the result of the functor: > (forall i1. (a i1 -> b i1)) -> (forall i2. (f a i2 -> f b i2)) But what I want is subtly different: > (forall i. (a i -> b i)) -> f a -> f b Indeed, with my code, "f a i" doesn't make much sense as "f a" itself is of type *. What I'd find useful is something like the following: > class HighFunctor f where > hfmap :: (forall a. t a -> u a) -> f t -> f u > > class HighFunctor2 f where > hfmap2 :: (forall a. t a -> u a -> v a) -> f t -> f u -> f v > > class HighFunctorMaybe f where > hfmapMaybe :: (forall a. Maybe (t a) -> u a) -> Maybe (f t) -> f u > > class HighFunctor2Maybe1 f where > hfmap2maybe1 :: (forall a. Maybe (t a) -> u a -> v a) -> Maybe (f t) -> f u -> f v > > class HighFunctor2Maybe2 f where > hfmap2maybe2 :: (forall a. t a -> Maybe (u a) -> v a) -> f t -> Maybe (f u) -> f v > > class HighFunctor2MaybeBoth f where > hfmap2maybeBoth :: (forall a. Maybe (t a) -> Maybe (u a) -> v a) -> Maybe (f t) -> Maybe (f u) -> f v As you can see. I'm basically hacking up with separate classes what can be done easily with applicative, and it's getting a bit messy. I've been trying to clean this up, so I don't need so many different functions for different combinations of maybes, by defining these helper functions: > data Transform outerT innerT a = Transform (outerT (innerT a)) > > transformIn :: outerT (f innerT) -> f (Transform outerT innerT) > > transformOut :: Transform outerT innerT a -> outerT (innerT a) > transformOut (Transform x) = x By applying "transformIn" to an argument on the way in to hfmapN, and "transformOut" on the way out, one can pass through maybes to the standard top to non-maybe "HighFunctor" instances. But note that whilst "transformOut" is always trivial to implement, the way in, "transformIn" doesn't seem trivial. "transformIn" I think has to be implemented for each combination of "outerT" and "f", like so: > class TransformIn outerT f where > f :: outerT (f innerT) -> f (Transform outerT innerT) Anyway, the point of all this is that I'd like to be able to just launch my base functions (over the "forall i" space) into these higher level datatypes that wrap the foralls up in a datatype, in a similar way I can do so with functor and applicative. I think the code in the first post is the best illustration of what I'm trying to achieve but with two added things: 1. The ability to deal with multiple arguments in an applicative style <$> <*> way 2. The ability to promote "wrapped" types, I think kind of in a way "traversable" does. Sorry if this all is a bit vague, but hopefully the code in the first post and this gives the gist of what I'm trying to achieve. Any help or ideas appreciated. Thanks, Clinton On Fri, Jul 7, 2017 at 4:40 PM, Erik Hesselink wrote: > I think the keyword you're looking for might be 'indexed', although that > also seems to be used for something different (two indices for pre and post > conditions). Your functor seems to be in 'index-core' [0], and probably > other places (it seems there was something in category-extras but it's > unclear where it went). > > Regards, > > Erik > > [0] http://hackage.haskell.org/package/index-core-1.0.4/docs/ > Control-IMonad-Core.html > > On 7 July 2017 at 06:48, Clinton Mead wrote: > >> Consider the illustrative code below: >> >> >> {-# LANGUAGE GADTs #-} >> {-# LANGUAGE DataKinds #-} >> {-# LANGUAGE KindSignatures #-} >> {-# LANGUAGE RankNTypes #-} >> {-# LANGUAGE PolyKinds #-} >> {-# LANGUAGE StandaloneDeriving #-} >> {-# LANGUAGE UndecidableInstances #-} >> >> data Param = Param1 | Param2 >> >> data T (p :: Param) where >> TInt :: Int -> T Param1 >> TInteger :: Integer -> T Param1 >> TBool :: Bool -> T Param2 >> >> data U (p :: Param) where >> UDouble :: Double -> U Param1 >> UString :: String -> U Param2 >> >> data F (t :: Param -> *) where >> F :: t Param1 -> t Param2 -> F t >> >> f :: T a -> U a >> f (TInt x) = UDouble (fromIntegral x) >> f (TInteger x) = UDouble (fromIntegral x) >> f (TBool x) = UString (show x) >> >> class MyFunctor f where >> myFmap :: (forall a. t a -> u a) -> f t -> f u >> >> instance MyFunctor F where >> myFmap f (F x1 x2) = F (f x1) (f x2) >> >> deriving instance Show (U a) >> deriving instance (Show (t Param1), Show (t Param2)) => Show (F t) >> >> main = print $ myFmap f (F (TInt 42) (TBool False)) >> >> >> Basically this is a sort of "higher order" functor, but I can't seem to >> fit it into an ordinary functor. >> >> But it seems like I'm reinventing the wheel, as my code is suspiciously >> like `Functor` but only slightly different. >> >> Has this sort of class already been created and if so what package is it >> in? >> >> >> >> _______________________________________________ >> 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 rein.henrichs at gmail.com Fri Jul 7 18:50:07 2017 From: rein.henrichs at gmail.com (Rein Henrichs) Date: Fri, 07 Jul 2017 18:50:07 +0000 Subject: [Haskell-cafe] Higher order functor package? In-Reply-To: References: Message-ID: I recommend posting this question to StackOverflow and hoping that Conor McBride notices it. On Fri, Jul 7, 2017 at 11:46 AM Clinton Mead wrote: > Hi Erik and All > > I don't think "indexed-core" is what I'm looking for. "indexed-code" > refers to the following type: > > > (a :-> > b) > -> f a :-> > f > b > > Where: > > > type (:->) a b = forall i. a i -> b i > > This effectively makes the result of the functor: > > > (forall i1. (a i1 -> b i1)) -> (forall i2. (f a i2 -> f b i2)) > > But what I want is subtly different: > > > (forall i. (a i -> b i)) -> f a -> f b > > Indeed, with my code, "f a i" doesn't make much sense as "f a" itself is > of type *. > > What I'd find useful is something like the following: > > > class HighFunctor f where > > hfmap :: (forall a. t a -> u a) -> f t -> f u > > > > class HighFunctor2 f where > > hfmap2 :: (forall a. t a -> u a -> v a) -> f t -> f u -> f v > > > > class HighFunctorMaybe f where > > hfmapMaybe :: (forall a. Maybe (t a) -> u a) -> Maybe (f t) -> f u > > > > class HighFunctor2Maybe1 f where > > hfmap2maybe1 :: (forall a. Maybe (t a) -> u a -> v a) -> Maybe (f t) > -> f u -> f v > > > > class HighFunctor2Maybe2 f where > > hfmap2maybe2 :: (forall a. t a -> Maybe (u a) -> v a) -> f t -> Maybe > (f u) -> f v > > > > class HighFunctor2MaybeBoth f where > > hfmap2maybeBoth :: (forall a. Maybe (t a) -> Maybe (u a) -> v a) -> > Maybe (f t) -> Maybe (f u) -> f v > > As you can see. I'm basically hacking up with separate classes what can be > done easily with applicative, and it's getting a bit messy. I've been > trying to clean this up, so I don't need so many different functions for > different combinations of maybes, by defining these helper functions: > > > data Transform outerT innerT a = Transform (outerT (innerT a)) > > > > transformIn :: outerT (f innerT) -> f (Transform outerT innerT) > > > > transformOut :: Transform outerT innerT a -> outerT (innerT a) > > transformOut (Transform x) = x > > By applying "transformIn" to an argument on the way in to hfmapN, and > "transformOut" on the way out, one can pass through maybes to the standard > top to non-maybe "HighFunctor" instances. > > But note that whilst "transformOut" is always trivial to implement, the > way in, "transformIn" doesn't seem trivial. "transformIn" I think has to be > implemented for each combination of "outerT" and "f", like so: > > > class TransformIn outerT f where > > f :: outerT (f innerT) -> f (Transform outerT innerT) > > Anyway, the point of all this is that I'd like to be able to just launch > my base functions (over the "forall i" space) into these higher level > datatypes that wrap the foralls up in a datatype, in a similar way I can do > so with functor and applicative. > > I think the code in the first post is the best illustration of what I'm > trying to achieve but with two added things: > > 1. The ability to deal with multiple arguments in an applicative style <$> > <*> way > 2. The ability to promote "wrapped" types, I think kind of in a way > "traversable" does. > > Sorry if this all is a bit vague, but hopefully the code in the first post > and this gives the gist of what I'm trying to achieve. > > Any help or ideas appreciated. > > Thanks, > > Clinton > > On Fri, Jul 7, 2017 at 4:40 PM, Erik Hesselink > wrote: > >> I think the keyword you're looking for might be 'indexed', although that >> also seems to be used for something different (two indices for pre and post >> conditions). Your functor seems to be in 'index-core' [0], and probably >> other places (it seems there was something in category-extras but it's >> unclear where it went). >> >> Regards, >> >> Erik >> >> [0] >> http://hackage.haskell.org/package/index-core-1.0.4/docs/Control-IMonad-Core.html >> >> On 7 July 2017 at 06:48, Clinton Mead wrote: >> >>> Consider the illustrative code below: >>> >>> >>> {-# LANGUAGE GADTs #-} >>> {-# LANGUAGE DataKinds #-} >>> {-# LANGUAGE KindSignatures #-} >>> {-# LANGUAGE RankNTypes #-} >>> {-# LANGUAGE PolyKinds #-} >>> {-# LANGUAGE StandaloneDeriving #-} >>> {-# LANGUAGE UndecidableInstances #-} >>> >>> data Param = Param1 | Param2 >>> >>> data T (p :: Param) where >>> TInt :: Int -> T Param1 >>> TInteger :: Integer -> T Param1 >>> TBool :: Bool -> T Param2 >>> >>> data U (p :: Param) where >>> UDouble :: Double -> U Param1 >>> UString :: String -> U Param2 >>> >>> data F (t :: Param -> *) where >>> F :: t Param1 -> t Param2 -> F t >>> >>> f :: T a -> U a >>> f (TInt x) = UDouble (fromIntegral x) >>> f (TInteger x) = UDouble (fromIntegral x) >>> f (TBool x) = UString (show x) >>> >>> class MyFunctor f where >>> myFmap :: (forall a. t a -> u a) -> f t -> f u >>> >>> instance MyFunctor F where >>> myFmap f (F x1 x2) = F (f x1) (f x2) >>> >>> deriving instance Show (U a) >>> deriving instance (Show (t Param1), Show (t Param2)) => Show (F t) >>> >>> main = print $ myFmap f (F (TInt 42) (TBool False)) >>> >>> >>> Basically this is a sort of "higher order" functor, but I can't seem to >>> fit it into an ordinary functor. >>> >>> But it seems like I'm reinventing the wheel, as my code is suspiciously >>> like `Functor` but only slightly different. >>> >>> Has this sort of class already been created and if so what package is it >>> in? >>> >>> >>> >>> _______________________________________________ >>> 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 benjamin.rickels at gmail.com Fri Jul 7 18:58:35 2017 From: benjamin.rickels at gmail.com (Benjamin Rickels) Date: Fri, 07 Jul 2017 18:58:35 +0000 Subject: [Haskell-cafe] Prelude's documentation on Hackage incomplete? Message-ID: I was recently looking at the various functions the RealFrac type class provides and noticed, that Double isn't listed as an instance of it; and neither are Num, Real and Fractional mentioned as implemented instances in the documentation for Double. Now, somebody who is familiar with the hierarchy of the numeric type classes could of course rather easily deduct, that, since Double is an instance of RealFloat (this is mentioned in the documentation on Hackage), it is also required to implement all of the above. And (surely enough) the Haskell 98 Report lists all the relevant implementations and so does a quick *:info Double* in GHCi. However I'd (assume and thus) argue, that most beginners who google (or especially hoogle) anything about Haskell, are often directed to the Hackage documentation itself - and any missing information there could lead to quite a bit of a headache; even more so, if this concerns something as important as the Prelude. Therefore I'd like to ask, whether this is a known issue and independently propose, that (in the meantime) an official recommendation somewhere to do a quick *:info * or :info * *in GHCi yourself, as to find out, which type class instances are currently available, might help to alleviate some confusion. Benjamin -------------- next part -------------- An HTML attachment was scrubbed... URL: From lysxia at gmail.com Fri Jul 7 19:10:57 2017 From: lysxia at gmail.com (Li-yao Xia) Date: Fri, 7 Jul 2017 15:10:57 -0400 Subject: [Haskell-cafe] Higher order functor package? In-Reply-To: References: Message-ID: <29386f6e-916a-5e2f-c349-36037ade5a23@gmail.com> Hi Clinton, This should be a compilable Literate Haskell program; a copy of your preliminary definitions is at the end. > {-# LANGUAGE MultiParamTypeClasses, PolyKinds, FunctionalDependencies, TypeOperators, GADTs, > RankNTypes, DataKinds, StandaloneDeriving, UndecidableInstances, FlexibleContexts, InstanceSigs #-} > > import Control.Category > import Prelude hiding ((.), id, Functor(..)) What you want certainly looks like a functor[1] in the general sense, only not in the usual category that the Functortype class is specialized for. A more general definition of functors can be found in the categories[2] package. This one also abstracts over the domain and codomain categories r and t. You obtain the standard Functor by restricting to r ~ (->), t ~ (->). > class (Category r, Category t) => Functor f r t | f r -> t, f t -> r where > fmap :: r a b -> t (f a) (f b) The expected result type of myFmap is (f t -> f u), so the codomain category is still (->) (category of types and functions). But t and u here are objects in a different category, which can be defined by the (:->) type below: > -- Objects are types (t, u, ...) of kind (Param -> *), > -- morphisms are polymorphic functions of type (forall a. t a -> u a). > newtype (:->) t u = HFun (forall a. t a -> u a) You can indeed implement the type class in Control.Category, and check the category laws... > instance Category (:->) where > id = HFun id > HFun f . HFun g = HFun (f . g) And here is a Functor instance: > instance Functor F (:->) (->) where > fmap :: (t :-> u) -> F t -> F u > fmap (HFun f) (F x1 x2) = F (f x1) (f x2) Hide away the wrapping of the (:->) newtype: > myFmap :: Functor f (:->) (->) => (forall a. t a -> u a) -> f t -> f u > myFmap f = fmap (HFun f) Voilà. > main = print $ myFmap f (F (TInt 42) (TBool False)) [1] https://en.wikipedia.org/wiki/Category_(mathematics) [2] http://hackage.haskell.org/package/categories Auxiliary definitions > data Param = Param1 | Param2 > > data T (p :: Param) where > TInt :: Int -> T Param1 > TInteger :: Integer -> T Param1 > TBool :: Bool -> T Param2 > > data U (p :: Param) where > UDouble :: Double -> U Param1 > UString :: String -> U Param2 > > data F (t :: Param -> *) where > F :: t Param1 -> t Param2 -> F t > > f :: T a -> U a > f (TInt x) = UDouble (fromIntegral x) > f (TInteger x) = UDouble (fromIntegral x) > f (TBool x) = UString (show x) > > deriving instance Show (U a) > deriving instance (Show (t Param1), Show (t Param2)) => Show (F t) From dave at zednenem.com Fri Jul 7 19:16:41 2017 From: dave at zednenem.com (David Menendez) Date: Fri, 7 Jul 2017 15:16:41 -0400 Subject: [Haskell-cafe] Higher order functor package? In-Reply-To: References: Message-ID: This is indeed a functor, but it’s a functor from type constructors and index-preserving functions to types and functions. You can’t represent these with the standard Functor class, and I’m not aware of a specific package that provides these. There have been a few attempts to make more general Functor classes that could include these functors, such as Kmett’s “hask”, but I suspect they’re a bit more powerful than you need. You are probably better off defining your class, if you find it useful. For reference, the Functor class represents objects in Hask -> Hask. McBride’s indexed functors are (|k| -> Hask) -> (|k| -> Hask), where k may be Hask or a data kind. (The bars indicate a category with no arrows between objects.) Your functors are (|k| -> Hask) -> Hask. On Fri, Jul 7, 2017 at 12:48 AM, Clinton Mead wrote: > Consider the illustrative code below: > > > {-# LANGUAGE GADTs #-} > {-# LANGUAGE DataKinds #-} > {-# LANGUAGE KindSignatures #-} > {-# LANGUAGE RankNTypes #-} > {-# LANGUAGE PolyKinds #-} > {-# LANGUAGE StandaloneDeriving #-} > {-# LANGUAGE UndecidableInstances #-} > > data Param = Param1 | Param2 > > data T (p :: Param) where > TInt :: Int -> T Param1 > TInteger :: Integer -> T Param1 > TBool :: Bool -> T Param2 > > data U (p :: Param) where > UDouble :: Double -> U Param1 > UString :: String -> U Param2 > > data F (t :: Param -> *) where > F :: t Param1 -> t Param2 -> F t > > f :: T a -> U a > f (TInt x) = UDouble (fromIntegral x) > f (TInteger x) = UDouble (fromIntegral x) > f (TBool x) = UString (show x) > > class MyFunctor f where > myFmap :: (forall a. t a -> u a) -> f t -> f u > > instance MyFunctor F where > myFmap f (F x1 x2) = F (f x1) (f x2) > > deriving instance Show (U a) > deriving instance (Show (t Param1), Show (t Param2)) => Show (F t) > > main = print $ myFmap f (F (TInt 42) (TBool False)) > > > Basically this is a sort of "higher order" functor, but I can't seem to fit > it into an ordinary functor. > > But it seems like I'm reinventing the wheel, as my code is suspiciously like > `Functor` but only slightly different. > > Has this sort of class already been created and if so what package is it in? > > > > _______________________________________________ > 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. -- Dave Menendez From lysxia at gmail.com Fri Jul 7 19:17:47 2017 From: lysxia at gmail.com (Li-yao Xia) Date: Fri, 7 Jul 2017 15:17:47 -0400 Subject: [Haskell-cafe] Fwd: constraint inference In-Reply-To: References: Message-ID: <34454cf6-33b3-7d8d-0211-d696f0a2358b@gmail.com> On 07/07/2017 02:50 AM, Dmitry Olshansky wrote: > I am not sure why but when I didn't set RankNTypes I got an appropriate > error. So I specified it. > > But if I write > let { f :: (forall n. KnownSymbol n => Proxy n) -> String; f p = > symbolVal p } > then nothing is changed. > > What would the String (f Proxy) be? (Note that (Proxy :: forall n. KnownSymbol n => Proxy n) would be a valid argument here.) From mblazevic at stilo.com Fri Jul 7 19:57:52 2017 From: mblazevic at stilo.com (=?UTF-8?Q?Mario_Bla=c5=beevi=c4=87?=) Date: Fri, 7 Jul 2017 15:57:52 -0400 Subject: [Haskell-cafe] Higher order functor package? In-Reply-To: References: Message-ID: On 2017-07-07 12:48 AM, Clinton Mead wrote: > Consider the illustrative code below: > ... > class MyFunctor f where > myFmap :: (forall a. t a -> u a) -> f t -> f u > ... > > > Basically this is a sort of "higher order" functor, but I can't seem to > fit it into an ordinary functor. > > But it seems like I'm reinventing the wheel, as my code is suspiciously > like `Functor` but only slightly different. > > Has this sort of class already been created and if so what package is it in? Yes, I have recently created rank2classes package: http://hackage.haskell.org/package/rank2classes Apart from the mirror-universe Functor class, the package exports the Applicative, Foldable, Traversable, Applicative, and Distributive classes, as well as some Template Hashell to derive some of their instances automatically. From harendra.kumar at gmail.com Fri Jul 7 20:03:06 2017 From: harendra.kumar at gmail.com (Harendra Kumar) Date: Sat, 8 Jul 2017 01:33:06 +0530 Subject: [Haskell-cafe] "stack script" and extra-deps In-Reply-To: References: Message-ID: "stack script" does not allow packages outside the snapshot. If you need extra-deps, you can use "stack runghc" instead. -harendra On 7 July 2017 at 18:42, Patrick Pelletier wrote: > When I use "stack script", how can I specify a package which is not in > Stackage? When using a stack.yaml, I can just specify such a package in > extra-deps, but I'm not clear how to translate this to "stack script". > > 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. -------------- next part -------------- An HTML attachment was scrubbed... URL: From wolfgang-it at jeltsch.info Fri Jul 7 22:36:16 2017 From: wolfgang-it at jeltsch.info (Wolfgang Jeltsch) Date: Sat, 08 Jul 2017 01:36:16 +0300 Subject: [Haskell-cafe] Haskell in Leipzig 2017: 2nd call for papers Message-ID: <1499466976.2497.211.camel@jeltsch.info> Event:    Haskell in Leipzig 2017 Time:     October 26–28, 2017 Place:    HTWK Leipzig, Germany Homepage: https://hal2017.softbase.org/ About ===== Haskell is a modern functional programming language that allows rapid development of robust and correct software. It is renowned for its expressive type system, its unique approaches to concurrency and parallelism, and its excellent refactoring capabilities. Haskell is both the playing field of cutting-edge programming language research and a reliable base for commercial software development. The workshop series Haskell in Leipzig (HaL), now in its 12th year, brings together Haskell developers, Haskell researchers, Haskell enthusiasts, and Haskell beginners to listen to talks, take part in tutorials, join in interesting conversations, and hack together. To support the latter, HaL will include a one-day hackathon this year. The workshop will have a focus on functional reactive programming (FRP) this time, while continuing to be open to all aspects of Haskell. As in the previous year, the workshop will be in English. Contributions ============= Everything related to Haskell is on topic, whether it is about current research, practical applications, interesting ideas off the beaten track, education, or art, and topics may extend to functional programming in general and its connections to other programming paradigms. Contributions can take the form of   * talks (about 30 minutes),   * tutorials (about 90 minutes),   * demonstrations, artistic performances, or other extraordinary     things. Please submit an abstract that describes the content and form of your presentation, the intended audience, and required previous knowledge. We recommend a length of 2 pages, so that the program committee and the audience get a good idea of your contribution, but this is not a hard requirement. Please submit your abstract as a PDF document at     https://easychair.org/conferences/?conf=hal2017 until Friday, August 4, 2017. You will be notified by Friday, August 25, 2017. Hacking Projects ================ Projects for the hackathon can be presented during the workshop. A prior submission is not needed for this. Invited Speaker ===============   * Ivan Perez, University of Nottingham, UK Program Committee =================   * Edward Amsden, Plow Technologies, USA   * Heinrich Apfelmus, Germany   * Jurriaan Hage, Utrecht University, The Netherlands   * Petra Hofstedt, BTU Cottbus-Senftenberg, Germany   * Wolfgang Jeltsch, Tallinn University of Technology, Estonia (chair)   * Andres Löh, Well-Typed LLP, Germany   * Keiko Nakata, SAP SE, Germany   * Henrik Nilsson, University of Nottingham, UK   * Ertuğrul Söylemez, Intelego GmbH, Germany   * Henning Thielemann, Germany   * Niki Vazou, University of Maryland, USA   * Johannes Waldmann, HTWK Leipzig, Germany Questions ========= If you have any questions, please do not hesitate to contact Wolfgang Jeltsch at wolfgang-it at jeltsch.info. From yotam2206 at gmail.com Sat Jul 8 08:17:07 2017 From: yotam2206 at gmail.com (Yotam Ohad) Date: Sat, 08 Jul 2017 08:17:07 +0000 Subject: [Haskell-cafe] Collision Detection Message-ID: Dear Cafe, I am thinking about writing a small physics engine with collision detection and I wanted to go over my ideas with you to help me refine them. I want to express objects as a group of inequalities and their domain. For example, a sphere would be only one inequality: x^2+y^2+z^2 -1 <= 0 on the whole domain. That way, to check a collision between two objects, one needs to check if at least one pair of inequalities with overlapping domains has a solution. I am unsure about how to express the inequalities in a way that could still allow me to compare between two of them. To add forces in, I think I can express them by adding a time dimension to the inequalities. For example, a constant force in the x-dimension on the previous sphere could be represented as (C+dx/dt*t+0.5*a*t^2)^2+y^2+z^2 <= 0. But then I am not sure about how to treat non-integrable forces. Another approach is to calculate the displacement of the object after each time interval. I don't like this approach as I want to integrate it with FRP in the end, and FRP continues time is something I would like to preserve. After I'll have everything above sorted, the next things would be to run simulations. I think at the start I'll check every pair of objects and try to calculate whether or not the will collide in the future. I'll save all the results in ascending time order. and every iteration, update the movement after the closest collision and update the collision pair order. Thanks, Yotam -------------- next part -------------- An HTML attachment was scrubbed... URL: From jake.mcarthur at gmail.com Sat Jul 8 15:07:07 2017 From: jake.mcarthur at gmail.com (Jake McArthur) Date: Sat, 8 Jul 2017 11:07:07 -0400 Subject: [Haskell-cafe] Magic values, WAS: Encrypting streamed data In-Reply-To: References: Message-ID: You can avoid the underscores by defining the constants as pattern synonyms so that they are syntactically more like constructors. This also, of course, allows you to use them as patterns, which can also be nice for constants. On Thu, Jul 6, 2017 at 9:09 AM, MarLinn wrote: > > https://gist.github.com/snoyberg/20243aae347b38ad09daaf8b129e2efb > > It's got some magic values in a few places (especially that 65!) > > > Off topic, but sometimes when I find myself using magic values I > can't/won't get rid off, I'll just apply the good old habits learned in > Java times. For example you might find a section at the top of a file with > things like > > _DAYS_IN_A_WEEK_ , _KNOWN_SIZE_OF_POINT_ :: INT > > -- | Seems to be a good approximation for now > _DAYS_IN_A_WEEK_ = 7 > > -- | When you ask "What's the point", this will not answer your question. > _KNOWN_SIZE_OF_POINT_ = 65 > > Uppercase makes it easy to identify these as constants/magic values. The > underscore in front works as an initial lowercase letter so they can be > used as values despite uppercase. > > The goal is not necessarily to make these values easy to change, but to > add documentation to usage sites. > > It's unnecessary In such a quick demonstration, but I wanted to take the > opportunity to throw in my _VALUE_OF_CONTRIBUTION_IN_CENTS_ cents because > I haven't seen others do something like this. > > > Cheers, > MarLinn > > > PS: The underscore does introduce its own error message though. > > • Found hole: _VALUE_OF_CONTRIBUTION_IN_CENTS_ :: Double > Or perhaps ‘_VALUE_OF_CONTRIBUTION_IN_CENTS_’ is mis-spelled, or not in scope > > > > _______________________________________________ > 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 monkleyon at gmail.com Sat Jul 8 17:40:05 2017 From: monkleyon at gmail.com (MarLinn) Date: Sat, 8 Jul 2017 19:40:05 +0200 Subject: [Haskell-cafe] Magic values In-Reply-To: References: Message-ID: <8c115f8b-56c7-5840-e137-593ff3afbfbc@gmail.com> > You can avoid the underscores by defining the constants as pattern > synonyms so that they are syntactically more like constructors. This > also, of course, allows you to use them as patterns, which can also be > nice for constants. > > Off topic, but sometimes when I find myself using magic values I > can't/won't get rid off, I'll just apply the good old habits > learned in Java times. For example you might find a section at the > top of a file with things like > > _DAYS_IN_A_WEEK_ , _KNOWN_SIZE_OF_POINT_ :: INT-- | Seems to be a > good approximation for now _DAYS_IN_A_WEEK_ = 7 -- | When you ask > "What's the point", this will not answer your question. > _KNOWN_SIZE_OF_POINT_ = 65 > Nice! This seems a bit evil, and not a full substitute. But it also helps hijack syntax highlighting, and it forces users to use a recent-ish version of GHC. I consider that A Good Thing™. Now… as everything is “constant” in Haskell, on to define everything in capital letter patterns and return to good old COBOL times! 🍺 Wohoo! Cheers, MarLinn -------------- next part -------------- An HTML attachment was scrubbed... URL: From lamefun.x0r at gmail.com Sun Jul 9 04:38:30 2017 From: lamefun.x0r at gmail.com (Nikita Churaev) Date: Sun, 09 Jul 2017 07:38:30 +0300 Subject: [Haskell-cafe] I'm afraid of OverloadedLabels. Message-ID: <1499575110.2042.6.camel@gmail.com> So gi-gtk is already using OverloadedLabels to fight the namespacing problem. What I'm afraid is that eventually people will pick up on this and stop using normal functions altogether. My problem with OverloadedLabels is that it is a class: if people start using it widely, the original modules of types are going to become even more privileged than they already are: only it will be canonically able to define functions which can be conveniently called, and everybody else will have to only define "second-class" normal functions or risk instance collisions. I mean yes, it's the same as in most OOP languages, but isn't it also bad? There must be a better way... Is there any alternative approach to name collisions coming? From david.sorokin at gmail.com Sun Jul 9 10:41:13 2017 From: david.sorokin at gmail.com (David Sorokin) Date: Sun, 9 Jul 2017 13:41:13 +0300 Subject: [Haskell-cafe] Speed of simulation in Aivika Message-ID: Hi Cafe, I’m glad to inform that the speed of simulation in the aivika [1] simulation library of version >= 5.2 has been dramatically increased after I started using the mwc-random [2] package for generating random numbers. It was possible to use custom random number generators before, but now the random number generator from the mentioned package is used by default. To improve the speed of simulation, in most cases it will be sufficient just to recompile your simulation models. In some my tests the speed of simulation has been increased up to 7 times when using default settings. The mwc-random package is just fantastic! Another good news is that I recently improved the distributed simulation module [3], which has recovering capabilities now in case of temporary connection errors. It should be quite unusual for the optimistic Time Warp method. In short, it means that we can build discrete event distributed simulation models using the ordinary Internet and cloud services. Best regards, David Sorokin [1] http://hackage.haskell.org/package/aivika [2] http://hackage.haskell.org/package/mwc-random [3] http://hackage.haskell.org/package/aivika-distributed From sivanov at colimite.fr Sun Jul 9 11:16:50 2017 From: sivanov at colimite.fr (Sergiu Ivanov) Date: Sun, 09 Jul 2017 13:16:50 +0200 Subject: [Haskell-cafe] Collision Detection In-Reply-To: References: Message-ID: <878tjxuafx.fsf@colimite.fr> Dear Yotam, Disclaimer first: I'm not a specialist in numeric simulations nor in computer algebra systems, nor in physical simulations, although I've done some simple contributions to these domains in the past. Thus quoth Yotam Ohad at 08:17 on Sat, Jul 08 2017: > > I am thinking about writing a small physics engine with collision detection > and I wanted to go over my ideas with you to help me refine them. That's cool! > I want to express objects as a group of inequalities and their domain. For > example, a sphere would be only one inequality: x^2+y^2+z^2 -1 <= 0 on the > whole domain. That way, to check a collision between two objects, one needs > to check if at least one pair of inequalities with overlapping domains has > a solution. I am unsure about how to express the inequalities in a way that > could still allow me to compare between two of them. The problem you are stating looks like that of representing and solving a system of non-linear polynomial equations. Haskell's ecosystem has some numerical solvers which you may want to use [0]. If you want exact (symbolic) solutions, however, that's what computer algebra systems (like SymPy [1]) are good at, but it looks like Haskell has no recent actively maintained libraries for that [2]. In general, representing systems of polynomial equations/inequalities is done using collections of polynomials, which are collections of monomials, which are essentially dictionaries (vectors) assigning the power and the coefficient to each variable. For example: 2x^2 3y - 5z^3 2x --> [ {x: (2,2), y: (3,1), z: (0,0) } , {x: (2,1), y: (0,0), z: (5,3) } ] (I denote multiplication by juxtaposition (omitting *)). Finding the roots of such a polynomial is often non-trivial business. > To add forces in, I think I can express them by adding a time dimension to > the inequalities. For example, a constant force in the x-dimension on the > previous sphere could be represented as (C+dx/dt*t+0.5*a*t^2)^2+y^2+z^2 <= > 0. Given that the equation of a sphere is (x-x0)^2 + (y-y0)^2 + (z-z0)^2 = r^2 and that you seem to be trying to express the movement of its centre (x0,y0,z0) along the x axis, I suppose that you meant to write something like (x-x0(t))^2 + y^2 + z^2 - r^2 <= 0 where x0(t) = x0 + v t + a t^2/2. > But then I am not sure about how to treat non-integrable forces. You probably don't want to go that complicated for a lot of real-world applications. (Especially if you are doing numerical resolution.) > Another approach is to calculate the displacement of the object after > each time interval. I'm not sure how that differs from what you wrote previously. > I don't like this approach as I want to integrate it with FRP in the > end, and FRP continues time is something I would like to preserve. Good news: If you are able to compute the time delta between two events, you can plug it into your equations to compute the new position. Very bad news: Usually when your time step gets too big, the simulations (at least for Newtonian mechanics) stop working. That's because the equations like x = v t + a^t/2 give you velocity _at a given moment of time_, and if this velocity varies quickly, you are likely to miss important events. Now, you may also have something different in mind. > After I'll have everything above sorted, the next things would be to run > simulations. I think at the start I'll check every pair of objects and try > to calculate whether or not the will collide in the future. That's a reasonable naive solution that will probably not scale well with the number of objects. I hear people use "proximity volumes" (they use different words which I cannot remember right away): each object is assigned a sphere which contains it completely, and then some space. Now, you only test collisions with the objects in your proximity volume, to save time. > I'll save all the results in ascending time order. and every > iteration, update the movement after the closest collision and update > the collision pair order. I'm not sure why you want to do this. -- Sergiu [0] https://wiki.haskell.org/Applications_and_libraries/Mathematics [1] http://www.sympy.org/en/index.html [2] https://wiki.haskell.org/Applications_and_libraries/Mathematics#Computer_Algebra -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 487 bytes Desc: not available URL: From vagarenko at gmail.com Sun Jul 9 15:46:49 2017 From: vagarenko at gmail.com (Alexey Vagarenko) Date: Sun, 9 Jul 2017 20:46:49 +0500 Subject: [Haskell-cafe] Speed of simulation in Aivika In-Reply-To: References: Message-ID: FYI Gmail put your message into the spam folder for some reason. You probably should also make an announcement on Reddit. 2017-07-09 15:41 GMT+05:00 David Sorokin : > Hi Cafe, > > I’m glad to inform that the speed of simulation in the aivika [1] > simulation library of version >= 5.2 has been dramatically increased after > I started using the mwc-random [2] package for generating random numbers. > It was possible to use custom random number generators before, but now the > random number generator from the mentioned package is used by default. To > improve the speed of simulation, in most cases it will be sufficient just > to recompile your simulation models. > > In some my tests the speed of simulation has been increased up to 7 times > when using default settings. The mwc-random package is just fantastic! > > Another good news is that I recently improved the distributed simulation > module [3], which has recovering capabilities now in case of temporary > connection errors. It should be quite unusual for the optimistic Time Warp > method. In short, it means that we can build discrete event distributed > simulation models using the ordinary Internet and cloud services. > > Best regards, > David Sorokin > > [1] http://hackage.haskell.org/package/aivika > [2] http://hackage.haskell.org/package/mwc-random > [3] http://hackage.haskell.org/package/aivika-distributed > _______________________________________________ > 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 esz at posteo.de Sun Jul 9 17:36:02 2017 From: esz at posteo.de (Ertugrul =?utf-8?Q?S=C3=B6ylemez?=) Date: Sun, 09 Jul 2017 19:36:02 +0200 Subject: [Haskell-cafe] I'm afraid of OverloadedLabels. In-Reply-To: <1499575110.2042.6.camel@gmail.com> References: <1499575110.2042.6.camel@gmail.com> Message-ID: <87a84dy0l9.fsf@posteo.de> > I mean yes, it's the same as in most OOP languages, but isn't it also > bad? There must be a better way... > > Is there any alternative approach to name collisions coming? I think we should start considering what problem we're actually solving (the "record problem"), and where all solutions inevitably converge toward when it comes to name resolution: ad-hoc overloading. In particular, I think OverloadedLabels is a bad solution, and every other special-case solution is similarly going to be bad. My opinion is and has always been: just allow type-directed name resolution in Haskell. All naming problems would go away instantly without any awkward, inconsistent extensions that need new syntax and heavy type-level machinery to work. C++ is doing it. Every OOP language is doing it. They do it, because it's useful and convenient. Let's do it, too! AND PLEASE not the way an [existing proposal] suggests to do it! Please let's just do ad-hoc overloading. There is no reason to introduce new syntax, because syntax is completely orthogonal to this problem. [existing proposal]: https://prime.haskell.org/wiki/TypeDirectedNameResolution 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 adam at well-typed.com Sun Jul 9 19:58:56 2017 From: adam at well-typed.com (Adam Gundry) Date: Sun, 9 Jul 2017 20:58:56 +0100 Subject: [Haskell-cafe] I'm afraid of OverloadedLabels. In-Reply-To: <87a84dy0l9.fsf@posteo.de> References: <1499575110.2042.6.camel@gmail.com> <87a84dy0l9.fsf@posteo.de> Message-ID: On 09/07/17 18:36, Ertugrul Söylemez wrote: >> I mean yes, it's the same as in most OOP languages, but isn't it also >> bad? There must be a better way... >> >> Is there any alternative approach to name collisions coming? > > I think we should start considering what problem we're actually solving > (the "record problem"), and where all solutions inevitably converge > toward when it comes to name resolution: ad-hoc overloading. In > particular, I think OverloadedLabels is a bad solution, and every other > special-case solution is similarly going to be bad. > > My opinion is and has always been: just allow type-directed name > resolution in Haskell. All naming problems would go away instantly > without any awkward, inconsistent extensions that need new syntax and > heavy type-level machinery to work. C++ is doing it. Every OOP > language is doing it. They do it, because it's useful and convenient. > Let's do it, too! > > AND PLEASE not the way an [existing proposal] suggests to do it! Please > let's just do ad-hoc overloading. There is no reason to introduce new > syntax, because syntax is completely orthogonal to this problem. > > [existing proposal]: https://prime.haskell.org/wiki/TypeDirectedNameResolution How would you propose to do TDNR instead, then? It's far from clear (to me at least) how to combine ad-hoc type-based overloading with Haskell's type inference, which is part of the reason why TDNR proposals have never been implemented. There are two basic questions that need to be answered: 1. When does an identifier get special treatment, as opposed to the usual name resolution process? 2. At what point during type inference does an ambiguous name get resolved, and what impact does that have on the type inference process? The OverloadedLabels answer to question 1 is that special identifiers get a syntactic cue (the prefix hash). It's ugly, but it's obvious that something special is happening. Similarly, the TDNR proposal uses the dot. We could say that any ambiguous identifier (i.e. one that would cause a name resolution error at present) gets special treatment, but that's rather implicit and leads to odd changes in type inference behaviour if a colliding name is brought into or removed from scope. The OverloadedLabels answer to question 2 is to use normal type class constraints to defer resolving the ambiguity to the constraint solver. This is relatively easy to specify and understand. Few alternatives have ever been properly specified (in particular, the original TDNR proposal does not really answer this question). FWIW, it has been suggested that OverloadedLabels be removed on the basis that using TypeApplications with a Symbol literal gives a not completely unreasonable syntax (fromLabel @"bar"). Note that OverloadedLabels as it currently stands does not have much interaction with records, though that might change in the future (see discussion on https://github.com/ghc-proposals/ghc-proposals/pull/6). Adam -- Adam Gundry, Haskell Consultant Well-Typed LLP, http://www.well-typed.com/ From lexi.lambda at gmail.com Sun Jul 9 20:37:23 2017 From: lexi.lambda at gmail.com (Alexis King) Date: Sun, 9 Jul 2017 13:37:23 -0700 Subject: [Haskell-cafe] I'm afraid of OverloadedLabels. In-Reply-To: <87a84dy0l9.fsf@posteo.de> References: <1499575110.2042.6.camel@gmail.com> <87a84dy0l9.fsf@posteo.de> Message-ID: > On Jul 9, 2017, at 10:36, Ertugrul Söylemez wrote: > > AND PLEASE not the way an [existing proposal] suggests to do it! > Please let's just do ad-hoc overloading. There is no reason to > introduce new syntax, because syntax is completely orthogonal to this > problem. > > [existing proposal]: > https://prime.haskell.org/wiki/TypeDirectedNameResolution If I understand correctly, what you’re proposing is the “syntax-free” variant of TDNR, which is already outlined here: https://ghc.haskell.org/trac/ghc/wiki/SyntaxFreeTypeDirectedNameResolution I agree that would be a very nice feature to have, and I think doing it without new syntax would be strongly preferable to adding new syntax. The proposal outlines the basics of how it would work, but I have no idea how difficult it would be to implement in practice. From lamefun.x0r at gmail.com Sun Jul 9 21:03:24 2017 From: lamefun.x0r at gmail.com (Nikita Churaev) Date: Mon, 10 Jul 2017 00:03:24 +0300 Subject: [Haskell-cafe] I'm afraid of OverloadedLabels. In-Reply-To: <87a84dy0l9.fsf@posteo.de> References: <1499575110.2042.6.camel@gmail.com> <87a84dy0l9.fsf@posteo.de> Message-ID: <1499634204.2068.1.camel@gmail.com> > AND PLEASE not the way an [existing proposal] suggests to do > it!  Please > let's just do ad-hoc overloading.  There is no reason to introduce > new > syntax, because syntax is completely orthogonal to this problem. I think that a new syntax is needed though. Here's my reasoning: Why do mainstream OOP languages have it so easy, while Haskell hasn't been able to solve the name collision problem for many, many years? I think one of the obstacles is that currying has encouraged most libraries to put any object arguments last, eg:     insert :: Int -> a -> [a] -> [a]     insert :: a -> Set a -> Set a     insert :: k -> v -> Map k v -> Map k v instead of putting it first (like in most OOP languages):     insert :: [a] -> Int -> a -> [a]     insert :: Set a -> a -> Set a     insert :: Map k v -> k -> v -> Map k v I think this is precisely the reason why OOP languages have it easy while Haskell is struggling. If the significant argument is predictably first, TNDR is super-easy to implement even in current Haskell, if you are willing to create a class for every single method:     {-# LANGUAGE FunctionalDependencies #-}     {-# LANGUAGE FlexibleInstances #-}     import Data.Set (Set)     import Data.Map (Map)     import qualified Data.Set as Set     import qualified Data.Map as Map     class Insert a f | a -> f where         insert :: a -> f     instance Insert [a] (Int -> a -> [a]) where         insert list at item = take at list ++ [item] ++ drop at list     instance Ord a => Insert (Set a) (a -> Set a) where         insert set item = Set.insert item set     instance Ord k => Insert (Map k v) (k -> v -> Map k v) where         insert map k v = Map.insert k v map     main = do         print (insert [1, 3, 4] 1 2)         print (insert Set.empty "hello")         print (insert Map.empty "hello" "world") So, a new syntax is surely needed if the TNDR implementation relies on object arguments being the first, since $ no longer works for such functions. Also, I think that methods should get a namespace of their own, just like operators. The reason is to preserve backwards compatibility without having to create any new modules: methods can be implemented alongside old-style functions. Another reason:     let name = person.name in ... If the .name method is in a namespace of its own, the name variable doesn't become ambiguous (with all associated problems). I don't think it would even be necessary to introduce any ambiguity- resolving behaviour into normal namespace if methods are in a namespace of their own. Methods would be defined like this:     .insert :: Ord k => Map k v -> k -> v -> Map k v     .insert map k v = ... Invoked like this (just like in existing proposal):     Map.empty .insert "hello" "world"               .insert "cat" "meow"               .insert "haskell" "awesome" Currying by not applying the object:     .insert x y :: Map k v -> Map k v Currying by not applying the arguments:     map .insert :: k -> v -> Map k v Prefix application: (.insert) map k v From monkleyon at gmail.com Sun Jul 9 21:04:33 2017 From: monkleyon at gmail.com (MarLinn) Date: Sun, 9 Jul 2017 23:04:33 +0200 Subject: [Haskell-cafe] I'm afraid of OverloadedLabels. In-Reply-To: References: <1499575110.2042.6.camel@gmail.com> <87a84dy0l9.fsf@posteo.de> Message-ID: On 2017-07-09 21:58, Adam Gundry wrote: > On 09/07/17 18:36, Ertugrul Söylemez wrote: >>> I mean yes, it's the same as in most OOP languages, but isn't it also >>> bad? There must be a better way... >>> >>> Is there any alternative approach to name collisions coming? >> […] >> >> My opinion is and has always been: just allow type-directed name >> resolution in Haskell. > […] > There are two basic questions that need to be answered: > > 1. When does an identifier get special treatment, as opposed to the > usual name resolution process? > > 2. At what point during type inference does an ambiguous name get > resolved, and what impact does that have on the type inference process? I want to apologize beforehand for the incoherence of my thoughts. These are only titbits I would like to throw into the discussion. Please excuse me if they are obvious or distracting for the more knowledgeable people here. The first titbit looks esoteric at first glance. About two months ago, Oleg dug up what seems like an old experiment of his. He showed that all classes, including fundeps, can be reduced to exactly one, carefully chosen class. (thread and link to the article ) Playing around with it I realized that a version of this one class is already in base. It is non other than IsLabel from OverloadedLabels. In a sense, IsLabel is the mother of all classes. That's not extremely surprising, as classes are basically records with, and IsLabel offers a kind of name-directed type resolution the same way classes do. What it means to me is that OverloadedLabels might have a more fundamental nature than is visible on the surface. Possible replacements should be approached with care. What this also tells me is that, in a way, OverloadedLabels offers the inverse of type-directed name resolution. No wonder it's awkward for that usecase. But maybe that perspective can lead to more ideas? The other titbit is much simpler: Isn't it about time to allow explicit imports, and more importantly, explicit non-imports for instances? Some time ago I fantasised about some special syntax for this, calling the (very rough) idea "aspects" (thread ). But we needn't go that far. The simplest implementation would entail only expanded import/export syntax. That wouldn't really be type-directed, but brute-force-directed, but sometime it's better to be explicit. And the time where our world is so small that only one mathematical truth is enough to rule all code is coming closer and closer to it's end. Just two small ideas. Hope they contribute something. Cheery, MarLinn -------------- next part -------------- An HTML attachment was scrubbed... URL: From ok at cs.otago.ac.nz Mon Jul 10 00:16:02 2017 From: ok at cs.otago.ac.nz (Richard A. O'Keefe) Date: Mon, 10 Jul 2017 12:16:02 +1200 Subject: [Haskell-cafe] I'm afraid of OverloadedLabels. In-Reply-To: <1499634204.2068.1.camel@gmail.com> References: <1499575110.2042.6.camel@gmail.com> <87a84dy0l9.fsf@posteo.de> <1499634204.2068.1.camel@gmail.com> Message-ID: > On 10/07/2017, at 9:03 AM, Nikita Churaev wrote: > > I think that a new syntax is needed though. Here's my reasoning: > > Why do mainstream OOP languages have it so easy, while Haskell hasn't > been able to solve the name collision problem for many, many years? Because mainstream object-oriented programming languages do not do (bidirectional) type inference, and the one exception I can think of (Ada) does not have variables in its type language. Amongst non-mainstream languages, F# might repay examination. Suspicious examination. I see F# code doing . all the time where you might have expected its OOP magic to be used... > > I think one of the obstacles is that currying has encouraged most > libraries to put any object arguments last, eg: F# is a .Net language, which is thoroughly OO. Yet we see > > Set.add;; > val it : ('a -> Set<'a> -> Set<'a>) when 'a : comparison = Note: the "object" argument is second, not first. Currying and argument order really don't seem to be related. Haskell type-classes don't depend on which argument is which, after all. Consider class Addable f where Eq t => add :: t -> f t -> f t instance Addable [] where add x ys = if x`elem`ys then ys else x:ys newtype Set t = Set [t] instance (Eq x) => Addable Set where add x (Set ys) = Set (add x ys) > I think this is precisely the reason why OOP languages have it easy > while Haskell is struggling. And the OOP languages struggle to do what Haskell does easily. It is also worth remembering that ad hoc overloading (because that is what we're talking about) was present in PL/I, Algol 68, and Ada 83, without any trace of OOPiness at all. Also while letting the clue to resolution come from any argument (or combination of arguments). As a native speaker of an SVO language (English) in a country where one of the official languages is VSO (Māori), I sometimes find the OVS structure of "mainstream OO languages" a little uncomfortable... "Backward ran sentences until reeled the mind." From will.yager at gmail.com Mon Jul 10 01:20:11 2017 From: will.yager at gmail.com (Will Yager) Date: Mon, 10 Jul 2017 08:20:11 +0700 Subject: [Haskell-cafe] Collision Detection In-Reply-To: References: Message-ID: <2308F81A-3B1D-4FB6-81D1-404B4DACBF8F@gmail.com> Take a look at the (WIP) course notes from Etienne Vouga's physical simulation class (shared with permission). I recommend these very strongly to anyone interested in macro-scale physical simulation. Its relatively rigorous approach to algebraic object types should also appeal to haskellers. http://www.dropbox.com/s/62ugse0jcpnsy4l/sim.pdf?dl=0 Chapter 10 discusses practical efficient collision techniques. --Will > On Jul 8, 2017, at 3:17 PM, Yotam Ohad wrote: > > Dear Cafe, > I am thinking about writing a small physics engine with collision detection and I wanted to go over my ideas with you to help me refine them. > > ... > Thanks, > Yotam > _______________________________________________ > 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 lamefun.x0r at gmail.com Mon Jul 10 01:53:21 2017 From: lamefun.x0r at gmail.com (Nikita Churaev) Date: Mon, 10 Jul 2017 04:53:21 +0300 Subject: [Haskell-cafe] I'm afraid of OverloadedLabels. In-Reply-To: References: <1499575110.2042.6.camel@gmail.com> <87a84dy0l9.fsf@posteo.de> <1499634204.2068.1.camel@gmail.com> Message-ID: <1499651601.2078.2.camel@gmail.com> > > Why do mainstream OOP languages have it so easy, while Haskell > hasn't > > been able to solve the name collision problem for many, many years? >  > Because mainstream object-oriented programming languages do not do > (bidirectional) type inference, and the one exception I can think > of (Ada) does not have variables in its type language. Then isn't it a trade-off? Convenience of bidirectional type inference vs. convenience of name collision resolution? And Haskell type system seems to support making this trade-off on case by case basis. OverloadedLabels and my Insert example implement the exact behaviour provided by mainstream OOP languages (looking up the function by the type of the main argument and the name of the function). Are there some hidden pitfalls that I am not aware of? If not or if they aren't particularly devastating, then what's left is to make making the trade-off in favor of avoiding name collisions as convenient as in OOP languages. > Note: the "object" argument is second, not first.  Currying and > argument order really don't seem to be related.  Haskell type-classes > don't depend on which argument is which, after all.  Consider >  > class Addable f >   where Eq t => add :: t -> f t -> f t Yes, but as far as I know classes still depend on the predictability of argument positions. The problem is that "the last argument of a function" is not easily (if at all, somebody please enlighten me) expressible. > And the OOP languages struggle to do what Haskell does easily. Yes, but the lack of something this obvious, present in most languages and extremely convenient definitely has the potential to plant doubts in the minds of Haskell beginners, thoughts that can make them give up Haskell without giving it a fair chance: "Haskell is impractical, just as the rumours say. Oh well..." "Haskell development is too hindered by fear of making decisions. Long- standing problems will never get solved. Sigh... Back to Microsoft C# we go..." From anthony_clayden at clear.net.nz Mon Jul 10 01:55:25 2017 From: anthony_clayden at clear.net.nz (Anthony Clayden) Date: Mon, 10 Jul 2017 13:55:25 +1200 Subject: [Haskell-cafe] I'm afraid of OverloadedLabels Message-ID: <5962de8d.257.f98.7413@clear.net.nz> > On Sun Jul 9 21:04:33 UTC 2017, MarLinn wrote: > ... > Isn't it about time to allow explicit imports, and more importantly, > explicit non-imports for instances? > Some time ago I fantasised about some special syntax for this, > calling the (very rough) idea "aspects" ... Sorry, I didn't realise that "aspects" thread was about controlling instance scope. I did try to start a thread on instance scope a few days ago https://mail.haskell.org/pipermail/haskell-cafe/2017-July/127435.html I am interested in use cases for scope-controlling instances. Specifically I'm not seeing how scoping instances (instances of what, exactly?) helps with the "record problem". Typically if you have several record types with the same-named field, you want all of those to be in scope, where the field-access gets resolved according to the record's type. The `DuplicateRecordFields` extension now provides reasonable support for that, doesn't it? AntC From allbery.b at gmail.com Mon Jul 10 01:58:46 2017 From: allbery.b at gmail.com (Brandon Allbery) Date: Sun, 9 Jul 2017 21:58:46 -0400 Subject: [Haskell-cafe] I'm afraid of OverloadedLabels. In-Reply-To: <1499651601.2078.2.camel@gmail.com> References: <1499575110.2042.6.camel@gmail.com> <87a84dy0l9.fsf@posteo.de> <1499634204.2068.1.camel@gmail.com> <1499651601.2078.2.camel@gmail.com> Message-ID: On Sun, Jul 9, 2017 at 9:53 PM, Nikita Churaev wrote: > > And the OOP languages struggle to do what Haskell does easily. > > Yes, but the lack of something this obvious, present in most languages > and extremely convenient definitely has the potential to plant doubts > in the minds of Haskell beginners, thoughts that can make them give up > Are you seriously arguing that Haskell must go OOP to matter? -- 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 Mon Jul 10 02:09:20 2017 From: allbery.b at gmail.com (Brandon Allbery) Date: Sun, 9 Jul 2017 22:09:20 -0400 Subject: [Haskell-cafe] I'm afraid of OverloadedLabels. In-Reply-To: References: <1499575110.2042.6.camel@gmail.com> <87a84dy0l9.fsf@posteo.de> <1499634204.2068.1.camel@gmail.com> <1499651601.2078.2.camel@gmail.com> Message-ID: On Sun, Jul 9, 2017 at 9:58 PM, Brandon Allbery wrote: > On Sun, Jul 9, 2017 at 9:53 PM, Nikita Churaev > wrote: > >> > And the OOP languages struggle to do what Haskell does easily. >> >> Yes, but the lack of something this obvious, present in most languages >> and extremely convenient definitely has the potential to plant doubts >> in the minds of Haskell beginners, thoughts that can make them give up >> > > Are you seriously arguing that Haskell must go OOP to matter? > To be more clear: you brought up typeclasses, but typeclasses are the way they are in support of the real reason: putting the "object" last encourages functional programming. Last I checked, Haskell was about functional programming. You seem to be asserting that it is more important to support OOP thinking and discard the unnecessary FP baggage. -- 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 anthony_clayden at clear.net.nz Mon Jul 10 02:17:39 2017 From: anthony_clayden at clear.net.nz (Anthony Clayden) Date: Mon, 10 Jul 2017 14:17:39 +1200 Subject: [Haskell-cafe] I'm afraid of OverloadedLabels. Message-ID: <5962e3c3.1da.4a67.23634@clear.net.nz> > On Sun Jul 9 20:37:23 UTC 2017, Alexis King wrote: > > On Jul 9, 2017, at 10:36, Ertugrul Söylemez wrote: > > > AND PLEASE not the way an [existing proposal] suggests to do it! > > Please let's just do ad-hoc overloading. There is no reason to > > introduce new syntax, because syntax is completely orthogonal > > to this problem. > > > > [existing proposal]: > > https://prime.haskell.org/wiki/TypeDirectedNameResolution Folks, that is not an existing proposal. SPJ's write-up is seductive, but fatally flawed, as Edward Kmett pointed out during the OverLoadedRecordFields development work. Quite apart from its relying on special syntax, TDNR can't cope with nested records. In: > ... student.course.instructor ... the `.course.instructor` is irresolvably ambiguous, in exactly the same way as `(show . read)`. You can maybe fix that up with FunDeps or TypeFamilies, but then you lose most of TDNR's benefits (esp not coping with existential quanted fields, which is typically a requirement to cope with OOP-style). > If I understand correctly, what you’re proposing is the “syntax-free” > variant of TDNR, which is already outlined here: > https://ghc.haskell.org/trac/ghc/wiki/SyntaxFreeTypeDirectedNameResolution I think everyone should read the accompanying discussion. That turned out to be not an 'outline' but just a piece of wishful thinking. It has all the flaws of the original TDNR, plus a few of its own. > I agree that would be a very nice feature to have, and I think doing it > without new syntax would be strongly preferable to adding new syntax. > The proposal outlines the basics of how it would work, but I have no > idea how difficult it would be to implement in practice. Quite. AntC From lamefun.x0r at gmail.com Mon Jul 10 02:57:02 2017 From: lamefun.x0r at gmail.com (Nikita Churaev) Date: Mon, 10 Jul 2017 05:57:02 +0300 Subject: [Haskell-cafe] I'm afraid of OverloadedLabels. In-Reply-To: <5962e3c3.1da.4a67.23634@clear.net.nz> References: <5962e3c3.1da.4a67.23634@clear.net.nz> Message-ID: <1499655422.3098.1.camel@gmail.com> > You can maybe fix that up with FunDeps > or TypeFamilies, but then you lose most of TDNR's > benefits (esp not coping with existential quanted fields, > which is typically a requirement to cope with OOP-style). What benefits exactly are lost? From anthony_clayden at clear.net.nz Mon Jul 10 03:19:43 2017 From: anthony_clayden at clear.net.nz (Anthony Clayden) Date: Mon, 10 Jul 2017 15:19:43 +1200 Subject: [Haskell-cafe] I'm afraid of OverloadedLabels. Message-ID: <5962f24f.1e2.735d.11535@clear.net.nz> > On Mon Jul 10 00:16:02 UTC 2017, Richard A. O'Keefe wrote: > ... > As a native speaker of an SVO language (English) > in a country where one of the official languages is VSO (Māori), > I sometimes find the OVS structure of > "mainstream OO languages" a little uncomfortable... > "Backward ran sentences until reeled the mind." lol. That's a cute comparison. I don't think "mainstream OO" is OVS. In: > ... button.colour <- red Gloss: 'button's colour goes red'. `button's colour` is the grammatical Subject. (Yes it represents an OOP 'Object.method', but that's because everything in OOP is an 'Object'; and the only way to access is by methods.) > ... button.reset Again `button` is the grammatical Subject. (It must be, because there's no grammatical Object.) Then `reset` must be the verb, used intransitively. (In French you'd use a reflexive: `the button resets itself`.) This dot-suffixing is already in Haskell: Data.ByteString.Lazy.Builder.Extras 'Data's ByteString's Lazy's Builder's Extras'. To me it seemed natural to carry on ....Extras.untrimmedStrategy.buffSize That is, a field is just a component that might have (sub-)sub-component(s). The field 'belongs to' the structure, so dot represents English possessive. And that's just how lenses look, deliberately. (But that's a mystifying pun on use of the dot: the dot changes from compound name separator to function composition.) But the outcry against TDNR's proposal for dot really was voiciferous. (And nobody paid so much attention to the semantics. So the flaw in TDNR wasn't discovered for a long time.) AntC From ok at cs.otago.ac.nz Mon Jul 10 03:45:23 2017 From: ok at cs.otago.ac.nz (Richard A. O'Keefe) Date: Mon, 10 Jul 2017 15:45:23 +1200 Subject: [Haskell-cafe] I'm afraid of OverloadedLabels. In-Reply-To: <5962f24f.1e2.735d.11535@clear.net.nz> References: <5962f24f.1e2.735d.11535@clear.net.nz> Message-ID: <92b4eb4c-05f0-06c2-7ace-b4299ba006fb@cs.otago.ac.nz> On 10/07/17 3:19 PM, Anthony Clayden wrote: >> As a native speaker of an SVO language (English) >> in a country where one of the official languages is VSO > (Māori), >> I sometimes find the OVS structure of >> "mainstream OO languages" a little uncomfortable... >> "Backward ran sentences until reeled the mind." > > lol. That's a cute comparison. > > I don't think "mainstream OO" is OVS. In: > >> ... button.colour <- red This is normally written button.setColour(red) object verb something Maybe it's OV without a subject, object vp[+imperative] > > Gloss: 'button's colour goes red'. > > `button's colour` is the grammatical Subject. (Yes it > represents an > OOP 'Object.method', but that's because everything in OOP > is an 'Object'; and the only way to access is by methods.) Yes, but there is no law in OOP that the object has to be first. In Ada, I could perfectly well write Set_Colour(Red, Some_Object); and have it dispatch on the 2nd argument. In Common Lisp, I could perfectly well write (set-colour 'red some-object) and have it dispatch on the 2nd argument (or indeed, have it dispatch on more than one argument). The object.selector(arguments) syntax is a generalisation of record.field syntax, and there's no law requiring that either. Algol 68 used field OF object. OOP really isn't about the *syntax*, any more than FP is. That's only a human usability issue. (Only. Heh.) > This dot-suffixing is already in Haskell: > Data.ByteString.Lazy.Builder.Extras > 'Data's ByteString's Lazy's Builder's Extras'. That is "path" syntax, which again older languages would have written Extras in Builder in Lazy in ByteString in Data and none of the components resembles a verb, in the way that method selectors do. > > But the outcry against TDNR's proposal for dot > really was vociferous. Because the dot already has too many uses. There are at least three forms of overloading: - ad hoc, as found in PL/I, Fortran, Algol 68, Ada, and Java. - parametric, as found in ML, Clean, F#, Haskell, and others. - type-based, as found in Eiffel and Haskell, say. Fitting all three together is tricky. From imantc at gmail.com Mon Jul 10 06:26:39 2017 From: imantc at gmail.com (Imants Cekusins) Date: Mon, 10 Jul 2017 09:26:39 +0300 Subject: [Haskell-cafe] I'm afraid of OverloadedLabels. In-Reply-To: <92b4eb4c-05f0-06c2-7ace-b4299ba006fb@cs.otago.ac.nz> References: <5962f24f.1e2.735d.11535@clear.net.nz> <92b4eb4c-05f0-06c2-7ace-b4299ba006fb@cs.otago.ac.nz> Message-ID: New language features need to make their way into IDE to be fully usable. Name resolution happens with common user activities: goto, find usages, rename. Would any of the new forms of overloading be easy to implement in e.g. http://hackage.haskell.org/package/haskell-names ? Syntax-free name resolution in non-haskell AST parser (of Haskell files) may be tricky to implement. It would likely require more data to be stored, extra lookups and checks. This may slow IDEs down. This is not to advocate a particular TDNR proposal. Rather, a reminder that new language features need to be implemented and may break working applications. -------------- next part -------------- An HTML attachment was scrubbed... URL: From anthony_clayden at clear.net.nz Mon Jul 10 06:35:05 2017 From: anthony_clayden at clear.net.nz (Anthony Clayden) Date: Mon, 10 Jul 2017 18:35:05 +1200 Subject: [Haskell-cafe] I'm afraid of OverloadedLabels. Message-ID: <59632019.2d5.1622.28498@clear.net.nz> > On Mon Jul 10 02:57:02 UTC 2017, Nikita Churaev wrote: > > You can maybe fix that up with FunDeps > > or TypeFamilies, but then you lose most of TDNR's > > benefits (esp not coping with existential quanted fields > > , which is typically a requirement to cope with > > OOP-style). > > What benefits exactly are lost? Hi Nikita, I'm not sure I (or anybody) has the energy for another round of the "records debate". The TDNR (ex-)proposal seems so attractive because it just doesn't consider in detail all the complexities. They're magically swept under the carpet with the special dot syntax. So you might expect TDNR would support all of the functionality with H98 field names, plus having multiple fields of the same name. But how? Note the comment on TDNR section 'The Proposal' "TDNR is not "overloading" in the sense of type classes." And there were plenty of complaints that it's confusingly similar-but-different to type classes. You could look at SPJ's re-working of TDNR [2010] as SORF [2013]: https://ghc.haskell.org/trac/ghc/wiki/Records/OverloadedRecordFields/SORF SORF took advantage of the new Symbol Kinds (not available in 2010), and tried to be more type-class-like, with the `Has` class. One of the motivations with SORF is "Records with polymorphic fields are very important in practice, so it would be a major wart not to support them." TDNR just didn't discuss higher-ranked types. It turned out that was just too hard, even for SORF. (Or rather for OverloadedRecordFields, which is what's being delivered from SORF.) SORF tries to tackle record update, for which TDNR said "However I propose not to apply it [TDNR] to record update. " I don't think our cousins in OOP would be impressed by a records system in which you can't write polymorphic record updates. (I.e. a method to update the `firstName` in any record that has that field.) Actually delivering improvements in GHC around records is being painfully slow. `DuplicateRecordFields` has eased the pain a little. Ironically `OverloadedRecordFields` doesn't tackle higher-ranked types, nor record updates. And needs special syntax `#firstName`. So perhaps TDNR's "benefits" were never achievable? ANtC From daniel.berecz at gmail.com Mon Jul 10 08:22:49 2017 From: daniel.berecz at gmail.com (Daniel Berecz) Date: Mon, 10 Jul 2017 10:22:49 +0200 Subject: [Haskell-cafe] [ANN] [Reminder] Budapest Haskell Hackathon 2017, 29-30th July 2017 Message-ID: <1499674969.1773605.1035692640.3CBC0404@webmail.messagingengine.com> Hi everybody, Just a last reminder about our hackathon in Budapest at the end of July: Our local user group will hold a Haskell Hackathon in Budapest this year (this will be the second)! We will hold it from the 29th to the 30th of July (Saturday & Sunday). You can find out more on the following link: https://wiki.haskell.org/Budapest_Hackathon_2017 We will reguraly update the site with new information. If you decide to come, please fill out the following Google Form: https://goo.gl/forms/QjTNdXTD1aEOMEQU2 If you have a project, demo, or talk that you want to bring to the event please contact us, and we can talk about the details. You can find our contact info the events wiki site, or you can just contact me directly. The event will be open to people of all experience levels, from beginners to gurus. The only requisite is that you’re interested in the Haskell language, and want to hang out with us, and have a good time! Greetings from Daniel, and the other BP-HUG organizers. From olshanskydr at gmail.com Mon Jul 10 14:28:08 2017 From: olshanskydr at gmail.com (Dmitry Olshansky) Date: Mon, 10 Jul 2017 17:28:08 +0300 Subject: [Haskell-cafe] Fwd: constraint inference In-Reply-To: <34454cf6-33b3-7d8d-0211-d696f0a2358b@gmail.com> References: <34454cf6-33b3-7d8d-0211-d696f0a2358b@gmail.com> Message-ID: You are right, thanks! 2017-07-07 22:17 GMT+03:00 Li-yao Xia : > > > On 07/07/2017 02:50 AM, Dmitry Olshansky wrote: > >> I am not sure why but when I didn't set RankNTypes I got an appropriate >> error. So I specified it. >> >> But if I write >> let { f :: (forall n. KnownSymbol n => Proxy n) -> String; f p = >> symbolVal p } >> then nothing is changed. >> >> >> > > What would the String (f Proxy) be? (Note that (Proxy :: forall n. > KnownSymbol n => Proxy n) would be a valid argument here.) > > _______________________________________________ > 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 esz at posteo.de Mon Jul 10 21:38:01 2017 From: esz at posteo.de (Ertugrul =?utf-8?Q?S=C3=B6ylemez?=) Date: Mon, 10 Jul 2017 23:38:01 +0200 Subject: [Haskell-cafe] I'm afraid of OverloadedLabels. In-Reply-To: References: <1499575110.2042.6.camel@gmail.com> <87a84dy0l9.fsf@posteo.de> Message-ID: <874lukx9ae.fsf@posteo.de> >> AND PLEASE not the way an [existing proposal] suggests to do it! >> Please let's just do ad-hoc overloading. There is no reason to >> introduce new syntax, because syntax is completely orthogonal to this >> problem. >> >> [existing proposal]: https://prime.haskell.org/wiki/TypeDirectedNameResolution > > How would you propose to do TDNR instead, then? It's far from clear > (to me at least) how to combine ad-hoc type-based overloading with > Haskell's type inference, which is part of the reason why TDNR > proposals have never been implemented. > > There are two basic questions that need to be answered: > > 1. When does an identifier get special treatment, as opposed to the > usual name resolution process? My proposal is *always*: ... > 2. At what point during type inference does an ambiguous name get > resolved, and what impact does that have on the type inference > process? ... type inference would have to be done multiple times, once for each matching identifier in scope. Do each of them independently, then see which ones turn out to be well-typed (no ambiguity, no missing instances, no mismatch, etc.). If there is exactly one, take it, otherwise give up with a type error. For regular unique identifiers nothing would change, so this is a backward-compatible extension. > The OverloadedLabels answer to question 1 is that special identifiers > get a syntactic cue (the prefix hash). It's ugly, but it's obvious > that something special is happening. Similarly, the TDNR proposal uses > the dot. We could say that any ambiguous identifier (i.e. one that > would cause a name resolution error at present) gets special > treatment, but that's rather implicit and leads to odd changes in type > inference behaviour if a colliding name is brought into or removed > from scope. My point is that that's inevitable. 1. nice syntax, 2. simple semantics, 3. no inference interference -- pick two. In today's Haskell we have 2 and 3, but we lack 1, because we need to prefix our identifiers or use qualified imports. OverloadedLabels seems to go with 1 and 3, lacking 2, because of the heavy type-level machinery it relies on. I propose that we go with 1 and 2 instead. This can of course cause problems with applications that don't fully saturate a function. Since that's common in Haskell, we would have to use it sparingly, potentially only for record fields or lenses. But that's also the primary use case, so I'd be fine with that. 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 lexi.lambda at gmail.com Tue Jul 11 01:21:23 2017 From: lexi.lambda at gmail.com (Alexis King) Date: Mon, 10 Jul 2017 18:21:23 -0700 Subject: [Haskell-cafe] I'm afraid of OverloadedLabels. In-Reply-To: <874lukx9ae.fsf@posteo.de> References: <1499575110.2042.6.camel@gmail.com> <87a84dy0l9.fsf@posteo.de> <874lukx9ae.fsf@posteo.de> Message-ID: <02822EC2-CC5C-435D-B6D6-C93C056E44EF@gmail.com> > On Jul 10, 2017, at 2:38 PM, Ertugrul Söylemez wrote: > > ... type inference would have to be done multiple times, once for each > matching identifier in scope. Do each of them independently, then see > which ones turn out to be well-typed (no ambiguity, no missing > instances, no mismatch, etc.). If there is exactly one, take it, > otherwise give up with a type error. This would make type inference go exponential *extremely* quickly. This sort of approach is a non-starter, since it would imply typechecking a module 2^n times for n ambiguities where only 2 of the same identifiers are in scope; it would be even worse when there are more than 2. Due to the way Haskell’s type inference works, it would be very difficult (impossible?) in general to limit the duplicate work the typechecker would need to perform if you want to run it multiple times to see which binding would typecheck. GHC does no backtracking in the typechecker, and this would be even worse than backtracking, since it would always need to run multiple times. The only workable approach I can imagine for TDNR is something like the following: 1. If an identifier is unambiguous, don’t do anything differently from what already happens now. 2. If an identifier is ambiguous, ignore the bindings’ types entirely and assign the identifier a fresh type variable. (If the binding is in function application position, it can be assigned the type (a -> b -> c -> ...), depending on the number of expressions it is applied to, but this doesn’t fundamentally change anything.) 3. Typecheck the program using that information alone. Defer name resolution to the constraint solver. If the program typechecks, try to find an unambiguous substitution during constraint solving via subsumption. If one can be found, use it. Otherwise, bail with an appropriate error message. In my head, this seems less invasive than trying to typecheck the program multiple times and less wishful thinking than trying to divine the proper binding during the bulk of the typechecking process. However, I am not familiar with the details of GHC’s particularly advanced and complex typechecker, and it’s entirely possible that even the heavily constrained approach I just outlined is an enormous amount of work or even impossible. Even if it were possible to implement the above approach, it would still be limited. It’s possible it would need to be restricted to imported and top-level bindings (excluding local bindings), and it would probably sometimes fail to typecheck even when one of the bindings would successfully typecheck (when higher-rank types are involved, for example). I’d personally be quite happy with the feature even with those limitations, but I can’t make any claims to its practicality or possibility, since I have never touched GHC’s source at all, much less the typechecker. From clintonmead at gmail.com Tue Jul 11 06:18:11 2017 From: clintonmead at gmail.com (Clinton Mead) Date: Tue, 11 Jul 2017 16:18:11 +1000 Subject: [Haskell-cafe] Higher order functor package? In-Reply-To: References: Message-ID: Hi All Thanks for all your help. I've actually picked up Mario's rank2classes package as it seems like I need a little but more power than Functors, as I want things like `liftA2` for example. I've pushed across a very simple pull request to you Mario that simply adds "PolyKinds" to your list of language extensions. This automatically this generalises the kinds your Functor and Apply accept (and perhaps others) as I'm quantifying not over * but over a data kind type. No other changes are needed. Clinton On Sat, Jul 8, 2017 at 5:57 AM, Mario Blažević wrote: > On 2017-07-07 12:48 AM, Clinton Mead wrote: > >> Consider the illustrative code below: >> ... >> class MyFunctor f where >> myFmap :: (forall a. t a -> u a) -> f t -> f u >> ... >> >> >> Basically this is a sort of "higher order" functor, but I can't seem to >> fit it into an ordinary functor. >> >> But it seems like I'm reinventing the wheel, as my code is suspiciously >> like `Functor` but only slightly different. >> >> Has this sort of class already been created and if so what package is it >> in? >> > > Yes, I have recently created rank2classes package: > > http://hackage.haskell.org/package/rank2classes > > Apart from the mirror-universe Functor class, the package exports > the Applicative, Foldable, Traversable, Applicative, and Distributive > classes, as well as some Template Hashell to derive some of their instances > automatically. > > > > > _______________________________________________ > 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 serg.foo at gmail.com Tue Jul 11 07:02:26 2017 From: serg.foo at gmail.com (Sergey Vinokurov) Date: Tue, 11 Jul 2017 10:02:26 +0300 Subject: [Haskell-cafe] Higher order functor package? In-Reply-To: References: Message-ID: Hi Clinton, Sorry for late reply, but just for the sake of completeness the compdata package defines just the functor you mentioned http://hackage.haskell.org/package/compdata-0.11/docs/Data-Comp-Multi-HFunctor.html#t:HFunctor. Regards, Sergey On Tue, Jul 11, 2017 at 9:18 AM, Clinton Mead wrote: > Hi All > > Thanks for all your help. > > I've actually picked up Mario's rank2classes package as it seems like I need > a little but more power than Functors, as I want things like `liftA2` for > example. > > I've pushed across a very simple pull request to you Mario that simply adds > "PolyKinds" to your list of language extensions. This automatically this > generalises the kinds your Functor and Apply accept (and perhaps others) as > I'm quantifying not over * but over a data kind type. No other changes are > needed. > > Clinton > > On Sat, Jul 8, 2017 at 5:57 AM, Mario Blažević wrote: >> >> On 2017-07-07 12:48 AM, Clinton Mead wrote: >>> >>> Consider the illustrative code below: >>> ... >>> class MyFunctor f where >>> myFmap :: (forall a. t a -> u a) -> f t -> f u >>> ... >>> >>> >>> Basically this is a sort of "higher order" functor, but I can't seem to >>> fit it into an ordinary functor. >>> >>> But it seems like I'm reinventing the wheel, as my code is suspiciously >>> like `Functor` but only slightly different. >>> >>> Has this sort of class already been created and if so what package is it >>> in? >> >> >> Yes, I have recently created rank2classes package: >> >> http://hackage.haskell.org/package/rank2classes >> >> Apart from the mirror-universe Functor class, the package exports >> the Applicative, Foldable, Traversable, Applicative, and Distributive >> classes, as well as some Template Hashell to derive some of their instances >> automatically. >> >> >> >> >> _______________________________________________ >> 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 clintonmead at gmail.com Tue Jul 11 07:13:09 2017 From: clintonmead at gmail.com (Clinton Mead) Date: Tue, 11 Jul 2017 17:13:09 +1000 Subject: [Haskell-cafe] Higher order functor package? In-Reply-To: References: Message-ID: I don't think this is quite the same. `compdata` seems to define: (f :-> g) -> h f :-> h g But I want: (f :-> g) -> h f -> h g Notice the lack of colon between the last two arguments. It's ordinary function application there. On Tue, Jul 11, 2017 at 5:02 PM, Sergey Vinokurov wrote: > Hi Clinton, > > Sorry for late reply, but just for the sake of completeness the > compdata package defines just the functor you mentioned > http://hackage.haskell.org/package/compdata-0.11/docs/ > Data-Comp-Multi-HFunctor.html#t:HFunctor. > > Regards, > Sergey > > On Tue, Jul 11, 2017 at 9:18 AM, Clinton Mead > wrote: > > Hi All > > > > Thanks for all your help. > > > > I've actually picked up Mario's rank2classes package as it seems like I > need > > a little but more power than Functors, as I want things like `liftA2` for > > example. > > > > I've pushed across a very simple pull request to you Mario that simply > adds > > "PolyKinds" to your list of language extensions. This automatically this > > generalises the kinds your Functor and Apply accept (and perhaps others) > as > > I'm quantifying not over * but over a data kind type. No other changes > are > > needed. > > > > Clinton > > > > On Sat, Jul 8, 2017 at 5:57 AM, Mario Blažević > wrote: > >> > >> On 2017-07-07 12:48 AM, Clinton Mead wrote: > >>> > >>> Consider the illustrative code below: > >>> ... > >>> class MyFunctor f where > >>> myFmap :: (forall a. t a -> u a) -> f t -> f u > >>> ... > >>> > >>> > >>> Basically this is a sort of "higher order" functor, but I can't seem to > >>> fit it into an ordinary functor. > >>> > >>> But it seems like I'm reinventing the wheel, as my code is suspiciously > >>> like `Functor` but only slightly different. > >>> > >>> Has this sort of class already been created and if so what package is > it > >>> in? > >> > >> > >> Yes, I have recently created rank2classes package: > >> > >> http://hackage.haskell.org/package/rank2classes > >> > >> Apart from the mirror-universe Functor class, the package > exports > >> the Applicative, Foldable, Traversable, Applicative, and Distributive > >> classes, as well as some Template Hashell to derive some of their > instances > >> automatically. > >> > >> > >> > >> > >> _______________________________________________ > >> 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 Tue Jul 11 14:35:56 2017 From: dct25-561bs at mythic-beasts.com (David Turner) Date: Tue, 11 Jul 2017 15:35:56 +0100 Subject: [Haskell-cafe] Encrypting streamed data In-Reply-To: References: <1E280315-0C09-4776-BE6B-3F135C543E05@dukhovni.org> Message-ID: Hi, I can't think of a terribly good way to achieve GPG/PGP-compatibility without simply using GPG/PGP, since the file format is quite involved. That said, here is how to implement a CBC-mode block cipher encryption using Conduit, which is suitable for something like AES256 encryption. It is almost certainly vulnerable to side-channel attacks (timing, cache-poisoning, etc) but as a pure function from input to output it is equivalent to `openssl aes-256-cbc -e -K -iv -in data/plain-text.txt` which I should hope would be standard enough for analysis. This leaves you with the problem of storing the key and IV securely, encrypted using the asymmetric key that you first thought of, but hopefully that problem is surmountable! Cheers, David import Control.Monad import Control.Monad.IO.Class import Control.Monad.Trans.Resource import Crypto.Cipher.AES import Crypto.Cipher.Types import Crypto.Data.Padding import Crypto.Error import qualified Data.ByteString as B import Data.Conduit import Data.Conduit.Binary import Data.Monoid loadKey :: IO B.ByteString loadKey = B.readFile "data/key.dat" loadIV :: IO (IV AES256) loadIV = do bytes <- B.readFile "data/iv.dat" maybe (error "makeIV failed") return $ makeIV bytes loadCipher :: IO AES256 loadCipher = throwCryptoErrorIO =<< cipherInit <$> loadKey loadPlainText :: IO B.ByteString loadPlainText = B.readFile "data/plain-text.txt" encryptConduit :: (BlockCipher c, Monad m) => c -> IV c -> B.ByteString -> Conduit B.ByteString m B.ByteString encryptConduit cipher iv partialBlock = await >>= \case Nothing -> yield $ cbcEncrypt cipher iv $ pad (PKCS7 (blockSize cipher)) partialBlock Just moreBytes -> let fullBlocks = (B.length moreBytes + B.length partialBlock) `div` blockSize cipher (thisTime, nextTime) = B.splitAt (fullBlocks * blockSize cipher) (partialBlock <> moreBytes) in do iv' <- if B.null thisTime then return iv else do let cipherText = cbcEncrypt cipher iv thisTime lastBlockOfCipherText = B.drop (B.length cipherText - blockSize cipher) cipherText yield cipherText maybe (error "makeIV failed") return $ makeIV lastBlockOfCipherText encryptConduit cipher iv' nextTime go :: IO () go = do c <- loadCipher iv <- loadIV pt <- loadPlainText let padded = pad (PKCS7 (blockSize c)) $ pt encrypted = cbcEncrypt c iv padded B.writeFile "data/haskell-oneshot.dat" encrypted runResourceT $ runConduit $ sourceFile "data/plain-text.txt" =$= encryptConduit c iv mempty =$= sinkFile "data/haskell-streaming.dat" On 6 July 2017 at 23:29, Ivan Lazar Miljenovic wrote: > On 7 July 2017 at 01:44, Viktor Dukhovni wrote: > > > >> On Jul 6, 2017, at 12:58 AM, Ivan Lazar Miljenovic < > ivan.miljenovic at gmail.com> wrote: > >> > >> I have a use case for needing to use public key cryptography to > >> encrypt a large amount of data in a streaming fashion (get it out of a > >> DB, encrypt, put into an AWS S3 bucket). > > > > What are the data-format requirements? Do you need (binary) CMS output? > > GPG-compatible output? Or just roll your own? > > The intent is to be able to transfer data between two parties such > that only the recipient is able to view it (hence the usage of public > key cryptography). GPG/PGP compatability is preferable as it's > common, but anything that is sufficiently standardised (as this will > potentially be used by others that aren't me doing so with Haskell and > thus can't just use a library to do so) will suffice. > > (The other advantage of GPG/PGP is that the security testing team is > more familiar with it and thus likely to sign off on it.) > > > > > Integrity protection can be tricky with large data streams. Most data > > formats for enveloped data have a single MAC at the end, which means > > that the decoder has to consume all the data before it is known to be > > valid! > > > > So if you're in a position to avoid a standard all-in-one format, it > > makes sense to "packetize" the stream, with integrity protection for > > each "packet", and packet sequence numbers to preserve overall stream > > integrity. With vast amounts of data, you'll want to be careful with > > the symmetric cipher modes, AEAD (AES-GCM, for example) protects only > > a limited amount of data before you need to rekey. It may be simplest > > to just generate a new symmetric key for every N megabytes of data. > > > > With a careful design of the "packet" format, you can use in-memory > > crypto for each packet. Don't forget to include an "end-of-stream" > > packet to defeat truncation attacks. > > This sounds good in theory, but in practice I'm not versed enough in > security to want to try and roll my own if I could avoid it, and > trying to document such a format for others to use could be > problematic.allowed to post. > > -- > Ivan Lazar Miljenovic > Ivan.Miljenovic at gmail.com > http://IvanMiljenovic.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. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dennis.raddle at gmail.com Tue Jul 11 20:29:34 2017 From: dennis.raddle at gmail.com (Dennis Raddle) Date: Tue, 11 Jul 2017 13:29:34 -0700 Subject: [Haskell-cafe] problems with "stack ghc" Message-ID: I'm using Haskell stack in the normal way (i.e. "stack build", "stack exec") for most of my application. However, I also need to build files that aren't in the stack source tree. My stack source tree is at ~/stack/cac/src/ Let's say I want to build the program /Users/Dennis/test.hs. So far I have been using stack ghc --stack-yaml ~/stack/cac/stack.yaml -- --make /Users/Dennis/test.hs I am confused. I thought this was working until today. I made some modifications in various places, including to my cac.cabal (but NOT my stack.yaml) and I'm having a problem. The libraries that test.hs imports are not getting rebuilt when they change. Are they *supposed* to be rebuilt? Any ideas how to debug this? D -------------- next part -------------- An HTML attachment was scrubbed... URL: From ietf-dane at dukhovni.org Tue Jul 11 22:33:24 2017 From: ietf-dane at dukhovni.org (Viktor Dukhovni) Date: Tue, 11 Jul 2017 22:33:24 +0000 Subject: [Haskell-cafe] Encrypting streamed data In-Reply-To: References: <1E280315-0C09-4776-BE6B-3F135C543E05@dukhovni.org> Message-ID: <20170711223324.GF8146@mournblade.imrryr.org> On Tue, Jul 11, 2017 at 03:35:56PM +0100, David Turner wrote: > I can't think of a terribly good way to achieve GPG/PGP-compatibility > without simply using GPG/PGP, since the file format is quite involved. > > That said, here is how to implement a CBC-mode block cipher encryption > using Conduit, which is suitable for something like AES256 encryption. It > is almost certainly vulnerable to side-channel attacks (timing, > cache-poisoning, etc) but as a pure function from input to output it is > equivalent to `openssl aes-256-cbc -e -K -iv -in > data/plain-text.txt` which I should hope would be standard enough for > analysis. Just straight CBC lacks integrity protection. A MAC is still required, and usually one wants asymmetric key exchange, rather than a shared symmetric key. So in practice one wants something like CMS (successor to S/MIME). The OpenSSL cms(1) command can do clear signing, encryption, or both (in either order) by piping the output of one to the other. In many applications it is safer to encrypt then sign, rather than sign and then encrypt. Packetizing large input streams is well worth it, but while each "packet" can use any of a number of standar formats, some standards (notably CMS AFAIK) may lack support for packetizing large input streams. The OpenPGP standard does support breaking streams into "packets", so for large streams that may be optimal, you just need an OpenPGP library implementation that supports sensible packet sizes, and perhaps an FFI interface for Haskell. Alternatively, just a pipe to a CLI will do, bug the "gpg" CLI does not appear to support creating streams with more than one packet (Unless this happens implicitly for "large-enough" streams). -- Viktor. From dennis.raddle at gmail.com Wed Jul 12 01:11:57 2017 From: dennis.raddle at gmail.com (Dennis Raddle) Date: Tue, 11 Jul 2017 18:11:57 -0700 Subject: [Haskell-cafe] parallelism and state Message-ID: I'm trying to parallelize a Monte Carlo backtracking search algorithm. The trick is that my algorithm is expressed in a State monad, because I need to hold a StdGen as well as keep several records of computations and metrics. So I know that if I'm going to run a State computation in several parallel lines of execution, I need to conceive of a way to split the state and later recombine it. Here is a simple example I came up with. I have no idea if I'm doing this in a good way, so any comments are welcome. http://lpaste.net/356879 D -------------- next part -------------- An HTML attachment was scrubbed... URL: From lysxia at gmail.com Wed Jul 12 01:21:24 2017 From: lysxia at gmail.com (Li-yao Xia) Date: Tue, 11 Jul 2017 21:21:24 -0400 Subject: [Haskell-cafe] parallelism and state In-Reply-To: References: Message-ID: For a splittable PRNG, check out tf-random. LY On 07/11/2017 09:11 PM, Dennis Raddle wrote: > I'm trying to parallelize a Monte Carlo backtracking search algorithm. The > trick is that my algorithm is expressed in a State monad, because I need to > hold a StdGen as well as keep several records of computations and metrics. > > So I know that if I'm going to run a State computation in several parallel > lines of execution, I need to conceive of a way to split the state and > later recombine it. > > Here is a simple example I came up with. I have no idea if I'm doing this > in a good way, so any comments are welcome. > > http://lpaste.net/356879 > > 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 michael at snoyman.com Wed Jul 12 02:41:45 2017 From: michael at snoyman.com (Michael Snoyman) Date: Wed, 12 Jul 2017 05:41:45 +0300 Subject: [Haskell-cafe] problems with "stack ghc" In-Reply-To: References: Message-ID: No, the `ghc` command has no rebuild logic built in, since it doesn't know which of your packages you're expecting to be available. You can pass in the `--package` flag, however, to tell it which packages you're expecting. I'm not sure if I've ever tested in the exact case you're trying, so you may have to resort to `stack build` in the directory, but `--package` is worth a shot. On Tue, Jul 11, 2017 at 11:29 PM, Dennis Raddle wrote: > I'm using Haskell stack in the normal way (i.e. "stack build", "stack > exec") for most of my application. However, I also need to build files that > aren't in the stack source tree. > > My stack source tree is at ~/stack/cac/src/ > > Let's say I want to build the program /Users/Dennis/test.hs. > > So far I have been using > > stack ghc --stack-yaml ~/stack/cac/stack.yaml -- --make > /Users/Dennis/test.hs > > I am confused. I thought this was working until today. I made some > modifications in various places, including to my cac.cabal (but NOT my > stack.yaml) and I'm having a problem. The libraries that test.hs imports > are not getting rebuilt when they change. > > Are they *supposed* to be rebuilt? Any ideas how to debug 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 dennis.raddle at gmail.com Wed Jul 12 07:24:29 2017 From: dennis.raddle at gmail.com (Dennis Raddle) Date: Wed, 12 Jul 2017 00:24:29 -0700 Subject: [Haskell-cafe] problems with "stack ghc" In-Reply-To: References: Message-ID: --package seems to work. But this brings up another question. This takes a long time to run for a change to a single file, because stack is preprocessing and building *all* my executables, then installing them all. In my situation this is a lot of wasted time for something that needs to be fast. It's not just "stack ghc." I tried to get "stack build" to build a specific executable. I tried something like "stack build cac:myExec" (my package name is "cac") but this builds all my executables every time. I haven't been able to find the right approach to this in the docs. So, aside from wondering why "stack ghc" builds all my executables, how do I use "stack build" to build just one executable? D On Tue, Jul 11, 2017 at 7:41 PM, Michael Snoyman wrote: > No, the `ghc` command has no rebuild logic built in, since it doesn't know > which of your packages you're expecting to be available. You can pass in > the `--package` flag, however, to tell it which packages you're expecting. > I'm not sure if I've ever tested in the exact case you're trying, so you > may have to resort to `stack build` in the directory, but `--package` is > worth a shot. > > On Tue, Jul 11, 2017 at 11:29 PM, Dennis Raddle > wrote: > >> I'm using Haskell stack in the normal way (i.e. "stack build", "stack >> exec") for most of my application. However, I also need to build files that >> aren't in the stack source tree. >> >> My stack source tree is at ~/stack/cac/src/ >> >> Let's say I want to build the program /Users/Dennis/test.hs. >> >> So far I have been using >> >> stack ghc --stack-yaml ~/stack/cac/stack.yaml -- --make >> /Users/Dennis/test.hs >> >> I am confused. I thought this was working until today. I made some >> modifications in various places, including to my cac.cabal (but NOT my >> stack.yaml) and I'm having a problem. The libraries that test.hs imports >> are not getting rebuilt when they change. >> >> Are they *supposed* to be rebuilt? Any ideas how to debug 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 jan.loewenstein at gmail.com Wed Jul 12 08:30:22 2017 From: jan.loewenstein at gmail.com (=?UTF-8?Q?Jan_von_L=C3=B6wenstein?=) Date: Wed, 12 Jul 2017 08:30:22 +0000 Subject: [Haskell-cafe] What are the essential parts of a binary GHC package Message-ID: Hi, if I plan to compile Haskell code on the customers side, which parts of https://www.haskell.org/ghc/download_ghc_8_0_2.html#linux_x86_64 could I remove in order to reduce the size of my delivery? Some things are pretty clear: - GHC has to be in - LICENSE has to be in - libraries have to be in - docs can probably be left out But what about - compiler/stage1/** - compiler/stage2/** - libraries/Cabal/Cabal/** Any advice? Thanks and best regards Jan -------------- next part -------------- An HTML attachment was scrubbed... URL: From michael at snoyman.com Wed Jul 12 10:52:12 2017 From: michael at snoyman.com (Michael Snoyman) Date: Wed, 12 Jul 2017 13:52:12 +0300 Subject: [Haskell-cafe] problems with "stack ghc" In-Reply-To: References: Message-ID: I think you'll be happy about this PR: https://github.com/commercialhaskell/stack/pull/3237 On Wed, Jul 12, 2017 at 10:24 AM, Dennis Raddle wrote: > --package seems to work. > > But this brings up another question. This takes a long time to run for a > change to a single file, because stack is preprocessing and building *all* > my executables, then installing them all. In my situation this is a lot of > wasted time for something that needs to be fast. > > It's not just "stack ghc." I tried to get "stack build" to build a > specific executable. I tried something like "stack build cac:myExec" (my > package name is "cac") but this builds all my executables every time. I > haven't been able to find the right approach to this in the docs. > > So, aside from wondering why "stack ghc" builds all my executables, how do > I use "stack build" to build just one executable? > > D > > > On Tue, Jul 11, 2017 at 7:41 PM, Michael Snoyman > wrote: > >> No, the `ghc` command has no rebuild logic built in, since it doesn't >> know which of your packages you're expecting to be available. You can pass >> in the `--package` flag, however, to tell it which packages you're >> expecting. I'm not sure if I've ever tested in the exact case you're >> trying, so you may have to resort to `stack build` in the directory, but >> `--package` is worth a shot. >> >> On Tue, Jul 11, 2017 at 11:29 PM, Dennis Raddle >> wrote: >> >>> I'm using Haskell stack in the normal way (i.e. "stack build", "stack >>> exec") for most of my application. However, I also need to build files that >>> aren't in the stack source tree. >>> >>> My stack source tree is at ~/stack/cac/src/ >>> >>> Let's say I want to build the program /Users/Dennis/test.hs. >>> >>> So far I have been using >>> >>> stack ghc --stack-yaml ~/stack/cac/stack.yaml -- --make >>> /Users/Dennis/test.hs >>> >>> I am confused. I thought this was working until today. I made some >>> modifications in various places, including to my cac.cabal (but NOT my >>> stack.yaml) and I'm having a problem. The libraries that test.hs imports >>> are not getting rebuilt when they change. >>> >>> Are they *supposed* to be rebuilt? Any ideas how to debug 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 olshanskydr at gmail.com Wed Jul 12 19:48:57 2017 From: olshanskydr at gmail.com (Dmitry Olshansky) Date: Wed, 12 Jul 2017 22:48:57 +0300 Subject: [Haskell-cafe] persistent in types Message-ID: Hello cafe, I am trying to develop a library PersT for working with database persistent in types (instead of e.g. template-haskell in persistent library). Now there are base DDL/DML functionality and additional DML functionality for tree-like structures. Small dirty example of using it is located here . The main problem which I have is compile time. Compiling of my small example (five tables with five fields) needs 7 minutes and more than 6Gb RAM (!) I compile using stack and ghc 8.0.2. To check you need additionally only sqlite installed. Are there any ways to reduce resource utilization in compile time? Is it some problem in ghc which can be changed in future? What do you think? I also will be thankful for any feedback about library. Regards, Dima -------------- next part -------------- An HTML attachment was scrubbed... URL: From dennis.raddle at gmail.com Thu Jul 13 04:32:54 2017 From: dennis.raddle at gmail.com (Dennis Raddle) Date: Wed, 12 Jul 2017 21:32:54 -0700 Subject: [Haskell-cafe] problems with "stack ghc" In-Reply-To: References: Message-ID: Sorry if this is a basic question, but I've never tried to download and build a Haskell project before. I've only used Haskell for small local projects. So I'm guessing I need to get the latest source code for Stack and build it in order to incorporate this feature? I did try getting the source code from GitHub, but I don't know how to build it. D On Wed, Jul 12, 2017 at 3:52 AM, Michael Snoyman wrote: > I think you'll be happy about this PR: > > https://github.com/commercialhaskell/stack/pull/3237 > > On Wed, Jul 12, 2017 at 10:24 AM, Dennis Raddle > wrote: > >> --package seems to work. >> >> But this brings up another question. This takes a long time to run for a >> change to a single file, because stack is preprocessing and building *all* >> my executables, then installing them all. In my situation this is a lot of >> wasted time for something that needs to be fast. >> >> It's not just "stack ghc." I tried to get "stack build" to build a >> specific executable. I tried something like "stack build cac:myExec" (my >> package name is "cac") but this builds all my executables every time. I >> haven't been able to find the right approach to this in the docs. >> >> So, aside from wondering why "stack ghc" builds all my executables, how >> do I use "stack build" to build just one executable? >> >> D >> >> >> On Tue, Jul 11, 2017 at 7:41 PM, Michael Snoyman >> wrote: >> >>> No, the `ghc` command has no rebuild logic built in, since it doesn't >>> know which of your packages you're expecting to be available. You can pass >>> in the `--package` flag, however, to tell it which packages you're >>> expecting. I'm not sure if I've ever tested in the exact case you're >>> trying, so you may have to resort to `stack build` in the directory, but >>> `--package` is worth a shot. >>> >>> On Tue, Jul 11, 2017 at 11:29 PM, Dennis Raddle >> > wrote: >>> >>>> I'm using Haskell stack in the normal way (i.e. "stack build", "stack >>>> exec") for most of my application. However, I also need to build files that >>>> aren't in the stack source tree. >>>> >>>> My stack source tree is at ~/stack/cac/src/ >>>> >>>> Let's say I want to build the program /Users/Dennis/test.hs. >>>> >>>> So far I have been using >>>> >>>> stack ghc --stack-yaml ~/stack/cac/stack.yaml -- --make >>>> /Users/Dennis/test.hs >>>> >>>> I am confused. I thought this was working until today. I made some >>>> modifications in various places, including to my cac.cabal (but NOT my >>>> stack.yaml) and I'm having a problem. The libraries that test.hs imports >>>> are not getting rebuilt when they change. >>>> >>>> Are they *supposed* to be rebuilt? Any ideas how to debug 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 michael at snoyman.com Thu Jul 13 04:52:49 2017 From: michael at snoyman.com (Michael Snoyman) Date: Thu, 13 Jul 2017 07:52:49 +0300 Subject: [Haskell-cafe] problems with "stack ghc" In-Reply-To: References: Message-ID: Keep in mind that this is experimental software, so there may be rough edges. The code I linked to is not on master, only on a topic branch In order to build it: git clone --branch exe-targets-3229 --depth=1 https://github.com/commercialhaskell/stack cd stack stack install Then make sure that you have $HOME/.local/bin on your PATH, or copy the generated executable to wherever your stack executable currently resides. If you have problems with the new version, you can revert with: stack upgrade --binary-version 1.4.0 On Thu, Jul 13, 2017 at 7:32 AM, Dennis Raddle wrote: > Sorry if this is a basic question, but I've never tried to download and > build a Haskell project before. I've only used Haskell for small local > projects. So I'm guessing I need to get the latest source code for Stack > and build it in order to incorporate this feature? > > I did try getting the source code from GitHub, but I don't know how to > build it. > > D > > > On Wed, Jul 12, 2017 at 3:52 AM, Michael Snoyman > wrote: > >> I think you'll be happy about this PR: >> >> https://github.com/commercialhaskell/stack/pull/3237 >> >> On Wed, Jul 12, 2017 at 10:24 AM, Dennis Raddle >> wrote: >> >>> --package seems to work. >>> >>> But this brings up another question. This takes a long time to run for a >>> change to a single file, because stack is preprocessing and building *all* >>> my executables, then installing them all. In my situation this is a lot of >>> wasted time for something that needs to be fast. >>> >>> It's not just "stack ghc." I tried to get "stack build" to build a >>> specific executable. I tried something like "stack build cac:myExec" (my >>> package name is "cac") but this builds all my executables every time. I >>> haven't been able to find the right approach to this in the docs. >>> >>> So, aside from wondering why "stack ghc" builds all my executables, how >>> do I use "stack build" to build just one executable? >>> >>> D >>> >>> >>> On Tue, Jul 11, 2017 at 7:41 PM, Michael Snoyman >>> wrote: >>> >>>> No, the `ghc` command has no rebuild logic built in, since it doesn't >>>> know which of your packages you're expecting to be available. You can pass >>>> in the `--package` flag, however, to tell it which packages you're >>>> expecting. I'm not sure if I've ever tested in the exact case you're >>>> trying, so you may have to resort to `stack build` in the directory, but >>>> `--package` is worth a shot. >>>> >>>> On Tue, Jul 11, 2017 at 11:29 PM, Dennis Raddle < >>>> dennis.raddle at gmail.com> wrote: >>>> >>>>> I'm using Haskell stack in the normal way (i.e. "stack build", "stack >>>>> exec") for most of my application. However, I also need to build files that >>>>> aren't in the stack source tree. >>>>> >>>>> My stack source tree is at ~/stack/cac/src/ >>>>> >>>>> Let's say I want to build the program /Users/Dennis/test.hs. >>>>> >>>>> So far I have been using >>>>> >>>>> stack ghc --stack-yaml ~/stack/cac/stack.yaml -- --make >>>>> /Users/Dennis/test.hs >>>>> >>>>> I am confused. I thought this was working until today. I made some >>>>> modifications in various places, including to my cac.cabal (but NOT my >>>>> stack.yaml) and I'm having a problem. The libraries that test.hs imports >>>>> are not getting rebuilt when they change. >>>>> >>>>> Are they *supposed* to be rebuilt? Any ideas how to debug 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 dct25-561bs at mythic-beasts.com Thu Jul 13 10:29:53 2017 From: dct25-561bs at mythic-beasts.com (David Turner) Date: Thu, 13 Jul 2017 11:29:53 +0100 Subject: [Haskell-cafe] Unicode silliness Message-ID: Hi, One of my colleagues asked about using Unicode symbols in Haskell operators and I initially thought that this was supported. However, the code at the bottom of this message doesn't parse, reporting a lexical error on basically all of the funny characters of the form: Main.hs:1:5: error: lexical error at character '\65288' Character 65288 (0xff08) is punctuation [Ps] which I understand to mean it counts as a uniSymbol in the lexical structure described in the Haskell Report. https://www.haskell.org/onlinereport/haskell2010/haskellch2.html#x7-160002.2 Should this work? Not that I really want this specific example to work, but I'm interested to know why. Many thanks, David $ cat app/Main.hs foo (›’-’)› bar = False foo ‹(’-’‹) bar = False foo ∧(’-’)∧ bar = False foo ∨(’-’)∨ bar = False $ cat app/Main.hs | base64 # try and avoid mangling in email Zm9vIO+8iOKAuuKAmS3igJnvvInigLogYmFyID0gRmFsc2UKZm9vIOKAue+8iOKAmS3igJnigLnv vIkgYmFyID0gRmFsc2UKZm9vIOKIp++8iOKAmS3igJnvvIniiKcgYmFyID0gRmFsc2UKZm9vIOKI qO+8iOKAmS3igJnvvIniiKggYmFyID0gRmFsc2UK -------------- next part -------------- An HTML attachment was scrubbed... URL: From monkleyon at gmail.com Thu Jul 13 11:58:20 2017 From: monkleyon at gmail.com (MarLinn) Date: Thu, 13 Jul 2017 13:58:20 +0200 Subject: [Haskell-cafe] Unicode silliness In-Reply-To: References: Message-ID: > foo (›’-’)› bar = False > > Main.hs:1:5: error: lexical error at character '\65288' Brackets. To see unicode operators in action, take a look at https://hackage.haskell.org/package/base-unicode-symbols and https://hackage.haskell.org/package/acme-flipping-tables Cheers. From taylor at fausak.me Thu Jul 13 12:57:52 2017 From: taylor at fausak.me (Taylor Fausak) Date: Thu, 13 Jul 2017 07:57:52 -0500 Subject: [Haskell-cafe] Issue 63 :: Haskell Weekly Message-ID: <1499950672.3844983.1039691896.6AE13E18@webmail.messagingengine.com> \ Haskell Weekly \/\/ Issue 63 Welcome to another issue of Haskell Weekly! Haskell is a purely functional programming language that focuses on robustness, concision, and correctness. This is a weekly summary of what's going on in its community. ## Featured ## - GHC 8.2.1 release candidate 3 available > This release candidate fixes a number of regressions from 8.0.2 found in release candidate 2, as well as a major correctness bug present in several previous GHC major releases. Users taking advantage of parallelism in their programs will be strongly encouraged to upgrade to 8.2.1 once it is released. Editor's note: Use this stack.yaml to test GHC 8.2.1-rc3 with Stack. - Stack's new extensible snapshots > There is a collection of features in Stack that have been added in bit by bit, as opposed to being designed into a cohesive whole from the start. The features work, but could be a bit better. We've known for a while that, instead of putting in place strategic fixes, a more general refactoring of the core dependency management logic was in order. - ZuriHac 2017 Videos of the Haskell keynotes from ZuriHac, the Zurich Haskell hackathon. Includes presentations from Edward Kmett, Stephen Diehl, Simon Thompson, Neil Mitchell, and Julie Moronuki. - Front Row is hiring a senior backend Haskell engineer > Come change how 6.5+ million K-12 US students learn Math, Language Arts, Social Studies and more. Use data, advanced type systems, great product design and deep pedagogy to change lives. - Iterators and streams in Rust and Haskell > Real streaming data is handled at the library level in Haskell, with many different options available. Rust does things differently: it bakes in a concept called iterators not only with the standard library, but the language itself: `for` loops are built-in syntax for iterators. - Introducing Vaultenv: Keeping your secrets secure with Vault and Haskell > We're pleased to announce our first bit of open source code. It is a CLI utility that fetches secrets from the HashiCorp Vault secret store. It makes secrets available using environment variables to a process of your choosing. - Danger and HLint > Danger is a Ruby gem that you can use on your continuous integration process to automate code reviews. Danger can automatically go through the code in a an open pull request and check if it respects the rules your team and you have established. - Reader monad part 2 > In part 1 I went over the basics of the reader monad. In this post I'll cover some more advanced topics and alternatives to the reader monad. - Encoding objects > Objects can be thought of as Mealy machines of effects, and their Haskell encoding is actually straightforward. This novel building block might be too strong to use everyday, but I'm pretty sure there are places where this abstraction fits well, like game programming. - Playing match maker > So at this point, are we condemned to choose between a fast inaccurate algorithm and a correct but slow one? In this case the answer is no! This problem is actually best solved by using a graph algorithm! ## Package of the week ## This week's package of the week is Solga, a library for easily specifying web APIs and implementing them in a type-safe way. ## Call for participation ## Are you interested in contributing to open-source Haskell projects but not sure where to start? Here are some tasks from the Haskell community for you to pick and get started! - aeson: Hindent? - cabal: Print out more information about the effective configuration when you build - esqueleto: Make examples for the README buildable - miso: phantomjs2 fails to build on OSX - servant: BasicAuthentication has no documentation for client-side use - stack: `stack new` can't be pointed at an intranet site - text: Add tshow function Email with your beginner-friendly issues to get them included. ## In brief ## - A tale of two provers: Verifying monoidal string matching in Liquid Haskell and Coq - Named extensible effects - Profunctor optics: Modular data accessors - Profunctor optics: The categorical view - PureScript 0.11.6 From dct25-561bs at mythic-beasts.com Thu Jul 13 15:03:53 2017 From: dct25-561bs at mythic-beasts.com (David Turner) Date: Thu, 13 Jul 2017 16:03:53 +0100 Subject: [Haskell-cafe] Unicode silliness In-Reply-To: References: Message-ID: On 13 July 2017 at 12:58, MarLinn wrote: > foo (›’-’)› bar = False >> >> Main.hs:1:5: error: lexical error at character '\65288' >> > > Brackets. > Yes, brackets, but why is this a problem? I found this code [1] in GHC which seems like it might be relevant. Is it? It seems to suggest that classes Pc, Pd, Po, Sm, Sc, Sk and So are allowed in infix names, but Ps, Pe, Pi and Pf are not. Am I reading that right? [1] https://github.com/ghc/ghc/blob/49012ebc9ed44a0b1f8de3781e15c8115d3074f8/compiler/parser/Lexer.x#L2013 Cheers, David -------------- next part -------------- An HTML attachment was scrubbed... URL: From clintonmead at gmail.com Thu Jul 13 15:13:20 2017 From: clintonmead at gmail.com (Clinton Mead) Date: Fri, 14 Jul 2017 01:13:20 +1000 Subject: [Haskell-cafe] Unicode silliness In-Reply-To: References: Message-ID: I think MarLinn was highlighting that this line: > foo ‹(’-’‹) bar = False Should read like this: > foo ‹(’-’)‹ bar = False On Fri, Jul 14, 2017 at 1:03 AM, David Turner wrote: > On 13 July 2017 at 12:58, MarLinn wrote: > >> foo (›’-’)› bar = False >>> >>> Main.hs:1:5: error: lexical error at character '\65288' >>> >> >> Brackets. >> > > Yes, brackets, but why is this a problem? > > I found this code [1] in GHC which seems like it might be relevant. Is it? > It seems to suggest that classes Pc, Pd, Po, Sm, Sc, Sk and So are allowed > in infix names, but Ps, Pe, Pi and Pf are not. Am I reading that right? > > [1] https://github.com/ghc/ghc/blob/49012ebc9ed44a0b1f8de3781e15c8 > 115d3074f8/compiler/parser/Lexer.x#L2013 > > Cheers, > > David > > > > _______________________________________________ > 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 Thu Jul 13 15:17:54 2017 From: dct25-561bs at mythic-beasts.com (David Turner) Date: Thu, 13 Jul 2017 16:17:54 +0100 Subject: [Haskell-cafe] Unicode silliness In-Reply-To: References: Message-ID: On 13 July 2017 at 16:13, Clinton Mead wrote: > I think MarLinn was highlighting that this line: > > foo ‹(’-’‹) bar = False > > Should read like this: > > foo ‹(’-’)‹ bar = False > That doesn't seem to help, unfortunately. It says: > Main.hs:1:5: error: lexical error at character '\8249' -------------- next part -------------- An HTML attachment was scrubbed... URL: From clintonmead at gmail.com Thu Jul 13 15:20:55 2017 From: clintonmead at gmail.com (Clinton Mead) Date: Fri, 14 Jul 2017 01:20:55 +1000 Subject: [Haskell-cafe] Unicode silliness In-Reply-To: References: Message-ID: And also: > foo (›’-’)› bar = False should be > foo ›(’-’)› bar = False I'd suggest ensuring your code compiles without the unicode first, before trying to add the unicode symbols, so you can be sure it's the unicode causing the problem. On Fri, Jul 14, 2017 at 1:17 AM, David Turner wrote: > > On 13 July 2017 at 16:13, Clinton Mead wrote: > >> I think MarLinn was highlighting that this line: >> > foo ‹(’-’‹) bar = False >> >> Should read like this: >> > > foo ‹(’-’)‹ bar = False >> > > That doesn't seem to help, unfortunately. It says: > > > Main.hs:1:5: error: lexical error at character '\8249' > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dct25-561bs at mythic-beasts.com Thu Jul 13 15:28:07 2017 From: dct25-561bs at mythic-beasts.com (David Turner) Date: Thu, 13 Jul 2017 16:28:07 +0100 Subject: [Haskell-cafe] Unicode silliness In-Reply-To: References: Message-ID: On 13 July 2017 at 16:20, Clinton Mead wrote: > And also: > > > foo (›’-’)› bar = False > > should be > > > foo ›(’-’)› bar = False > > I'd suggest ensuring your code compiles without the unicode first, before > trying to add the unicode symbols, so you can be sure it's the unicode > causing the problem. > It does. This is fine: > foo ?!?!?!? bar = False It's the Unicode punctuation that isn't. Note that the things that look like parentheses aren't ASCII parentheses, they're U+FF08 FULLWIDTH LEFT PARENTHESIS and U+FF09 FULLWIDTH RIGHT PARENTHESIS, which are in classes Ps and Pe respectively, and the code I linked to earlier seems to dislike those classes. Cheers, David -------------- next part -------------- An HTML attachment was scrubbed... URL: From publicityifl at gmail.com Thu Jul 13 20:13:46 2017 From: publicityifl at gmail.com (publicityifl at gmail.com) Date: Thu, 13 Jul 2017 20:13:46 +0000 Subject: [Haskell-cafe] 2nd CfP: IFL 2017 (29th Symposium on Implementation and Application of Functional Languages) Message-ID: <001a113dccd4e6175805543891f8@google.com>
Hello,

Please, find below the second call for papers for IFL 2017.
Please forward these to anyone you think may be interested.
Apologies for any duplicates you may receive.

best regards,
Jurriaan Hage
Publicity Chair of IFL

---

IFL 2017 - CALL FOR PAPERS
==========================

29th SYMPOSIUM ON IMPLEMENTATION AND APPLICATION OF FUNCTIONAL LANGUAGES
========================================================================

University of Bristol, UK

In cooperation with ACM SIGPLAN

Wednesday 30 August - Friday 1 September, 2017

http://iflconference.org/

Scope
-----

The goal of the IFL symposia is to bring together researchers actively engaged
in the implementation and application of functional and function-based
programming languages. IFL 2017 will be a venue for researchers to present and
discuss new ideas and concepts, work in progress, and publication-ripe results
related to the implementation and application of functional languages and
function-based programming.

Peer-review
-----------

Following the IFL tradition, IFL 2017 will use a post-symposium review process
to produce the formal proceedings. All participants of IFL 2017 are invited to
submit either a draft paper or an extended abstract describing work to be
presented at the symposium. At no time may work submitted to IFL be
simultaneously submitted to other venues; submissions must adhere to ACM
SIGPLAN's republication policy:

http://www.sigplan.org/Resources/Policies/Republication

The submissions will be screened by the program committee chair to make sure
they are within the scope of IFL, and will appear in the draft proceedings
distributed at the symposium. Submissions appearing in the draft proceedings
are not peer-reviewed publications. Hence, publications that appear only in the
draft proceedings are not subject to the ACM SIGPLAN republication policy.
After the symposium, authors will be given the opportunity to incorporate the
feedback from discussions at the symposium and will be invited to submit a
revised full article for the formal review process. From the revised
submissions, the program committee will select papers for the formal
proceedings considering their correctness, novelty, originality, relevance,
significance, and clarity. The formal proceedings will appear in the
International Conference Proceedings Series of the ACM Digital Library.

Important dates
---------------

Mon 31 July     2017 : Submission deadline draft papers
Wed  2 August   2017 : Notification of acceptance for presentation
Fri  4 August   2017 : Early registration deadline
Fri 11 August   2017 : Late registration deadline
Mon 21 August   2017 : Submission deadline for pre-symposium proceedings
Wed 30 August   2017 - Fri 1 September 2017 : IFL Symposium
Mon  4 December 2017 : Submission deadline for post-symposium proceedings
Wed 31 January  2018 : Notification of acceptance for post-symposium proceedings
Mon 12 March    2018 : Camera-ready version for post-symposium proceedings

Submission details
------------------

Prospective authors are encouraged to submit papers or extended abstracts to be
published in the draft proceedings and to present them at the symposium. All
contributions must be written in English. Papers must use the new ACM two
columns conference format, which can be found at:

http://www.acm.org/publications/proceedings-template

For the pre-symposium proceedings we adopt a 'weak' page limit of 12 pages. For
the post-symposium proceedings the page limit of 12 pages is firm.

Authors submit through EasyChair:

https://easychair.org/conferences/?conf=ifl2017

Topics
------

IFL welcomes submissions describing practical and theoretical work as well as
submissions describing applications and tools in the context of functional
programming. If you are not sure whether your work is appropriate for IFL 2017,
please contact the PC chair at nicolas.wu at bristol.ac.uk. Topics of interest include,
but are not limited to:

- language concepts
- type systems, type checking, type inferencing
- compilation techniques
- staged compilation
- run-time function specialization
- run-time code generation
- partial evaluation
- (abstract) interpretation
- metaprogramming
- generic programming
- automatic program generation
- array processing
- concurrent/parallel programming
- concurrent/parallel program execution
- embedded systems
- web applications
- (embedded) domain specific languages
- security
- novel memory management techniques
- run-time profiling performance measurements
- debugging and tracing
- virtual/abstract machine architectures
- validation, verification of functional programs
- tools and programming techniques
- (industrial) applications

Peter Landin Prize
------------------

The Peter Landin Prize is awarded to the best paper presented at the symposium
every year. The honored article is selected by the program committee based on
the submissions received for the formal review process. The prize carries a
cash award equivalent to 150 Euros.

Programme committee
-------------------

Chair: Nicolas Wu, University of Bristol, UK

- Kenichi Asai, Ochanomizu University, Japan
- Sandrine Blazy, University of Rennes 1, France
- Carlos Camarao, Universidade Federal de Minas Gerais, Brazil
- Stephen Dolan, University of Cambridge, UK
- Jurriaan Hage, Utrecht University, Netherlands
- Yukiyoshi Kameyama, University of Tsukuba, Japan
- Benjamin Lerner, Brown University, USA
- Bas Lijnse, Radboud University, Netherlands
- Garrett Morris, University of Kansas, USA
- Miguel Pagano, Universidad Nacional de Córdoba, Argentina
- Tomas Petricek, Alan Turing Institute, UK
- Maciej Piróg, University of Wroclaw, Poland
- Exequiel Rivas, Universidad Nacional de Rosario, Argentina
- Neil Sculthorpe, Nottingham Trent University, UK
- Melinda Toth, Eotvos Lorand University, Hungary
- Phil Trinder, Glasgow University, UK
- Kanae Tsushima, National Institute of Informatics, Japan
- Marcos Viera, Universidad de la Republica, Uruguay
- Meng Wang, University of Kent, UK

Venue
-----

The IFL 2017 will be held in association with the Department of
Computer Science, University of Bristol, UK. Bristol is located in
South West England, and can be easily reached from Bristol Airport.
See the website for more information on the venue.

 

powered by GSM. Free mail merge and email marketing software for Gmail. -------------- next part -------------- An HTML attachment was scrubbed... URL: From atrudyjane at protonmail.com Thu Jul 13 21:29:44 2017 From: atrudyjane at protonmail.com (Atrudyjane) Date: Thu, 13 Jul 2017 17:29:44 -0400 Subject: [Haskell-cafe] Feedback on use of State monad Message-ID: Hello Everyone, In the HPFFP book, there's a homework problem where you're supposed to refactor a recursive function that rolls dice to return the number of rolls it takes to reach or exceed an input sum and the list of die that occurred. As practice, decided to take the solution and implement it using the State monad: -- Refactor rollsCountLoggged to use State -- limit sum count StdGen [Die] type RollsState = (Int, Int, Int, StdGen, [Die]) -- count [Die] type RollsValue = (Int, [Die]) runRolls :: State RollsState RollsValue runRolls = do (l, s, c, sg, xs) <- get if (s >= l) then return (c, reverse xs) else do let (d, ng) = randomR (1, 6) sg put (l, s + d, c + 1, ng, intToDie d : xs) runRolls rollsCountState :: Int -> IO () rollsCountState n = print $ evalState (runRolls) (n, 0, 0, mkStdGen 0, []) I'm wondering if that 'do' block under the else is a not so great stylistic choice. If the 'let' and 'put' is moved above the 'if', then that's just an unnecessary call at the end. Or is it just the nature of running inside a monad? Thank You, Andrea Sent with [ProtonMail](https://protonmail.com) Secure Email. -------------- next part -------------- An HTML attachment was scrubbed... URL: From monkleyon at gmail.com Fri Jul 14 08:22:31 2017 From: monkleyon at gmail.com (MarLinn) Date: Fri, 14 Jul 2017 10:22:31 +0200 Subject: [Haskell-cafe] Feedback on use of State monad In-Reply-To: References: Message-ID: <788b1b26-a5e9-5d50-3e53-ac48e7e1e4dc@gmail.com> On 2017-07-13 23:29, Atrudyjane via Haskell-Cafe wrote: > runRolls :: State RollsState RollsValue > runRolls = do > (l, s, c, sg, xs) <- get > if (s >= l) then > return (c, reverse xs) > else > do > let (d, ng) = randomR (1, 6) sg > put (l, s + d, c + 1, ng, intToDie d : xs) > runRolls > > rollsCountState :: Int -> IO () > rollsCountState n = print $ evalState (runRolls) (n, 0, 0, mkStdGen 0, []) > > I'm wondering if that 'do' block under the else is a not so great > stylistic choice. If the 'let' and 'put' is moved above the 'if', then > that's just an unnecessary call at the end. Or is it just the nature > of running inside a monad? It is the nature of running inside a monad. But at the same time, runRolls contains the implementation of two things. Which, to a purist like me, would be one too many. Pulling one of them out into a second function already makes this one much nicer. But there are other, more pressing stylistic choices to make. Namely to use records and mnemonic names. Here is an adapted version taken to more beauty and then beyond into ridiculousness: {-# LANGUAGE RecordWildCards , MultiWayIf #-} […] rollsCountState :: Int -> IO () rollsCountState rollLimit = print $ evalState runRolls initialRollState where runRolls = get >>= \RollsState{..} -> if | rollSum >= rollLimit -> pure (rollCount, reverse rolledDice) | otherwise -> modify rollDice >> runRolls The “ideal” version is probably somewhere in between. Maybe with one of the many whileM or untilM implementations thrown in that everyone keeps reinventing. Cheers, MarLinn From oleg.grenrus at iki.fi Fri Jul 14 16:17:28 2017 From: oleg.grenrus at iki.fi (Oleg Grenrus) Date: Fri, 14 Jul 2017 19:17:28 +0300 Subject: [Haskell-cafe] parallelism and state In-Reply-To: References: Message-ID: <2875c002-285c-4e3b-da73-47ef18b10812@iki.fi> I recently made a SplitMix implentation: http://hackage.haskell.org/package/splitmix When generating `Word64`s it's noticeable faster than `tf-random` (and `mwc-random` and obviously `random). I didn't benchmark `Double` generation, as `tf-random` own `Random` class doesn't support it [1], and using `random`'s class would be very unfair. I haven't announced it (well, mentioned on Twitter), but please give it a try! - Oleg -[1] http://hackage.haskell.org/package/tf-random-0.5/docs/System-Random-TF-Instances.html On 12.07.2017 04:21, Li-yao Xia wrote: > For a splittable PRNG, check out tf-random. > > LY > > On 07/11/2017 09:11 PM, Dennis Raddle wrote: >> I'm trying to parallelize a Monte Carlo backtracking search >> algorithm. The >> trick is that my algorithm is expressed in a State monad, because I >> need to >> hold a StdGen as well as keep several records of computations and >> metrics. >> >> So I know that if I'm going to run a State computation in several >> parallel >> lines of execution, I need to conceive of a way to split the state and >> later recombine it. >> >> Here is a simple example I came up with. I have no idea if I'm doing >> this >> in a good way, so any comments are welcome. >> >> http://lpaste.net/356879 >> >> 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. > > _______________________________________________ > 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: 819 bytes Desc: OpenPGP digital signature URL: From amindfv at gmail.com Fri Jul 14 20:29:23 2017 From: amindfv at gmail.com (amindfv at gmail.com) Date: Fri, 14 Jul 2017 15:29:23 -0500 Subject: [Haskell-cafe] Safely reading RemoteRefs? Message-ID: <6E74B4E0-B1B8-429B-A18A-BF5B598DE61E@gmail.com> I notice I'm able to retrieve haskell variables after a :r in ghci: :m + Data.Binary :m + GHCi.RemoteTypes > encodeFile "/tmp/foo" =<< mkRemoteRef "hello!" (:reload) > putStrLn =<< localRef =<< decodeFile "/tmp/foo" "hello!" Is this safe? It works correctly in the common case but are there things I need to be careful of? In the string case it's not too interesting but it would be great to e.g. retrieve the pid of a running process. Tom -------------- next part -------------- An HTML attachment was scrubbed... URL: From atrudyjane at protonmail.com Sat Jul 15 05:05:47 2017 From: atrudyjane at protonmail.com (Atrudyjane) Date: Sat, 15 Jul 2017 01:05:47 -0400 Subject: [Haskell-cafe] Feedback on use of State monad In-Reply-To: <788b1b26-a5e9-5d50-3e53-ac48e7e1e4dc@gmail.com> References: <788b1b26-a5e9-5d50-3e53-ac48e7e1e4dc@gmail.com> Message-ID: Will need more experience before discerning between beauty and ridiculousness in Haskell code, but your version is helpful nonetheless. Can see that separating out the dice rolls at least makes a big difference. And since there's only one bind, it's readable enough without do syntax. Thank you for your suggestions! Regards, Andrea Sent with [ProtonMail](https://protonmail.com) Secure Email. > -------- Original Message -------- > Subject: Re: [Haskell-cafe] Feedback on use of State monad > Local Time: July 14, 2017 3:22 AM > UTC Time: July 14, 2017 8:22 AM > From: monkleyon at gmail.com > To: haskell-cafe at haskell.org > On 2017-07-13 23:29, Atrudyjane via Haskell-Cafe wrote: >> runRolls :: State RollsState RollsValue >> runRolls = do >> (l, s, c, sg, xs) <- get >> if (s >= l) then >> return (c, reverse xs) >> else >> do >> let (d, ng) = randomR (1, 6) sg >> put (l, s + d, c + 1, ng, intToDie d : xs) >> runRolls >> >> rollsCountState :: Int -> IO () >> rollsCountState n = print $ evalState (runRolls) (n, 0, 0, mkStdGen 0, []) >> >> I"m wondering if that "do" block under the else is a not so great >> stylistic choice. If the "let" and "put" is moved above the "if", then >> that"s just an unnecessary call at the end. Or is it just the nature >> of running inside a monad? > It is the nature of running inside a monad. But at the same time, > runRolls contains the implementation of two things. Which, to a purist > like me, would be one too many. Pulling one of them out into a second > function already makes this one much nicer. But there are other, more > pressing stylistic choices to make. Namely to use records and mnemonic > names. Here is an adapted version taken to more beauty and then beyond > into ridiculousness: > {-# LANGUAGE RecordWildCards , MultiWayIf #-} > […] > rollsCountState :: Int -> IO () > rollsCountState rollLimit = print $ evalState runRolls initialRollState > where > runRolls = get >>= \RollsState{..} -> > if | rollSum >= rollLimit -> pure (rollCount, reverse rolledDice) > | otherwise -> modify rollDice >> runRolls > The “ideal” version is probably somewhere in between. Maybe with one of > the many whileM or untilM implementations thrown in that everyone keeps > reinventing. > Cheers, > MarLinn > _______________________________________________ > 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 Sat Jul 15 17:37:37 2017 From: trebla at vex.net (Albert Y. C. Lai) Date: Sat, 15 Jul 2017 13:37:37 -0400 Subject: [Haskell-cafe] "cabal quine" Message-ID: <40de5c82-336a-9a4a-77a5-4aef3dac0181@vex.net> Today a few of us on IRC (freenode #haskell) discovered: The following cabal-install command cabal manpage outputs cabal-install's man page (and is mainly how cabal-install can come with a man page without carrying an extra source file). This inspires the following feature request in jest: Could "cabal quine" output its source code please? :) kthxbye From codygman.consulting at gmail.com Sun Jul 16 07:52:06 2017 From: codygman.consulting at gmail.com (Cody Goodman) Date: Sun, 16 Jul 2017 02:52:06 -0500 Subject: [Haskell-cafe] Wrapping Turtle ls function to work with 0 or 1 arguments (polyvariadic) Message-ID: I'm trying to get ls to work in ghci like it does in bash using variadiac arguments in Haskell. I'm stuck at the moment so I thought I'd send this to #haskell-cafe for some help. I'm not quite sure how to proceed. See the main function for what I want the end result to look like. Here is the code: {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE OverloadedStrings #-} -- | An example module. module Example (main) where import qualified Turtle as Turtle import Control.Foldl import Control.Monad.IO.Class lsDirEx :: MonadIO io => io [Turtle.FilePath] lsDirEx = do Turtle.fold (Turtle.ls "/home") list class PrintAllType t where -- use PrintAllType from https://rosettacode.org/wiki/Variadic_function#Haskell process :: [Turtle.FilePath] -> t -- instance MonadIO io => PrintAllType (io [Turtle.FilePath]) where instance PrintAllType (IO [Turtle.FilePath]) where process [] = do -- ls received no args print current directory Turtle.pwd >>= \fp -> Turtle.fold (Turtle.ls fp) list process (filePath:[]) = do -- ls recieved one filePath liftIO $ Turtle.fold (Turtle.ls filePath) list process _ = error "multiple arguments not currently supported" -- instance (Show a, PrintAllType r) => PrintAllType (a -> r) where -- process args = \a -> process (args ++ [fmt a]) -- where fmt thing = _ $ Turtle.format Turtle.w thing ls :: (PrintAllType t) => t ls = process [] -- | An example function. main :: IO () main = do ls -- lists current directory ls ("/home" :: String) -- lists /home directory Thanks, Cody -------------- next part -------------- An HTML attachment was scrubbed... URL: From dominic at steinitz.org Sun Jul 16 12:18:28 2017 From: dominic at steinitz.org (dominic at steinitz.org) Date: Sun, 16 Jul 2017 13:18:28 +0100 Subject: [Haskell-cafe] parallelism and state Message-ID: <4D066AA5-D389-4598-B461-7266A45CC165@steinitz.org> Excellent news! How did you test it? One way would be to make it callable by C and then use testu01 but perhaps you have already done this or similar? See here for a bit more detail: https://idontgetoutmuch.wordpress.com/2017/01/14/calling-haskell-from-c/ . Testing the split function might need thinking about though. > I recently made a SplitMix implentation: > http://hackage.haskell.org/package/splitmix > > When generating `Word64`s it's noticeable faster than `tf-random` (and > `mwc-random` and obviously `random). I didn't benchmark `Double` > generation, as `tf-random` own `Random` class doesn't support it [1], > and using `random`'s class would be very unfair. > > I haven't announced it (well, mentioned on Twitter), but please give it > a try! > > - Oleg Dominic Steinitz dominic at steinitz.org http://idontgetoutmuch.wordpress.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From anfelor at posteo.de Sun Jul 16 15:46:09 2017 From: anfelor at posteo.de (Anton Felix Lorenzen) Date: Sun, 16 Jul 2017 17:46:09 +0200 Subject: [Haskell-cafe] Wrapping Turtle ls function to work with 0 or 1 arguments (polyvariadic) In-Reply-To: References: Message-ID: I'm not sure that it is possible to do that, as you need to return a result. I am no expert on this, though. My solution sidesteps that problem by putting all the magic into the 't' in 'process :: [Turtle.FilePath] -> t [Turtle.FilePath]', composing the types into a single functor. In order to supply arguments, you now have to unpack that functor again. Anton {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE TypeFamilies #-} module Example (main) where import qualified Turtle as Turtle import Control.Foldl import Control.Monad.IO.Class -- | Composition of unary type constructors as found in TypeCompose -- https://hackage.haskell.org/package/TypeCompose-0.9.12/ newtype (g :. f) a = Compose { (!) :: g (f a)} instance (Functor g, Functor f) => Functor (g :. f) where fmap f (Compose c) = Compose $ fmap (fmap f) c -- | This is the variadic type class used to implement 'ls' -- See https://rosettacode.org/wiki/Variadic_function#Haskell class (Functor t) => PrintAllType t where process :: [Turtle.FilePath] -> t [Turtle.FilePath] instance PrintAllType IO where process [] = do fp <- Turtle.pwd Turtle.fold (Turtle.ls fp) list process xs = do concat <$> mapM (\filePath -> Turtle.fold (Turtle.ls filePath) list) xs -- Use "a ~ FilePath" instead of simply 'FilePath' to avoid problems -- with OverloadedStrings instance (a ~ Turtle.FilePath, PrintAllType r) => PrintAllType ((->) a :. r) where process args = Compose $ \a -> process (a:args) ls :: (PrintAllType t) => t [Turtle.FilePath] ls = process [] main :: IO () main = do inThisDir <- ls print inThisDir inHomeOptDir <- ls ! "/home" ! "/opt" print inHomeOptDir On 16.07.2017 09:52, Cody Goodman wrote: > I'm trying to get ls to work in ghci like it does in bash using > variadiac arguments in Haskell. I'm stuck at the moment so I thought I'd > send this to #haskell-cafe for some help. I'm not quite sure how to proceed. > > See the main function for what I want the end result to look like. Here > is the code: > > > {-# LANGUAGE FlexibleInstances #-} > {-# LANGUAGE OverloadedStrings #-} > -- | An example module. > module Example (main) where > > import qualified Turtle as Turtle > import Control.Foldl > import Control.Monad.IO.Class > > lsDirEx :: MonadIO io => io [Turtle.FilePath] > lsDirEx = do > Turtle.fold (Turtle.ls "/home") list > > class PrintAllType t where -- use PrintAllType from > https://rosettacode.org/wiki/Variadic_function#Haskell > process :: [Turtle.FilePath] -> t > > -- instance MonadIO io => PrintAllType (io [Turtle.FilePath]) where > instance PrintAllType (IO [Turtle.FilePath]) where > process [] = do -- ls received no args print current directory > Turtle.pwd >>= \fp -> Turtle.fold (Turtle.ls fp) list > process (filePath:[]) = do -- ls recieved one filePath > liftIO $ Turtle.fold (Turtle.ls filePath) list > process _ = error "multiple arguments not currently supported" > > -- instance (Show a, PrintAllType r) => PrintAllType (a -> r) where > -- process args = \a -> process (args ++ [fmt a]) > -- where fmt thing = _ $ Turtle.format Turtle.w thing > > ls :: (PrintAllType t) => t > ls = process [] > > -- | An example function. > main :: IO () > main = do > ls -- lists current directory > ls ("/home" :: String) -- lists /home directory > > > > Thanks, > > Cody > > > > _______________________________________________ > 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 lysxia at gmail.com Sun Jul 16 16:33:27 2017 From: lysxia at gmail.com (Li-yao Xia) Date: Sun, 16 Jul 2017 12:33:27 -0400 Subject: [Haskell-cafe] Wrapping Turtle ls function to work with 0 or 1 arguments (polyvariadic) In-Reply-To: References: Message-ID: <2ed87105-24c9-59d8-2cde-8e5434a707c1@gmail.com> Try this instance instead. instance (a ~ [Turtle.FilePath]) => PrintAllType (IO a) where When you try to use `ls` at some type `IO a`, instance resolution won't instantiate `a`, and thus it will not match `IO [FilePath]`. However, here, it will match `IO a`, and after having picked that instance, it gets to unify `a ~ [FilePath]`. Li-yao On 07/16/2017 03:52 AM, Cody Goodman wrote: > I'm trying to get ls to work in ghci like it does in bash using variadiac > arguments in Haskell. I'm stuck at the moment so I thought I'd send this to > #haskell-cafe for some help. I'm not quite sure how to proceed. > > See the main function for what I want the end result to look like. Here is > the code: > > > {-# LANGUAGE FlexibleInstances #-} > {-# LANGUAGE OverloadedStrings #-} > -- | An example module. > module Example (main) where > > import qualified Turtle as Turtle > import Control.Foldl > import Control.Monad.IO.Class > > lsDirEx :: MonadIO io => io [Turtle.FilePath] > lsDirEx = do > Turtle.fold (Turtle.ls "/home") list > > class PrintAllType t where -- use PrintAllType from > https://rosettacode.org/wiki/Variadic_function#Haskell > process :: [Turtle.FilePath] -> t > > -- instance MonadIO io => PrintAllType (io [Turtle.FilePath]) where > instance PrintAllType (IO [Turtle.FilePath]) where > process [] = do -- ls received no args print current directory > Turtle.pwd >>= \fp -> Turtle.fold (Turtle.ls fp) list > process (filePath:[]) = do -- ls recieved one filePath > liftIO $ Turtle.fold (Turtle.ls filePath) list > process _ = error "multiple arguments not currently supported" > > -- instance (Show a, PrintAllType r) => PrintAllType (a -> r) where > -- process args = \a -> process (args ++ [fmt a]) > -- where fmt thing = _ $ Turtle.format Turtle.w thing > > ls :: (PrintAllType t) => t > ls = process [] > > -- | An example function. > main :: IO () > main = do > ls -- lists current directory > ls ("/home" :: String) -- lists /home directory > > > > Thanks, > > Cody > > > > _______________________________________________ > 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 Sun Jul 16 20:20:55 2017 From: dennis.raddle at gmail.com (Dennis Raddle) Date: Sun, 16 Jul 2017 13:20:55 -0700 Subject: [Haskell-cafe] any cloud computing services for running Haskell? Message-ID: I'm thinking of using cloud computing services for running my CPU-intensive parallel Haskell code, in order to get results faster. Instead of buying a faster computer, I would take advantage of existing services. Note that my budget is small, so I need something that doesn't have a large minimum charge. I'm thinking $10 - 30 per month. Are there any cloud services like that that run Haskell? D -------------- next part -------------- An HTML attachment was scrubbed... URL: From sanghak at andychun.info Sun Jul 16 22:48:16 2017 From: sanghak at andychun.info (Sang Hak (Andy) Chun) Date: Sun, 16 Jul 2017 15:48:16 -0700 Subject: [Haskell-cafe] any cloud computing services for running Haskell? In-Reply-To: References: Message-ID: Hey Dennis, I'm not aware of any cloud services that offer Haskell-specific services; however, you should be fine on many mainstream cloud services (AWS, Azure, etc.) as long as you write your program so that it uses multiple threads/CUDA/whatever. There's nothing special about programs that come out of GHC. You may be interested in packaging your program in a Nix environment if you intend to run your program across many different environments. Regards, Andy On 7/16/2017 1:20 PM, Dennis Raddle wrote: > I'm thinking of using cloud computing services for running my > CPU-intensive parallel Haskell code, in order to get results faster. > Instead of buying a faster computer, I would take advantage of > existing services. > > Note that my budget is small, so I need something that doesn't have a > large minimum charge. I'm thinking $10 - 30 per month. > > Are there any cloud services like that that run Haskell? > 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 zhangjun.julian at gmail.com Mon Jul 17 02:48:05 2017 From: zhangjun.julian at gmail.com (jun zhang) Date: Mon, 17 Jul 2017 10:48:05 +0800 Subject: [Haskell-cafe] How to deal with last item with concatMapAccumC in Conduit. Message-ID: <0BCF7A76-5564-4CA9-8512-44A87F03B46A@gmail.com> Dear cafes I use Conduit to parse a huge file. And I need merge lines by condition. I find the concatMapAccumC can do that and I write a demo as blow(with conduit-combinators-1.0.6,lts-6.18). The problem is if the last item didn’t make condition true, the data only keep in the accum but missing in stream. Any one can give me some advises? Thanks ---------------------------- import Conduit test'::Int->Int->(Int,[Int]) test' a s = case (a+s) > 5 of True -> (0,[a+s]) False -> (a+s,[]) testlog::IO [Int] testlog = runConduit $ (yieldMany [1,2,3,4,5,6,3]) $= (concatMapAccumC test' 0 ) $$ sinkList From dennis.raddle at gmail.com Mon Jul 17 05:48:18 2017 From: dennis.raddle at gmail.com (Dennis Raddle) Date: Sun, 16 Jul 2017 22:48:18 -0700 Subject: [Haskell-cafe] any cloud computing services for running Haskell? In-Reply-To: References: Message-ID: Thanks. I guess I don't know much about cloud services. Will they run a lot of threads in parallel? Or do they run my program on only one CPU and/or use only the number of cores in one processor? That's the point of using them, to run more threads in parallel than I have cores on my MacBook. D -------------- next part -------------- An HTML attachment was scrubbed... URL: From dct25-561bs at mythic-beasts.com Mon Jul 17 05:57:29 2017 From: dct25-561bs at mythic-beasts.com (David Turner) Date: Mon, 17 Jul 2017 06:57:29 +0100 Subject: [Haskell-cafe] any cloud computing services for running Haskell? In-Reply-To: References: Message-ID: On 17 Jul 2017 06:49, "Dennis Raddle" wrote: Thanks. I guess I don't know much about cloud services. Will they run a lot of threads in parallel? Or do they run my program on only one CPU and/or use only the number of cores in one processor? That's the point of using them, to run more threads in parallel than I have cores on my MacBook. Depending on your budget, on AWS you can rent a machine from the miniscule t2.nano all the way up to the 128-core x1.32xlarge, with various tradeoffs on memory vs CPU vs storage vs ... in between. All can run Haskell programs. There's also various options in Haskell for distributing your computation across multiple machines, if that sounds useful. A good place to start is the pricing page which gives you a good overview of the options. https://aws.amazon.com/ec2/pricing/on-demand/ Other cloud providers are available, of course. Cheers, 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 maydwell at gmail.com Mon Jul 17 06:07:37 2017 From: maydwell at gmail.com (Lyndon Maydwell) Date: Mon, 17 Jul 2017 16:07:37 +1000 Subject: [Haskell-cafe] any cloud computing services for running Haskell? In-Reply-To: References: Message-ID: I heard about https://www.clever-cloud.com/ providing Haskell app support. Didn't get to try it out though. Warm Regards, - Lyndon On Mon, Jul 17, 2017 at 3:57 PM, David Turner wrote: > On 17 Jul 2017 06:49, "Dennis Raddle" wrote: > > Thanks. I guess I don't know much about cloud services. Will they run a lot > of threads in parallel? Or do they run my program on only one CPU and/or use > only the number of cores in one processor? That's the point of using them, > to run more threads in parallel than I have cores on my MacBook. > > > Depending on your budget, on AWS you can rent a machine from the miniscule > t2.nano all the way up to the 128-core x1.32xlarge, with various tradeoffs > on memory vs CPU vs storage vs ... in between. All can run Haskell programs. > There's also various options in Haskell for distributing your computation > across multiple machines, if that sounds useful. > > A good place to start is the pricing page which gives you a good overview of > the options. > > https://aws.amazon.com/ec2/pricing/on-demand/ > > Other cloud providers are available, of course. > > Cheers, > > > > 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. > > > > _______________________________________________ > 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 imantc at gmail.com Mon Jul 17 06:37:35 2017 From: imantc at gmail.com (Imants Cekusins) Date: Mon, 17 Jul 2017 09:37:35 +0300 Subject: [Haskell-cafe] any cloud computing services for running Haskell? In-Reply-To: References: Message-ID: check these folks too: https://cloud.google.com/products/calculator/ ​ pretty good choice -------------- next part -------------- An HTML attachment was scrubbed... URL: From alan.zimm at gmail.com Mon Jul 17 12:59:05 2017 From: alan.zimm at gmail.com (Alan & Kim Zimmerman) Date: Mon, 17 Jul 2017 14:59:05 +0200 Subject: [Haskell-cafe] Haskell IDE Engine progress report for July 2017 Message-ID: This report is also available online at [1] Haskell IDE Engine progress report for July 2017. What is Haskell IDE Engine? Not an IDE. It is a common point for people in the Haskell community to pool their efforts with respect to tooling. For tool writers, provide tools as a HIE plugin, so it can be available on supported IDEs For IDE developers, integrate to HIE, and all the Haskell tools supported as plugins become available For users, it means the overall Haskell experience should improve. Currently, we are targeting the Language Server Protocol as the channel via which we talk to IDEs and editors. This would allow much broader IDE support. Important developments Zubin Duggal started work on a Summer of Haskell project to improve the LSP support in HIE and implement more of the protocol. Large portions of the HIE codebase have been refactored and rearchitectured with LSP support in mind. Plugins for brittany and hoogle have been implemented. A new plugin request and dispatcher system has been implemented, along with a new architecture for the loading and caching of TypecheckedModules from source, which are used to drive many queries and features like type information, document symbols, document highlights and go to definition. Technical details regarding these changes are described in Architecture . As of July 2017, HIE supports a large portion of the LSP. For the complete feature list, check the README . Current project focus HIE (with vscode support via a plugin) is ready for an alpha release. Currently, the focus is on bug fixing and hooking up already existing features in HIE to LSP, like Hoogle queries and HaRe refactorings, and also providing additional features via LSP Code Actions and Code Lenses If you have experience writing Typescript or developing Visual Studio Code extensions, your help is needed to improve the vscode hie extension. Contributors active in June and July Alan Zimmerman, Zubin Duggal, Lennart Spitzner Contributing Haskell IDE Engine needs volunteers like any other open source project. For more information see: https://github.com/haskell/haskell-ide-engine Also drop by our IRC channel: #haskell-ide-engine at irc.freenode.net. Thanks! Zubin and Alan [1] https://github.com/haskell/haskell-ide-engine/blob/master/docs/Report-2017-07.md -------------- next part -------------- An HTML attachment was scrubbed... URL: From olshanskydr at gmail.com Mon Jul 17 15:19:35 2017 From: olshanskydr at gmail.com (Dmitry Olshansky) Date: Mon, 17 Jul 2017 18:19:35 +0300 Subject: [Haskell-cafe] Memoization in Type Calculation Message-ID: Hello, cafe! I wonder is there some possibility to get Memoization in Type Calculation (e.g. in closed Type Families)? Can we make something more efficient for famous Fib function then type family Fib (n::Nat) :: Nat where Fib 1 = 1 Fib 2 = 1 Fib n = Fib (n-1) + Fib (n-2) This Fib has obviously exponential calculation time and we need some memoization. If it is impossible right now, maybe there is a ticket for this? It seems to me very important things, no? Probably in this case we can write TypeChecker Plugin, but it looks like the common problem. Best regards, Dmitry -------------- next part -------------- An HTML attachment was scrubbed... URL: From vieira.ufpi at gmail.com Mon Jul 17 15:35:55 2017 From: vieira.ufpi at gmail.com (Francisco Vieira de Souza) Date: Mon, 17 Jul 2017 12:35:55 -0300 Subject: [Haskell-cafe] Is there something new in GHCi? Message-ID: I´m using GHCi for Windows and I found sometrhing new. Mainly, there is no way for using GHC tooI for making a executable program. I had been doing all that is written in the page of Haskell and the same thing. I think that is something wrong in this new way of installation of GHC. Someone can help me in this case? Thanks in advance! Vieira -- "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 parsonsmatt at gmail.com Mon Jul 17 16:01:56 2017 From: parsonsmatt at gmail.com (Matt) Date: Mon, 17 Jul 2017 10:01:56 -0600 Subject: [Haskell-cafe] intero-neovim: Bring the joy of Intero to your Neovim! Message-ID: Hi everyone, I would like to invite you to try out my intero-neovim[1] plugin for giving Neovim IDE-like features. It's a port of the excellent intero plugin for emacs, and does many of the same things: type at point, go to definition, loading specific stack targets, etc. It has recently been significantly refactored and a ton of bugs have been fixed thanks to contributions by Reuben D'Netto and Jake Zimmerman. It's been working great for me on my work projects (stack-based with about a dozen packages) as well as one-off files and smaller projects. I would appreciate any and all feedback on features or bugs :D https://github.com/parsonsmatt/intero-neovim Thanks, Matt Parsons -------------- next part -------------- An HTML attachment was scrubbed... URL: From mandeep at nstack.com Mon Jul 17 17:51:55 2017 From: mandeep at nstack.com (Mandeep Gill) Date: Mon, 17 Jul 2017 17:51:55 +0000 Subject: [Haskell-cafe] [Hiring] NStack is hiring Haskellers in London (onsite / remote) Message-ID: NStack (www.nstack.com / www.github.com/nstack/nstack) lets data scientists and analysts to do sophisticated data work in the cloud without a team of engineers. To accomplish this, we’re a building a platform for composable, data-driven microservices, using a mixture of Haskell and Linux systems tech (including Kubernetes, systemd, and local IPC) with some typed DSLs, systems code, and distributed systems thrown in - think Bash-piping for distributed, containerised microservices. Our aim is to bring many of the ideas from functional programming, such as typed APIs and composition to the analytics space. We have an early demo of the product available, see www.github.com/nstack/nstack to get started and https://demo.nstack.com (very early demo, built using GHCJS - see [1]), and are currently in trials with several enterprises. We’re looking for talented programmers experienced using typed functional languages with preferably some Linux/Unix systems knowledge. It’s a challenging role, working on hard problems, and offers the chance to work with a top technical team and shape a company and product from an early stage. NStack is funded by top-tier investors from the West Coast, the founders are both technical and ex-YC / academia, and our team is lucky enough to include world-class talent for the problem we're solving. Salaries are competitive and include generous stock options. We're generally hiring onsite, however several of us work across Europe and we welcome remote applications within suitable timezones. Unfortunately we can not sponsor work visas. We're a team of 10, including 5 full-time Haskellers, and are looking at a range of positions and experience levels - whether you’ve just left uni or been hacking for 20 years, so if you’re interested please get in touch. Any questions please email direct or take a look at https://angellist.com/nstack/jobs Cheers, Mandeep [1] log in using `user-id` = `be56de22d8444786ae3231953b2cf4b1` and `secret-key` = `8d245132f0a9402d9284cf2e0a280391` -------------- next part -------------- An HTML attachment was scrubbed... URL: From rahulmutt at gmail.com Mon Jul 17 18:33:35 2017 From: rahulmutt at gmail.com (Rahul Muttineni) Date: Mon, 17 Jul 2017 14:33:35 -0400 Subject: [Haskell-cafe] Memoization in Type Calculation In-Reply-To: References: Message-ID: Hi Dmitry, You can effectively think of the type-level language of Haskell as a strict functional language with almost no syntactic sugar, and recursion is the *only* way of getting the behaviour of a loop. The best you can do to improve the performance of that type family is to write it in tail-recursive form using a helper function and which will make the type family reduction look more linear vs a tree like it is now and make it easier for the type checker to quickly spit out the result. type family Fib (n::Nat) :: Nat where Fib n = GoFib 0 1 n type family GoFib (a :: Nat) (b :: Nat) (n :: Nat) where GoFib a _ 0 = a GoFib a b n = GoFib b (a + b) (n - 1) Hope that helps, Rahul On Mon, Jul 17, 2017 at 11:19 AM, Dmitry Olshansky wrote: > Hello, cafe! > > I wonder is there some possibility to get Memoization in Type Calculation > (e.g. in closed Type Families)? > > Can we make something more efficient for famous Fib function then > > type family Fib (n::Nat) :: Nat where > Fib 1 = 1 > Fib 2 = 1 > Fib n = Fib (n-1) + Fib (n-2) > > This Fib has obviously exponential calculation time and we need some > memoization. > > If it is impossible right now, maybe there is a ticket for this? It seems > to me very important things, no? > > Probably in this case we can write TypeChecker Plugin, but it looks like > the common problem. > > Best regards, > Dmitry > > > > > _______________________________________________ > 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 olshanskydr at gmail.com Mon Jul 17 19:03:50 2017 From: olshanskydr at gmail.com (Dmitry Olshansky) Date: Mon, 17 Jul 2017 22:03:50 +0300 Subject: [Haskell-cafe] Fwd: Memoization in Type Calculation In-Reply-To: References: Message-ID: Rahul, thanks! It is really simple! 2017-07-17 21:33 GMT+03:00 Rahul Muttineni : > Hi Dmitry, > > You can effectively think of the type-level language of Haskell as a > strict functional language with almost no syntactic sugar, and recursion is > the *only* way of getting the behaviour of a loop. The best you can do to > improve the performance of that type family is to write it in > tail-recursive form using a helper function and which will make the type > family reduction look more linear vs a tree like it is now and make it > easier for the type checker to quickly spit out the result. > > type family Fib (n::Nat) :: Nat where > Fib n = GoFib 0 1 n > > type family GoFib (a :: Nat) (b :: Nat) (n :: Nat) where > GoFib a _ 0 = a > GoFib a b n = GoFib b (a + b) (n - 1) > > Hope that helps, > Rahul > > On Mon, Jul 17, 2017 at 11:19 AM, Dmitry Olshansky > wrote: > >> Hello, cafe! >> >> I wonder is there some possibility to get Memoization in Type Calculation >> (e.g. in closed Type Families)? >> >> Can we make something more efficient for famous Fib function then >> >> type family Fib (n::Nat) :: Nat where >> Fib 1 = 1 >> Fib 2 = 1 >> Fib n = Fib (n-1) + Fib (n-2) >> >> This Fib has obviously exponential calculation time and we need some >> memoization. >> >> If it is impossible right now, maybe there is a ticket for this? It seems >> to me very important things, no? >> >> Probably in this case we can write TypeChecker Plugin, but it looks like >> the common problem. >> >> Best regards, >> Dmitry >> >> >> >> >> _______________________________________________ >> 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 dennis.raddle at gmail.com Tue Jul 18 09:18:15 2017 From: dennis.raddle at gmail.com (Dennis Raddle) Date: Tue, 18 Jul 2017 02:18:15 -0700 Subject: [Haskell-cafe] DeepSeq and random generators Message-ID: I'm having trouble using Control.DeepSeq.force (necessary for parallel code) on a StdGen from System.Random. I don't know how to derive NFData. A standalone deriving statement, like this deriving instance NFData StdGen gets me the error "the data constructors of StdGen are not all in scope..." Is it actually possible to derive an NFData instance of StdGen, and how would I do that? Or if not possible, how can I work about this? Note: I'm going to see if I can use tf-random in this application. Maybe it will be easier. D -------------- next part -------------- An HTML attachment was scrubbed... URL: From anselm.scholl at tu-harburg.de Tue Jul 18 09:40:16 2017 From: anselm.scholl at tu-harburg.de (Jonas Scholl) Date: Tue, 18 Jul 2017 11:40:16 +0200 Subject: [Haskell-cafe] DeepSeq and random generators In-Reply-To: References: Message-ID: You cannot derive the instance because the type is opaque, i.e. the constructors are not exported. However, there are multiple ways to write the instance yourself: Looking at the code for StdGen, it seems like rnf stdgen = stdgen `seq` () would suffice as an implementation (StdGen only contains two strict ints, so forcing it to WHNF is equivalent to HNF). However, this would be incorrect if StdGen would ever change. Another idea would be to generate something you can force (e.g. an Int) from the gen and force that Int. This assumes that getting the next random number from a generator would force all (relevant) parts of the old generator state. So you would have something like this: rnf stdgen = case next stdgen of (i, _) -> rnf i Depending on your application, you may want to wrap the StdGen in a newtype to avoid an orphan instance. On 07/18/2017 11:18 AM, Dennis Raddle wrote: > I'm having trouble using Control.DeepSeq.force (necessary for parallel > code) on a StdGen from System.Random. I don't know how to derive NFData. > A standalone deriving statement, like this > > deriving instance NFData StdGen > > gets me the error "the data constructors of StdGen are not all in scope..." > > Is it actually possible to derive an NFData instance of StdGen, and how > would I do that? Or if not possible, how can I work about this? > > Note: I'm going to see if I can use tf-random in this application. Maybe > it will be easier. > > 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 -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 488 bytes Desc: OpenPGP digital signature URL: From alois.cochard at gmail.com Tue Jul 18 12:34:49 2017 From: alois.cochard at gmail.com (=?UTF-8?Q?Alo=C3=AFs_Cochard?=) Date: Tue, 18 Jul 2017 14:34:49 +0200 Subject: [Haskell-cafe] "cabal quine" In-Reply-To: <40de5c82-336a-9a4a-77a5-4aef3dac0181@vex.net> References: <40de5c82-336a-9a4a-77a5-4aef3dac0181@vex.net> Message-ID: Hi Albert, I definitely see uses for `cabal manpage`; it's great, but how useful would be `cabal quine` in practice? I fail to see what purpose it could serve. Cheers On 15 July 2017 at 19:37, Albert Y. C. Lai wrote: > Today a few of us on IRC (freenode #haskell) discovered: The following > cabal-install command > > cabal manpage > > outputs cabal-install's man page (and is mainly how cabal-install can come > with a man page without carrying an extra source file). > > This inspires the following feature request in jest: > > Could "cabal quine" output its source code please? :) > > kthxbye > _______________________________________________ > 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. -- *Λ\oïs* http://twitter.com/aloiscochard http://github.com/aloiscochard -------------- next part -------------- An HTML attachment was scrubbed... URL: From sivanov at colimite.fr Tue Jul 18 12:44:19 2017 From: sivanov at colimite.fr (Sergiu Ivanov) Date: Tue, 18 Jul 2017 14:44:19 +0200 Subject: [Haskell-cafe] Is there something new in GHCi? In-Reply-To: References: Message-ID: <87wp75rk2k.fsf@colimite.fr> Hello Vieira, Thus quoth Francisco Vieira de Souza at 15:35 on Mon, Jul 17 2017: > > I´m using GHCi for Windows and I found sometrhing new. Mainly, there is no > way for using GHC tooI for making a executable program. I had been doing > all that is written > in the page of Haskell and the same thing. I think that is something wrong > in this new way of installation of GHC. Could you please give us a more precise description of what you are doing and of the failure you are getting? I don't have any Windows machines at hand, so I will probably not be able to help you out. However, you should give us some more information so that those of us who do have Windows can diagnose and probably reproduce your issue. If I remember correctly, last time I did Haskell on Windows, GHC worked pretty well. Also note that GHC is a Haskell compiler and GHCi is an interactive Haskell shell. They are two very similar but not the same tools. -- 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 Tue Jul 18 13:00:22 2017 From: jo at durchholz.org (Joachim Durchholz) Date: Tue, 18 Jul 2017 15:00:22 +0200 Subject: [Haskell-cafe] "cabal quine" In-Reply-To: References: <40de5c82-336a-9a4a-77a5-4aef3dac0181@vex.net> Message-ID: Am 18.07.2017 um 14:34 schrieb Aloïs Cochard: > Hi Albert, > > I definitely see uses for `cabal manpage`; it's great, but how useful > would be `cabal quine` in practice? > > I fail to see what purpose it could serve. That's exactly why he wrote that his request is "in jest": It's useless, just the logical generalization of `cabal manpage`. > Cheers > > On 15 July 2017 at 19:37, Albert Y. C. Lai > wrote: > > Today a few of us on IRC (freenode #haskell) discovered: The > following cabal-install command > > cabal manpage > > outputs cabal-install's man page (and is mainly how cabal-install > can come with a man page without carrying an extra source file). > > This inspires the following feature request in jest: > > Could "cabal quine" output its source code please? :) > > kthxbye > _______________________________________________ > 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. > > > > > -- > *Λ\oïs* > http://twitter.com/aloiscochard > http://github.com/aloiscochard > > > _______________________________________________ > 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 daniel.trstenjak at gmail.com Tue Jul 18 13:26:56 2017 From: daniel.trstenjak at gmail.com (Daniel Trstenjak) Date: Tue, 18 Jul 2017 15:26:56 +0200 Subject: [Haskell-cafe] "cabal quine" In-Reply-To: References: <40de5c82-336a-9a4a-77a5-4aef3dac0181@vex.net> Message-ID: <20170718132656.GA23482@octa> > That's exactly why he wrote that his request is "in jest": It's useless, > just the logical generalization of `cabal manpage`. In Haskell everything is abstract, even the humor. ;) From fa-ml at ariis.it Tue Jul 18 18:29:27 2017 From: fa-ml at ariis.it (Francesco Ariis) Date: Tue, 18 Jul 2017 20:29:27 +0200 Subject: [Haskell-cafe] getChar (NoBuffering) not working on Windows Message-ID: <20170718182927.uhlfwlbv5axotm3g@x60s.casa> Hello list, I am writing a small console application. Today I was bitten by #2189 [1] ("hSetBuffering stdin NoBuffering doesn't work on Windows"). To reproduce: import System.IO main :: IO () main = hSetBuffering stdin NoBuffering >> getChar >>= putChar -- on linux you just need to press, say, 'c', on Win you -- need to press too. Is there any sensible (cross-platform) way of working around this? [1] https://ghc.haskell.org/trac/ghc/ticket/2189 From zk65900931 at gmail.com Tue Jul 18 18:46:31 2017 From: zk65900931 at gmail.com (Kai Zhang) Date: Tue, 18 Jul 2017 18:46:31 +0000 Subject: [Haskell-cafe] How to statically link some external libraries? Message-ID: I want to produce a statically-linked executable. First I tried "-optl-static -optc-static -optl-pthrea", which statically links all external libraries. But when I ran this executable it gives me "abort (core dumped)" error. I suspect the statically-linked glibc library might be the cause. So I decide to statically link all other libraries and leave the glibc as a dynamic library. How to do this using Cabal? Should I write a custom "Setup.hs"? -------------- next part -------------- An HTML attachment was scrubbed... URL: From dennis.raddle at gmail.com Tue Jul 18 20:36:38 2017 From: dennis.raddle at gmail.com (Dennis Raddle) Date: Tue, 18 Jul 2017 13:36:38 -0700 Subject: [Haskell-cafe] any cloud computing services for running Haskell? In-Reply-To: References: Message-ID: Neat, I like that they have a Haskell environment. But, if I go with Google or Amazon, just curious about how I would create an app with my Mac, as they don't provide a macOS environment. Can I cross-compile for Windows or Linux on my Mac? Or, should I run a Windows virtual machine and build my app in that environment? (Not my favorite choice, as I would end up working in Windows most of the time.) D On Sun, Jul 16, 2017 at 11:07 PM, Lyndon Maydwell wrote: > I heard about https://www.clever-cloud.com/ providing Haskell app support. > > Didn't get to try it out though. > > > Warm Regards, > > - Lyndon > > On Mon, Jul 17, 2017 at 3:57 PM, David Turner > wrote: > > On 17 Jul 2017 06:49, "Dennis Raddle" wrote: > > > > Thanks. I guess I don't know much about cloud services. Will they run a > lot > > of threads in parallel? Or do they run my program on only one CPU and/or > use > > only the number of cores in one processor? That's the point of using > them, > > to run more threads in parallel than I have cores on my MacBook. > > > > > > Depending on your budget, on AWS you can rent a machine from the > miniscule > > t2.nano all the way up to the 128-core x1.32xlarge, with various > tradeoffs > > on memory vs CPU vs storage vs ... in between. All can run Haskell > programs. > > There's also various options in Haskell for distributing your computation > > across multiple machines, if that sounds useful. > > > > A good place to start is the pricing page which gives you a good > overview of > > the options. > > > > https://aws.amazon.com/ec2/pricing/on-demand/ > > > > Other cloud providers are available, of course. > > > > Cheers, > > > > > > > > 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. > > > > > > > > _______________________________________________ > > 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 damian.only at gmail.com Tue Jul 18 20:41:13 2017 From: damian.only at gmail.com (Damian) Date: Tue, 18 Jul 2017 22:41:13 +0200 Subject: [Haskell-cafe] any cloud computing services for running Haskell? In-Reply-To: References: Message-ID: On Jul 18, 2017 22:38, "Dennis Raddle" wrote: Neat, I like that they have a Haskell environment. But, if I go with Google or Amazon, just curious about how I would create an app with my Mac, as they don't provide a macOS environment. Can I cross-compile for Windows or Linux on my Mac? Or, should I run a Windows virtual machine and build my app in that environment? (Not my favorite choice, as I would end up working in Windows most of the time.) I'd use docker and run a docker container. Stack has nice support for building them. D On Sun, Jul 16, 2017 at 11:07 PM, Lyndon Maydwell wrote: > I heard about https://www.clever-cloud.com/ providing Haskell app support. > > Didn't get to try it out though. > > > Warm Regards, > > - Lyndon > > On Mon, Jul 17, 2017 at 3:57 PM, David Turner > wrote: > > On 17 Jul 2017 06:49, "Dennis Raddle" wrote: > > > > Thanks. I guess I don't know much about cloud services. Will they run a > lot > > of threads in parallel? Or do they run my program on only one CPU and/or > use > > only the number of cores in one processor? That's the point of using > them, > > to run more threads in parallel than I have cores on my MacBook. > > > > > > Depending on your budget, on AWS you can rent a machine from the > miniscule > > t2.nano all the way up to the 128-core x1.32xlarge, with various > tradeoffs > > on memory vs CPU vs storage vs ... in between. All can run Haskell > programs. > > There's also various options in Haskell for distributing your computation > > across multiple machines, if that sounds useful. > > > > A good place to start is the pricing page which gives you a good > overview of > > the options. > > > > https://aws.amazon.com/ec2/pricing/on-demand/ > > > > Other cloud providers are available, of course. > > > > Cheers, > > > > > > > > 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. > > > > > > > > _______________________________________________ > > 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 cdsmith at gmail.com Tue Jul 18 20:45:25 2017 From: cdsmith at gmail.com (Chris Smith) Date: Tue, 18 Jul 2017 16:45:25 -0400 Subject: [Haskell-cafe] any cloud computing services for running Haskell? In-Reply-To: References: Message-ID: Why not do your production builds and testing on a virtual machine from your cloud provider, configured from the same OS, image, etc. as your production host? Anything else seems like asking for trouble. On Tue, Jul 18, 2017 at 4:36 PM, Dennis Raddle wrote: > Neat, I like that they have a Haskell environment. > > But, if I go with Google or Amazon, just curious about how I would create > an app with my Mac, as they don't provide a macOS environment. Can I > cross-compile for Windows or Linux on my Mac? Or, should I run a Windows > virtual machine and build my app in that environment? (Not my favorite > choice, as I would end up working in Windows most of the time.) > > > D > > > On Sun, Jul 16, 2017 at 11:07 PM, Lyndon Maydwell > wrote: > >> I heard about https://www.clever-cloud.com/ providing Haskell app >> support. >> >> Didn't get to try it out though. >> >> >> Warm Regards, >> >> - Lyndon >> >> On Mon, Jul 17, 2017 at 3:57 PM, David Turner >> wrote: >> > On 17 Jul 2017 06:49, "Dennis Raddle" wrote: >> > >> > Thanks. I guess I don't know much about cloud services. Will they run a >> lot >> > of threads in parallel? Or do they run my program on only one CPU >> and/or use >> > only the number of cores in one processor? That's the point of using >> them, >> > to run more threads in parallel than I have cores on my MacBook. >> > >> > >> > Depending on your budget, on AWS you can rent a machine from the >> miniscule >> > t2.nano all the way up to the 128-core x1.32xlarge, with various >> tradeoffs >> > on memory vs CPU vs storage vs ... in between. All can run Haskell >> programs. >> > There's also various options in Haskell for distributing your >> computation >> > across multiple machines, if that sounds useful. >> > >> > A good place to start is the pricing page which gives you a good >> overview of >> > the options. >> > >> > https://aws.amazon.com/ec2/pricing/on-demand/ >> > >> > Other cloud providers are available, of course. >> > >> > Cheers, >> > >> > >> > >> > 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. >> > >> > >> > >> > _______________________________________________ >> > 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 dennis.raddle at gmail.com Tue Jul 18 21:11:50 2017 From: dennis.raddle at gmail.com (Dennis Raddle) Date: Tue, 18 Jul 2017 14:11:50 -0700 Subject: [Haskell-cafe] any cloud computing services for running Haskell? In-Reply-To: References: Message-ID: Makes sense.​ Thanks D -------------- next part -------------- An HTML attachment was scrubbed... URL: From icfp.publicity at googlemail.com Tue Jul 18 21:34:02 2017 From: icfp.publicity at googlemail.com (Lindsey Kuper) Date: Tue, 18 Jul 2017 14:34:02 -0700 Subject: [Haskell-cafe] Call for Participation: ICFP 2017 Message-ID: <596e7eca4876a_602d3fdee4455be869313@landin.local.mail> [ Early registration ends 4 August. ] ===================================================================== Call for Participation ICFP 2017 22nd ACM SIGPLAN International Conference on Functional Programming and affiliated events September 3 - September 9, 2017 Oxford, UK http://icfp17.sigplan.org/ ===================================================================== ICFP provides a forum for researchers and developers to hear about the latest work on the design, implementations, principles, and uses of functional programming. The conference covers the entire spectrum of work, from practice to theory, including its peripheries. A full week dedicated to functional programming: ICFP, 2 co-hosted conferences, 1 co-hosted symposium, workshops, tutorials, programming contest results, student research competition, and mentoring workshop * Overview and affiliated events: http://icfp17.sigplan.org/home * Program: http://icfp17.sigplan.org/program/program-icfp-2017 * Accepted papers: http://icfp17.sigplan.org/track/icfp-2017-papers * Registration is available via: https://regmaster4.com/2017conf/ICFP17/register.php Early registration is due 4 August, 2016. * Programming contest, 4-7 August, 2016: http://2017.icfpcontest.org * Student Research Competition: http://icfp17.sigplan.org/track/icfp-2017-Student-Research-Competition * Follow @icfp_conference on twitter for the latest news: http://twitter.com/icfp_conference There are several events affiliated with ICFP: Sunday, September 3 Workshop on Higher-order Programming with Effects Workshop on Type-Driven Development Scheme and Functional Programming Workshop Programming Languages Mentoring Workshop ICFP Tutorials Monday, September 4 – Wednesday, September 6 ICFP FSCD - Days 1-3 Thursday, September 7 Haskell Symposium – Day 1 ML Family Workshop Workshop on Functional High-Performance Computing Commercial Users of Functional Programming – Day 1 FSCD - Day 4 Friday, September 8 Haskell Symposium – Day 2 OCaml Workshop Erlang Workshop Commercial Users of Functional Programming – Day 2 Saturday, September 9 Commercial Users of Functional Programming – Day 3 Haskell Implementors Workshop Functional Art, Music, Modeling and Design Conference Organizers: General Chair: Jeremy Gibbons (University of Oxford, UK) Program Chair: Mark Jones (Portland State University, USA) Artifact Evaluation Co-Chair: Matthew Flatt (University of Utah, USA) Artifact Evaluation Co-Chair: Ryan R. Newton (Indiana University, USA) Industrial Relations Chair: Ryan Trinkle (Obsidian Systems LLC, USA) PLMW Co-Chair: Neelakantan R. Krishnawami (University of Cambridge, UK) PLMW Co-Chair: Dan Licata (Wesleyan University, USA) PLMW Co-Chair: Brigitte Pientka (McGill University, Canada) Programming Contest Organiser: Sam Lindley (University of Edinburgh, UK) Publicity and Web Chair: Lindsey Kuper (Intel Labs, USA) Student Research Competition Chair: Ilya Sergey (University College London, UK) Student Volunteer Co-Captain: Yosuke Fukuda (Kyoto University, Japan) Student Volunteer Co-Captain: Yuki Nishida (Kyoto University, Japan) Student Volunteer Co-Captain: Jakub Zalewski (University of Edinburgh, UK) Video Chair: Jose Calderon (Galois, Inc., USA) Workshops Co-Chair: Andres Löh (Well-Typed LLP, UK) Workshops Co-Chair: David Christiansen (Indiana University, USA) Sponsors and industrial partners: Platinum partners Ahrefs Jane Street Capital Gold partners Bloomberg X Silver partners Galois Oracle Bronze partners Obsidian Systems Portland State University Well-Typed From mark.fine at gmail.com Wed Jul 19 03:25:40 2017 From: mark.fine at gmail.com (Mark Fine) Date: Tue, 18 Jul 2017 20:25:40 -0700 Subject: [Haskell-cafe] any cloud computing services for running Haskell? In-Reply-To: References: Message-ID: The performance might not be what you're looking for (there are some more performant configurations but they might not be cost effective), but it's pretty easy to get a stack project running on Heroku - this script took ~3 minutes (dominated by installing GHC on the first push) to get a simple worker running in the cloud: https://gist.github.com/mfine/b3dd21cfd03d1775084780f955cdc784#gistcomment-2151378 Sample run: ~ $ stack new worker https://gist.githubusercontent.com/mfine/b3dd21cfd03d1775084780f955cdc784/raw/4779a2ea55ac29b469a98eedfba35f74ba7785dc/worker.hsfiles Downloading template "https://gist.githubusercontent.com/mfine/b3dd21cfd03d1775084780f955cdc784/raw/522fc42d9c7a46e26673a73fae629c92c28da648/worker.hsfiles" to create project "worker" in worker/ ... Looking for .cabal or package.yaml files to use to init the project. Using cabal packages: - worker/worker.cabal Selecting the best among 10 snapshots... * Matches lts-8.23 Selected resolver: lts-8.23 Initialising configuration using resolver: lts-8.23 Total number of user packages considered: 1 Writing configuration to file: worker/stack.yaml All done.~ $~ $ cd worker~/worker $~/worker $ git init . Initialized empty Git repository in ~/worker/.git/~/worker $~/worker $ git add .~/worker $~/worker $ git commit -m "initial" [master (root-commit) a19a152] initial 4 files changed, 84 insertions(+) create mode 100644 Procfile create mode 100644 main.hs create mode 100644 stack.yaml create mode 100644 worker.cabal~/worker $~/worker $ heroku create --buildpack https://github.com/mfine/heroku-buildpack-stack.git Creating app... done, ⬢ serene-earth-29336 Setting buildpack to https://github.com/mfine/heroku-buildpack-stack.git... donehttps://serene-earth-29336.herokuapp.com/ | https://git.heroku.com/serene-earth-29336.git~/worker $~/worker $ git push heroku master Counting objects: 6, done. Delta compression using up to 4 threads. Compressing objects: 100% (5/5), done. Writing objects: 100% (6/6), 1.61 KiB | 0 bytes/s, done. Total 6 (delta 0), reused 0 (delta 0) remote: Compressing source files... done. remote: Building source: remote: remote: -----> Haskell app detected remote: -----> 2017-07-19_02:58:20 Starting... remote: -----> 2017-07-19_02:58:20 Exporting config vars remote: -----> 2017-07-19_02:58:20 Installing libgmp-6.0.0a into cache remote: ######################################################################## 100.0% remote: -----> 2017-07-19_02:58:20 Restoring 6.0.0a files from cache remote: -----> 2017-07-19_02:58:20 Downloading stack-1.4.0 remote: ######################################################################## 100.0% remote: -----> 2017-07-19_02:58:21 Restoring stack-1.4.0 remote: -----> 2017-07-19_02:58:21 Substituting stack vars remote: -----> 2017-07-19_02:58:21 Running stack remote: Downloading lts-8.23 build plan ... remote: Downloaded lts-8.23 build plan. remote: Updating package index Hackage (mirrored at https://s3.amazonaws.com/hackage.fpcomplete.com/) ... remote: Selected mirror https://s3.amazonaws.com/hackage.fpcomplete.com/ remote: Downloading root remote: Selected mirror https://s3.amazonaws.com/hackage.fpcomplete.com/ remote: Downloading timestamp remote: Downloading snapshot remote: Downloading mirrors remote: Cannot update index (no local copy) remote: Downloading index remote: Updated package list downloaded remote: Populating index cache ... remote: Populated index cache. remote: Preparing to install GHC to an isolated location. remote: This will not interfere with any system-level installation. remote: Preparing to download ghc-8.0.2 ... remote: ghc-8.0.2: download has begun remote: ghc-8.0.2: 27.84 MiB / 107.55 MiB ( 25.89%) downloaded... remote: ghc-8.0.2: 54.10 MiB / 107.55 MiB ( 50.31%) downloaded... remote: ghc-8.0.2: 77.99 MiB / 107.55 MiB ( 72.52%) downloaded... remote: ghc-8.0.2: 101.87 MiB / 107.55 MiB ( 94.72%) downloaded... remote: ghc-8.0.2: 107.55 MiB / 107.55 MiB (100.00%) downloaded... remote: Downloaded ghc-8.0.2. remote: Unpacking GHC into /app/tmp/cache/.stack/programs/x86_64-linux/ghc-8.0.2.temp/ ... remote: Configuring GHC ... remote: Installing GHC ... remote: Installed GHC. remote: stack will use a sandboxed GHC it installed remote: For more information on paths, see 'stack path' and 'stack exec env' remote: To use this GHC and packages outside of a project, consider using: remote: stack ghc, stack ghci, stack runghc, or stack exec remote: [1 of 2] Compiling Main ( /app/tmp/cache/.stack/setup-exe-src/setup-mPHDZzAJ.hs, /app/tmp/cache/.stack/setup-exe-src/setup-mPHDZzAJ.o ) remote: [2 of 2] Compiling StackSetupShim ( /app/tmp/cache/.stack/setup-exe-src/setup-shim-mPHDZzAJ.hs, /app/tmp/cache/.stack/setup-exe-src/setup-shim-mPHDZzAJ.o ) remote: Linking /app/tmp/cache/.stack/setup-exe-cache/x86_64-linux/tmp-Cabal-simple_mPHDZzAJ_1.24.2.0_ghc-8.0.2 ... remote: worker-0.1.0.0: configure (exe) remote: Configuring worker-0.1.0.0... remote: worker-0.1.0.0: build (exe) remote: Preprocessing executable 'worker' for worker-0.1.0.0... remote: [1 of 1] Compiling Main ( main.hs, .stack-work/dist/x86_64-linux/Cabal-1.24.2.0/build/worker/worker-tmp/Main.o ) remote: Linking .stack-work/dist/x86_64-linux/Cabal-1.24.2.0/build/worker/worker ... remote: worker-0.1.0.0: copy/register remote: Installing executable(s) in remote: /app/.stack-work/install/x86_64-linux/lts-8.23/8.0.2/bin remote: Copying from /app/.stack-work/install/x86_64-linux/lts-8.23/8.0.2/bin/worker to /app/.local/bin/worker remote: remote: Copied executables to /app/.local/bin: remote: - worker remote: -----> 2017-07-19_03:01:26 Making stack binaries available remote: -----> 2017-07-19_03:01:26 Caching .stack-work remote: -----> 2017-07-19_03:01:26 Finished! remote: -----> Discovering process types remote: Procfile declares types -> worker remote: remote: -----> Compressing... remote: Done: 1.5M remote: -----> Launching... remote: Released v3 remote: https://serene-earth-29336.herokuapp.com/ deployed to Heroku remote: remote: Verifying deploy... done. To https://git.heroku.com/serene-earth-29336.git * [new branch] master -> master~/worker $~/worker $ heroku ps:scale worker+1 Scaling dynos... done, now running worker at 1:Free~/worker $~/worker $ heroku logs -t 2017-07-19T03:07:19.755903+00:00 heroku[worker.1]: Starting process with command `worker` 2017-07-19T03:07:20.553903+00:00 heroku[worker.1]: State changed from starting to up 2017-07-19T03:07:22.393957+00:00 app[worker.1]: Hello! 2017-07-19T03:07:23.397139+00:00 app[worker.1]: Hello! 2017-07-19T03:07:24.398803+00:00 app[worker.1]: Hello! 2017-07-19T03:07:25.400211+00:00 app[worker.1]: Hello! 2017-07-19T03:07:26.405199+00:00 app[worker.1]: Hello! Mark On Sun, Jul 16, 2017 at 1:20 PM, Dennis Raddle wrote: > I'm thinking of using cloud computing services for running my > CPU-intensive parallel Haskell code, in order to get results faster. > Instead of buying a faster computer, I would take advantage of existing > services. > > Note that my budget is small, so I need something that doesn't have a > large minimum charge. I'm thinking $10 - 30 per month. > > Are there any cloud services like that that run Haskell? > 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 sylvain at haskus.fr Wed Jul 19 08:16:18 2017 From: sylvain at haskus.fr (Sylvain Henry) Date: Wed, 19 Jul 2017 10:16:18 +0200 Subject: [Haskell-cafe] How to statically link some external libraries? In-Reply-To: References: Message-ID: <5df27ff7-de20-35a1-70c6-5d047fee54e9@haskus.fr> Hi, This is what I have in my .cabal file to get a statically-linked executable: ghc-options: -Wall -static -threaded cc-options: -static ld-options: -static -pthread Sylvain On 18/07/2017 20:46, Kai Zhang wrote: > I want to produce a statically-linked executable. First I tried > "-optl-static -optc-static -optl-pthrea", which statically links all > external libraries. But when I ran this executable it gives me "abort > (core dumped)" error. I suspect the statically-linked glibc library > might be the cause. So I decide to statically link all other libraries > and leave the glibc as a dynamic library. How to do this using Cabal? > Should I write a custom "Setup.hs"? > > > _______________________________________________ > 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 alois.cochard at gmail.com Wed Jul 19 09:18:45 2017 From: alois.cochard at gmail.com (=?UTF-8?Q?Alo=C3=AFs_Cochard?=) Date: Wed, 19 Jul 2017 11:18:45 +0200 Subject: [Haskell-cafe] "cabal quine" In-Reply-To: <20170718132656.GA23482@octa> References: <40de5c82-336a-9a4a-77a5-4aef3dac0181@vex.net> <20170718132656.GA23482@octa> Message-ID: Thanks all for teaching me English expressions :-) Everything is abstract around here indeed, had no idea what "in jest" means! On 18 July 2017 at 15:26, Daniel Trstenjak wrote: > > > That's exactly why he wrote that his request is "in jest": It's useless, > > just the logical generalization of `cabal manpage`. > > In Haskell everything is abstract, even the humor. ;) > _______________________________________________ > 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. > -- *Λ\oïs* http://twitter.com/aloiscochard http://github.com/aloiscochard -------------- next part -------------- An HTML attachment was scrubbed... URL: From michael at snoyman.com Wed Jul 19 11:50:10 2017 From: michael at snoyman.com (Michael Snoyman) Date: Wed, 19 Jul 2017 14:50:10 +0300 Subject: [Haskell-cafe] How to deal with last item with concatMapAccumC in Conduit. In-Reply-To: <0BCF7A76-5564-4CA9-8512-44A87F03B46A@gmail.com> References: <0BCF7A76-5564-4CA9-8512-44A87F03B46A@gmail.com> Message-ID: I'm afraid I doon't follow what it meant by the stream here. Could you provide a complete, runnable example and indicate what the expected and actual output are? On Mon, Jul 17, 2017 at 5:48 AM, jun zhang wrote: > Dear cafes > > I use Conduit to parse a huge file. And I need merge lines by condition. > > I find the concatMapAccumC can do that and I write a demo as blow(with > conduit-combinators-1.0.6,lts-6.18). > The problem is if the last item didn’t make condition true, the data only > keep in the accum but missing in stream. > > Any one can give me some advises? > > Thanks > > > ---------------------------- > import Conduit > > test'::Int->Int->(Int,[Int]) > test' a s = case (a+s) > 5 of > True -> (0,[a+s]) > False -> (a+s,[]) > > testlog::IO [Int] > testlog = runConduit $ (yieldMany [1,2,3,4,5,6,3]) $= (concatMapAccumC > test' 0 ) $$ sinkList > > > > > > > _______________________________________________ > 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 bneijt at gmail.com Wed Jul 19 16:03:36 2017 From: bneijt at gmail.com (Bram Neijt) Date: Wed, 19 Jul 2017 18:03:36 +0200 Subject: [Haskell-cafe] any cloud computing services for running Haskell? In-Reply-To: References: Message-ID: Some links I like to to add to the thread: AWS lambda https://github.com/abailly/aws-lambda-haskell Google Cloud functions might be an option using GHCJS Heroku has been around for a long time: https://www.christopherbiscardi.com/2014/2/2/deploy-haskells-snap-on-heroku/ Greetings, Bram On Wed, Jul 19, 2017 at 5:25 AM, Mark Fine wrote: > The performance might not be what you're looking for (there are some more > performant configurations but they might not be cost effective), but it's > pretty easy to get a stack project running on Heroku - this script took ~3 > minutes (dominated by installing GHC on the first push) to get a simple > worker running in the cloud: > > https://gist.github.com/mfine/b3dd21cfd03d1775084780f955cdc784#gistcomment-2151378 > > Sample run: > > ~ $ stack new worker > https://gist.githubusercontent.com/mfine/b3dd21cfd03d1775084780f955cdc784/raw/4779a2ea55ac29b469a98eedfba35f74ba7785dc/worker.hsfiles > Downloading template > "https://gist.githubusercontent.com/mfine/b3dd21cfd03d1775084780f955cdc784/raw/522fc42d9c7a46e26673a73fae629c92c28da648/worker.hsfiles" > to create project "worker" in worker/ ... > Looking for .cabal or package.yaml files to use to init the project. > Using cabal packages: > - worker/worker.cabal > > Selecting the best among 10 snapshots... > > * Matches lts-8.23 > > Selected resolver: lts-8.23 > Initialising configuration using resolver: lts-8.23 > Total number of user packages considered: 1 > Writing configuration to file: worker/stack.yaml > All done. > ~ $ > ~ $ cd worker > ~/worker $ > ~/worker $ git init . > Initialized empty Git repository in ~/worker/.git/ > ~/worker $ > ~/worker $ git add . > ~/worker $ > ~/worker $ git commit -m "initial" > [master (root-commit) a19a152] initial > 4 files changed, 84 insertions(+) > create mode 100644 Procfile > create mode 100644 main.hs > create mode 100644 stack.yaml > create mode 100644 worker.cabal > ~/worker $ > ~/worker $ heroku create --buildpack > https://github.com/mfine/heroku-buildpack-stack.git > Creating app... done, ⬢ serene-earth-29336 > Setting buildpack to https://github.com/mfine/heroku-buildpack-stack.git... > done > https://serene-earth-29336.herokuapp.com/ | > https://git.heroku.com/serene-earth-29336.git > ~/worker $ > ~/worker $ git push heroku master > Counting objects: 6, done. > Delta compression using up to 4 threads. > Compressing objects: 100% (5/5), done. > Writing objects: 100% (6/6), 1.61 KiB | 0 bytes/s, done. > Total 6 (delta 0), reused 0 (delta 0) > remote: Compressing source files... done. > remote: Building source: > remote: > remote: -----> Haskell app detected > remote: -----> 2017-07-19_02:58:20 Starting... > remote: -----> 2017-07-19_02:58:20 Exporting config vars > remote: -----> 2017-07-19_02:58:20 Installing libgmp-6.0.0a into cache > remote: > ######################################################################## > 100.0% > remote: -----> 2017-07-19_02:58:20 Restoring 6.0.0a files from cache > remote: -----> 2017-07-19_02:58:20 Downloading stack-1.4.0 > remote: > ######################################################################## > 100.0% > remote: -----> 2017-07-19_02:58:21 Restoring stack-1.4.0 > remote: -----> 2017-07-19_02:58:21 Substituting stack vars > remote: -----> 2017-07-19_02:58:21 Running stack > remote: Downloading lts-8.23 build plan ... > remote: Downloaded lts-8.23 build plan. > remote: Updating package index Hackage (mirrored at > https://s3.amazonaws.com/hackage.fpcomplete.com/) ... > remote: Selected mirror https://s3.amazonaws.com/hackage.fpcomplete.com/ > remote: Downloading root > remote: Selected mirror https://s3.amazonaws.com/hackage.fpcomplete.com/ > remote: Downloading timestamp > remote: Downloading snapshot > remote: Downloading mirrors > remote: Cannot update index (no local copy) > remote: Downloading index > remote: Updated package list downloaded > remote: Populating index cache ... > remote: Populated index cache. > remote: Preparing to install GHC to an isolated location. > remote: This will not interfere with any system-level installation. > remote: Preparing to download ghc-8.0.2 ... > remote: ghc-8.0.2: download has begun > remote: ghc-8.0.2: 27.84 MiB / 107.55 MiB ( 25.89%) downloaded... > remote: ghc-8.0.2: 54.10 MiB / 107.55 MiB ( 50.31%) downloaded... > remote: ghc-8.0.2: 77.99 MiB / 107.55 MiB ( 72.52%) downloaded... > remote: ghc-8.0.2: 101.87 MiB / 107.55 MiB ( 94.72%) downloaded... > remote: ghc-8.0.2: 107.55 MiB / 107.55 MiB (100.00%) downloaded... > remote: Downloaded ghc-8.0.2. > remote: Unpacking GHC into > /app/tmp/cache/.stack/programs/x86_64-linux/ghc-8.0.2.temp/ ... > remote: Configuring GHC ... > remote: Installing GHC ... > remote: Installed GHC. > remote: stack will use a sandboxed GHC it installed > remote: For more information on paths, see 'stack path' and 'stack exec env' > remote: To use this GHC and packages outside of a project, consider using: > remote: stack ghc, stack ghci, stack runghc, or stack exec > remote: [1 of 2] Compiling Main ( > /app/tmp/cache/.stack/setup-exe-src/setup-mPHDZzAJ.hs, > /app/tmp/cache/.stack/setup-exe-src/setup-mPHDZzAJ.o ) > remote: [2 of 2] Compiling StackSetupShim ( > /app/tmp/cache/.stack/setup-exe-src/setup-shim-mPHDZzAJ.hs, > /app/tmp/cache/.stack/setup-exe-src/setup-shim-mPHDZzAJ.o ) > remote: Linking > /app/tmp/cache/.stack/setup-exe-cache/x86_64-linux/tmp-Cabal-simple_mPHDZzAJ_1.24.2.0_ghc-8.0.2 > ... > remote: worker-0.1.0.0: configure (exe) > remote: Configuring worker-0.1.0.0... > remote: worker-0.1.0.0: build (exe) > remote: Preprocessing executable 'worker' for worker-0.1.0.0... > remote: [1 of 1] Compiling Main ( main.hs, > .stack-work/dist/x86_64-linux/Cabal-1.24.2.0/build/worker/worker-tmp/Main.o > ) > remote: Linking > .stack-work/dist/x86_64-linux/Cabal-1.24.2.0/build/worker/worker ... > remote: worker-0.1.0.0: copy/register > remote: Installing executable(s) in > remote: /app/.stack-work/install/x86_64-linux/lts-8.23/8.0.2/bin > remote: Copying from > /app/.stack-work/install/x86_64-linux/lts-8.23/8.0.2/bin/worker to > /app/.local/bin/worker > remote: > remote: Copied executables to /app/.local/bin: > remote: - worker > remote: -----> 2017-07-19_03:01:26 Making stack binaries available > remote: -----> 2017-07-19_03:01:26 Caching .stack-work > remote: -----> 2017-07-19_03:01:26 Finished! > remote: -----> Discovering process types > remote: Procfile declares types -> worker > remote: > remote: -----> Compressing... > remote: Done: 1.5M > remote: -----> Launching... > remote: Released v3 > remote: https://serene-earth-29336.herokuapp.com/ deployed to Heroku > remote: > remote: Verifying deploy... done. > To https://git.heroku.com/serene-earth-29336.git > * [new branch] master -> master > ~/worker $ > ~/worker $ heroku ps:scale worker+1 > Scaling dynos... done, now running worker at 1:Free > ~/worker $ > ~/worker $ heroku logs -t > 2017-07-19T03:07:19.755903+00:00 heroku[worker.1]: Starting process with > command `worker` > 2017-07-19T03:07:20.553903+00:00 heroku[worker.1]: State changed from > starting to up > 2017-07-19T03:07:22.393957+00:00 app[worker.1]: Hello! > 2017-07-19T03:07:23.397139+00:00 app[worker.1]: Hello! > 2017-07-19T03:07:24.398803+00:00 app[worker.1]: Hello! > 2017-07-19T03:07:25.400211+00:00 app[worker.1]: Hello! > 2017-07-19T03:07:26.405199+00:00 app[worker.1]: Hello! > > > Mark > > On Sun, Jul 16, 2017 at 1:20 PM, Dennis Raddle > wrote: >> >> I'm thinking of using cloud computing services for running my >> CPU-intensive parallel Haskell code, in order to get results faster. Instead >> of buying a faster computer, I would take advantage of existing services. >> >> Note that my budget is small, so I need something that doesn't have a >> large minimum charge. I'm thinking $10 - 30 per month. >> >> Are there any cloud services like that that run Haskell? >> 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. > > > > _______________________________________________ > 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 wolfgang-it at jeltsch.info Wed Jul 19 20:22:21 2017 From: wolfgang-it at jeltsch.info (Wolfgang Jeltsch) Date: Wed, 19 Jul 2017 23:22:21 +0300 Subject: [Haskell-cafe] DeepSeq and random generators In-Reply-To: References: Message-ID: <1500495741.2422.154.camel@jeltsch.info> Am Dienstag, den 18.07.2017, 11:40 +0200 schrieb Jonas Scholl: > StdGen only contains two strict ints, so forcing it to WHNF is > equivalent to HNF. The rnf function reduces to normal form (NF), not head normal form (HNF). All the best, Wolfgang From kai at kzhang.org Thu Jul 20 06:11:16 2017 From: kai at kzhang.org (Kai Zhang) Date: Thu, 20 Jul 2017 06:11:16 +0000 Subject: [Haskell-cafe] How to statically link some external libraries? In-Reply-To: <5df27ff7-de20-35a1-70c6-5d047fee54e9@haskus.fr> References: <5df27ff7-de20-35a1-70c6-5d047fee54e9@haskus.fr> Message-ID: Thanks, but that would link all libraries statically. On Wed, Jul 19, 2017 at 1:17 AM Sylvain Henry wrote: > Hi, > > This is what I have in my .cabal file to get a statically-linked > executable: > > ghc-options: -Wall -static -threaded > cc-options: -static > ld-options: -static -pthread > > Sylvain > > On 18/07/2017 20:46, Kai Zhang wrote: > > I want to produce a statically-linked executable. First I tried > "-optl-static -optc-static -optl-pthrea", which statically links all > external libraries. But when I ran this executable it gives me "abort (core > dumped)" error. I suspect the statically-linked glibc library might be the > cause. So I decide to statically link all other libraries and leave the > glibc as a dynamic library. How to do this using Cabal? Should I write a > custom "Setup.hs"? > > > _______________________________________________ > 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 haskell-cafe at brisammon.fastmail.fm Thu Jul 20 06:25:09 2017 From: haskell-cafe at brisammon.fastmail.fm (Brian Sammon) Date: Thu, 20 Jul 2017 02:25:09 -0400 Subject: [Haskell-cafe] runghc and linking in libraries Message-ID: <20170720022509.c5cdbf29fbd947cb1c8d196f@brisammon.fastmail.fm> If I want to have (and run without explicitly invoking ghc or runghc) a script that starts as follows: #!/usr/bin/runghc module Main where import MyLib I can do it just fine if MyLib is a pure-haskell MyLib.hs -- it doesn't have to be packaged or installed or anything complicated. If I want to create a MyLib that uses C code (that I wrote) through FFI, it doesn't seem to be possible to use it in a runghc script like this, unless I create a package and install it. Am I correct about this? In the course of researching this, I realized that I have a rather poor understanding of what "packages" are in ghc-land. I have a high-level-overview understanding ("It's like rubygems, but for haskell"), but I'm rather unclear about the nuts-and-bolts of it. The tight coupling between packages and the ghc core is rather different than what I've seen in other programming languages I've used (I haven't programmed in Java though) It would be useful if ghc had an argument to take a "MyLib.lib" file (or maybe a directory) and temporarily act like it's an installed package for the one invocation. Unsurprisingly, web-searching for "haskell" and "package" doesn't give me the focused result set that I want. I found the relevant section of the GHC Users Guide https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/packages.html but links to other reading materials would be appreciated. From zhangjun.julian at gmail.com Thu Jul 20 06:34:58 2017 From: zhangjun.julian at gmail.com (jun zhang) Date: Thu, 20 Jul 2017 14:34:58 +0800 Subject: [Haskell-cafe] How to deal with last item with concatMapAccumC in Conduit. In-Reply-To: References: <0BCF7A76-5564-4CA9-8512-44A87F03B46A@gmail.com> Message-ID: <311ECB7C-361E-4ABE-9C2C-C3A9ADB4E7EC@gmail.com> Dear all the runnable example code is as blow =================================================================== import Conduit import Text.Regex (matchRegex,mkRegex,Regex) loghead = mkRegex "^([0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2},[0-9]{3} )" -- "2015-01-25 00:04:18,840" logMerge::Regex->String->String->(String,[String]) logMerge logregex str accum = case matchRegex logregex str of Just _ -> (str,[(accum++"\n")]) Nothing -> case null accum of True -> (str,[]) False -> (accum ++ "
" ++ str,[]) runMerge::String->String->IO () runMerge infile outfile = runResourceT $ sourceFile infile $= linesUnboundedC $= concatMapAccumC (logMerge loghead ) "" $$ sinkFile outfile ================================================================ the example input file is --------- 2015-01-25 00:03:44,331 | DEBUG | WebContainer : 20 | | errorCode: toString() = null 2015-01-25 00:03:44,331 | DEBUG | WebContainer : 20 | codsexception.getErrorCode(): toString() { errorCode = "UNEXPECTED_PROBLEM" severity = "" } 2015-01-25 00:03:44,331 | DEBUG | WebContainer : 20 | | 2015-01-25 00:03:45,331 | DEBUG | WebContainer : 20 | | --------- the expected output is --------- 2015-01-25 00:03:44,331 | DEBUG | WebContainer : 20 | | errorCode: toString() = null 2015-01-25 00:03:44,331 | DEBUG | WebContainer : 20 | codsexception.getErrorCode(): toString()
{
errorCode =
"UNEXPECTED_PROBLEM"
severity = ""
} 2015-01-25 00:03:44,331 | DEBUG | WebContainer : 20 | | 2015-01-25 00:03:45,331 | DEBUG | WebContainer : 20 | | --------- the actual output is blow, missing the last line of log --------- 2015-01-25 00:03:44,331 | DEBUG | WebContainer : 20 | | errorCode: toString() = null 2015-01-25 00:03:44,331 | DEBUG | WebContainer : 20 | codsexception.getErrorCode(): toString()
{
errorCode =
"UNEXPECTED_PROBLEM"
severity = ""
} 2015-01-25 00:03:44,331 | DEBUG | WebContainer : 20 | | --------- Thanks > 在 2017年7月19日,下午7:50,Michael Snoyman > 写道: > > I'm afraid I doon't follow what it meant by the stream here. Could you provide a complete, runnable example and indicate what the expected and actual output are? > > On Mon, Jul 17, 2017 at 5:48 AM, jun zhang > wrote: > Dear cafes > > I use Conduit to parse a huge file. And I need merge lines by condition. > > I find the concatMapAccumC can do that and I write a demo as blow(with conduit-combinators-1.0.6,lts-6.18). > The problem is if the last item didn’t make condition true, the data only keep in the accum but missing in stream. > > Any one can give me some advises? > > Thanks > > > ---------------------------- > import Conduit > > test'::Int->Int->(Int,[Int]) > test' a s = case (a+s) > 5 of > True -> (0,[a+s]) > False -> (a+s,[]) > > testlog::IO [Int] > testlog = runConduit $ (yieldMany [1,2,3,4,5,6,3]) $= (concatMapAccumC test' 0 ) $$ sinkList > > > > > > > _______________________________________________ > 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 erkokl at gmail.com Thu Jul 20 08:10:17 2017 From: erkokl at gmail.com (Levent Erkok) Date: Thu, 20 Jul 2017 01:10:17 -0700 Subject: [Haskell-cafe] [ANN] New release of SBV (v7.0), now with incremental solving Message-ID: I'm pleased to announce v7.0 release of SBV, a library for integrating SMT solvers into Haskell. This release adds incremental solving capabilities to SBV: Users can now interact with the underlying solver using a typed API capturing the SMTLib language, issuing commands, getting model values, and asserting further constraints on-the-fly. The possibility of issuing multiple check-sat commands allows incremental assertion of facts, a key feature of modern constraint solving systems. Hackage: https://hackage.haskell.org/package/sbv Homepage: http://leventerkok.github.io/sbv/ Release notes: https://github.com/LeventErkok/sbv/blob/master/CHANGES.md SMTLib initiative: http://smtlib.cs.uiowa.edu/ Feedback and bug reports are most welcome! -Levent. -------------- next part -------------- An HTML attachment was scrubbed... URL: From allbery.b at gmail.com Thu Jul 20 15:00:35 2017 From: allbery.b at gmail.com (Brandon Allbery) Date: Thu, 20 Jul 2017 11:00:35 -0400 Subject: [Haskell-cafe] runghc and linking in libraries In-Reply-To: <20170720022509.c5cdbf29fbd947cb1c8d196f@brisammon.fastmail.fm> References: <20170720022509.c5cdbf29fbd947cb1c8d196f@brisammon.fastmail.fm> Message-ID: On Thu, Jul 20, 2017 at 2:25 AM, Brian Sammon < haskell-cafe at brisammon.fastmail.fm> wrote: > If I want to create a MyLib that uses C code (that I wrote) through FFI, > it doesn't seem to be possible to use it in a runghc script like this, > unless I create a package and install it. Am I correct about this? You would have to explicitly link it in: runghc Foo.hs bar.o (or -lbar if it's a library). It's not really designed for anything larger than a single source file without non-package dependencies. In the course of researching this, I realized that I have a rather poor > understanding of what "packages" are in ghc-land. I have a > high-level-overview understanding ("It's like rubygems, but for haskell"), > but I'm rather unclear about the nuts-and-bolts of it. > The tight coupling between packages and the ghc core is rather different > than what I've seen in other programming languages I've used (I haven't > programmed in Java though) > Have you programmed in C, especially with heavy use of inline or CPP? The cause of the tight dependencies is that ghc inlines a lot of things, even across modules; which means that even parts of a module that aren't explicitly exported are generally visible for inlining. And performance will suck if you defeat this. -- 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 jake.waksbaum at gmail.com Thu Jul 20 17:26:17 2017 From: jake.waksbaum at gmail.com (Jake) Date: Thu, 20 Jul 2017 17:26:17 +0000 Subject: [Haskell-cafe] Feeding a monad into itself Message-ID: I have a function f :: a -> Maybe a that I want to feed into itself with some initial input until it returns Nothing. untilNothing :: (a -> Maybe a) -> a -> a untilNothing f x = case f x of Just x' -> untilNothing f x' Nothing -> x Is there a better way to do this? I feel like there is something more general going on with Monads being fed into themselves, but maybe I'm wrong. Thoughts? -------------- next part -------------- An HTML attachment was scrubbed... URL: From rein.henrichs at gmail.com Thu Jul 20 18:03:48 2017 From: rein.henrichs at gmail.com (Rein Henrichs) Date: Thu, 20 Jul 2017 18:03:48 +0000 Subject: [Haskell-cafe] Feeding a monad into itself In-Reply-To: References: Message-ID: This is about as good as you can do. The monad-loops package provides a variety of similar combinators, generally implemented in similar ways, but not this specific combinator. The downside of this combinator is that it is partial: it will run forever without producing anything if f never gives a Nothing. On Thu, Jul 20, 2017 at 10:27 AM Jake wrote: > I have a function f :: a -> Maybe a that I want to feed into itself with > some initial input until it returns Nothing. > > untilNothing :: (a -> Maybe a) -> a -> a > untilNothing f x = case f x of > Just x' -> untilNothing f x' > Nothing -> x > > Is there a better way to do this? I feel like there is something more > general going on with Monads being fed into themselves, but maybe I'm > wrong. Thoughts? > _______________________________________________ > 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 fa-ml at ariis.it Thu Jul 20 21:02:36 2017 From: fa-ml at ariis.it (Francesco Ariis) Date: Thu, 20 Jul 2017 23:02:36 +0200 Subject: [Haskell-cafe] getChar (NoBuffering) not working on Windows In-Reply-To: <20170718182927.uhlfwlbv5axotm3g@x60s.casa> References: <20170718182927.uhlfwlbv5axotm3g@x60s.casa> Message-ID: <20170720210236.przmfasblhdsqz5h@x60s.casa> On Tue, Jul 18, 2017 at 08:29:27PM +0200, Francesco Ariis wrote: > Hello list, > > I am writing a small console application. > > Today I was bitten by #2189 [1] ("hSetBuffering stdin NoBuffering doesn't > work on Windows"). To reproduce: > > [...] > > Is there any sensible (cross-platform) way of working around this? I'll answer myself: http://hackage.haskell.org/package/hidden-char (works with concurrency too). From jclites at mac.com Fri Jul 21 02:16:15 2017 From: jclites at mac.com (Jeff Clites) Date: Thu, 20 Jul 2017 19:16:15 -0700 Subject: [Haskell-cafe] Feeding a monad into itself In-Reply-To: References: Message-ID: <0B73DA75-83D3-4378-BD83-D16040AC8825@mac.com> Also this pattern does seem Maybe-specific, in that for the general Monad case there's not an obvious termination condition. JEff > On Jul 20, 2017, at 11:03 AM, Rein Henrichs wrote: > > This is about as good as you can do. The monad-loops package provides a variety of similar combinators, generally implemented in similar ways, but not this specific combinator. The downside of this combinator is that it is partial: it will run forever without producing anything if f never gives a Nothing. > >> On Thu, Jul 20, 2017 at 10:27 AM Jake wrote: >> I have a function f :: a -> Maybe a that I want to feed into itself with some initial input until it returns Nothing. >> >> untilNothing :: (a -> Maybe a) -> a -> a >> untilNothing f x = case f x of >> Just x' -> untilNothing f x' >> Nothing -> x >> >> Is there a better way to do this? I feel like there is something more general going on with Monads being fed into themselves, but maybe I'm wrong. Thoughts? >> _______________________________________________ >> 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 jgrosso1 at asu.edu Fri Jul 21 02:52:11 2017 From: jgrosso1 at asu.edu (Joshua Grosso) Date: Thu, 20 Jul 2017 19:52:11 -0700 Subject: [Haskell-cafe] Feeding a monad into itself In-Reply-To: <0B73DA75-83D3-4378-BD83-D16040AC8825@mac.com> References: <0B73DA75-83D3-4378-BD83-D16040AC8825@mac.com> Message-ID: Could MonadPlus (with mzero) or Alternative (with empty) provide the termination condition, if this pattern turned out to be more generally useful? Joshua Grosso On Thu, Jul 20, 2017 at 7:16 PM, Jeff Clites wrote: > Also this pattern does seem Maybe-specific, in that for the general Monad > case there's not an obvious termination condition. > > JEff > > On Jul 20, 2017, at 11:03 AM, Rein Henrichs > wrote: > > This is about as good as you can do. The monad-loops package provides a > variety of similar combinators, generally implemented in similar ways, but > not this specific combinator. The downside of this combinator is that it is > partial: it will run forever without producing anything if f never gives a > Nothing. > > On Thu, Jul 20, 2017 at 10:27 AM Jake wrote: > >> I have a function f :: a -> Maybe a that I want to feed into itself with >> some initial input until it returns Nothing. >> >> untilNothing :: (a -> Maybe a) -> a -> a >> untilNothing f x = case f x of >> Just x' -> untilNothing f x' >> Nothing -> x >> >> Is there a better way to do this? I feel like there is something more >> general going on with Monads being fed into themselves, but maybe I'm >> wrong. Thoughts? >> _______________________________________________ >> 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 jake.waksbaum at gmail.com Fri Jul 21 03:17:36 2017 From: jake.waksbaum at gmail.com (Jake) Date: Fri, 21 Jul 2017 03:17:36 +0000 Subject: [Haskell-cafe] Feeding a monad into itself In-Reply-To: References: <0B73DA75-83D3-4378-BD83-D16040AC8825@mac.com> Message-ID: That's what I was thinking, but I couldn't figure out if I wanted MonadPlus, Alternative or maybe Monoid because they all have zero elements. On Thu, Jul 20, 2017, 21:52 Joshua Grosso wrote: > Could MonadPlus (with mzero) or Alternative (with empty) provide the > termination condition, if this pattern turned out to be more generally > useful? > > Joshua Grosso > > On Thu, Jul 20, 2017 at 7:16 PM, Jeff Clites wrote: > >> Also this pattern does seem Maybe-specific, in that for the general Monad >> case there's not an obvious termination condition. >> >> JEff >> >> On Jul 20, 2017, at 11:03 AM, Rein Henrichs >> wrote: >> >> This is about as good as you can do. The monad-loops package provides a >> variety of similar combinators, generally implemented in similar ways, but >> not this specific combinator. The downside of this combinator is that it is >> partial: it will run forever without producing anything if f never gives a >> Nothing. >> >> On Thu, Jul 20, 2017 at 10:27 AM Jake wrote: >> >>> I have a function f :: a -> Maybe a that I want to feed into itself with >>> some initial input until it returns Nothing. >>> >>> untilNothing :: (a -> Maybe a) -> a -> a >>> untilNothing f x = case f x of >>> Just x' -> untilNothing f x' >>> Nothing -> x >>> >>> Is there a better way to do this? I feel like there is something more >>> general going on with Monads being fed into themselves, but maybe I'm >>> wrong. Thoughts? >>> _______________________________________________ >>> 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 dave at zednenem.com Fri Jul 21 04:51:45 2017 From: dave at zednenem.com (David Menendez) Date: Fri, 21 Jul 2017 00:51:45 -0400 Subject: [Haskell-cafe] Feeding a monad into itself In-Reply-To: References: <0B73DA75-83D3-4378-BD83-D16040AC8825@mac.com> Message-ID: Another possibility is to use Either for an early exit. iterateM :: Monad m => (a -> m a) -> a -> m b iterateM f a = f a >>= iterateM f exitOnNothing :: (a -> Maybe a) -> a -> Either a a exitOnNothing f a = maybe (Left a) Right (f a) Now, your untilNothing is iterateM . exitOnNothing, but you can easily extend it to use IO or whatever pattern you like. On Thu, Jul 20, 2017 at 11:17 PM, Jake wrote: > That's what I was thinking, but I couldn't figure out if I wanted MonadPlus, > Alternative or maybe Monoid because they all have zero elements. > > > On Thu, Jul 20, 2017, 21:52 Joshua Grosso wrote: >> >> Could MonadPlus (with mzero) or Alternative (with empty) provide the >> termination condition, if this pattern turned out to be more generally >> useful? >> >> Joshua Grosso >> >> On Thu, Jul 20, 2017 at 7:16 PM, Jeff Clites wrote: >>> >>> Also this pattern does seem Maybe-specific, in that for the general Monad >>> case there's not an obvious termination condition. >>> >>> JEff >>> >>> On Jul 20, 2017, at 11:03 AM, Rein Henrichs >>> wrote: >>> >>> This is about as good as you can do. The monad-loops package provides a >>> variety of similar combinators, generally implemented in similar ways, but >>> not this specific combinator. The downside of this combinator is that it is >>> partial: it will run forever without producing anything if f never gives a >>> Nothing. >>> >>> On Thu, Jul 20, 2017 at 10:27 AM Jake wrote: >>>> >>>> I have a function f :: a -> Maybe a that I want to feed into itself with >>>> some initial input until it returns Nothing. >>>> >>>> untilNothing :: (a -> Maybe a) -> a -> a >>>> untilNothing f x = case f x of >>>> Just x' -> untilNothing f x' >>>> Nothing -> x >>>> >>>> Is there a better way to do this? I feel like there is something more >>>> general going on with Monads being fed into themselves, but maybe I'm wrong. >>>> Thoughts? >>>> _______________________________________________ >>>> 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. -- Dave Menendez From silvio.frischi at gmail.com Fri Jul 21 06:32:00 2017 From: silvio.frischi at gmail.com (Silvio Frischknecht) Date: Fri, 21 Jul 2017 08:32:00 +0200 Subject: [Haskell-cafe] Feeding a monad into itself In-Reply-To: References: Message-ID: <25a1e3aa-9d2f-ddd3-6e5b-b4f5360d54da@gmail.com> Well you can usually replace a recursion with a fix and a case Maybe with a maybe. Then you would get something like this. untilNothing f = fix (\f' a -> maybe a f' (f a)) But it's really unreadable. Or at least I can't read it. Though it's fun to think up. Also no connection to monads. Cheers Silvio From michael at snoyman.com Fri Jul 21 07:17:02 2017 From: michael at snoyman.com (Michael Snoyman) Date: Fri, 21 Jul 2017 10:17:02 +0300 Subject: [Haskell-cafe] How to deal with last item with concatMapAccumC in Conduit. In-Reply-To: <311ECB7C-361E-4ABE-9C2C-C3A9ADB4E7EC@gmail.com> References: <0BCF7A76-5564-4CA9-8512-44A87F03B46A@gmail.com> <311ECB7C-361E-4ABE-9C2C-C3A9ADB4E7EC@gmail.com> Message-ID: I'll preface by saying this probably indicates that the API for concatMapAccumC should be slightly different than it is currently. The problem is that there is no way to convert the final accumulator value into output, and therefore when the input stream ends, that accumulator is simply dropped. One solution (pretty hacky) is to wrap all of the lines in a `Just` and then send in a final `Nothing` value to indicate that the stream is ended. This would look like: https://gist.github.com/snoyberg/6537120fca2e9b8944e41fe60d285793 Another option is to simply use the conduit primitives (await and yield) directly: https://gist.github.com/snoyberg/bd58030db9b9c90f9e1fcf8b31ea10e9 I'd lean towards the latter. On Thu, Jul 20, 2017 at 9:34 AM, jun zhang wrote: > Dear all > > the runnable example code is as blow > > =================================================================== > import Conduit > import Text.Regex (matchRegex,mkRegex,Regex) > > > > loghead = mkRegex "^([0-9]{4}-[0-9]{2}-[0-9]{2} > [0-9]{2}:[0-9]{2}:[0-9]{2},[0-9]{3} )" > -- "2015-01-25 00:04:18,840" > > logMerge::Regex->String->String->(String,[String]) > logMerge logregex str accum = > case matchRegex logregex str of > Just _ -> (str,[(accum++"\n")]) > Nothing -> case null accum of > True -> (str,[]) > False -> (accum ++ "
" ++ str,[]) > > > runMerge::String->String->IO () > runMerge infile outfile = > runResourceT $ sourceFile infile $= linesUnboundedC $= > concatMapAccumC (logMerge loghead ) "" $$ sinkFile outfile > > ================================================================ > > the example input file is > --------- > 2015-01-25 00:03:44,331 | DEBUG | WebContainer : 20 | | errorCode: > toString() = null > 2015-01-25 00:03:44,331 | DEBUG | WebContainer : 20 | > codsexception.getErrorCode(): toString() > { > errorCode = "UNEXPECTED_PROBLEM" > severity = "" > } > 2015-01-25 00:03:44,331 | DEBUG | WebContainer : 20 | | > 2015-01-25 00:03:45,331 | DEBUG | WebContainer : 20 | | > --------- > > the expected output is > --------- > 2015-01-25 00:03:44,331 | DEBUG | WebContainer : 20 | | errorCode: > toString() = null > 2015-01-25 00:03:44,331 | DEBUG | WebContainer : 20 | > codsexception.getErrorCode(): toString()
{
errorCode > =
"UNEXPECTED_PROBLEM"
severity = ""
} > 2015-01-25 00:03:44,331 | DEBUG | WebContainer : 20 | | > 2015-01-25 00:03:45,331 | DEBUG | WebContainer : 20 | | > --------- > > the actual output is blow, missing the last line of log > --------- > 2015-01-25 00:03:44,331 | DEBUG | WebContainer : 20 | | errorCode: > toString() = null > 2015-01-25 00:03:44,331 | DEBUG | WebContainer : 20 | > codsexception.getErrorCode(): toString()
{
errorCode > =
"UNEXPECTED_PROBLEM"
severity = ""
} > 2015-01-25 00:03:44,331 | DEBUG | WebContainer : 20 | | > --------- > > Thanks > > > > 在 2017年7月19日,下午7:50,Michael Snoyman 写道: > > I'm afraid I doon't follow what it meant by the stream here. Could you > provide a complete, runnable example and indicate what the expected and > actual output are? > > On Mon, Jul 17, 2017 at 5:48 AM, jun zhang > wrote: > >> Dear cafes >> >> I use Conduit to parse a huge file. And I need merge lines by condition. >> >> I find the concatMapAccumC can do that and I write a demo as blow(with >> conduit-combinators-1.0.6,lts-6.18). >> The problem is if the last item didn’t make condition true, the data only >> keep in the accum but missing in stream. >> >> Any one can give me some advises? >> >> Thanks >> >> >> ---------------------------- >> import Conduit >> >> test'::Int->Int->(Int,[Int]) >> test' a s = case (a+s) > 5 of >> True -> (0,[a+s]) >> False -> (a+s,[]) >> >> testlog::IO [Int] >> testlog = runConduit $ (yieldMany [1,2,3,4,5,6,3]) $= (concatMapAccumC >> test' 0 ) $$ sinkList >> >> >> >> >> >> >> _______________________________________________ >> 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 zhangjun.julian at gmail.com Fri Jul 21 07:24:20 2017 From: zhangjun.julian at gmail.com (jun zhang) Date: Fri, 21 Jul 2017 15:24:20 +0800 Subject: [Haskell-cafe] How to deal with last item with concatMapAccumC in Conduit. In-Reply-To: References: <0BCF7A76-5564-4CA9-8512-44A87F03B46A@gmail.com> <311ECB7C-361E-4ABE-9C2C-C3A9ADB4E7EC@gmail.com> Message-ID: <6BDB94C9-E6E9-4FE5-BD26-DC2FADDAD8E1@gmail.com> Thanks very much > 在 2017年7月21日,下午3:17,Michael Snoyman 写道: > > I'll preface by saying this probably indicates that the API for concatMapAccumC should be slightly different than it is currently. > > The problem is that there is no way to convert the final accumulator value into output, and therefore when the input stream ends, that accumulator is simply dropped. One solution (pretty hacky) is to wrap all of the lines in a `Just` and then send in a final `Nothing` value to indicate that the stream is ended. This would look like: > > https://gist.github.com/snoyberg/6537120fca2e9b8944e41fe60d285793 > > Another option is to simply use the conduit primitives (await and yield) directly: > > https://gist.github.com/snoyberg/bd58030db9b9c90f9e1fcf8b31ea10e9 > > I'd lean towards the latter. > > On Thu, Jul 20, 2017 at 9:34 AM, jun zhang > wrote: > Dear all > > the runnable example code is as blow > > =================================================================== > import Conduit > import Text.Regex (matchRegex,mkRegex,Regex) > > > > loghead = mkRegex "^([0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2},[0-9]{3} )" > -- "2015-01-25 00:04:18,840" > > logMerge::Regex->String->String->(String,[String]) > logMerge logregex str accum = > case matchRegex logregex str of > Just _ -> (str,[(accum++"\n")]) > Nothing -> case null accum of > True -> (str,[]) > False -> (accum ++ "
" ++ str,[]) > > > runMerge::String->String->IO () > runMerge infile outfile = > runResourceT $ sourceFile infile $= linesUnboundedC $= concatMapAccumC (logMerge loghead ) "" $$ sinkFile outfile > > ================================================================ > > the example input file is > --------- > 2015-01-25 00:03:44,331 | DEBUG | WebContainer : 20 | | errorCode: toString() = null > 2015-01-25 00:03:44,331 | DEBUG | WebContainer : 20 | codsexception.getErrorCode(): toString() > { > errorCode = "UNEXPECTED_PROBLEM" > severity = "" > } > 2015-01-25 00:03:44,331 | DEBUG | WebContainer : 20 | | > 2015-01-25 00:03:45,331 | DEBUG | WebContainer : 20 | | > --------- > > the expected output is > --------- > 2015-01-25 00:03:44,331 | DEBUG | WebContainer : 20 | | errorCode: toString() = null > 2015-01-25 00:03:44,331 | DEBUG | WebContainer : 20 | codsexception.getErrorCode(): toString()
{
errorCode =
"UNEXPECTED_PROBLEM"
severity = ""
} > 2015-01-25 00:03:44,331 | DEBUG | WebContainer : 20 | | > 2015-01-25 00:03:45,331 | DEBUG | WebContainer : 20 | | > --------- > > the actual output is blow, missing the last line of log > --------- > 2015-01-25 00:03:44,331 | DEBUG | WebContainer : 20 | | errorCode: toString() = null > 2015-01-25 00:03:44,331 | DEBUG | WebContainer : 20 | codsexception.getErrorCode(): toString()
{
errorCode =
"UNEXPECTED_PROBLEM"
severity = ""
} > 2015-01-25 00:03:44,331 | DEBUG | WebContainer : 20 | | > --------- > > Thanks > > > >> 在 2017年7月19日,下午7:50,Michael Snoyman > 写道: >> >> I'm afraid I doon't follow what it meant by the stream here. Could you provide a complete, runnable example and indicate what the expected and actual output are? >> >> On Mon, Jul 17, 2017 at 5:48 AM, jun zhang > wrote: >> Dear cafes >> >> I use Conduit to parse a huge file. And I need merge lines by condition. >> >> I find the concatMapAccumC can do that and I write a demo as blow(with conduit-combinators-1.0.6,lts-6.18). >> The problem is if the last item didn’t make condition true, the data only keep in the accum but missing in stream. >> >> Any one can give me some advises? >> >> Thanks >> >> >> ---------------------------- >> import Conduit >> >> test'::Int->Int->(Int,[Int]) >> test' a s = case (a+s) > 5 of >> True -> (0,[a+s]) >> False -> (a+s,[]) >> >> testlog::IO [Int] >> testlog = runConduit $ (yieldMany [1,2,3,4,5,6,3]) $= (concatMapAccumC test' 0 ) $$ sinkList >> >> >> >> >> >> >> _______________________________________________ >> 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 jeffbrown.the at gmail.com Fri Jul 21 07:28:35 2017 From: jeffbrown.the at gmail.com (Jeffrey Brown) Date: Fri, 21 Jul 2017 00:28:35 -0700 Subject: [Haskell-cafe] How is this variable not in scope? Message-ID: The following compiles and runs perfectly: main = do (inputFile:_) <- getArgs input <- readFile inputFile let pairs = pairFilesToContents $ readSmsnLines input mapM_ f pairs where f :: (FilePath, String) -> IO () f (name, content) = writeFile name content But the following triggers the error "Not in scope: ‘root’". main' = do (root : inputFile :_) <- getArgs input <- readFile inputFile let pairs = pairFilesToContents $ readSmsnLines input mapM_ f pairs where f :: (FilePath, String) -> IO () f (name, content) = writeFile (root+name) content -- Jeff Brown | Jeffrey Benjamin Brown Website | Facebook | LinkedIn (spammy, so I often miss messages here) | Github -------------- next part -------------- An HTML attachment was scrubbed... URL: From trupill at gmail.com Fri Jul 21 07:52:16 2017 From: trupill at gmail.com (Alejandro Serrano Mena) Date: Fri, 21 Jul 2017 09:52:16 +0200 Subject: [Haskell-cafe] How is this variable not in scope? In-Reply-To: References: Message-ID: The problem is that in the "where" clause the only things which are in scope are (roughly) the arguments of the function. In particular, neither "root" nor "inputFile" nor "input" nor "pairs". The solution is to add an extra argument: main' = do ... mapM_ (f root) pairs where f root (name, content) = writeFile (root ++ name) content 2017-07-21 9:28 GMT+02:00 Jeffrey Brown : > The following compiles and runs perfectly: > > main = do > (inputFile:_) <- getArgs > input <- readFile inputFile > let pairs = pairFilesToContents $ readSmsnLines input > mapM_ f pairs where > f :: (FilePath, String) -> IO () > f (name, content) = writeFile name content > > But the following triggers the error "Not in scope: ‘root’". > > main' = do > (root : inputFile :_) <- getArgs > input <- readFile inputFile > let pairs = pairFilesToContents $ readSmsnLines input > mapM_ f pairs where > f :: (FilePath, String) -> IO () > f (name, content) = writeFile (root+name) content > > -- > Jeff Brown | Jeffrey Benjamin Brown > Website | Facebook > | LinkedIn > (spammy, so I often > miss messages here) | Github > > > _______________________________________________ > 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 jeffbrown.the at gmail.com Fri Jul 21 08:03:44 2017 From: jeffbrown.the at gmail.com (Jeffrey Brown) Date: Fri, 21 Jul 2017 01:03:44 -0700 Subject: [Haskell-cafe] How is this variable not in scope? In-Reply-To: References: Message-ID: Excellent! Thanks, Alejandro! On Fri, Jul 21, 2017 at 12:52 AM, Alejandro Serrano Mena wrote: > The problem is that in the "where" clause the only things which are in > scope are (roughly) the arguments of the function. In particular, neither > "root" nor "inputFile" nor "input" nor "pairs". The solution is to add an > extra argument: > > main' = do > ... > mapM_ (f root) pairs where > f root (name, content) = writeFile (root ++ name) content > > 2017-07-21 9:28 GMT+02:00 Jeffrey Brown : > >> The following compiles and runs perfectly: >> >> main = do >> (inputFile:_) <- getArgs >> input <- readFile inputFile >> let pairs = pairFilesToContents $ readSmsnLines input >> mapM_ f pairs where >> f :: (FilePath, String) -> IO () >> f (name, content) = writeFile name content >> >> But the following triggers the error "Not in scope: ‘root’". >> >> main' = do >> (root : inputFile :_) <- getArgs >> input <- readFile inputFile >> let pairs = pairFilesToContents $ readSmsnLines input >> mapM_ f pairs where >> f :: (FilePath, String) -> IO () >> f (name, content) = writeFile (root+name) content >> >> -- >> Jeff Brown | Jeffrey Benjamin Brown >> Website | Facebook >> | LinkedIn >> (spammy, so I often >> miss messages here) | Github >> >> >> _______________________________________________ >> 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. >> > > -- Jeff Brown | Jeffrey Benjamin Brown Website | Facebook | LinkedIn (spammy, so I often miss messages here) | Github -------------- next part -------------- An HTML attachment was scrubbed... URL: From adam at bergmark.nl Fri Jul 21 15:09:10 2017 From: adam at bergmark.nl (Adam Bergmark) Date: Fri, 21 Jul 2017 15:09:10 +0000 Subject: [Haskell-cafe] How is this variable not in scope? In-Reply-To: References: Message-ID: Another solution is to define `f` below `root` within the do block: ``` main' = do (root : inputFile :_) <- getArgs input <- readFile inputFile let pairs = pairFilesToContents $ readSmsnLines input let f :: (FilePath, String) -> IO () f (name, content) = writeFile (root+name) content mapM_ f pairs ``` On Fri, 21 Jul 2017 at 10:07 Jeffrey Brown wrote: > Excellent! Thanks, Alejandro! > > On Fri, Jul 21, 2017 at 12:52 AM, Alejandro Serrano Mena < > trupill at gmail.com> wrote: > >> The problem is that in the "where" clause the only things which are in >> scope are (roughly) the arguments of the function. In particular, neither >> "root" nor "inputFile" nor "input" nor "pairs". The solution is to add an >> extra argument: >> >> main' = do >> ... >> mapM_ (f root) pairs where >> f root (name, content) = writeFile (root ++ name) content >> >> 2017-07-21 9:28 GMT+02:00 Jeffrey Brown : >> >>> The following compiles and runs perfectly: >>> >>> main = do >>> (inputFile:_) <- getArgs >>> input <- readFile inputFile >>> let pairs = pairFilesToContents $ readSmsnLines input >>> mapM_ f pairs where >>> f :: (FilePath, String) -> IO () >>> f (name, content) = writeFile name content >>> >>> But the following triggers the error "Not in scope: ‘root’". >>> >>> main' = do >>> (root : inputFile :_) <- getArgs >>> input <- readFile inputFile >>> let pairs = pairFilesToContents $ readSmsnLines input >>> mapM_ f pairs where >>> f :: (FilePath, String) -> IO () >>> f (name, content) = writeFile (root+name) content >>> >>> -- >>> Jeff Brown | Jeffrey Benjamin Brown >>> Website | Facebook >>> | LinkedIn >>> (spammy, so I often >>> miss messages here) | Github >>> >>> >>> _______________________________________________ >>> 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. >>> >> >> > > > -- > Jeff Brown | Jeffrey Benjamin Brown > Website | Facebook > | LinkedIn > (spammy, so I often > miss messages here) | Github > > _______________________________________________ > 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 ky3 at atamo.com Fri Jul 21 15:57:08 2017 From: ky3 at atamo.com (Kim-Ee Yeoh) Date: Fri, 21 Jul 2017 22:57:08 +0700 Subject: [Haskell-cafe] Feeding a monad into itself In-Reply-To: References: Message-ID: Another perfectly cromulent definition is: untilNothing f = fromJust . last . takeWhile isJust . iterate (f =<<) . Just This has 2 advantages: 1. It illustrates the haskellism that "A list is a loop is a list." 2. It composes much-beloved list combinators into a reasonable pipeline. -- Kim-Ee On Fri, Jul 21, 2017 at 12:26 AM, Jake wrote: > I have a function f :: a -> Maybe a that I want to feed into itself with > some initial input until it returns Nothing. > > untilNothing :: (a -> Maybe a) -> a -> a > untilNothing f x = case f x of > Just x' -> untilNothing f x' > Nothing -> x > > Is there a better way to do this? I feel like there is something more > general going on with Monads being fed into themselves, but maybe I'm > wrong. Thoughts? > > _______________________________________________ > 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 monkleyon at gmail.com Fri Jul 21 18:06:03 2017 From: monkleyon at gmail.com (MarLinn) Date: Fri, 21 Jul 2017 20:06:03 +0200 Subject: [Haskell-cafe] Feeding a monad into itself In-Reply-To: References: Message-ID: An HTML attachment was scrubbed... URL: From jake.waksbaum at gmail.com Fri Jul 21 20:17:05 2017 From: jake.waksbaum at gmail.com (Jake) Date: Fri, 21 Jul 2017 20:17:05 +0000 Subject: [Haskell-cafe] Feeding a monad into itself In-Reply-To: References: Message-ID: Very interesting! What do you mean by a "better" unfold? On Fri, Jul 21, 2017, 13:06 MarLinn wrote: > On 2017-07-21 17:57, Kim-Ee Yeoh wrote: > > Another perfectly cromulent definition is: > > untilNothing f = fromJust . last . takeWhile isJust . iterate (f =<<) . > Just > > This has 2 advantages: > > 1. It illustrates the haskellism that "A list is a loop is a list." > 2. It composes much-beloved list combinators into a reasonable pipeline. > > Note that > > fromJust . last . takeWhile isJust . iterate (f =<<) . Just > ≡ > last . catMaybes . takeWhile isJust . iterate (f =<<) . Just > > Note further that that with duplicate x = (x,x), > > \initialElement -> catMaybes . takeWhile isJust . iterate (f =<<) . Just $ initialElement > ≡ > \initialElement -> initialElement: unfoldr (fmap duplicate . f) initialElement > > In other words, the pipeline is basically equivalent to a simple unfoldr > modulo the first step. Therefore, > > untilNothing f initialElement = last $ initialElement : unfoldr (fmap duplicate . f) initialElement > > Which reveals the relation to anamorphisms and makes it possible to drop > two of the three pain-inducing functions (isJust and fromJust). > > This further hints at the fact that loops are a combination of > anamorphisms/unfolds (here: unfoldr) and catamorphisms/folds (here: last). > As last can easily be replaced with better options like foldMap Last, the > search for a "better" implementation should basically consist of a search > for a more suitable unfold. A simple hoogle seems to reveal several options. > > > Cheers, > MarLinn > > PS: The relation to lists still remains in my version, but it may be > easier to see that the "haskellism" is just an unfortunate result of both > their prominence in the standard libraries and the specialised syntax we > have for them. That's why it's a "haskellism", and not a universal relation. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lamefun.x0r at gmail.com Fri Jul 21 20:54:22 2017 From: lamefun.x0r at gmail.com (Nikita Churaev) Date: Fri, 21 Jul 2017 23:54:22 +0300 Subject: [Haskell-cafe] Haskell modules: Morton's fork? Message-ID: <1500670462.2183.1.camel@gmail.com> Option 1: module App.Component (Foo, Bar, Qux) -- re-exports module App.Component.Foo (Foo, make, func1, func2) module App.Component.Bar (Bar, make, func1, func2) module App.Component.Qux (Qux, make, func1, func2) API clients will have to write long import lists: import App.Component import qualified App.Component.Foo as Foo import qualified App.Component.Bar as Bar import qualified App.Component.Qux as Qux Option 2: module App.Component (module Foo, module Bar) -- re-exports module App.Component.Foo (Foo, makeFoo, fooFunc1, fooFunc2) module App.Component.Bar (Bar, makeBar, barFunc1, barFunc2) module App.Component.Qux (Qux, makeQux, quxFunc1, quxFunc2) Now you can import easily: import App.Component But now you have to prefix your functions, just like in C... Is there another, cleaner option? From monkleyon at gmail.com Fri Jul 21 21:16:02 2017 From: monkleyon at gmail.com (MarLinn) Date: Fri, 21 Jul 2017 23:16:02 +0200 Subject: [Haskell-cafe] Feeding a monad into itself In-Reply-To: References: Message-ID: <5cc4a374-5c47-3131-879d-5e615ca29523@gmail.com> > Very interesting! What do you mean by a "better" unfold? > Well you asked the original question, so I'll leave that up to you to define. ;) Your original version is relatively specialised, but simple and efficient. The one I adapted uses quite a bit of intermediate wrapping and unwrapping and needs to move parts around on every iteration. Only because of list fusion does it have a chance to compete. It's also quite indirect and uses up cognitive energy when trying to understand it. So yours is "better" in several ways. Maybe there's a general unfold that is easier to understand. Or more efficient. Or easier to adapt to more situations. It depends highly on what your actual goals are… From jclites at mac.com Fri Jul 21 21:33:53 2017 From: jclites at mac.com (Jeff Clites) Date: Fri, 21 Jul 2017 14:33:53 -0700 Subject: [Haskell-cafe] Feeding a monad into itself In-Reply-To: References: <0B73DA75-83D3-4378-BD83-D16040AC8825@mac.com> Message-ID: <1B71AC86-C17A-4AEF-A91A-58B8C22E6E05@mac.com> Another interesting thought: although all of those give you a way to obtain a zero, I don't think any give you a way to test whether something is that zero. Hmm. JEff > On Jul 20, 2017, at 8:17 PM, Jake wrote: > > That's what I was thinking, but I couldn't figure out if I wanted MonadPlus, Alternative or maybe Monoid because they all have zero elements. > > >> On Thu, Jul 20, 2017, 21:52 Joshua Grosso wrote: >> Could MonadPlus (with mzero) or Alternative (with empty) provide the termination condition, if this pattern turned out to be more generally useful? >> >> Joshua Grosso >> >>> On Thu, Jul 20, 2017 at 7:16 PM, Jeff Clites wrote: >>> Also this pattern does seem Maybe-specific, in that for the general Monad case there's not an obvious termination condition. >>> >>> JEff >>> >>>> On Jul 20, 2017, at 11:03 AM, Rein Henrichs wrote: >>>> >>>> This is about as good as you can do. The monad-loops package provides a variety of similar combinators, generally implemented in similar ways, but not this specific combinator. The downside of this combinator is that it is partial: it will run forever without producing anything if f never gives a Nothing. >>>> >>>>> On Thu, Jul 20, 2017 at 10:27 AM Jake wrote: >>>>> I have a function f :: a -> Maybe a that I want to feed into itself with some initial input until it returns Nothing. >>>>> >>>>> untilNothing :: (a -> Maybe a) -> a -> a >>>>> untilNothing f x = case f x of >>>>> Just x' -> untilNothing f x' >>>>> Nothing -> x >>>>> >>>>> Is there a better way to do this? I feel like there is something more general going on with Monads being fed into themselves, but maybe I'm wrong. Thoughts? >>>>> _______________________________________________ >>>>> 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 monkleyon at gmail.com Fri Jul 21 21:50:30 2017 From: monkleyon at gmail.com (MarLinn) Date: Fri, 21 Jul 2017 23:50:30 +0200 Subject: [Haskell-cafe] Feeding a monad into itself In-Reply-To: <1B71AC86-C17A-4AEF-A91A-58B8C22E6E05@mac.com> References: <0B73DA75-83D3-4378-BD83-D16040AC8825@mac.com> <1B71AC86-C17A-4AEF-A91A-58B8C22E6E05@mac.com> Message-ID: <7fb6561c-257d-7a10-9f19-571403d0bb6b@gmail.com> On 2017-07-21 23:33, Jeff Clites wrote: > Another interesting thought: although all of those give you a way to > obtain a zero, I don't think any give you a way to test whether > something is that zero. Hmm. Well you could always use Eq. Or Foldable's null. That would generalize the loop to all foldable monads. Is that useful? I doubt it, but it's interesting. Cheers. From olf at aatal-apotheke.de Fri Jul 21 22:30:13 2017 From: olf at aatal-apotheke.de (Olaf Klinke) Date: Sat, 22 Jul 2017 00:30:13 +0200 Subject: [Haskell-cafe] Feeding a monad into itself Message-ID: <5FA2795F-BCA5-4108-986B-7C964A846256@aatal-apotheke.de> Joshua Grosso wrote: >Could MonadPlus (with mzero) or Alternative (with empty) provide the >termination condition, if this pattern turned out to be more generally >useful? MonadPlus and Alternative provide a way to put the zero into the monad, but no way to check for zeroness. In the Maybe type you have the isNothing function, but the MonadPlus and Alternative classes don't require such a thing, and probably shouldn't. In the following I present a class that allows to do stuff conditional on mzero. The starting observation is that in logic, False => anything == True. Hence the implication arrow is a (binary) function that turns nothing into something. Consider the following binary operation. (Logicians: think conjunction) (/\) :: Monad m => m a -> (a -> m ()) -> m a ma /\ f = (\a -> liftM (const a) (f a)) =<< ma It's a bit like Control.Monad.mfilter but deletes stuff by mapping it to mzero instead of False. For example, ghci> [0,1,2,3] /\ (\n -> replicate n ()) [1,2,2,3,3,3] Some MonadPlus monads are set-like. Think of Nothing as the empty set, Just x as the singleton set {x} and think of the list [x,y,z] as the finite set {x,y,z}, disregarding muliplicities. For such monads m, the types m a have a preorder ≤ which is set inclusion under the "set interpretation". For example, Nothing ≤ Just () [1,2,3] ≤ [1,2,3,4] but not [1,2] ≤ [1,4]. Now consider the following type class. class (Monad m) => Heyting m where (-->) :: (Eq a) => m a -> m a -> a -> m () We reqire that for all x, y and f x /\ f ≤ y if and only if f ≤ x --> y That is, (x /\) is left adjoint to (x -->), which reminds the logician of the Heyting implication arrow. For MonadPlus instances, we suggest that (mzero -->) == const (const (return ())) Here are some instances: instance Heyting [] where ys --> xs = \a -> if (a `notElem` ys) || (a `elem` xs) then [()] else [] instance Heyting Maybe where y --> x = listToMaybe.((maybeToList y) --> (maybeToList x)) Without the Eq constraint, I couldn't have used the elem function, hence the Heyting class carries that constraint. (There is also a Heyting instance for the monad of finite distributions [1], see the package probable [2] and its siblings.) Heyting monads have a sort of negation, turning mzero into something: neg :: (MonadPlus m, Heyting m) => m a -> m () neg x = ((liftM (const ()) x) --> mzero) () Using neg, we can do stuff on mzero: ghci> neg Nothing Just () ghci> neg (Just ()) Nothing ghci> neg [1,2,3] [] ghci> neg [] [()] Finally we implement Jake's function, but more general. untilMZero :: (Heyting m, MonadPlus m) => (a -> m a) -> a -> m a untilMZero f x = (liftM (const x) (neg (f x))) `mplus` ((f x) >>= (untilMZero f)) ghci> untilMZero (\n -> if n > 5 then Nothing else Just (n+1)) 0 Just 6 ghci> untilMZero (\n -> if n > 5 then [] else [n+1,2*n]) 1 [6,10,8,6,6,10,8,6,10,8,6,6,10,8] -- Olaf [1] For the Giry monad, --> computes the Radon-Nikodym derivative. It type-checks. [2] https://hackage.haskell.org/package/probable-0.1.2/docs/Math-Probable-Distribution-Finite.html From monkleyon at gmail.com Sat Jul 22 15:14:52 2017 From: monkleyon at gmail.com (MarLinn) Date: Sat, 22 Jul 2017 17:14:52 +0200 Subject: [Haskell-cafe] Feeding a monad into itself In-Reply-To: <5FA2795F-BCA5-4108-986B-7C964A846256@aatal-apotheke.de> References: <5FA2795F-BCA5-4108-986B-7C964A846256@aatal-apotheke.de> Message-ID: This sounds very interesting, thank you. So if I understand correctly, (––>) is supposed to mean “something like implication”? So far so good, but I fail to grasp that in a more precise way because the law makes no sense to me yet. Or rather, something seems to be missing? I suppose it's because I don't have the mathematical perspective to get that part. Even such common things like “Left Adjoints” fail to click in my head, so they're missing on my side… So the operations have the types (∧) ∷ Monad m ⇒ m a → (a → m ()) → m a (≤) ∷ SetLike m ⇒ m a → m a → Bool -- implicitely (––>) ∷ (Eq a) ⇒ m a → m a → a → m () Because (≤) returns something non-monadic, the only way the law makes sense is if it's bracketed like this: (x ∧ f) ≤ y iff f ≤ (x ––> y) Because of the left side, f must have type (a → m ()). That makes sense because (x ––> y) has that same type. But now (≤) has to be defined over this type of functor. In other words you seem to claim this type of functors is “set-like”? I assume the definition is something like f ≤ g iff ∀ x.f x ≤ g x ? I'm still not sure what that would mean for the law, but it seems like the first step towards understanding it a bit. Cheers, MarLinn From rein.henrichs at gmail.com Sat Jul 22 19:19:15 2017 From: rein.henrichs at gmail.com (Rein Henrichs) Date: Sat, 22 Jul 2017 19:19:15 +0000 Subject: [Haskell-cafe] Haskell modules: Morton's fork? In-Reply-To: <1500670462.2183.1.camel@gmail.com> References: <1500670462.2183.1.camel@gmail.com> Message-ID: A typeclass with the shared functions as members is an option. YMMV on whether it is cleaner. On Fri, Jul 21, 2017 at 1:56 PM Nikita Churaev wrote: > Option 1: > > module App.Component (Foo, Bar, Qux) -- re-exports > module App.Component.Foo (Foo, make, func1, func2) > module App.Component.Bar (Bar, make, func1, func2) > module App.Component.Qux (Qux, make, func1, func2) > > API clients will have to write long import lists: > > import App.Component > import qualified App.Component.Foo as Foo > import qualified App.Component.Bar as Bar > import qualified App.Component.Qux as Qux > > > Option 2: > > module App.Component (module Foo, module Bar) -- re-exports > module App.Component.Foo (Foo, makeFoo, fooFunc1, fooFunc2) > module App.Component.Bar (Bar, makeBar, barFunc1, barFunc2) > module App.Component.Qux (Qux, makeQux, quxFunc1, quxFunc2) > > Now you can import easily: > > import App.Component > > But now you have to prefix your functions, just like in C... > > Is there another, cleaner option? > _______________________________________________ > 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 harendra.kumar at gmail.com Sun Jul 23 05:58:30 2017 From: harendra.kumar at gmail.com (Harendra Kumar) Date: Sun, 23 Jul 2017 11:28:30 +0530 Subject: [Haskell-cafe] benchmark regression/improvement reporting Message-ID: Hi Cafe, I am looking for a package/tool/way that can tell me the difference in criterion benchmarks that a particular change introduced? If there is a way to just diff two criterion benchmark reports and show the difference in each benchmark result that should also do, I can write a CI script on top of that. Thanks, Harendra -------------- next part -------------- An HTML attachment was scrubbed... URL: From vhaisman at gmail.com Sun Jul 23 21:10:46 2017 From: vhaisman at gmail.com (=?UTF-8?Q?V=C3=A1clav_Haisman?=) Date: Sun, 23 Jul 2017 23:10:46 +0200 Subject: [Haskell-cafe] [hs-bibutils] intention to take over package Message-ID: Hi. I would like to take over the hs-bibutils Hackage package. It has not been updated since 2014, the listed maintainer is not responsive to emails, and listed home page is 404 page. -- VH From olf at aatal-apotheke.de Sun Jul 23 21:46:20 2017 From: olf at aatal-apotheke.de (Olaf Klinke) Date: Sun, 23 Jul 2017 23:46:20 +0200 Subject: [Haskell-cafe] Feeding a monad into itself Message-ID: MarLinn, you observed well, I swept something under the carpet. So here are the definitions in full glory. Apologies to all the not-so mathematically minded in Haskell-Cafe, the mail has grown rather long. A partially ordered set is a type X together with a function (≤) :: X -> X -> Bool obeying three laws. ∀ x. x ≤ x x ≤ y and y ≤ z implies x ≤ z x ≤ y and y ≤ x implies x == y Note that total orders, like the Ord typeclass, require that either x ≤ y or y ≤ x hold, but not so partial orders. Now suppose you have two partially ordered types, say X and A. By abuse of notation we use ≤ for each of the orders. Suppose we have functions f :: X -> A g :: A -> X Suppose further that f and g are order-preserving, that is x ≤ x' implies f x ≤ f x' a ≤ a' implies g a ≤ g a'. Then f is said to be left adjoint to y if for all x :: X and a :: A, f x ≤ a precisely when x ≤ g a. If X is partially ordered, so is each function space (as you suggested correctly), namely pointwise. Define for f, g :: Z -> X f ≤ g when ∀ z. f z ≤ g z If you like, (->) Z is an applicative functor and the ≤ function for the type Z -> X is built using liftA2 (≤). A bounded lattice is a partially ordered type L that has two nullary and two binary operations: least :: L greatest :: L min :: L -> L -> L max :: L -> L -> L subject to the following laws. ∀ x. least ≤ x ∀ x. x ≤ greatest z ≤ x and z ≤ y precisely when z ≤ min x y x ≤ z and y ≤ z precisely when max x y ≤ z An example is the type Bool where False ≤ True, least = False, greatest = True, min = (&&) and max = (||). Observe that for each x :: L, the partial application (min x) is a monotone function of type L -> L. Hence we can ask when each such function has a right adjoint. If each such right adjoint exists, we call L a Heyting algebra and denote the right adjoint to (min x) by (-->) x. For every MonadPlus m, we can embed Bool into m () using the function Control.Monad.guard. In this reading, False is represented by Nothing and True is represented by Just (). We thus obtain partial orders on Maybe () as well as on any function type X -> Maybe (). Recall that my (/\) function had type m a -> (a -> m ()) -> m a Specialising to a = () we obtain meet = \x y -> x /\ (const y) :: m () -> m () -> m () which you can convince yourself produces the (&&) operator in case of Maybe () == Bool. Likewise, my arrow (-->) has type m a -> m a -> a -> m () from which we can build impl = \x y -> (x --> y) () :: m () -> m () -> m () Now, in the bounded distributive lattice Bool the right adjoint to (&&) x is the logical implication (→) x and we check ghci> guard True `impl` guard True :: Maybe () Just () ghci> guard True `impl` guard False :: Maybe () Nothing ghci> guard False `impl` guard False :: Maybe () Just () ghci> guard False `impl` guard True :: Maybe () Just () Summarising, for some MonadPlus monads m, the type m () looks like a bounded lattice with least = mzero greatest = return () max = mplus min = meet and for a subclass of these monads, including m = Maybe, m () is a Heyting algebra with the right adjoint to min defined as the impl function above. On to a more complicated example. Let R = [0,∞] denote the type of non-negative real numbers, including positive infinity, (totally) ordered by the obvious ≤ relation. Observe that for each r :: R, the multiplication function (*) r :: R -> R is order-preserving if we define 0 * ∞ = 0. Hence we can ask for its right adjoint, which will be a function of type R -> R as well. Exercise: Prove that the right adjoint is division (/) of real numbers, with boundary cases r / 0 = ∞ = ∞ / x for all r and x. This demonstrates the parallels between logical implication and divison: They are both right adjoints in a certain sense. Is there a monad m with m () = R? Yes: The monad G of measures, a.k.a. the Giry monad. Is is not a Haskell monad, though. There is no Haskell type which has R as denotational semantics. But let's pretend. Let's pretend all sets are finite and of Eq class. Then a measure on X can be encoded by a list of type [(X,R)]. It is what packages like probable do. What is (/\) for this monad of measures? Look at the type: (/\) :: G a -> (a -> R) -> G a It modifies a measure by a real-valued function. If x :: X previously had the weight r, then the new weight is r * (f x). Obviously, for each measure dx the operator \f -> dx /\ f is order-preserving, since multiplication is monotone. Hence we can ask for a right adjoint. It must be a function of type G a -> G a -> (a -> R) associating a real-valued function to a pair of measures. For a = () we already know the answer: It is division. For all other types, the right adjoint is known as the Radon-Nikodym derivative [*]. It is an important gadget in machine learning because it can be used to build conditional probabilites. Intuitively, you can see the connection: For a conditional probability, you first filter the list [(X,R)] for all the allowed x, then divide by the sum of all remaining weights to make the total weight 1 again. Hence without division there is no conditional probability. Moral of the story: Logical implication and conditional probabilities are both instances of the same problem, only for different monads. -- Olaf [*] Again, I am sweeping stuff under the carpet. On function space (X -> R), the order ≤ is defined up to sets of measure zero. From p0nk at ya.ru Sun Jul 23 22:26:49 2017 From: p0nk at ya.ru (Artem) Date: Mon, 24 Jul 2017 01:26:49 +0300 Subject: [Haskell-cafe] Peformance digression when using "proc" notation for arrows In-Reply-To: <3627431500848623@web10o.yandex.ru> Message-ID: <83551500848809@web58j.yandex.ru> An HTML attachment was scrubbed... URL: From allbery.b at gmail.com Sun Jul 23 22:43:38 2017 From: allbery.b at gmail.com (Brandon Allbery) Date: Sun, 23 Jul 2017 18:43:38 -0400 Subject: [Haskell-cafe] Peformance digression when using "proc" notation for arrows In-Reply-To: <83551500848809@web58j.yandex.ru> References: <3627431500848623@web10o.yandex.ru> <83551500848809@web58j.yandex.ru> Message-ID: On Sun, Jul 23, 2017 at 6:26 PM, Artem wrote: > > sumArr = scan (\acc x -> let !newAcc = acc + x in newAcc) 0 > sumArr' = proc v -> do sumArr -< v > > testData :: [Int] > testData = [1..1000000] > > main = print $ L.last $ evalList sumArr' testData > > Running time for main with sumArr (i.e. no proc notation) is 0.087 sec, > while for sumArr' it is 3.2 seconds (and around 300mb memory usage), > although sumArr' is just sumArr called within a proc block. > Absent other information (like the core from each) I would be tempted to think that the problem is some stream fusion RULES either did not fire or degraded into a pessimization. -- 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 yotam2206 at gmail.com Mon Jul 24 10:54:33 2017 From: yotam2206 at gmail.com (Yotam Ohad) Date: Mon, 24 Jul 2017 10:54:33 +0000 Subject: [Haskell-cafe] Avoiding ad-hoc with yesod-form Message-ID: Hello cafe, I have a custom data type: data Foo = Foo | Bar | Baz deriving (Show, Bounded, Enum) In my yesod app I need to have two forms, one that get two Foo and a second that recieve three Foo. From What I've seen online I need to create two new data types: data Foo2 = { foo1 :: Foo, foo2 :: Foo } data Foo3 = { foo1 :: Foo, foo2 :: Foo, foo3 :: Foo } This is tedious and very much ad-hoc. In my actual app it goes up to Foo6 :( Is there a better way to do it? This is how I defined the forms: foo2AForm :: AForm Handler Foo2 foo2AForm = Foo2 <$> areq (selectFieldList foos) "foo1" Nothing <*> areq (selectFieldList foos) "foo2" Nothing where foos:: [(Text, Role)] foos= map (pack . show &&& id) [minBound..] foo2Form :: Html -> MForm Handler (FormResult Foo2, Widget) foo2Form = renderTable teamAForm foo3AForm :: AForm Handler Foo3 foo3AForm = Foo3 <$> areq (selectFieldList foos) "foo1" Nothing <*> areq (selectFieldList foos) "foo2" Nothing <*> areq (selectFieldList foos) "foo3" Nothing where foos:: [(Text, Role)] foos= map (pack . show &&& id) [minBound..] foo3Form :: Html -> MForm Handler (FormResult Foo2, Widget) foo3Form = renderTable teamAForm Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From monkleyon at gmail.com Mon Jul 24 12:54:38 2017 From: monkleyon at gmail.com (MarLinn) Date: Mon, 24 Jul 2017 14:54:38 +0200 Subject: [Haskell-cafe] Avoiding ad-hoc with yesod-form In-Reply-To: References: Message-ID: <61b9668c-8d8a-bca0-d107-749a0838da39@gmail.com> On 2017-07-24 12:54, Yotam Ohad wrote: > > […] > > Is there a better way to do it? Yes. AForm is Applicative. So you should just be able to use other applicative combinators. For example (untested): fooAForm :: Int -> AForm Handler [Foo] fooAForm count = traverse makeFooField [1..count] where makeFooField :: Int -> AForm Handler Foo makeFooField n = areq (selectFieldList foos) (makeFooName n) Nothing foos :: [(Text, Role)] foos = first tshow . join (,) <$> [minBound..] Note that traverse works on any Traversable (Duh.), and the usual maps are all Traversable, so you can easily adapt this to return, say, a (Map String Foo) or a (Map FooName Foo). And similar methods work for monadic forms. But: The way you asked the question smells like there might be something bad in either the user interface or the structural design. Maybe you want just one form with six fields plus CSS to conditionally hide some of them? Maybe you want one form with n fields plus an additional field to select the n? (Monadic fields should be able to do that.) Maybe there's no real maximum limit so you need just one field generator but a more complex front-end? I'm not saying you're doing it wrong, it's just that my nose is itching. Cheers. > This is how I defined the forms: > foo2AForm :: AForm Handler Foo2 > > foo2AForm = Foo2 > <$> areq (selectFieldList foos) "foo1" Nothing > <*> areq (selectFieldList foos) "foo2" Nothing > where > foos:: [(Text, Role)] > foos= map (pack . show &&& id) [minBound..] > > […] > From jann.mueller at lbrm.de Mon Jul 24 13:45:35 2017 From: jann.mueller at lbrm.de (=?iso-8859-1?Q?Dr=2E_Jann_M=FCller?=) Date: Mon, 24 Jul 2017 13:45:35 +0000 Subject: [Haskell-cafe] [Hiring] Part-time student job in Mannheim, Germany (remote possible) Message-ID: We are working on a new approach to financial risk modelling based on recent research. Having obtained some initial funding, we are now looking for a developer to help us implement a prototype. The work will be mostly on the frontend using GHCJS and probably the miso framework (but we are open to other suggestions if you have previous experience in that space). - 10-20h per week at market rates - Flexible hours, remote work possible, but must be able to come to Mannheim for one day each month. Train tickets from anywhere in Germany will be paid for. - Start date: First week of October There is also a lot of potential for thesis projects, if you are interested in domain-specific languages, interpreters, or in dealing with uncertainty, please get in touch. Please send your inquiries and applications to jobs at lbrm.de Regards, Jann Müller -------------- next part -------------- An HTML attachment was scrubbed... URL: From yotam2206 at gmail.com Mon Jul 24 15:28:41 2017 From: yotam2206 at gmail.com (Yotam Ohad) Date: Mon, 24 Jul 2017 15:28:41 +0000 Subject: [Haskell-cafe] Avoiding ad-hoc with yesod-form In-Reply-To: <61b9668c-8d8a-bca0-d107-749a0838da39@gmail.com> References: <61b9668c-8d8a-bca0-d107-749a0838da39@gmail.com> Message-ID: Hi, Thanks, I'm feeling kinda dumb because I forgot this is applicative, but yet feeling amazed on how great Haskell is to let you do stuff like that. Your nose may not have betrayed you, I'm using these forms to show rows from a database with added buttons to manage it from the web. On the other hand, I might be really bad at explaining my questions :) ‫בתאריך יום ב׳, 24 ביולי 2017 ב-15:54 מאת ‪MarLinn‬‏ <‪monkleyon at gmail.com ‬‏>:‬ > On 2017-07-24 12:54, Yotam Ohad wrote: > > > > […] > > > > Is there a better way to do it? > > Yes. AForm is Applicative. So you should just be able to use other > applicative combinators. > > For example (untested): > > fooAForm :: Int -> AForm Handler [Foo] > fooAForm count = traverse makeFooField [1..count] > where > > makeFooField :: Int -> AForm Handler Foo > makeFooField n = areq (selectFieldList foos) (makeFooName n) > Nothing > > > foos :: [(Text, Role)] > foos = first tshow . join (,) <$> [minBound..] > > Note that traverse works on any Traversable (Duh.), and the usual maps > are all Traversable, so you can easily adapt this to return, say, a > (Map String Foo) or a (Map FooName Foo). And similar methods work for > monadic forms. > > But: The way you asked the question smells like there might be something > bad in either the user interface or the structural design. Maybe you > want just one form with six fields plus CSS to conditionally hide some > of them? Maybe you want one form with n fields plus an additional field > to select the n? (Monadic fields should be able to do that.) Maybe > there's no real maximum limit so you need just one field generator but a > more complex front-end? I'm not saying you're doing it wrong, it's just > that my nose is itching. > > Cheers. > > > > This is how I defined the forms: > > foo2AForm :: AForm Handler Foo2 > > > > foo2AForm = Foo2 > > <$> areq (selectFieldList foos) "foo1" Nothing > > <*> areq (selectFieldList foos) "foo2" Nothing > > where > > foos:: [(Text, Role)] > > foos= map (pack . show &&& id) [minBound..] > > > > […] > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lemming at henning-thielemann.de Tue Jul 25 13:19:07 2017 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Tue, 25 Jul 2017 15:19:07 +0200 (CEST) Subject: [Haskell-cafe] Parallel QuickCheck testing with live counter Message-ID: I like pretty much how QuickCheck counts the number of successful tests until it reports that all tests are performed. It gives me feedback on the difficulty of the tests quickly or how long the tests will still run. I also want to run tests in parallel on multiple computing cores. There are dozens of test frameworks now. I have only tried 'pqc' and 'tasty' so far, both of them only show completed test runs but no live counters. Is there a package that runs QuickCheck tests in parallel and shows test counts live? From manny at fpcomplete.com Tue Jul 25 16:31:45 2017 From: manny at fpcomplete.com (Emanuel Borsboom) Date: Tue, 25 Jul 2017 09:31:45 -0700 Subject: [Haskell-cafe] ANN: stack-1.5.0 released Message-ID: <02169A56-565D-4BD6-AC08-3CE3A3670F1B@fpcomplete.com> See https://haskellstack.org for installation and upgrade instructions. ## 1.5.0 Behavior changes: * `stack profile` and `stack trace` now add their extra RTS arguments for benchmarks and tests to the beginning of the args, instead of the end. See [#2399](https://github.com/commercialhaskell/stack/issues/2399) * Support for Git-based indices has been removed. Other enhancements: * `stack setup` allow to control options passed to ghcjs-boot with `--ghcjs-boot-options` (one word at a time) and `--[no-]ghcjs-boot-clean` * `stack setup` now accepts a `--install-cabal VERSION` option which will install a specific version of the Cabal library globally. * Updates to store-0.4.1, which has improved performance and better error reporting for version tags. A side-effect of this is that all of stack's binary caches will be invalidated. * `stack solver` will now warn about unexpected cabal-install versions. See [#3044](https://github.com/commercialhaskell/stack/issues/3044) * Upstream packages unpacked to a temp dir are now deleted as soon as possible to avoid running out of space in `/tmp`. See [#3018](https://github.com/commercialhaskell/stack/issues/3018) * Add short synonyms for `test-arguments` and `benchmark-arguments` options. * Adds `STACK_WORK` environment variable, to specify work dir. See [#3063](https://github.com/commercialhaskell/stack/issues/3063) * Can now use relative paths for `extra-include-dirs` and `extra-lib-dirs`. See [#2830](https://github.com/commercialhaskell/stack/issues/2830) * Improved bash completion for many options, including `--ghc-options`, `--flag`, targets, and project executables for `exec`. * `--haddock-arguments` is actually used now when `haddock` is invoked during documentation generation. * `--[no-]haddock-hyperlink-source` flag added which allows toggling of sources being included in Haddock output. See [#3099](https://github.com/commercialhaskell/stack/issues/3099) * `stack ghci` will now skip building all local targets, even if they have downstream deps, as long as it's registered in the DB. * The pvp-bounds feature now supports adding `-revision` to the end of each value, e.g. `pvp-bounds: both-revision`. This means that, when uploading to Hackage, Stack will first upload your tarball with an unmodified `.cabal` file, and then upload a cabal file revision with the PVP bounds added. This can be useful—especially combined with the [Stackage no-revisions feature](http://www.snoyman.com/blog/2017/04/stackages-no-revisions-field)—as a method to ensure PVP compliance without having to proactively fix bounds issues for Stackage maintenance. * Expose a `save-hackage-creds` configuration option * On GHC <= 7.8, filters out spurious linker warnings on windows See [#3127](https://github.com/commercialhaskell/stack/pull/3127) * Better error messages when creating or building packages which alias wired-in packages. See [#3172](https://github.com/commercialhaskell/stack/issues/3172). * MinGW bin folder now is searched for dynamic libraries. See [#3126](https://github.com/commercialhaskell/stack/issues/3126) * When using Nix, nix-shell now depends always on git to prevent runtime errors while fetching metadata * The `stack unpack` command now accepts a form where an explicit Hackage revision hash is specified, e.g. `stack unpack foo-1.2.3 at gitsha1:deadbeef`. Note that this should be considered _experimental_, Stack will likely move towards a different hash format in the future. * Binary "stack upgrade" will now warn if the installed executable is not on the PATH or shadowed by another entry. * Allow running tests on tarball created by sdist and upload [#717](https://github.com/commercialhaskell/stack/issues/717). Bug fixes: * Fixes case where `stack build --profile` might not cause executables / tests / benchmarks to be rebuilt. See [#2984](https://github.com/commercialhaskell/stack/issues/2984) * `stack ghci file.hs` now loads the file even if it isn't part of your project. * `stack clean --full` now works when docker is enabled. See [#2010](https://github.com/commercialhaskell/stack/issues/2010) * Fixes an issue where cyclic deps can cause benchmarks or tests to be run before they are built. See [#2153](https://github.com/commercialhaskell/stack/issues/2153) * Fixes `stack build --file-watch` in cases where a directory is removed See [#1838](https://github.com/commercialhaskell/stack/issues/1838) * Fixes `stack dot` and `stack list-dependencies` to use info from the package database for wired-in-packages (ghc, base, etc). See [#3084](https://github.com/commercialhaskell/stack/issues/3084) * Fixes `stack --docker build` when user is part of libvirt/libvirtd groups on Ubuntu Yakkety (16.10). See [#3092](https://github.com/commercialhaskell/stack/issues/3092) * Switching a package between extra-dep and local package now forces rebuild (previously it wouldn't if versions were the same). See [#2147](https://github.com/commercialhaskell/stack/issues/2147) * `stack upload` no longer reveals your password when you type it on MinTTY-based Windows shells, such as Cygwin and MSYS2. See [#3142](https://github.com/commercialhaskell/stack/issues/3142) * `stack script`'s import parser will now properly parse files that have Windows-style line endings (CRLF) Thanks to all our contributors for this release: * Aayush Kapoor * Albert Netymk * Alexey Kuleshevich * Anders Kaseorg * Arash Rouhani * Bryan Richter * Dawei LIU * Dmitry Nikulin * Domen Kožar * Emanuel Borsboom * Felix Yan * Ivan Lazar Miljenovic * James Hamilton * Luke Murphy * Marcin Tolysz * Martin Kolinek * Mateusz Kowalczyk * Michael Sloan * Michael Snoyman * Niklas Hambüchen * Noah Doersing * Omari Norman * Paolo G. Giarrusso * Peter Stuart * Ryan Scott * Sergey Vinokurov * Sibi Prabakaran * Tej Chajed * Tim Dysinger * Tomáš Janoušek * Vassil Keremidchiev From wolfgang-it at jeltsch.info Tue Jul 25 22:01:45 2017 From: wolfgang-it at jeltsch.info (Wolfgang Jeltsch) Date: Wed, 26 Jul 2017 01:01:45 +0300 Subject: [Haskell-cafe] [ANNOUNCE] GHC 8.2.1 available In-Reply-To: <87bmobrh1b.fsf@ben-laptop.smart-cactus.org> References: <87bmobrh1b.fsf@ben-laptop.smart-cactus.org> Message-ID: <1501020105.14379.125.camel@jeltsch.info> Am Samstag, den 22.07.2017, 23:03 -0400 schrieb Ben Gamari: > In addition, there are a number of new features, > >  * A new, more type-safe type reflection mechanism > >  * The long-awaited Backpack module system > >  * Deriving strategies to disambiguate between GHC's various instance >    deriving mechanisms > >  * Unboxed sum types, for efficient unpacked representation of sum >    data types > >  * Compact regions, allowing better control over garbage collection >    in the presence of large heaps containing many long-lived objects. > >  * Colorful messages and caret diagnostics for more legible errors > > A more thorough list of the changes in this release can be found in > the release notes, > >   https://haskell.org/ghc/docs/8.2.1/docs/html/users_guide/8.2.1-notes.html It seems that the release notes mention the new type reflection mechanism und colorful messages only in the “Highlights” section, not in the “Full details” section, and that they do not mention the Backpack module system and unboxed sums at all. All the best, Wolfgang From oleg.grenrus at iki.fi Wed Jul 26 09:06:38 2017 From: oleg.grenrus at iki.fi (Oleg Grenrus) Date: Wed, 26 Jul 2017 12:06:38 +0300 Subject: [Haskell-cafe] ANN: (unofficial) nightly cabal-install builds for OSX Message-ID: Dear Haskellers, I set up a semi-automatic system to provide you with `cabal` head builds for OSX / macOS at: https://haskell.futurice.com/ As a single highlight, these builds are useful if you need to setup OSX CI; multi-travis-ghc [1] can be used almost as is, see [2]. Hopefully you find these useful! [1]: https://github.com/hvr/multi-ghc-travis [2]: https://github.com/futurice/haskell-futurice-site/commit/3d9b40c6c61788589d3f0074e13007a9ae924c98 Best regards, Oleg "phadej" Grenrus -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: OpenPGP digital signature URL: From dons00 at gmail.com Wed Jul 26 10:11:08 2017 From: dons00 at gmail.com (Don Stewart) Date: Wed, 26 Jul 2017 11:11:08 +0100 Subject: [Haskell-cafe] Static analysis engineering at Facebook (Clang/OCaml) Message-ID: The Infer static analysis team at Facebook is hiring. We have a functional programming engineering role in London to work on the open source Clang/C++ frontend to Infer. Infer is a static analysis suite for C++, Java and Objective C used by thousands of engineers at Facebook and elsewhere to find bugs. The role is a "compiler" role - working on the Clang AST to OCaml, and intermediate phases of Infer to improve our C++ analysis capabilities. Good FP engineering skills (e.g. Haskell or OCaml) are desirable. You should have a working knowledge of C++ semantics, language or compiler design or experience in a range of C++ projects. Infer: http://fbinfer.com/ Apply via: https://www.facebook.com/careers/jobs/a0I1200000LT8aA -------------- next part -------------- An HTML attachment was scrubbed... URL: From ben at smart-cactus.org Wed Jul 26 14:15:00 2017 From: ben at smart-cactus.org (Ben Gamari) Date: Wed, 26 Jul 2017 10:15:00 -0400 Subject: [Haskell-cafe] [ANNOUNCE] GHC 8.2.1 available In-Reply-To: <1501020105.14379.125.camel@jeltsch.info> References: <87bmobrh1b.fsf@ben-laptop.smart-cactus.org> <1501020105.14379.125.camel@jeltsch.info> Message-ID: <87h8xzp9nf.fsf@ben-laptop.smart-cactus.org> Wolfgang Jeltsch writes: > Am Samstag, den 22.07.2017, 23:03 -0400 schrieb Ben Gamari: >> In addition, there are a number of new features, >> >>  * A new, more type-safe type reflection mechanism >> >>  * The long-awaited Backpack module system >> >>  * Deriving strategies to disambiguate between GHC's various instance >>    deriving mechanisms >> >>  * Unboxed sum types, for efficient unpacked representation of sum >>    data types >> >>  * Compact regions, allowing better control over garbage collection >>    in the presence of large heaps containing many long-lived objects. >> >>  * Colorful messages and caret diagnostics for more legible errors >> >> A more thorough list of the changes in this release can be found in >> the release notes, >> >>   https://haskell.org/ghc/docs/8.2.1/docs/html/users_guide/8.2.1-notes.html > > It seems that the release notes mention the new type reflection > mechanism und colorful messages only in the “Highlights” section, not in > the “Full details” section, and that they do not mention the Backpack > module system and unboxed sums at all. > Yes, indeed these were oversights. They are fixed in the ghc-8.2 branch and I will try to push newly generated documentation shortly. 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 qdunkan at gmail.com Thu Jul 27 01:45:44 2017 From: qdunkan at gmail.com (Evan Laforge) Date: Wed, 26 Jul 2017 18:45:44 -0700 Subject: [Haskell-cafe] [ANNOUNCE] GHC 8.2.1 available In-Reply-To: <87h8xzp9nf.fsf@ben-laptop.smart-cactus.org> References: <87bmobrh1b.fsf@ben-laptop.smart-cactus.org> <1501020105.14379.125.camel@jeltsch.info> <87h8xzp9nf.fsf@ben-laptop.smart-cactus.org> Message-ID: This seems like a silly question, but how can we install cabal-install now? The latest hackage version 1.24.0.2 has Cabal (>=1.24.2 && <1.25), but it looks like ghc Cabal is now at 2.*. I ran into this because if I get: % cabal install --only-dependencies Resolving dependencies... cabal: internal error when reading package index: failed to parse .cabal fileThe package index or index cache is probably corrupt. Running cabal update might fix it. It seems to be triggered by having 'ekg' in the deps list, since if I take it out then I get some other errors about packages not liking the new base, which is true. 'ekg' also doesn't like the new base, but "internal error" is not the clearest way to express that :) It's frustrating that cabal-install still doesn't report the parse error, even though the parse function returns one. It just ignores the ParseFailed case. I was going to try fixing it and send a pull request when I ran into the Cabal 2.* problem. On Wed, Jul 26, 2017 at 7:15 AM, Ben Gamari wrote: > Wolfgang Jeltsch writes: > >> Am Samstag, den 22.07.2017, 23:03 -0400 schrieb Ben Gamari: >>> In addition, there are a number of new features, >>> >>> * A new, more type-safe type reflection mechanism >>> >>> * The long-awaited Backpack module system >>> >>> * Deriving strategies to disambiguate between GHC's various instance >>> deriving mechanisms >>> >>> * Unboxed sum types, for efficient unpacked representation of sum >>> data types >>> >>> * Compact regions, allowing better control over garbage collection >>> in the presence of large heaps containing many long-lived objects. >>> >>> * Colorful messages and caret diagnostics for more legible errors >>> >>> A more thorough list of the changes in this release can be found in >>> the release notes, >>> >>> https://haskell.org/ghc/docs/8.2.1/docs/html/users_guide/8.2.1-notes.html >> >> It seems that the release notes mention the new type reflection >> mechanism und colorful messages only in the “Highlights” section, not in >> the “Full details” section, and that they do not mention the Backpack >> module system and unboxed sums at all. >> > Yes, indeed these were oversights. They are fixed in the ghc-8.2 branch > and I will try to push newly generated documentation shortly. > > Cheers, > > - Ben > > _______________________________________________ > Glasgow-haskell-users mailing list > Glasgow-haskell-users at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users > From wolfgang-it at jeltsch.info Thu Jul 27 02:01:22 2017 From: wolfgang-it at jeltsch.info (Wolfgang Jeltsch) Date: Thu, 27 Jul 2017 05:01:22 +0300 Subject: [Haskell-cafe] [ANNOUNCE] GHC 8.2.1 available In-Reply-To: References: <87bmobrh1b.fsf@ben-laptop.smart-cactus.org> <1501020105.14379.125.camel@jeltsch.info> <87h8xzp9nf.fsf@ben-laptop.smart-cactus.org> Message-ID: <1501120882.2815.104.camel@jeltsch.info> Hi! I ran into the same problem. Apparently, we need cabal-install 2.0, which has not been released yet. A preliminary solution is to use the development version from the 2.0 branch. Binary packages can be found at      http://ppa.launchpad.net/hvr/ghc/ubuntu/pool/main/c/cabal-install-2.0/ , for example. It is possible to extract the cabal-install executable from these packages, so that it can be installed without using some Linux distribution package manager. All the best, Wolfgang Am Mittwoch, den 26.07.2017, 18:45 -0700 schrieb Evan Laforge: > This seems like a silly question, but how can we install cabal-install > now?  The latest hackage version 1.24.0.2 has Cabal (>=1.24.2 && > <1.25), but it looks like ghc Cabal is now at 2.*. > > I ran into this because if I get: > > % cabal install --only-dependencies > Resolving dependencies... > cabal: internal error when reading package index: failed to parse > .cabal > fileThe package index or index cache is probably corrupt. Running > cabal update > might fix it. > > It seems to be triggered by having 'ekg' in the deps list, since if I > take it out then I get some other errors about packages not liking the > new base, which is true.  'ekg' also doesn't like the new base, but > "internal error" is not the clearest way to express that :) > > It's frustrating that cabal-install still doesn't report the parse > error, even though the parse function returns one.  It just ignores > the ParseFailed case.  I was going to try fixing it and send a pull > request when I ran into the Cabal 2.* problem. > > On Wed, Jul 26, 2017 at 7:15 AM, Ben Gamari > wrote: > > > > Wolfgang Jeltsch writes: > > > > > > > > Am Samstag, den 22.07.2017, 23:03 -0400 schrieb Ben Gamari: > > > > > > > > In addition, there are a number of new features, > > > > > > > >  * A new, more type-safe type reflection mechanism > > > > > > > >  * The long-awaited Backpack module system > > > > > > > >  * Deriving strategies to disambiguate between GHC's various > > > > instance > > > >    deriving mechanisms > > > > > > > >  * Unboxed sum types, for efficient unpacked representation of > > > > sum > > > >    data types > > > > > > > >  * Compact regions, allowing better control over garbage > > > > collection > > > >    in the presence of large heaps containing many long-lived > > > > objects. > > > > > > > >  * Colorful messages and caret diagnostics for more legible > > > > errors > > > > > > > > A more thorough list of the changes in this release can be found > > > > in > > > > the release notes, > > > > > > > >   https://haskell.org/ghc/docs/8.2.1/docs/html/users_guide/8.2.1 > > > > -notes.html > > > It seems that the release notes mention the new type reflection > > > mechanism und colorful messages only in the “Highlights” section, > > > not in > > > the “Full details” section, and that they do not mention the > > > Backpack > > > module system and unboxed sums at all. > > > > > Yes, indeed these were oversights. They are fixed in the ghc-8.2 > > branch > > and I will try to push newly generated documentation shortly. > > > > Cheers, > > > > - Ben > > > > _______________________________________________ > > Glasgow-haskell-users mailing list > > Glasgow-haskell-users at haskell.org > > http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-use > > rs > > From lemming at henning-thielemann.de Thu Jul 27 07:47:08 2017 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Thu, 27 Jul 2017 09:47:08 +0200 (CEST) Subject: [Haskell-cafe] custom package for Verbosity, info, warn etc. in console programs Message-ID: I have several command-line tools that support a verbosity flag. The Cabal library provides an appropriate data type and related reporting functions: https://hackage.haskell.org/package/Cabal-2.0.0.2/docs/Distribution-Verbosity.html https://hackage.haskell.org/package/Cabal-2.0.0.2/docs/Distribution-Simple-Utils.html However, Cabal moves pretty fast (frequent version increments) and I do not need all the distribution stuff. Is there a package that provides only the Verbosity and reporting functionality? From hpacheco at gmail.com Thu Jul 27 09:30:13 2017 From: hpacheco at gmail.com (Hugo Pacheco) Date: Thu, 27 Jul 2017 10:30:13 +0100 Subject: [Haskell-cafe] GHC Platform-independent object files Message-ID: Hi cafe, I am wondering if there is any easy way to distribute a Haskell module/library in a platform-independent manner without revealing the source code, that can be seamlessly linked with GHC? I am thinking about some sort of GHC object files or any intermediate representation such as C,LLVM or Haskell Core. My use case would be to release a small utility module as part of a student assignment without revealing its source code to students. Thanks, hugo -- www.di.uminho.pt/~hpacheco -------------- next part -------------- An HTML attachment was scrubbed... URL: From ivan.miljenovic at gmail.com Thu Jul 27 09:52:40 2017 From: ivan.miljenovic at gmail.com (Ivan Lazar Miljenovic) Date: Thu, 27 Jul 2017 19:52:40 +1000 Subject: [Haskell-cafe] GHC Platform-independent object files In-Reply-To: References: Message-ID: On 27 July 2017 at 19:30, Hugo Pacheco wrote: > Hi cafe, > > I am wondering if there is any easy way to distribute a Haskell > module/library in a platform-independent manner without revealing the source > code, that can be seamlessly linked with GHC? > I am thinking about some sort of GHC object files or any intermediate > representation such as C,LLVM or Haskell Core. > My use case would be to release a small utility module as part of a student > assignment without revealing its source code to students. It's probably overkill, but maybe a Docker image containing the compiled libraries and have the students do their work within the image as well? > > Thanks, > hugo > > -- > www.di.uminho.pt/~hpacheco > > _______________________________________________ > 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. -- Ivan Lazar Miljenovic Ivan.Miljenovic at gmail.com http://IvanMiljenovic.wordpress.com From hpacheco at gmail.com Thu Jul 27 10:26:07 2017 From: hpacheco at gmail.com (Hugo Pacheco) Date: Thu, 27 Jul 2017 11:26:07 +0100 Subject: [Haskell-cafe] GHC Platform-independent object files In-Reply-To: References: Message-ID: That would work, but seems too limitative. I was hoping more for some sufficiently-obfuscated intermediate files that GHC could read (e.g., .hc). On Thu, Jul 27, 2017 at 10:52 AM, Ivan Lazar Miljenovic < ivan.miljenovic at gmail.com> wrote: > On 27 July 2017 at 19:30, Hugo Pacheco wrote: > > Hi cafe, > > > > I am wondering if there is any easy way to distribute a Haskell > > module/library in a platform-independent manner without revealing the > source > > code, that can be seamlessly linked with GHC? > > I am thinking about some sort of GHC object files or any intermediate > > representation such as C,LLVM or Haskell Core. > > My use case would be to release a small utility module as part of a > student > > assignment without revealing its source code to students. > > It's probably overkill, but maybe a Docker image containing the > compiled libraries and have the students do their work within the > image as well? > > > > > Thanks, > > hugo > > > > -- > > www.di.uminho.pt/~hpacheco > > > > _______________________________________________ > > 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. > > > > -- > Ivan Lazar Miljenovic > Ivan.Miljenovic at gmail.com > http://IvanMiljenovic.wordpress.com > -- www.di.uminho.pt/~hpacheco -------------- next part -------------- An HTML attachment was scrubbed... URL: From ivan.miljenovic at gmail.com Thu Jul 27 11:11:19 2017 From: ivan.miljenovic at gmail.com (Ivan Lazar Miljenovic) Date: Thu, 27 Jul 2017 21:11:19 +1000 Subject: [Haskell-cafe] GHC Platform-independent object files In-Reply-To: References: Message-ID: On 27 July 2017 at 20:26, Hugo Pacheco wrote: > That would work, but seems too limitative. > I was hoping more for some sufficiently-obfuscated intermediate files that > GHC could read (e.g., .hc). I think they're all OS/platform specific (and then you have to deal with registering the libraries with ghc-pkg). Maybe it's possible to distribute Core and have that compiled by GHC; it would at least be partially obfuscated compared to the original Haskell. > > On Thu, Jul 27, 2017 at 10:52 AM, Ivan Lazar Miljenovic > wrote: >> >> On 27 July 2017 at 19:30, Hugo Pacheco wrote: >> > Hi cafe, >> > >> > I am wondering if there is any easy way to distribute a Haskell >> > module/library in a platform-independent manner without revealing the >> > source >> > code, that can be seamlessly linked with GHC? >> > I am thinking about some sort of GHC object files or any intermediate >> > representation such as C,LLVM or Haskell Core. >> > My use case would be to release a small utility module as part of a >> > student >> > assignment without revealing its source code to students. >> >> It's probably overkill, but maybe a Docker image containing the >> compiled libraries and have the students do their work within the >> image as well? >> >> > >> > Thanks, >> > hugo >> > >> > -- >> > www.di.uminho.pt/~hpacheco >> > >> > _______________________________________________ >> > 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. >> >> >> >> -- >> Ivan Lazar Miljenovic >> Ivan.Miljenovic at gmail.com >> http://IvanMiljenovic.wordpress.com > > > > > -- > www.di.uminho.pt/~hpacheco -- Ivan Lazar Miljenovic Ivan.Miljenovic at gmail.com http://IvanMiljenovic.wordpress.com From hpacheco at gmail.com Thu Jul 27 12:02:57 2017 From: hpacheco at gmail.com (Hugo Pacheco) Date: Thu, 27 Jul 2017 13:02:57 +0100 Subject: [Haskell-cafe] GHC Platform-independent object files In-Reply-To: References: Message-ID: Yes, Core would be a good format. AFAIK, GHC only supports generating Core, but not reading Core. On Thu, Jul 27, 2017 at 12:11 PM, Ivan Lazar Miljenovic < ivan.miljenovic at gmail.com> wrote: > On 27 July 2017 at 20:26, Hugo Pacheco wrote: > > That would work, but seems too limitative. > > I was hoping more for some sufficiently-obfuscated intermediate files > that > > GHC could read (e.g., .hc). > > I think they're all OS/platform specific (and then you have to deal > with registering the libraries with ghc-pkg). > > Maybe it's possible to distribute Core and have that compiled by GHC; > it would at least be partially obfuscated compared to the original > Haskell. > > > > > On Thu, Jul 27, 2017 at 10:52 AM, Ivan Lazar Miljenovic > > wrote: > >> > >> On 27 July 2017 at 19:30, Hugo Pacheco wrote: > >> > Hi cafe, > >> > > >> > I am wondering if there is any easy way to distribute a Haskell > >> > module/library in a platform-independent manner without revealing the > >> > source > >> > code, that can be seamlessly linked with GHC? > >> > I am thinking about some sort of GHC object files or any intermediate > >> > representation such as C,LLVM or Haskell Core. > >> > My use case would be to release a small utility module as part of a > >> > student > >> > assignment without revealing its source code to students. > >> > >> It's probably overkill, but maybe a Docker image containing the > >> compiled libraries and have the students do their work within the > >> image as well? > >> > >> > > >> > Thanks, > >> > hugo > >> > > >> > -- > >> > www.di.uminho.pt/~hpacheco > >> > > >> > _______________________________________________ > >> > 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. > >> > >> > >> > >> -- > >> Ivan Lazar Miljenovic > >> Ivan.Miljenovic at gmail.com > >> http://IvanMiljenovic.wordpress.com > > > > > > > > > > -- > > www.di.uminho.pt/~hpacheco > > > > -- > Ivan Lazar Miljenovic > Ivan.Miljenovic at gmail.com > http://IvanMiljenovic.wordpress.com > -- www.di.uminho.pt/~hpacheco -------------- next part -------------- An HTML attachment was scrubbed... URL: From dons00 at gmail.com Thu Jul 27 12:57:48 2017 From: dons00 at gmail.com (Don Stewart) Date: Thu, 27 Jul 2017 13:57:48 +0100 Subject: [Haskell-cafe] Static analysis engineering at Facebook (Clang/OCaml) In-Reply-To: References: Message-ID: Link moved, apply here: https://www.facebook.com/careers/jobs/a0I1200000LT8aAEAT On Thu, Jul 27, 2017 at 12:39 PM, Shannon Sequeira < shannonsequeira at gmail.com> wrote: > Hi Don, the job link appears to be broken. > > Best, > Shannon Sequeira > > On 26 July 2017 at 13:11, Don Stewart wrote: > >> The Infer static analysis team at Facebook is hiring. We have a >> functional programming engineering role in London to work on the open >> source Clang/C++ frontend to Infer. >> >> Infer is a static analysis suite for C++, Java and Objective C used by >> thousands of engineers at Facebook and elsewhere to find bugs. >> >> The role is a "compiler" role - working on the Clang AST to OCaml, and >> intermediate phases of Infer to improve our C++ analysis capabilities. Good >> FP engineering skills (e.g. Haskell or OCaml) are desirable. >> >> You should have a working knowledge of C++ semantics, language or >> compiler design or experience in a range of C++ projects. >> >> Infer: >> >> http://fbinfer.com/ >> >> Apply via: >> >> https://www.facebook.com/careers/jobs/a0I1200000LT8aA >> >> _______________________________________________ >> 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 Thu Jul 27 14:20:47 2017 From: saurabhnanda at gmail.com (Saurabh Nanda) Date: Thu, 27 Jul 2017 19:50:47 +0530 Subject: [Haskell-cafe] How to execute a function loaded via GHCI.ObjLink? Message-ID: Hi, I'm playing around with https://www.stackage.org/haddock/lts-9.0/ghci-8.0.2/GHCi-ObjLink.html to see if I can come up with some sort of hot-loading/plugin system in Haskell. I've managed to load a shared object (compiled from a Haskell source via -rdynamic) with the following code: {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE MagicHash, UnboxedTuples #-} module Main where import GHC.Exts ( addrToAny# ) import GHC.Ptr ( Ptr(..) ) import System.Info ( os, arch ) import Encoding import GHCi.ObjLink import Debug.Trace main :: IO () main = do traceM "before initObjLinker" initObjLinker traceM "before loadObj" loadObj "/Users/saurabhnanda/projects/test-plugins/test-plugins/app/PluginMarkup.o" traceM "after loadObj" -- NOTE: I've hardcoded the symbol name that I obtained from running `symbols PluginMarkup.o` sym <- lookupSymbol "PluginMarkup_foliage_info" traceM "after lookupsymbol" traceM (show sym) I'm getting the following output, which mean that I'm probably getting the Ptr to the function. before initObjLinker before loadObj after loadObj after lookupsymbol Just 0x0000000104be49a8 Question is, how do I run the function in the same Haskell environment/runtime? The underlying function is actually `foliage :: UtcTime -> Html` The code is available at https://github.com/vacationlabs/hint-test/blob/dll/app/Main.hs and the DLL is available at https://github.com/vacationlabs/hint-test/blob/dll/app/PluginMarkup.o -- Saurabh. -------------- next part -------------- An HTML attachment was scrubbed... URL: From moritz.kiefer at purelyfunctional.org Thu Jul 27 14:35:19 2017 From: moritz.kiefer at purelyfunctional.org (Moritz Kiefer) Date: Thu, 27 Jul 2017 16:35:19 +0200 Subject: [Haskell-cafe] How to execute a function loaded via GHCI.ObjLink? In-Reply-To: References: Message-ID: Hi, I have a blogpost which demonstrates this https://purelyfunctional.org/posts/2016-05-20-dynamic-loading-haskell-module.html Basically you need to unwrap the address and then use addrToAny. Obviously this is not typesafe so use it carefully. Cheers, Moritz On 07/27/2017 04:20 PM, Saurabh Nanda wrote: > Hi, > > I'm playing around > with https://www.stackage.org/haddock/lts-9.0/ghci-8.0.2/GHCi-ObjLink.html > to see if I can come up with some sort of hot-loading/plugin system in > Haskell. > > I've managed to load a shared object (compiled from a Haskell source via > -rdynamic) with the following code: > > {-# LANGUAGE OverloadedStrings #-} > {-# LANGUAGE MagicHash, UnboxedTuples #-} > > module Main where > > import GHC.Exts ( addrToAny# ) > import GHC.Ptr ( Ptr(..) ) > import System.Info ( os, arch ) > import Encoding > import GHCi.ObjLink > import Debug.Trace > > main :: IO () > main = do > traceM "before initObjLinker" > initObjLinker > traceM "before loadObj" > loadObj > "/Users/saurabhnanda/projects/test-plugins/test-plugins/app/PluginMarkup.o" > traceM "after loadObj" > > -- NOTE: I've hardcoded the symbol name that I obtained from > running `symbols PluginMarkup.o` > sym <- lookupSymbol "PluginMarkup_foliage_info" > traceM "after lookupsymbol" > traceM (show sym) > > I'm getting the following output, which mean that I'm probably getting > the Ptr to the function. > > before initObjLinker > before loadObj > after loadObj > after lookupsymbol > Just 0x0000000104be49a8 > > Question is, how do I run the function in the same Haskell > environment/runtime? The underlying function is actually `foliage :: > UtcTime -> Html` > > The code is available > at https://github.com/vacationlabs/hint-test/blob/dll/app/Main.hs and > the DLL is available > at https://github.com/vacationlabs/hint-test/blob/dll/app/PluginMarkup.o > > -- 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: 833 bytes Desc: OpenPGP digital signature URL: From yotam2206 at gmail.com Thu Jul 27 16:02:07 2017 From: yotam2206 at gmail.com (Yotam Ohad) Date: Thu, 27 Jul 2017 16:02:07 +0000 Subject: [Haskell-cafe] Damn you hmatrix Message-ID: Hi cafe, I have a very annoying problem with hmatrix. I have a project which depends on it. I can use `stack build` with no errors but when I try to load it to GHCi(`stack ghci`) I get the following error: sh-4.3$ stack ghci [0mApple-0.1.0.0: configure (lib) [0m [0mConfiguring Apple-0.1.0.0... [0m [0mApple-0.1.0.0: initial-build-steps (lib) [0m [0mConfiguring GHCi with the following packages: Apple [0m GHCi, version 8.0.2: http://www.haskell.org/ghc/ :? for help ghc.EXE: addDLL: libblas.dll (Win32 error 126): The specified module could not be found. ghc.EXE: Could not load `libblas.dll'. Reason: addDLL: could not load DLL ghc.EXE: addDLL: liblapack.dll (Win32 error 126): The specified module could not be found. ghc.EXE: Could not load `liblapack.dll'. Reason: addDLL: could not load DLL ghc.EXE: C:\Users\Yotam\Apple\.stack-work\install\ebd7be2b\lib\x86_64-windows-ghc-8.0.2\hmatrix-0.18.0.0-IA7RzrKn1o84vo5PLhGcwQ\HShmatrix-0.18.0.0-IA7RzrKn1o84vo5PLhGcwQ.o: unknown symbol `dgesvd_' ghc.EXE: unable to load package `hmatrix-0.18.0.0' This is really bizarre, and could not find something online to help me fix this. I'm using stack 1.5.0 with ghc 8.0.2 On a side note, I've seen some discussions about why the C libraries can't be added automatically but did not understand most of it, if someone can explain it would be highly appreciated. Yotam -------------- next part -------------- An HTML attachment was scrubbed... URL: From qdunkan at gmail.com Thu Jul 27 18:19:10 2017 From: qdunkan at gmail.com (Evan Laforge) Date: Thu, 27 Jul 2017 11:19:10 -0700 Subject: [Haskell-cafe] [ANNOUNCE] GHC 8.2.1 available In-Reply-To: <1501120882.2815.104.camel@jeltsch.info> References: <87bmobrh1b.fsf@ben-laptop.smart-cactus.org> <1501020105.14379.125.camel@jeltsch.info> <87h8xzp9nf.fsf@ben-laptop.smart-cactus.org> <1501120882.2815.104.camel@jeltsch.info> Message-ID: Thanks for the reply. I got cabal-install from https://github.com/haskell/cabal/ and assumed it was the latest version... but now that I look carefully I see it has a 2.0 branch. I compiled it and I don't get that confusing "parse error" any more. It looks like a nicer error message in general too (except still missing some spaces, specifically "After searching the rest of the dependency tree exhaustively, these were the goals I've had most trouble fulfilling: karya, ekgTrying configure anyway."), so that's probably thanks to the solver improvements in 2.0. Since it's apparently just a bug in older cabal-installs I guess I won't bother trying to find it. On Wed, Jul 26, 2017 at 7:01 PM, Wolfgang Jeltsch wrote: > Hi! > > I ran into the same problem. > > Apparently, we need cabal-install 2.0, which has not been released yet. > A preliminary solution is to use the development version from the 2.0 > branch. Binary packages can be found at > > http://ppa.launchpad.net/hvr/ghc/ubuntu/pool/main/c/cabal-install-2.0/ , > > for example. It is possible to extract the cabal-install executable from > these packages, so that it can be installed without using some Linux > distribution package manager. > > All the best, > Wolfgang > > Am Mittwoch, den 26.07.2017, 18:45 -0700 schrieb Evan Laforge: >> This seems like a silly question, but how can we install cabal-install >> now? The latest hackage version 1.24.0.2 has Cabal (>=1.24.2 && >> <1.25), but it looks like ghc Cabal is now at 2.*. >> >> I ran into this because if I get: >> >> % cabal install --only-dependencies >> Resolving dependencies... >> cabal: internal error when reading package index: failed to parse >> .cabal >> fileThe package index or index cache is probably corrupt. Running >> cabal update >> might fix it. >> >> It seems to be triggered by having 'ekg' in the deps list, since if I >> take it out then I get some other errors about packages not liking the >> new base, which is true. 'ekg' also doesn't like the new base, but >> "internal error" is not the clearest way to express that :) >> >> It's frustrating that cabal-install still doesn't report the parse >> error, even though the parse function returns one. It just ignores >> the ParseFailed case. I was going to try fixing it and send a pull >> request when I ran into the Cabal 2.* problem. >> >> On Wed, Jul 26, 2017 at 7:15 AM, Ben Gamari >> wrote: >> > >> > Wolfgang Jeltsch writes: >> > >> > > >> > > Am Samstag, den 22.07.2017, 23:03 -0400 schrieb Ben Gamari: >> > > > >> > > > In addition, there are a number of new features, >> > > > >> > > > * A new, more type-safe type reflection mechanism >> > > > >> > > > * The long-awaited Backpack module system >> > > > >> > > > * Deriving strategies to disambiguate between GHC's various >> > > > instance >> > > > deriving mechanisms >> > > > >> > > > * Unboxed sum types, for efficient unpacked representation of >> > > > sum >> > > > data types >> > > > >> > > > * Compact regions, allowing better control over garbage >> > > > collection >> > > > in the presence of large heaps containing many long-lived >> > > > objects. >> > > > >> > > > * Colorful messages and caret diagnostics for more legible >> > > > errors >> > > > >> > > > A more thorough list of the changes in this release can be found >> > > > in >> > > > the release notes, >> > > > >> > > > https://haskell.org/ghc/docs/8.2.1/docs/html/users_guide/8.2.1 >> > > > -notes.html >> > > It seems that the release notes mention the new type reflection >> > > mechanism und colorful messages only in the “Highlights” section, >> > > not in >> > > the “Full details” section, and that they do not mention the >> > > Backpack >> > > module system and unboxed sums at all. >> > > >> > Yes, indeed these were oversights. They are fixed in the ghc-8.2 >> > branch >> > and I will try to push newly generated documentation shortly. >> > >> > Cheers, >> > >> > - Ben >> > >> > _______________________________________________ >> > Glasgow-haskell-users mailing list >> > Glasgow-haskell-users at haskell.org >> > http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-use >> > rs >> > From max at amanshauser.eu Thu Jul 27 19:30:30 2017 From: max at amanshauser.eu (Max Amanshauser) Date: Thu, 27 Jul 2017 21:30:30 +0200 Subject: [Haskell-cafe] [ANN] saltine 0.0.1.0 released - Users urged to upgrade Message-ID: Saltine is a Haskell binding to libsodium. === Thomas DuBuisson of Galois Inc. found a serious issue in saltine that can lead to data corruption. Security implications cannot be ruled out. All users are advised to upgrade to saltine 0.0.0.6 or above, which are not affected. Saltine requires libsodium 1.0.11 or higher. === Saltine 0.0.1.0 also features: * Support for detached signatures (contributed by Thomas DuBuisson) -- Cheers, Max. From danburton.email at gmail.com Thu Jul 27 19:31:30 2017 From: danburton.email at gmail.com (Dan Burton) Date: Thu, 27 Jul 2017 12:31:30 -0700 Subject: [Haskell-cafe] Damn you hmatrix In-Reply-To: References: Message-ID: Have you seen the instructions here? https://github.com/albertoruiz/hmatrix/blob/master/INSTALL.md#windows -- Dan Burton On Thu, Jul 27, 2017 at 9:02 AM, Yotam Ohad wrote: > Hi cafe, > I have a very annoying problem with hmatrix. I have a project which > depends on it. I can use `stack build` with no errors but when I try to > load it to GHCi(`stack ghci`) I get the following error: > sh-4.3$ stack ghci > [0mApple-0.1.0.0: configure (lib) [0m > [0mConfiguring Apple-0.1.0.0... [0m > [0mApple-0.1.0.0: initial-build-steps (lib) [0m > [0mConfiguring GHCi with the following packages: Apple [0m > GHCi, version 8.0.2: http://www.haskell.org/ghc/ :? for help > ghc.EXE: addDLL: libblas.dll (Win32 error 126): The specified module could > not be found. > ghc.EXE: Could not load `libblas.dll'. Reason: addDLL: could not load DLL > > ghc.EXE: addDLL: liblapack.dll (Win32 error 126): The specified module > could not be found. > ghc.EXE: Could not load `liblapack.dll'. Reason: addDLL: could not load DLL > > ghc.EXE: C:\Users\Yotam\Apple\.stack-work\install\ebd7be2b\lib\x86_ > 64-windows-ghc-8.0.2\hmatrix-0.18.0.0-IA7RzrKn1o84vo5PLhGcwQ\ > HShmatrix-0.18.0.0-IA7RzrKn1o84vo5PLhGcwQ.o: unknown symbol `dgesvd_' > > ghc.EXE: unable to load package `hmatrix-0.18.0.0' > > This is really bizarre, and could not find something online to help me fix > this. > I'm using stack 1.5.0 with ghc 8.0.2 > > On a side note, I've seen some discussions about why the C libraries can't > be added automatically but did not understand most of it, if someone can > explain it would be highly appreciated. > > Yotam > > > > _______________________________________________ > 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 Jul 28 07:05:45 2017 From: saurabhnanda at gmail.com (Saurabh Nanda) Date: Fri, 28 Jul 2017 12:35:45 +0530 Subject: [Haskell-cafe] How to execute a function loaded via GHCI.ObjLink? In-Reply-To: References: Message-ID: > > I have a blogpost which demonstrates this > https://purelyfunctional.org/posts/2016-05-20-dynamic- > loading-haskell-module.html Hey Moritz, I'm not sure if you realised, but my code is based on your blog post itself -- thanks for writing it! It was just that I was trying to avoid using the `mangleSymbol` function by hard-coding the known symbol value. If I use the `mangleSymbol` method, the symbol lookup fails. If I hard-code the symbol name and try executing the function it segfaults. I'm stuck now and don't know enough about the internals of Ptr, FuncPtr, Any, etc. to figure out how to proceed. I'm on MacOSX if that makes any difference. -- Saurabh. -------------- next part -------------- An HTML attachment was scrubbed... URL: From yotam2206 at gmail.com Fri Jul 28 10:31:10 2017 From: yotam2206 at gmail.com (Yotam Ohad) Date: Fri, 28 Jul 2017 10:31:10 +0000 Subject: [Haskell-cafe] Damn you hmatrix In-Reply-To: References: Message-ID: I did not see this guide, but even when I follow the instruction when I try to install hmatrix as in the last step of the guide and get a /missing C library: libgfortran-3. All the actions I described in the first email have resulted in the same results. Yotam ‫בתאריך יום ה׳, 27 ביולי 2017 ב-22:31 מאת ‪Dan Burton‬‏ <‪ danburton.email at gmail.com‬‏>:‬ > Have you seen the instructions here? > > https://github.com/albertoruiz/hmatrix/blob/master/INSTALL.md#windows > > -- Dan Burton > > On Thu, Jul 27, 2017 at 9:02 AM, Yotam Ohad wrote: > >> Hi cafe, >> I have a very annoying problem with hmatrix. I have a project which >> depends on it. I can use `stack build` with no errors but when I try to >> load it to GHCi(`stack ghci`) I get the following error: >> sh-4.3$ stack ghci >> [0mApple-0.1.0.0: configure (lib) [0m >> [0mConfiguring Apple-0.1.0.0... [0m >> [0mApple-0.1.0.0: initial-build-steps (lib) [0m >> [0mConfiguring GHCi with the following packages: Apple [0m >> GHCi, version 8.0.2: http://www.haskell.org/ghc/ :? for help >> ghc.EXE: addDLL: libblas.dll (Win32 error 126): The specified module >> could not be found. >> ghc.EXE: Could not load `libblas.dll'. Reason: addDLL: could not load DLL >> >> ghc.EXE: addDLL: liblapack.dll (Win32 error 126): The specified module >> could not be found. >> ghc.EXE: Could not load `liblapack.dll'. Reason: addDLL: could not load >> DLL >> >> ghc.EXE: >> C:\Users\Yotam\Apple\.stack-work\install\ebd7be2b\lib\x86_64-windows-ghc-8.0.2\hmatrix-0.18.0.0-IA7RzrKn1o84vo5PLhGcwQ\HShmatrix-0.18.0.0-IA7RzrKn1o84vo5PLhGcwQ.o: >> unknown symbol `dgesvd_' >> >> ghc.EXE: unable to load package `hmatrix-0.18.0.0' >> >> This is really bizarre, and could not find something online to help me >> fix this. >> I'm using stack 1.5.0 with ghc 8.0.2 >> >> On a side note, I've seen some discussions about why the C libraries >> can't be added automatically but did not understand most of it, if someone >> can explain it would be highly appreciated. >> >> Yotam >> >> >> >> _______________________________________________ >> 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 tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk Fri Jul 28 13:45:41 2017 From: tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk (Tom Ellis) Date: Fri, 28 Jul 2017 14:45:41 +0100 Subject: [Haskell-cafe] What can be UNPACK'ed? Message-ID: <20170728134541.GA19583@weber> What types can be UNPACK'ed? From my vague understanding of what UNPACK does, it can only be types whose size is bounded by a known value, so whilst data Foo = Foo {-# UNPACK #-} !Float {-# UNPACK #-} !Int is fine, presumably data Foo = Foo {-# UNPACK #-} ![Float] is not fine. Or is it? Technically it could be possible to reserve enough space in Foo to store either a [] or a (:) Float [Float]. And if that is possible could we also UNPACK polymorphic fields? data Storable a => Foo a = Foo {-# UNPACK #-} a or data Foo a where Foo :: Storable a => {-# UNPACK #-} a -> Foo a if either DatatypeContexts worked or my imaginary GADT UNPACK syntax worked (I'm not sure if either does). What are the limits of what we could reasonably get to UNPACK in GHC? Thanks, Tom From ollie at ocharles.org.uk Fri Jul 28 15:01:02 2017 From: ollie at ocharles.org.uk (Oliver Charles) Date: Fri, 28 Jul 2017 15:01:02 +0000 Subject: [Haskell-cafe] What can be UNPACK'ed? In-Reply-To: <20170728134541.GA19583@weber> References: <20170728134541.GA19583@weber> Message-ID: Afaik, you couldn't UNPACK a list in the past because it's a sum type, and sum types could not be unpacked. That has changed with the latest GHC, so maybe that now works. I'm pretty certain you can't unpack polymorphic fields, and this is why libraries such as `ad` offer a polymorphic version, and a version specialized to a particular type: http://hackage.haskell.org/package/ad-4.3.3/docs/Numeric-AD-Mode-Forward.html - polymorphic http://hackage.haskell.org/package/ad-4.3.3/docs/Numeric-AD-Mode-Forward-Double.html - specialized to Double and significantly faster Does that help? On Fri, Jul 28, 2017 at 2:48 PM Tom Ellis < tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk> wrote: > What types can be UNPACK'ed? From my vague understanding of what UNPACK > does, it can only be types whose size is bounded by a known value, so > whilst > > data Foo = Foo {-# UNPACK #-} !Float {-# UNPACK #-} !Int > > is fine, presumably > > data Foo = Foo {-# UNPACK #-} ![Float] > > is not fine. Or is it? Technically it could be possible to reserve enough > space in Foo to store either a [] or a (:) Float [Float]. And if that is > possible could we also UNPACK polymorphic fields? > > data Storable a => Foo a = Foo {-# UNPACK #-} a > > or > > data Foo a where > Foo :: Storable a => {-# UNPACK #-} a -> Foo a > > if either DatatypeContexts worked or my imaginary GADT UNPACK syntax worked > (I'm not sure if either does). > > What are the limits of what we could reasonably get to UNPACK in GHC? > > Thanks, > > Tom > _______________________________________________ > 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 aditya.siram at gmail.com Fri Jul 28 19:59:56 2017 From: aditya.siram at gmail.com (aditya siram) Date: Fri, 28 Jul 2017 14:59:56 -0500 Subject: [Haskell-cafe] GHCi and custom preprocessors Message-ID: Hi all, I have a custom file format and custom preprocessor in my project that converts it to Haskell. GHCi is unable to detect when changes are made to the custom file, it only sees that the Haskell file hasn't changed and doesn't reload anything. Is this even supported in GHCi? Thanks! -deech -------------- next part -------------- An HTML attachment was scrubbed... URL: From sylvain at haskus.fr Fri Jul 28 20:18:15 2017 From: sylvain at haskus.fr (Sylvain Henry) Date: Fri, 28 Jul 2017 22:18:15 +0200 Subject: [Haskell-cafe] GHCi and custom preprocessors In-Reply-To: References: Message-ID: <8f98b499-3972-4799-bb2c-a828f8419143@haskus.fr> Hi, Maybe you could try adding a little bit of TH in the generated file to call `addDependentFile` (https://www.stackage.org/haddock/lts-9.0/template-haskell-2.11.1.0/Language-Haskell-TH-Syntax.html#v:addDependentFile). I haven't tested it though. Sylvain On 28/07/2017 21:59, aditya siram wrote: > Hi all, > I have a custom file format and custom preprocessor in my project that > converts it to Haskell. GHCi is unable to detect when changes are made > to the custom file, it only sees that the Haskell file hasn't changed > and doesn't reload anything. Is this even supported in GHCi? > > Thanks! > -deech > > > _______________________________________________ > 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 bruno at ruomad.net Sat Jul 29 08:12:42 2017 From: bruno at ruomad.net (bruno at ruomad.net) Date: Sat, 29 Jul 2017 10:12:42 +0200 Subject: [Haskell-cafe] Damn you hmatrix In-Reply-To: References: Message-ID: <31056191-e1d7-48b2-b83e-8c954379aa0b@Spark> Just rename/copy/link libgfortran-3 to libgfortran I solved the same problem this way On 28 Jul 2017, 12:32 +0200, Yotam Ohad , wrote: > I did not see this guide, but even when I follow the instruction when I try to install hmatrix as in the last step of the guide and get a /missing C library: libgfortran-3. > All the actions I described in the first email have resulted in the same results. > > Yotam > > > ‫בתאריך יום ה׳, 27 ביולי 2017 ב-22:31 מאת ‪Dan Burton‬‏ <‪danburton.email at gmail.com‬‏>:‬ > > > Have you seen the instructions here? > > > > > > https://github.com/albertoruiz/hmatrix/blob/master/INSTALL.md#windows > > > > > > -- Dan Burton > > > > > > > On Thu, Jul 27, 2017 at 9:02 AM, Yotam Ohad wrote: > > > > > Hi cafe, > > > > > I have a very annoying problem with hmatrix. I have a project which depends on it. I can use `stack build` with no errors but when I try to load it to GHCi(`stack ghci`) I get the following error: > > > > > sh-4.3$ stack ghci > > > > > [0mApple-0.1.0.0: configure (lib) [0m > > > > > [0mConfiguring Apple-0.1.0.0... [0m > > > > > [0mApple-0.1.0.0: initial-build-steps (lib) [0m > > > > > [0mConfiguring GHCi with the following packages: Apple [0m > > > > > GHCi, version 8.0.2: http://www.haskell.org/ghc/  :? for help > > > > > ghc.EXE: addDLL: libblas.dll (Win32 error 126): The specified module could not be found. > > > > > ghc.EXE: Could not load `libblas.dll'. Reason: addDLL: could not load DLL > > > > > > > > > > ghc.EXE: addDLL: liblapack.dll (Win32 error 126): The specified module could not be found. > > > > > ghc.EXE: Could not load `liblapack.dll'. Reason: addDLL: could not load DLL > > > > > > > > > > ghc.EXE: C:\Users\Yotam\Apple\.stack-work\install\ebd7be2b\lib\x86_64-windows-ghc-8.0.2\hmatrix-0.18.0.0-IA7RzrKn1o84vo5PLhGcwQ\HShmatrix-0.18.0.0-IA7RzrKn1o84vo5PLhGcwQ.o: unknown symbol `dgesvd_' > > > > > > > > > > ghc.EXE: unable to load package `hmatrix-0.18.0.0' > > > > > > > > > > This is really bizarre, and could not find something online to help me fix this. > > > > > I'm using stack 1.5.0 with ghc 8.0.2 > > > > > > > > > > On a side note, I've seen some discussions about why the C libraries can't be added automatically but did not understand most of it, if someone can explain it would be highly appreciated. > > > > > > > > > > Yotam > > > > > > > > > > > > > > > > > > > > _______________________________________________ > > > > > 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 yotam2206 at gmail.com Sat Jul 29 10:30:57 2017 From: yotam2206 at gmail.com (Yotam Ohad) Date: Sat, 29 Jul 2017 10:30:57 +0000 Subject: [Haskell-cafe] Damn you hmatrix In-Reply-To: <31056191-e1d7-48b2-b83e-8c954379aa0b@Spark> References: <31056191-e1d7-48b2-b83e-8c954379aa0b@Spark> Message-ID: Could you explain in more details? I've searched through the files (both on the msys folder and OpenBlas folder) but could not find a file called libgfortran/libgfortran-3 ‫בתאריך שבת, 29 ביולי 2017 ב-11:14 מאת <‪bruno at ruomad.net‬‏>:‬ > Just rename/copy/link libgfortran-3 to libgfortran > I solved the same problem this way > > On 28 Jul 2017, 12:32 +0200, Yotam Ohad , wrote: > > I did not see this guide, but even when I follow the instruction when I > try to install hmatrix as in the last step of the guide and get a /missing > C library: libgfortran-3. > All the actions I described in the first email have resulted in the same > results. > > Yotam > > ‫בתאריך יום ה׳, 27 ביולי 2017 ב-22:31 מאת ‪Dan Burton‬‏ <‪ > danburton.email at gmail.com‬‏>:‬ > >> Have you seen the instructions here? >> >> https://github.com/albertoruiz/hmatrix/blob/master/INSTALL.md#windows >> >> -- Dan Burton >> >> On Thu, Jul 27, 2017 at 9:02 AM, Yotam Ohad wrote: >> >>> Hi cafe, >>> I have a very annoying problem with hmatrix. I have a project which >>> depends on it. I can use `stack build` with no errors but when I try to >>> load it to GHCi(`stack ghci`) I get the following error: >>> sh-4.3$ stack ghci >>> [0mApple-0.1.0.0: configure (lib) [0m >>> [0mConfiguring Apple-0.1.0.0... [0m >>> [0mApple-0.1.0.0: initial-build-steps (lib) [0m >>> [0mConfiguring GHCi with the following packages: Apple [0m >>> GHCi, version 8.0.2: http://www.haskell.org/ghc/ :? for help >>> ghc.EXE: addDLL: libblas.dll (Win32 error 126): The specified module >>> could not be found. >>> ghc.EXE: Could not load `libblas.dll'. Reason: addDLL: could not load DLL >>> >>> ghc.EXE: addDLL: liblapack.dll (Win32 error 126): The specified module >>> could not be found. >>> ghc.EXE: Could not load `liblapack.dll'. Reason: addDLL: could not load >>> DLL >>> >>> ghc.EXE: >>> C:\Users\Yotam\Apple\.stack-work\install\ebd7be2b\lib\x86_64-windows-ghc-8.0.2\hmatrix-0.18.0.0-IA7RzrKn1o84vo5PLhGcwQ\HShmatrix-0.18.0.0-IA7RzrKn1o84vo5PLhGcwQ.o: >>> unknown symbol `dgesvd_' >>> >>> ghc.EXE: unable to load package `hmatrix-0.18.0.0' >>> >>> This is really bizarre, and could not find something online to help me >>> fix this. >>> I'm using stack 1.5.0 with ghc 8.0.2 >>> >>> On a side note, I've seen some discussions about why the C libraries >>> can't be added automatically but did not understand most of it, if someone >>> can explain it would be highly appreciated. >>> >>> Yotam >>> >>> >>> >>> _______________________________________________ >>> 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 bruno at ruomad.net Sat Jul 29 10:42:35 2017 From: bruno at ruomad.net (bruno at ruomad.net) Date: Sat, 29 Jul 2017 12:42:35 +0200 Subject: [Haskell-cafe] Damn you hmatrix In-Reply-To: References: <31056191-e1d7-48b2-b83e-8c954379aa0b@Spark> Message-ID: Well in my installation (windows) there is a libgfortran-3.dll in msys2-20150512/mingw64/bin On 29 Jul 2017, 12:31 +0200, Yotam Ohad , wrote: > Could you explain in more details? I've searched through the files (both on the msys folder and OpenBlas folder) but could not find a file called libgfortran/libgfortran-3 > > > ‫בתאריך שבת, 29 ביולי 2017 ב-11:14 מאת <‪bruno at ruomad.net‬‏>:‬ > > > Just rename/copy/link libgfortran-3 to libgfortran > > > I solved the same problem this way > > > > > > On 28 Jul 2017, 12:32 +0200, Yotam Ohad , wrote: > > > > I did not see this guide, but even when I follow the instruction when I try to install hmatrix as in the last step of the guide and get a /missing C library: libgfortran-3. > > > > All the actions I described in the first email have resulted in the same results. > > > > > > > > Yotam > > > > > > > > > ‫בתאריך יום ה׳, 27 ביולי 2017 ב-22:31 מאת ‪Dan Burton‬‏ <‪danburton.email at gmail.com‬‏>:‬ > > > > > > Have you seen the instructions here? > > > > > > > > > > > > https://github.com/albertoruiz/hmatrix/blob/master/INSTALL.md#windows > > > > > > > > > > > > -- Dan Burton > > > > > > > > > > > > > On Thu, Jul 27, 2017 at 9:02 AM, Yotam Ohad wrote: > > > > > > > > Hi cafe, > > > > > > > > I have a very annoying problem with hmatrix. I have a project which depends on it. I can use `stack build` with no errors but when I try to load it to GHCi(`stack ghci`) I get the following error: > > > > > > > > sh-4.3$ stack ghci > > > > > > > > [0mApple-0.1.0.0: configure (lib) [0m > > > > > > > > [0mConfiguring Apple-0.1.0.0... [0m > > > > > > > > [0mApple-0.1.0.0: initial-build-steps (lib) [0m > > > > > > > > [0mConfiguring GHCi with the following packages: Apple [0m > > > > > > > > GHCi, version 8.0.2: http://www.haskell.org/ghc/  :? for help > > > > > > > > ghc.EXE: addDLL: libblas.dll (Win32 error 126): The specified module could not be found. > > > > > > > > ghc.EXE: Could not load `libblas.dll'. Reason: addDLL: could not load DLL > > > > > > > > > > > > > > > > ghc.EXE: addDLL: liblapack.dll (Win32 error 126): The specified module could not be found. > > > > > > > > ghc.EXE: Could not load `liblapack.dll'. Reason: addDLL: could not load DLL > > > > > > > > > > > > > > > > ghc.EXE: C:\Users\Yotam\Apple\.stack-work\install\ebd7be2b\lib\x86_64-windows-ghc-8.0.2\hmatrix-0.18.0.0-IA7RzrKn1o84vo5PLhGcwQ\HShmatrix-0.18.0.0-IA7RzrKn1o84vo5PLhGcwQ.o: unknown symbol `dgesvd_' > > > > > > > > > > > > > > > > ghc.EXE: unable to load package `hmatrix-0.18.0.0' > > > > > > > > > > > > > > > > This is really bizarre, and could not find something online to help me fix this. > > > > > > > > I'm using stack 1.5.0 with ghc 8.0.2 > > > > > > > > > > > > > > > > On a side note, I've seen some discussions about why the C libraries can't be added automatically but did not understand most of it, if someone can explain it would be highly appreciated. > > > > > > > > > > > > > > > > Yotam > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > _______________________________________________ > > > > > > > > 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 tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk Sat Jul 29 12:35:45 2017 From: tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk (Tom Ellis) Date: Sat, 29 Jul 2017 13:35:45 +0100 Subject: [Haskell-cafe] What can be UNPACK'ed? In-Reply-To: References: <20170728134541.GA19583@weber> Message-ID: <20170729123545.GG20262@weber> Thanks, that's helpful info, but what I'm really after is a definitive condition under which fields can be UNPACK'ed. The docs are very vague: https://downloads.haskell.org/~ghc/7.0.2/docs/html/users_guide/pragmas.html On Fri, Jul 28, 2017 at 03:01:02PM +0000, Oliver Charles wrote: > Afaik, you couldn't UNPACK a list in the past because it's a sum type, and > sum types could not be unpacked. That has changed with the latest GHC, so > maybe that now works. > > I'm pretty certain you can't unpack polymorphic fields, and this is why > libraries such as `ad` offer a polymorphic version, and a version > specialized to a particular type: > > http://hackage.haskell.org/package/ad-4.3.3/docs/Numeric-AD-Mode-Forward.html > - polymorphic > http://hackage.haskell.org/package/ad-4.3.3/docs/Numeric-AD-Mode-Forward-Double.html > - specialized to Double and significantly faster > > Does that help? > > On Fri, Jul 28, 2017 at 2:48 PM Tom Ellis < > tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk> wrote: > > > What types can be UNPACK'ed? From my vague understanding of what UNPACK > > does, it can only be types whose size is bounded by a known value, so > > whilst > > > > data Foo = Foo {-# UNPACK #-} !Float {-# UNPACK #-} !Int > > > > is fine, presumably > > > > data Foo = Foo {-# UNPACK #-} ![Float] > > > > is not fine. Or is it? Technically it could be possible to reserve enough > > space in Foo to store either a [] or a (:) Float [Float]. And if that is > > possible could we also UNPACK polymorphic fields? > > > > data Storable a => Foo a = Foo {-# UNPACK #-} a > > > > or > > > > data Foo a where > > Foo :: Storable a => {-# UNPACK #-} a -> Foo a > > > > if either DatatypeContexts worked or my imaginary GADT UNPACK syntax worked > > (I'm not sure if either does). > > > > What are the limits of what we could reasonably get to UNPACK in GHC? From heraldhoi at gmail.com Sun Jul 30 12:51:30 2017 From: heraldhoi at gmail.com (Geraldus) Date: Sun, 30 Jul 2017 12:51:30 +0000 Subject: [Haskell-cafe] [ANNOUNCE] GHC 8.2.1 available In-Reply-To: References: <87bmobrh1b.fsf@ben-laptop.smart-cactus.org> <1501020105.14379.125.camel@jeltsch.info> <87h8xzp9nf.fsf@ben-laptop.smart-cactus.org> <1501120882.2815.104.camel@jeltsch.info> Message-ID: Thank you! чт, 27 июл. 2017 г. в 23:21, Evan Laforge : > Thanks for the reply. I got cabal-install from > https://github.com/haskell/cabal/ and assumed it was the latest > version... but now that I look carefully I see it has a 2.0 branch. I > compiled it and I don't get that confusing "parse error" any more. It > looks like a nicer error message in general too (except still missing > some spaces, specifically "After searching the rest of the dependency > tree exhaustively, these were the goals I've had most trouble > fulfilling: karya, ekgTrying configure anyway."), so that's probably > thanks to the solver improvements in 2.0. > > Since it's apparently just a bug in older cabal-installs I guess I > won't bother trying to find it. > > On Wed, Jul 26, 2017 at 7:01 PM, Wolfgang Jeltsch > wrote: > > Hi! > > > > I ran into the same problem. > > > > Apparently, we need cabal-install 2.0, which has not been released yet. > > A preliminary solution is to use the development version from the 2.0 > > branch. Binary packages can be found at > > > > > http://ppa.launchpad.net/hvr/ghc/ubuntu/pool/main/c/cabal-install-2.0/ , > > > > for example. It is possible to extract the cabal-install executable from > > these packages, so that it can be installed without using some Linux > > distribution package manager. > > > > All the best, > > Wolfgang > > > > Am Mittwoch, den 26.07.2017, 18:45 -0700 schrieb Evan Laforge: > >> This seems like a silly question, but how can we install cabal-install > >> now? The latest hackage version 1.24.0.2 has Cabal (>=1.24.2 && > >> <1.25), but it looks like ghc Cabal is now at 2.*. > >> > >> I ran into this because if I get: > >> > >> % cabal install --only-dependencies > >> Resolving dependencies... > >> cabal: internal error when reading package index: failed to parse > >> .cabal > >> fileThe package index or index cache is probably corrupt. Running > >> cabal update > >> might fix it. > >> > >> It seems to be triggered by having 'ekg' in the deps list, since if I > >> take it out then I get some other errors about packages not liking the > >> new base, which is true. 'ekg' also doesn't like the new base, but > >> "internal error" is not the clearest way to express that :) > >> > >> It's frustrating that cabal-install still doesn't report the parse > >> error, even though the parse function returns one. It just ignores > >> the ParseFailed case. I was going to try fixing it and send a pull > >> request when I ran into the Cabal 2.* problem. > >> > >> On Wed, Jul 26, 2017 at 7:15 AM, Ben Gamari > >> wrote: > >> > > >> > Wolfgang Jeltsch writes: > >> > > >> > > > >> > > Am Samstag, den 22.07.2017, 23:03 -0400 schrieb Ben Gamari: > >> > > > > >> > > > In addition, there are a number of new features, > >> > > > > >> > > > * A new, more type-safe type reflection mechanism > >> > > > > >> > > > * The long-awaited Backpack module system > >> > > > > >> > > > * Deriving strategies to disambiguate between GHC's various > >> > > > instance > >> > > > deriving mechanisms > >> > > > > >> > > > * Unboxed sum types, for efficient unpacked representation of > >> > > > sum > >> > > > data types > >> > > > > >> > > > * Compact regions, allowing better control over garbage > >> > > > collection > >> > > > in the presence of large heaps containing many long-lived > >> > > > objects. > >> > > > > >> > > > * Colorful messages and caret diagnostics for more legible > >> > > > errors > >> > > > > >> > > > A more thorough list of the changes in this release can be found > >> > > > in > >> > > > the release notes, > >> > > > > >> > > > https://haskell.org/ghc/docs/8.2.1/docs/html/users_guide/8.2.1 > >> > > > -notes.html > >> > > It seems that the release notes mention the new type reflection > >> > > mechanism und colorful messages only in the “Highlights” section, > >> > > not in > >> > > the “Full details” section, and that they do not mention the > >> > > Backpack > >> > > module system and unboxed sums at all. > >> > > > >> > Yes, indeed these were oversights. They are fixed in the ghc-8.2 > >> > branch > >> > and I will try to push newly generated documentation shortly. > >> > > >> > Cheers, > >> > > >> > - Ben > >> > > >> > _______________________________________________ > >> > Glasgow-haskell-users mailing list > >> > Glasgow-haskell-users at haskell.org > >> > http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-use > >> > rs > >> > > _______________________________________________ > 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 amindfv at gmail.com Sun Jul 30 21:29:19 2017 From: amindfv at gmail.com (amindfv at gmail.com) Date: Sun, 30 Jul 2017 16:29:19 -0500 Subject: [Haskell-cafe] What can be UNPACK'ed? In-Reply-To: <20170728134541.GA19583@weber> References: <20170728134541.GA19583@weber> Message-ID: > Technically it could be possible to reserve enough > space in Foo to store either a [] or a (:) Float [Float]. What if it's an infinite list? Do you just want to unpack the first cons and not the whole list? Tom From allbery.b at gmail.com Sun Jul 30 20:31:36 2017 From: allbery.b at gmail.com (Brandon Allbery) Date: Sun, 30 Jul 2017 16:31:36 -0400 Subject: [Haskell-cafe] What can be UNPACK'ed? In-Reply-To: References: <20170728134541.GA19583@weber> Message-ID: On Sun, Jul 30, 2017 at 5:29 PM, wrote: > > > Technically it could be possible to reserve enough > > space in Foo to store either a [] or a (:) Float [Float]. > > What if it's an infinite list? Do you just want to unpack the first cons > and not the whole list? Isn't the example exactly the first of those? -- brandon s allbery kf8nh sine nomine associates allbery.b at gmail.com ballbery at sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net -------------- next part -------------- An HTML attachment was scrubbed... URL: From tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk Sun Jul 30 20:32:29 2017 From: tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk (Tom Ellis) Date: Sun, 30 Jul 2017 21:32:29 +0100 Subject: [Haskell-cafe] What can be UNPACK'ed? In-Reply-To: References: <20170728134541.GA19583@weber> Message-ID: <20170730203229.GG22461@weber> On Sun, Jul 30, 2017 at 04:29:19PM -0500, amindfv at gmail.com wrote: > > Technically it could be possible to reserve enough space in Foo to > > store either a [] or a (:) Float [Float]. > > What if it's an infinite list? Do you just want to unpack the first cons > and not the whole list? Yes indeed. That's what I meant by store either a [] or a (:) Float [Float] (And I'm not saying I want to, just that it could be done.) From anthony_clayden at clear.net.nz Sun Jul 30 23:24:16 2017 From: anthony_clayden at clear.net.nz (Anthony Clayden) Date: Mon, 31 Jul 2017 11:24:16 +1200 Subject: [Haskell-cafe] Shout out for Chinese(?) speakers of Haskell Message-ID: <597e6aa0.95.604c.14096@clear.net.nz> Is there a Chinese language(s) equivalent to StackOverflow or reddit or haskell-cafe? I'm asking because someone keeps posting to Trac with beginner/intermediate level questions. They're posting code that doesn't work/doesn't compile, and expecting Trac support to 'fix' it. Clearly they do not speak good English, because they're not explaining what they want the code to do (despite several requests). There have been some comments via Google translate, which isn't well versed in Haskell terminology (no surprise). Their first few tickets had narrative in Chinese characters. Looks like traditional script, so they're maybe a Cantonese speaker; or in Taiwan(?) Thank you AntC From zk65900931 at gmail.com Mon Jul 31 05:15:21 2017 From: zk65900931 at gmail.com (Kai Zhang) Date: Mon, 31 Jul 2017 05:15:21 +0000 Subject: [Haskell-cafe] Problems with Type family and Typeable Message-ID: I got an error when compiling the following codes: {-# LANGUAGE TypeOperators #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE UndecidableInstances #-} import Data.Type.Bool import Data.Type.Equality import Data.Tagged (Tagged(..)) import Data.Typeable type family Elem x xs :: Bool where Elem _ '[] = 'False Elem a (x ': xs) = a == x || Elem a xs elemTag :: forall a s t ts . Proxy s -> Tagged (t ': ts) a -> Bool elemTag _ _ = if typeOf (Proxy :: Proxy (Elem s (t ': ts))) == typeOf (Proxy :: Proxy 'True) then True else False GHC says: • No instance for (Typeable (Data.Type.Equality.EqStar s t || Elem s ts)) arising from a use of ‘typeOf’ • In the first argument of ‘(==)’, namely ‘typeOf (Proxy :: Proxy (Elem s (t : ts)))’ In the expression: typeOf (Proxy :: Proxy (Elem s (t : ts))) == typeOf (Proxy :: Proxy True) In the expression: if typeOf (Proxy :: Proxy (Elem s (t : ts))) == typeOf (Proxy :: Proxy True) then True else False My question: why is ghc unable to deduce that "Data.Type.Equality.EqStar s t || Elem s ts" resolves to "Bool" which should be an instance of Typeable? How to fix this? -------------- next part -------------- An HTML attachment was scrubbed... URL: From lysxia at gmail.com Mon Jul 31 12:41:45 2017 From: lysxia at gmail.com (Li-yao Xia) Date: Mon, 31 Jul 2017 14:41:45 +0200 Subject: [Haskell-cafe] Problems with Type family and Typeable In-Reply-To: References: Message-ID: <60512fb0-2f2e-0a42-a609-cc28c5ae3d8b@gmail.com> Hello, "Data.Type.Equality.EqStar s t || Elem s ts" resolves to True or False, which are values of type Bool. To understand why that constraint can't be solved, think about how such a function is compiled. At run time, types are erased. A "Proxy p" value carries no more information than unit "()", and a "Tagged _ a" value is in fact just an "a" value. So elemTag is compiled to something equivalent to a function of this type, which has no way of performing the comparison you requested since the type-level boolean was erased: -- Original function elemTag :: Proxy s -> Tagged (t ': ts) a -> Bool -- After type erasure elemTag :: () -> a -> Bool As suggested by the type error, you can reify the boolean "Elem s (t ': ts)" by adding a Typeable constraint, which gets compiled to an additional run time argument. elemTag :: forall a s t ts . Typeable (Elem s (t ': ts)) => Proxy s -> Tagged (t ': ts) a -> Bool Li-yao On 07/31/2017 07:15 AM, Kai Zhang wrote: > I got an error when compiling the following codes: > > {-# LANGUAGE TypeOperators #-} > {-# LANGUAGE DataKinds #-} > {-# LANGUAGE TypeFamilies #-} > {-# LANGUAGE ScopedTypeVariables #-} > {-# LANGUAGE UndecidableInstances #-} > > import Data.Type.Bool > import Data.Type.Equality > import Data.Tagged (Tagged(..)) > import Data.Typeable > > type family Elem x xs :: Bool where > Elem _ '[] = 'False > Elem a (x ': xs) = a == x || Elem a xs > > elemTag :: forall a s t ts . Proxy s > -> Tagged (t ': ts) a -> Bool > elemTag _ _ = if typeOf (Proxy :: Proxy (Elem s (t ': ts))) == typeOf > (Proxy :: Proxy 'True) > then True > else False > > GHC says: > > • No instance for (Typeable > (Data.Type.Equality.EqStar s t || Elem s ts)) > arising from a use of ‘typeOf’ > • In the first argument of ‘(==)’, namely > ‘typeOf (Proxy :: Proxy (Elem s (t : ts)))’ > In the expression: > typeOf (Proxy :: Proxy (Elem s (t : ts))) > == typeOf (Proxy :: Proxy True) > In the expression: > if typeOf (Proxy :: Proxy (Elem s (t : ts))) > == typeOf (Proxy :: Proxy True) then > True > else > False > > My question: why is ghc unable to deduce that "Data.Type.Equality.EqStar s > t || Elem s ts" resolves to "Bool" which should be an instance of Typeable? > How to fix 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. From olshanskydr at gmail.com Mon Jul 31 13:15:49 2017 From: olshanskydr at gmail.com (Dmitry Olshansky) Date: Mon, 31 Jul 2017 16:15:49 +0300 Subject: [Haskell-cafe] Problems with Type family and Typeable In-Reply-To: <60512fb0-2f2e-0a42-a609-cc28c5ae3d8b@gmail.com> References: <60512fb0-2f2e-0a42-a609-cc28c5ae3d8b@gmail.com> Message-ID: Additionally, as I understand now, you will have better compile-time performance if write type Elem x xs = Elem' 'False x xs type family Elem' (b::Bool) x xs :: Bool where Elem' 'True _ _ = 'True Elem' 'False a (x ': xs) = Elem' (a == x) a xs Elem' 'False _ '[] = 'False All type calculation is not enough lazy! 2017-07-31 15:41 GMT+03:00 Li-yao Xia : > Hello, > > > "Data.Type.Equality.EqStar s t || Elem s ts" resolves to True or False, > which are values of type Bool. > To understand why that constraint can't be solved, think about how such a > function is compiled. At run time, types are erased. > A "Proxy p" value carries no more information than unit "()", and a > "Tagged _ a" value is in fact just an "a" value. > So elemTag is compiled to something equivalent to a function of this type, > which has no way of performing the comparison you requested since the > type-level boolean was erased: > > -- Original function > elemTag :: Proxy s -> Tagged (t ': ts) a -> Bool > > -- After type erasure > elemTag :: () -> a -> Bool > > As suggested by the type error, you can reify the boolean "Elem s (t ': > ts)" by adding a Typeable constraint, which gets compiled to an additional > run time argument. > > elemTag :: forall a s t ts > . Typeable (Elem s (t ': ts)) > => Proxy s > -> Tagged (t ': ts) a > -> Bool > > > Li-yao > > > > > On 07/31/2017 07:15 AM, Kai Zhang wrote: > >> I got an error when compiling the following codes: >> >> {-# LANGUAGE TypeOperators #-} >> {-# LANGUAGE DataKinds #-} >> {-# LANGUAGE TypeFamilies #-} >> {-# LANGUAGE ScopedTypeVariables #-} >> {-# LANGUAGE UndecidableInstances #-} >> >> import Data.Type.Bool >> import Data.Type.Equality >> import Data.Tagged (Tagged(..)) >> import Data.Typeable >> >> type family Elem x xs :: Bool where >> Elem _ '[] = 'False >> Elem a (x ': xs) = a == x || Elem a xs >> >> elemTag :: forall a s t ts . Proxy s >> -> Tagged (t ': ts) a -> Bool >> elemTag _ _ = if typeOf (Proxy :: Proxy (Elem s (t ': ts))) == typeOf >> (Proxy :: Proxy 'True) >> then True >> else False >> >> GHC says: >> >> • No instance for (Typeable >> (Data.Type.Equality.EqStar s t || Elem s ts)) >> arising from a use of ‘typeOf’ >> • In the first argument of ‘(==)’, namely >> ‘typeOf (Proxy :: Proxy (Elem s (t : ts)))’ >> In the expression: >> typeOf (Proxy :: Proxy (Elem s (t : ts))) >> == typeOf (Proxy :: Proxy True) >> In the expression: >> if typeOf (Proxy :: Proxy (Elem s (t : ts))) >> == typeOf (Proxy :: Proxy True) then >> True >> else >> False >> >> My question: why is ghc unable to deduce that "Data.Type.Equality.EqStar s >> t || Elem s ts" resolves to "Bool" which should be an instance of >> Typeable? >> How to fix 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. >> > > _______________________________________________ > 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 Mon Jul 31 16:10:12 2017 From: olf at aatal-apotheke.de (Olaf Klinke) Date: Mon, 31 Jul 2017 18:10:12 +0200 Subject: [Haskell-cafe] What can be UNPACK'ed? Message-ID: How is UNPACK and BangPatterns related to WHNF? I used to think that unpacking sort of forces the constructors up to the level where the bangs reside. Hence unpacking a tuple makes sense, whereas unpacking a linked list does not save much memory. -- Olaf From zk65900931 at gmail.com Mon Jul 31 17:07:03 2017 From: zk65900931 at gmail.com (Kai Zhang) Date: Mon, 31 Jul 2017 17:07:03 +0000 Subject: [Haskell-cafe] Problems with Type family and Typeable In-Reply-To: <60512fb0-2f2e-0a42-a609-cc28c5ae3d8b@gmail.com> References: <60512fb0-2f2e-0a42-a609-cc28c5ae3d8b@gmail.com> Message-ID: Thanks! Could you elaborate a little more about the Typeable constraint? What argument does it add during runtime? In the beginning I thought this constraint is redundant, as what it claims is always true in this case. If my understanding is correct, the purpose of this constraint is to tell GHC to retain the necessary type annotations in runtime? On Mon, Jul 31, 2017 at 5:41 AM Li-yao Xia wrote: > Hello, > > > "Data.Type.Equality.EqStar s t || Elem s ts" resolves to True or False, > which are values of type Bool. > To understand why that constraint can't be solved, think about how such a > function is compiled. At run time, types are erased. > A "Proxy p" value carries no more information than unit "()", and a > "Tagged _ a" value is in fact just an "a" value. > So elemTag is compiled to something equivalent to a function of this type, > which has no way of performing the comparison you requested since the > type-level boolean was erased: > > -- Original function > elemTag :: Proxy s -> Tagged (t ': ts) a -> Bool > > -- After type erasure > elemTag :: () -> a -> Bool > > As suggested by the type error, you can reify the boolean "Elem s (t ': > ts)" by adding a Typeable constraint, which gets compiled to an additional > run time argument. > > elemTag :: forall a s t ts > . Typeable (Elem s (t ': ts)) > => Proxy s > -> Tagged (t ': ts) a > -> Bool > > > Li-yao > > > > On 07/31/2017 07:15 AM, Kai Zhang wrote: > > I got an error when compiling the following codes: > > > > {-# LANGUAGE TypeOperators #-} > > {-# LANGUAGE DataKinds #-} > > {-# LANGUAGE TypeFamilies #-} > > {-# LANGUAGE ScopedTypeVariables #-} > > {-# LANGUAGE UndecidableInstances #-} > > > > import Data.Type.Bool > > import Data.Type.Equality > > import Data.Tagged (Tagged(..)) > > import Data.Typeable > > > > type family Elem x xs :: Bool where > > Elem _ '[] = 'False > > Elem a (x ': xs) = a == x || Elem a xs > > > > elemTag :: forall a s t ts . Proxy s > > -> Tagged (t ': ts) a -> Bool > > elemTag _ _ = if typeOf (Proxy :: Proxy (Elem s (t ': ts))) == typeOf > > (Proxy :: Proxy 'True) > > then True > > else False > > > > GHC says: > > > > • No instance for (Typeable > > (Data.Type.Equality.EqStar s t || Elem s ts)) > > arising from a use of ‘typeOf’ > > • In the first argument of ‘(==)’, namely > > ‘typeOf (Proxy :: Proxy (Elem s (t : ts)))’ > > In the expression: > > typeOf (Proxy :: Proxy (Elem s (t : ts))) > > == typeOf (Proxy :: Proxy True) > > In the expression: > > if typeOf (Proxy :: Proxy (Elem s (t : ts))) > > == typeOf (Proxy :: Proxy True) then > > True > > else > > False > > > > My question: why is ghc unable to deduce that "Data.Type.Equality.EqStar > s > > t || Elem s ts" resolves to "Bool" which should be an instance of > Typeable? > > How to fix 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 zk65900931 at gmail.com Mon Jul 31 17:13:43 2017 From: zk65900931 at gmail.com (Kai Zhang) Date: Mon, 31 Jul 2017 17:13:43 +0000 Subject: [Haskell-cafe] Problems with Type family and Typeable In-Reply-To: References: <60512fb0-2f2e-0a42-a609-cc28c5ae3d8b@gmail.com> Message-ID: Dmitry, where did you learn this? Is there a blog post that I can read? Thanks! On Mon, Jul 31, 2017 at 6:15 AM Dmitry Olshansky wrote: > Additionally, as I understand now, you will have better compile-time > performance if write > > type Elem x xs = Elem' 'False x xs > > type family Elem' (b::Bool) x xs :: Bool where > Elem' 'True _ _ = 'True > Elem' 'False a (x ': xs) = Elem' (a == x) a xs > Elem' 'False _ '[] = 'False > > All type calculation is not enough lazy! > > 2017-07-31 15:41 GMT+03:00 Li-yao Xia : > >> Hello, >> >> >> "Data.Type.Equality.EqStar s t || Elem s ts" resolves to True or False, >> which are values of type Bool. >> To understand why that constraint can't be solved, think about how such a >> function is compiled. At run time, types are erased. >> A "Proxy p" value carries no more information than unit "()", and a >> "Tagged _ a" value is in fact just an "a" value. >> So elemTag is compiled to something equivalent to a function of this >> type, which has no way of performing the comparison you requested since the >> type-level boolean was erased: >> >> -- Original function >> elemTag :: Proxy s -> Tagged (t ': ts) a -> Bool >> >> -- After type erasure >> elemTag :: () -> a -> Bool >> >> As suggested by the type error, you can reify the boolean "Elem s (t ': >> ts)" by adding a Typeable constraint, which gets compiled to an additional >> run time argument. >> >> elemTag :: forall a s t ts >> . Typeable (Elem s (t ': ts)) >> => Proxy s >> -> Tagged (t ': ts) a >> -> Bool >> >> >> Li-yao >> >> >> >> >> On 07/31/2017 07:15 AM, Kai Zhang wrote: >> >>> I got an error when compiling the following codes: >>> >>> {-# LANGUAGE TypeOperators #-} >>> {-# LANGUAGE DataKinds #-} >>> {-# LANGUAGE TypeFamilies #-} >>> {-# LANGUAGE ScopedTypeVariables #-} >>> {-# LANGUAGE UndecidableInstances #-} >>> >>> import Data.Type.Bool >>> import Data.Type.Equality >>> import Data.Tagged (Tagged(..)) >>> import Data.Typeable >>> >>> type family Elem x xs :: Bool where >>> Elem _ '[] = 'False >>> Elem a (x ': xs) = a == x || Elem a xs >>> >>> elemTag :: forall a s t ts . Proxy s >>> -> Tagged (t ': ts) a -> Bool >>> elemTag _ _ = if typeOf (Proxy :: Proxy (Elem s (t ': ts))) == typeOf >>> (Proxy :: Proxy 'True) >>> then True >>> else False >>> >>> GHC says: >>> >>> • No instance for (Typeable >>> (Data.Type.Equality.EqStar s t || Elem s ts)) >>> arising from a use of ‘typeOf’ >>> • In the first argument of ‘(==)’, namely >>> ‘typeOf (Proxy :: Proxy (Elem s (t : ts)))’ >>> In the expression: >>> typeOf (Proxy :: Proxy (Elem s (t : ts))) >>> == typeOf (Proxy :: Proxy True) >>> In the expression: >>> if typeOf (Proxy :: Proxy (Elem s (t : ts))) >>> == typeOf (Proxy :: Proxy True) then >>> True >>> else >>> False >>> >>> My question: why is ghc unable to deduce that "Data.Type.Equality.EqStar >>> s >>> t || Elem s ts" resolves to "Bool" which should be an instance of >>> Typeable? >>> How to fix 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. >>> >> >> _______________________________________________ >> 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 zk65900931 at gmail.com Mon Jul 31 18:34:18 2017 From: zk65900931 at gmail.com (Kai Zhang) Date: Mon, 31 Jul 2017 18:34:18 +0000 Subject: [Haskell-cafe] Problems with Type family and Typeable In-Reply-To: References: <60512fb0-2f2e-0a42-a609-cc28c5ae3d8b@gmail.com> Message-ID: I think this question was answered here: https://stackoverflow.com/questions/32408110/datakinds-and-type-class-instances On Mon, Jul 31, 2017 at 10:07 AM Kai Zhang wrote: > Thanks! Could you elaborate a little more about the Typeable constraint? > What argument does it add during runtime? In the beginning I thought this > constraint is redundant, as what it claims is always true in this case. If > my understanding is correct, the purpose of this constraint is to tell GHC > to retain the necessary type annotations in runtime? > > > On Mon, Jul 31, 2017 at 5:41 AM Li-yao Xia wrote: > >> Hello, >> >> >> "Data.Type.Equality.EqStar s t || Elem s ts" resolves to True or False, >> which are values of type Bool. >> To understand why that constraint can't be solved, think about how such a >> function is compiled. At run time, types are erased. >> A "Proxy p" value carries no more information than unit "()", and a >> "Tagged _ a" value is in fact just an "a" value. >> So elemTag is compiled to something equivalent to a function of this >> type, which has no way of performing the comparison you requested since the >> type-level boolean was erased: >> >> -- Original function >> elemTag :: Proxy s -> Tagged (t ': ts) a -> Bool >> >> -- After type erasure >> elemTag :: () -> a -> Bool >> >> As suggested by the type error, you can reify the boolean "Elem s (t ': >> ts)" by adding a Typeable constraint, which gets compiled to an additional >> run time argument. >> >> elemTag :: forall a s t ts >> . Typeable (Elem s (t ': ts)) >> => Proxy s >> -> Tagged (t ': ts) a >> -> Bool >> >> >> Li-yao >> >> >> >> On 07/31/2017 07:15 AM, Kai Zhang wrote: >> > I got an error when compiling the following codes: >> > >> > {-# LANGUAGE TypeOperators #-} >> > {-# LANGUAGE DataKinds #-} >> > {-# LANGUAGE TypeFamilies #-} >> > {-# LANGUAGE ScopedTypeVariables #-} >> > {-# LANGUAGE UndecidableInstances #-} >> > >> > import Data.Type.Bool >> > import Data.Type.Equality >> > import Data.Tagged (Tagged(..)) >> > import Data.Typeable >> > >> > type family Elem x xs :: Bool where >> > Elem _ '[] = 'False >> > Elem a (x ': xs) = a == x || Elem a xs >> > >> > elemTag :: forall a s t ts . Proxy s >> > -> Tagged (t ': ts) a -> Bool >> > elemTag _ _ = if typeOf (Proxy :: Proxy (Elem s (t ': ts))) == typeOf >> > (Proxy :: Proxy 'True) >> > then True >> > else False >> > >> > GHC says: >> > >> > • No instance for (Typeable >> > (Data.Type.Equality.EqStar s t || Elem s ts)) >> > arising from a use of ‘typeOf’ >> > • In the first argument of ‘(==)’, namely >> > ‘typeOf (Proxy :: Proxy (Elem s (t : ts)))’ >> > In the expression: >> > typeOf (Proxy :: Proxy (Elem s (t : ts))) >> > == typeOf (Proxy :: Proxy True) >> > In the expression: >> > if typeOf (Proxy :: Proxy (Elem s (t : ts))) >> > == typeOf (Proxy :: Proxy True) then >> > True >> > else >> > False >> > >> > My question: why is ghc unable to deduce that >> "Data.Type.Equality.EqStar s >> > t || Elem s ts" resolves to "Bool" which should be an instance of >> Typeable? >> > How to fix 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 danburton.email at gmail.com Mon Jul 31 21:14:44 2017 From: danburton.email at gmail.com (Dan Burton) Date: Mon, 31 Jul 2017 14:14:44 -0700 Subject: [Haskell-cafe] Many packages blocked on Stackage nightly for GHC 8.2.1 Message-ID: Please be advised that many packages were dropped from the Stackage nightly build plan in order to arrive at a successful build with the new ghc. (Note that this does not affect the build plans for LTS 9.) This is to be expected whenever ghc gets a major version bump. For details, see: https://github.com/fpco/stackage/blob/master/MAINTAINERS.md We have attempted to contact package authors whose packages were dropped. However, comprehensive notification is not fully automated, and there may be many who have not been directly contacted. You can check your section of build-constraints.yaml, as well as stackage.org/nightly, to see which of your packages are currently absent from the build plan. You may restore your packages to the nightly build plan (once they are buildable with ghc 8.2.1) in the same way they were added: by opening a PR, uncommenting your packages in build-constraints.yaml. Thank you for your efforts to keep the Haskell ecosystem up to date. -------------- next part -------------- An HTML attachment was scrubbed... URL: From nick at smallbone.se Mon Jul 31 21:44:20 2017 From: nick at smallbone.se (Nick Smallbone) Date: Mon, 31 Jul 2017 23:44:20 +0200 Subject: [Haskell-cafe] What can be UNPACK'ed? References: <20170728134541.GA19583@weber> <20170729123545.GG20262@weber> Message-ID: <87lgn4cmdn.fsf@smallbone.se> Tom Ellis writes: > Thanks, that's helpful info, but what I'm really after is a definitive > condition under which fields can be UNPACK'ed. The docs are very vague: > > https://downloads.haskell.org/~ghc/7.0.2/docs/html/users_guide/pragmas.html As far as I know, the restrictions for UNPACKing a field are as follows: * The field's type must have only one constructor * The type must not be just a type variable (i.e., the constructor must be known at compile time) * The field must be strict (this is because otherwise, UNPACKing changes the semantics of the data type you are declaring by making it more strict) So, for example, lists cannot be UNPACKed (because they have two constructors, nil and cons). Nor can polymorphic fields (because there may or may not be only one constructor). To apply this to primitive types, you have to know how they are defined. For example, Int can be UNPACKed because it has only one constructor: data Int = I# Int# But Integer cannot be UNPACKed because it has several constructors: data Integer = S# !Int# | Jp# {-# UNPACK #-} !BigNat | Jn# {-# UNPACK #-} !BigNat In practice, most primitive types apart from Integer can be UNPACKed - but to be sure you have to look at the standard library source code (or just pay attention to the compiler warnings). Nick From tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk Mon Jul 31 21:58:45 2017 From: tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk (Tom Ellis) Date: Mon, 31 Jul 2017 22:58:45 +0100 Subject: [Haskell-cafe] What can be UNPACK'ed? In-Reply-To: <87lgn4cmdn.fsf@smallbone.se> References: <20170728134541.GA19583@weber> <20170729123545.GG20262@weber> <87lgn4cmdn.fsf@smallbone.se> Message-ID: <20170731215845.GE26348@weber> On Mon, Jul 31, 2017 at 11:44:20PM +0200, Nick Smallbone wrote: > Tom Ellis writes: > > Thanks, that's helpful info, but what I'm really after is a definitive > > condition under which fields can be UNPACK'ed. The docs are very vague: > > > > https://downloads.haskell.org/~ghc/7.0.2/docs/html/users_guide/pragmas.html > > As far as I know, the restrictions for UNPACKing a field are as follows: Ah, very nice, thanks Nick. > * The field must be strict > (this is because otherwise, UNPACKing changes the semantics of the > data type you are declaring by making it more strict) That makes sense. > * The type must not be just a type variable > (i.e., the constructor must be known at compile time) Eventually I'd like to see if we can relax this condition but first ... > * The field's type must have only one constructor Do you know the rationale for this? It seems like there should be no problem unpacking a constructor tag plus payload, even if the payload size varies, as long as the maximum payload size in known. Tom From allbery.b at gmail.com Mon Jul 31 22:12:28 2017 From: allbery.b at gmail.com (Brandon Allbery) Date: Mon, 31 Jul 2017 18:12:28 -0400 Subject: [Haskell-cafe] What can be UNPACK'ed? In-Reply-To: <20170731215845.GE26348@weber> References: <20170728134541.GA19583@weber> <20170729123545.GG20262@weber> <87lgn4cmdn.fsf@smallbone.se> <20170731215845.GE26348@weber> Message-ID: On Mon, Jul 31, 2017 at 5:58 PM, Tom Ellis < tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk> wrote: > On Mon, Jul 31, 2017 at 11:44:20PM +0200, Nick Smallbone wrote: > > Tom Ellis writes: > > > Thanks, that's helpful info, but what I'm really after is a definitive > > > condition under which fields can be UNPACK'ed. The docs are very > vague: > > > > > > https://downloads.haskell.org/~ghc/7.0.2/docs/html/users_ > guide/pragmas.html > > > > As far as I know, the restrictions for UNPACKing a field are as follows: > > Ah, very nice, thanks Nick. I think this might be in the Commentary somewhere, as I've seen essentially that list. > * The type must not be just a type variable > > (i.e., the constructor must be known at compile time) > > Eventually I'd like to see if we can relax this condition but first ... > > > * The field's type must have only one constructor > > Do you know the rationale for this? It seems like there should be no > problem unpacking a constructor tag plus payload, even if the payload size > varies, as long as the maximum payload size in known. UNPACK means unbox, and the constructor tag is part of the box. I suspect something (gc?) assumes that a constructor tag is always the first thing in a memory chunk, so having a constructor tag unpacked into the middle of something else causes problems (e.g. it will try to gc the middle of the containing memory object). -- 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 lindsey at composition.al Mon Jul 31 23:48:21 2017 From: lindsey at composition.al (Lindsey Kuper) Date: Mon, 31 Jul 2017 16:48:21 -0700 Subject: [Haskell-cafe] DSLDI 2017: Second Call for Talk Proposals Message-ID: ********************************************************************* SECOND CALL FOR TALK PROPOSALS DSLDI 2017 Fifth Workshop on Domain-Specific Language Design and Implementation October 22, 2017 Vancouver, Canada Co-located with SPLASH http://2017.splashcon.org/track/dsldi-2017 https://twitter.com/wsdsldi ********************************************************************* Deadline for talk proposals: 7th of August, 2017 Well-designed and implemented domain-specific languages (DSLs) can achieve both usability and performance benefits over general-purpose programming languages. By raising the level of abstraction and exploiting domain knowledge, DSLs can make programming more accessible, increase programmer productivity, and support domain-specific optimizations. ## Workshop Goal Domain-Specific Language Design and Implementation (DSLDI) is a workshop intended to bring together researchers and practitioners interested in discussing how DSLs should be designed, implemented, supported by tools, and applied in realistic contexts. The focus of the workshop is on all aspects of this process, from soliciting domain knowledge from experts, through the design and implementation of the language, to evaluating whether and how a DSL is successful. More generally, we are interested in continuing to build a community that can drive forward the development of modern DSLs. ## Workshop Format DSLDI is a single-day workshop and will consist of an invited speaker followed by moderated audience discussions structured around a series of short talks. The role of the talks is to facilitate interesting and substantive discussion. Therefore, we welcome and encourage talks that express strong opinions, describe open problems, propose new research directions, and report on early research in progress. Proposed talks should be on topics within DSLDI’s area of interest, which include but are not limited to: * solicitation and representation of domain knowledge * DSL design principles and processes * DSL implementation techniques and language workbenches * domain-specific optimizations * human factors of DSLs * tool support for DSL users * community and educational support for DSL users * applications of DSLs to existing and emerging domains * studies of usability, performance, or other benefits of DSLs * experience reports of DSLs deployed in practice ## Call for Talk Proposals We solicit talk proposals in the form of short abstracts (max. 2 pages). A good talk proposal describes an interesting position, open problem, demonstration, or early achievement. The submissions will be reviewed on relevance and clarity, and used to plan the mostly interactive sessions of the workshop day. Publication of accepted abstracts and slides on the website is voluntary. * Deadline for talk proposals: August 7th, 2017 * Notification: September 11th, 2017 * Workshop: October 22nd, 2017 * Submission website: https://dsldi17.hotcrp.com/ ## Workshop Organization Co-chairs: * Lindsey Kuper (lindsey at composition.al), Intel Labs * Eric Walkingshaw (eric.walkingshaw at oregonstate.edu), Oregon State University Follow us on Twitter at https://twitter.com/wsdsldi Program committee: * Nada Amin (EPFL/University of Cambridge) * Eric Holk (Google) * Gabriele Keller (Data61, CSIRO (formerly NICTA) and UNSW) * Rebekah Leslie-Hurd (Intel Labs) * Chris Martens (NCSU) * Lee Pike (Galois) * Jonathan Ragan-Kelley (UC Berkeley) * Jesús Sánchez Cuadrado (Autonomous University of Madrid) * Vincent St-Amour (Northwestern University) * Philip Wadler (University of Edinburgh) -------------- next part -------------- An HTML attachment was scrubbed... URL: