From ekmett at gmail.com Tue Mar 1 05:58:32 2016 From: ekmett at gmail.com (Edward Kmett) Date: Tue, 1 Mar 2016 00:58:32 -0500 Subject: [Haskell-cafe] Haskell Summer of Code Message-ID: I'm sorry to announce that this year haskell.org was not accepted for the 2016 Google Summer of Code. There has been a lot of turnover over the last 3 years as they have rotated in and out new organizations, including many that have been in the program as long as us, so while this isn't entirely unexpected, it is disheartening. As this comes on the tail of our most successful year in the program, the news was particularly devastating to all involved. We do not expect this to be a permanent condition. Many organizations rotate back in and out of the Summer of Code each year. Operationally, this raises two main concerns: The first is that there will be a rather sharp dip in income for the next year for haskell.org. Last year's GSoC accounted for $9500 worth of income towards managing servers and the like, but we will not receive such a booster shot this year. The second is that we absolutely do not want the infrastructure we have in place around the Summer of Code to fall away. We had 50 mentors register last year! To address both of these concerns, we are exploring running our own self-funded *Haskell Summer of Code *this year*. *In December, we incorporated haskell.org as a 501(c)(3) non-profit. This now enables us to pay for work directly. We should be able to fund at least one slot out of pocket from existing haskell.org funds and fund additional slots with donations. https://wiki.haskell.org/Donate_to_Haskell.org More information will be forthcoming as we work out the details. Please feel free to contact me if you think you can help or if you have any questions or concerns. -Edward Kmett -------------- next part -------------- An HTML attachment was scrubbed... URL: From mikhail.glushenkov at gmail.com Tue Mar 1 07:49:18 2016 From: mikhail.glushenkov at gmail.com (Mikhail Glushenkov) Date: Tue, 1 Mar 2016 08:49:18 +0100 Subject: [Haskell-cafe] Compile times and separate compilation In-Reply-To: <56D496F9.6030801@power.com.pl> References: <56CB7D2C.7010409@htwk-leipzig.de> <56D32CBD.9030802@power.com.pl> <56D496F9.6030801@power.com.pl> Message-ID: Hi, On 29 February 2016 at 20:07, Wojtek Narczy?ski wrote: > > Today I realized I forgot -O2 yesterday, which cabal uses, I guess. Now > cabal does not look that bad. It only uses -O1 by default. From P.Achten at cs.ru.nl Tue Mar 1 08:00:15 2016 From: P.Achten at cs.ru.nl (Peter Achten) Date: Tue, 1 Mar 2016 09:00:15 +0100 Subject: [Haskell-cafe] [TFP 2016] 2nd call for papers Message-ID: <56D54C0F.6070600@cs.ru.nl> ----------------------------- C A L L F O R P A P E R S ----------------------------- ======== TFP 2016 =========== 17th Symposium on Trends in Functional Programming June 8-10, 2016 University of Maryland, College Park Near Washington, DC http://tfp2016.org/ The symposium on Trends in Functional Programming (TFP) is an international forum for researchers with interests in all aspects of functional programming, taking a broad view of current and future trends in the area. It aspires to be a lively environment for presenting the latest research results, and other contributions (see below). Authors of draft papers will be invited to submit revised papers based on the feedback receive at the symposium. A post-symposium refereeing process will then select a subset of these articles for formal publication. TFP 2016 will be the main event of a pair of functional programming events. TFP 2016 will be accompanied by the International Workshop on Trends in Functional Programming in Education (TFPIE), which will take place on June 7nd. == INVITED SPEAKERS == TFP 2016 is pleased to announce keynote talks by the following two invited speakers: * Ronald Garcia, University of British Columbia * Steve Zdancewic, University of Pennsylvania == HISTORY == The TFP symposium is the heir of the successful series of Scottish Functional Programming Workshops. Previous TFP symposia were held in * Edinburgh (Scotland) in 2003; * Munich (Germany) in 2004; * Tallinn (Estonia) in 2005; * Nottingham (UK) in 2006; * New York (USA) in 2007; * Nijmegen (The Netherlands) in 2008; * Komarno (Slovakia) in 2009; * Oklahoma (USA) in 2010; * Madrid (Spain) in 2011; * St. Andrews (UK) in 2012; * Provo (Utah, USA) in 2013; * Soesterberg (The Netherlands) in 2014; * and Inria Sophia-Antipolis (France) in 2015. For further general information about TFP please see the TFP homepage. (http://www.tifp.org/). == SCOPE == The symposium recognizes that new trends may arise through various routes. As part of the Symposium's focus on trends we therefore identify the following five article categories. High-quality articles are solicited in any of these categories: Research Articles: leading-edge, previously unpublished research work Position Articles: on what new trends should or should not be Project Articles: descriptions of recently started new projects Evaluation Articles: what lessons can be drawn from a finished project Overview Articles: summarizing work with respect to a trendy subject Articles must be original and not simultaneously submitted for publication to any other forum. They may consider any aspect of functional programming: theoretical, implementation-oriented, or experience-oriented. Applications of functional programming techniques to other languages are also within the scope of the symposium. Topics suitable for the symposium include, but are not limited to: Functional programming and multicore/manycore computing Functional programming in the cloud High performance functional computing Extra-functional (behavioural) properties of functional programs Dependently typed functional programming Validation and verification of functional programs Debugging and profiling for functional languages Functional programming in different application areas: security, mobility, telecommunications applications, embedded systems, global computing, grids, etc. Interoperability with imperative programming languages Novel memory management techniques Program analysis and transformation techniques Empirical performance studies Abstract/virtual machines and compilers for functional languages (Embedded) domain specific languages New implementation strategies Any new emerging trend in the functional programming area If you are in doubt on whether your article is within the scope of TFP, please contact the TFP 2016 program chair, David Van Horn. == BEST PAPER AWARDS == To reward excellent contributions, TFP awards a prize for the best paper accepted for the formal proceedings. TFP traditionally pays special attention to research students, acknowledging that students are almost by definition part of new subject trends. A student paper is one for which the authors state that the paper is mainly the work of students, the students are listed as first authors, and a student would present the paper. A prize for the best student paper is awarded each year. In both cases, it is the PC of TFP that awards the prize. In case the best paper happens to be a student paper, that paper will then receive both prizes. == SPONSORS == TFP is financially supported by CyberPoint, Galois, Trail of Bits, and the University of Maryland Computer Science Department. == PAPER SUBMISSIONS == Acceptance of articles for presentation at the symposium is based on a lightweight peer review process of extended abstracts (4 to 10 pages in length) or full papers (20 pages). The submission must clearly indicate which category it belongs to: research, position, project, evaluation, or overview paper. It should also indicate which authors are research students, and whether the main author(s) are students. A draft paper for which ALL authors are students will receive additional feedback by one of the PC members shortly after the symposium has taken place. We use EasyChair for the refereeing process. Papers must be submitted at: https://easychair.org/conferences/?conf=tfp2016 Papers must be written in English, and written using the LNCS style. For more information about formatting please consult the Springer LNCS web site: http://www.springer.com/computer/lncs?SGWID=0-164-6-793341-0 == IMPORTANT DATES == Submission of draft papers: April 8, 2016 Notification: April 15, 2016 Registration: May 13, 2016 TFP Symposium: June 8-10, 2016 Student papers feedback: June 14, 2016 Submission for formal review: July 14, 2016 Notification of acceptance: September 14, 2016 Camera ready paper: October 14, 2016 == PROGRAM COMMITTEE == Amal Ahmed Northeastern University (US) Nada Amin ?cole Polytechnique F?d?rale de Lausanne (CH) Kenichi Asai Ochanomizu University (JP) Malgorzata Biernacka University of Wroclaw (PL) Laura Castro University of A Coru?a (ES) Ravi Chugh University of Chicago (US) Silvia Ghilezan University of Novi Sad (SR) Clemens Grelck University of Amsterdam (NL) John Hughes Chalmers University of Technology (SE) Suresh Jagannathan Purdue University (US) Pieter Koopman Radboud University Nijmegen (NL) Geoffrey Mainland Drexel University (US) Chris Martens University of California, Santa Cruz (US) Jay McCarthy University of Massachusetts, Lowell (US) Heather Miller ?cole Polytechnique F?d?rale de Lausanne (CH) Manuel Serrano INRIA, Sophia-Antipolis (FR) Scott Smith Johns Hopkins University (US) ?ric Tanter University of Chile (CL) David Van Horn (Chair) University of Maryland (US) Niki Vazou University of California, San Diego (US) Stephanie Weirich University of Pennsylvania (US) From mainland at drexel.edu Tue Mar 1 22:01:35 2016 From: mainland at drexel.edu (Geoffrey Mainland) Date: Tue, 1 Mar 2016 17:01:35 -0500 Subject: [Haskell-cafe] Haskell 2016: Call for Papers Message-ID: <56D6113F.9000002@drexel.edu> ======================================================================== ACM SIGPLAN CALL FOR SUBMISSIONS Haskell Symposium 2016 Nara, Japan, 22-23 September 2015, directly after ICFP http://www.haskell.org/haskell-symposium/2016 ======================================================================== ** The Haskell Symposium has an early track this year ** ** See the Submission Timetable for details. ** The ACM SIGPLAN Haskell Symposium 2016 will be co-located with the International Conference on Functional Programming (ICFP 2016) in Vancouver, Canada. The Haskell Symposium aims to present original research on Haskell, discuss practical experience and future development of the language, and to promote other forms of denotative programming. Topics of interest include: * Language Design, with a focus on possible extensions and modifications of Haskell as well as critical discussions of the status quo; * Theory, such as formal semantics of the present language or future extensions, type systems, effects, metatheory, and foundations for program analysis and transformation; * Implementations, including program analysis and transformation, static and dynamic compilation for sequential, parallel, and distributed architectures, memory management, as well as foreign function and component interfaces; * Libraries, that demonstrate new ideas or techniques for functional programming in Haskell; * Tools, such as profilers, tracers, debuggers, preprocessors, and testing tools; * Applications, to scientific and symbolic computing, databases, multimedia, telecommunication, the web, and so forth; * Functional Pearls, being elegant and instructive programming examples; * Experience Reports, to document general practice and experience in education, industry, or other contexts. Papers in the latter three categories need not necessarily report original academic research results. For example, they may instead report reusable programming idioms, elegant ways to approach a problem, or practical experience that will be useful to other users, implementors, or researchers. The key criterion for such a paper is that it makes a contribution from which other Haskellers can benefit. It is not enough simply to describe a standard solution to a standard programming problem, or report on experience where you used Haskell in the standard way and achieved the result you were expecting. More advice is available via the Haskell wiki: (http://wiki.haskell.org/HaskellSymposium/ExperienceReports) Regular papers should explain their research contributions in both general and technical terms, identifying what has been accomplished, explaining why it is significant, and relating it to previous work, and to other languages where appropriate. In addition, we solicit proposals for: * System Demonstrations, based on running software rather than novel research results. These proposals should summarize the system capabilities that would be demonstrated. The proposals will be judged on whether the ensuing session is likely to be important and interesting to the Haskell community at large, whether on grounds academic or industrial, theoretical or practical, technical, social or artistic. Please contact the program chair with any questions about the relevance of a proposal. Travel Support: =============== Student attendees with accepted papers can apply for a SIGPLAN PAC grant to help cover travel expenses. PAC also offers other support, such as for child-care expenses during the meeting or for travel costs for companions of SIGPLAN members with physical disabilities, as well as for travel from locations outside of North America and Europe. For details on the PAC program, see its web page (http://pac.sigplan.org). Proceedings: ============ Accepted papers will be included in the ACM Digital Library. Authors must grant ACM publication rights upon acceptance (http://authors.acm.org/main.html). Authors are encouraged to publish auxiliary material with their paper (source code, test data, etc.); they retain copyright of auxiliary material. Accepted proposals for system demonstrations will be posted on the symposium website but not formally published in the proceedings. All accepted papers and proposals will be posted on the conference website one week before the meeting. Publication date: The official publication date of accepted papers is the date the proceedings are made available in the ACM Digital Library. This date may be up to two weeks prior to the first day of the conference. The official publication date affects the deadline for any patent filings related to published work. Submission Details: =================== Submitted papers should be in portable document format (PDF), formatted using the ACM SIGPLAN style guidelines (http://www.acm.org/sigs/sigplan/authorInformation.htm). The text should be in a 9-point font in two columns. The length is restricted to 12 pages, except for "Experience Report" papers, which are restricted to 6 pages. Papers need not fill the page limit---for example, a Functional Pearl may be much shorter than 12 pages. Each paper submission must adhere to SIGPLAN's republication policy, as explained on the web. Demo proposals are limited to 2-page abstracts, in the same ACM format as papers. "Functional Pearls", "Experience Reports", and "Demo Proposals" should be marked as such with those words in the title at time of submission. The paper submission deadline and length limitations are firm. There will be no extensions, and papers violating the length limitations will be summarily rejected. A link to the paper submission system will appear on the Haskell Symposium web site closer to the submission deadline. Submission Timetable: ===================== Early Track Regular Track System Demos ---------------- ------------------- --------------- 1st April Paper Submission 20th May Notification 6th June Abstract Submission 10th June Paper Submission 17th June Resubmission Demo Submission 8th July Notification Notification Notification 31st July Camera ready due Camera ready due Deadlines stated are valid anywhere on earth. The Haskell Symposium uses a two-track submission process so that some papers can gain early feedback. Papers can be submitted to the early track on 1st April. On 20th May, strong papers are accepted outright, and the others will be given their reviews and invited to resubmit. On 17th June, early track papers may be resubmitted and are sent back to the same reviewers. The Haskell Symposium regular track operates as in previous years. Papers accepted via the early and regular tracks are considered of equal value and will not be distinguished in the proceedings. Although all papers may be submitted to the early track, authors of functional pearls and experience reports are particularly encouraged to use this mechanism. The success of these papers depends heavily on the way they are presented, and submitting early will give the program committee a chance to provide feedback and help draw out the key ideas. Program Committee: =================== James Cheney University of Edinburgh Iavor Diatchki Galois David Duke University of Leeds Richard Eisenberg University of Pennsylvania Ken Friis Larsen University of Copenhagen Andy Gill University of Kansas Zhenjiang Hu National Institute of Informatics Ranjit Jhala UC San Diego Yukiyoshi Kameyama University of Tsukuba Geoffrey Mainland (chair) Drexel University Mary Sheeran Chalmers University of Technology David Terei Stanford Niki Vazou UC San Diego Dimitrios Vytiniotis Microsoft Research ===================================================================== From t_gass at gmx.de Wed Mar 2 12:59:58 2016 From: t_gass at gmx.de (Tilmann) Date: Wed, 2 Mar 2016 13:59:58 +0100 Subject: [Haskell-cafe] How do I sort items in a wxhaskell listCtrl? Message-ID: <56D6E3CE.6010908@gmx.de> Hi list, I couldn't find any clues googling and turn to you in the hope that someone might point me in the right direction: I found the function |listCtrlSortItems2| with type |ListCtrl a -> Closure b -> IO Bool| and |closureCreate| (which type is a bit involved..), but I have no idea how to use them.. In the end, I would like to have a listCtrl where clicking on column headers will sort the items and maybe even indicating sorting order with a little arrow. Any help is really appreciated, Tilmann -------------- next part -------------- An HTML attachment was scrubbed... URL: From ongy at ongy.net Wed Mar 2 15:31:36 2016 From: ongy at ongy.net (Markus Ongyerth) Date: Wed, 2 Mar 2016 16:31:36 +0100 Subject: [Haskell-cafe] Take over netlink-hs Message-ID: Hi, I want to take over the netlink package on hackage [1]. In accordance to [2] I want to announce that publicly on this list. I have tried to contact the auther in october 2015, and talked about it on the #haskell irc channel. I was able to reach the current maintainer, he told me that he forgot about it and doesn't know his hackage password anymore. Davean (on IRC) offerden to give me maintainer rights after checking back with Max himself. I didn't hear anything after that, neither have I made any effort in this matter since then. ongy [1] https://hackage.haskell.org/package/netlink [2] https://wiki.haskell.org/Taking_over_a_package -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: From icfp.publicity at googlemail.com Thu Mar 3 07:56:11 2016 From: icfp.publicity at googlemail.com (Lindsey Kuper) Date: Wed, 2 Mar 2016 23:56:11 -0800 Subject: [Haskell-cafe] ICFP 2016 Final Call for Papers Message-ID: ICFP 2016 The 21st ACM SIGPLAN International Conference on Functional Programming http://conf.researchr.org/home/icfp-2016 Final Call for Papers Important dates --------------- Submissions due: Wednesday, March 16 2016, 15:00 (UTC) https://icfp2016.hotcrp.com (now open) Author response: Monday, 2 May, 2016, 15:00 (UTC) - Thursday, 5 May, 2016, 15:00 (UTC) Notification: Friday, 20 May, 2016 Final copy due: TBA Early registration: TBA Conference: Monday, 19 September - Wednesday, 21 September, 2016 Please note ----------- For the sake of lightweight double-blind reviewing, the submission procedure may take a little more time than in previous ICFPs; we recommend that you register your submission as early as possible (you can update your paper until the deadline). Scope ----- ICFP 2016 seeks original papers on the art and science of functional programming. Submissions are invited on all topics from principles to practice, from foundations to features, and from abstraction to application. The scope includes all languages that encourage functional programming, including both purely applicative and imperative languages, as well as languages with objects, concurrency, or parallelism. Topics of interest include (but are not limited to): - Language Design: concurrency, parallelism, and distribution; modules; components and composition; metaprogramming; type systems; interoperability; domain-specific languages; and relations to imperative, object-oriented, or logic programming. - Implementation: abstract machines; virtual machines; interpretation; compilation; compile-time and run-time optimization; garbage collection and memory management; multi-threading; exploiting parallel hardware; interfaces to foreign functions, services, components, or low-level machine resources. - Software-Development Techniques: algorithms and data structures; design patterns; specification; verification; validation; proof assistants; debugging; testing; tracing; profiling. - Foundations: formal semantics; lambda calculus; rewriting; type theory; monads; continuations; control; state; effects; program verification; dependent types. - Analysis and Transformation: control-flow; data-flow; abstract interpretation; partial evaluation; program calculation. - Applications: symbolic computing; formal-methods tools; artificial intelligence; systems programming; distributed-systems and web programming; hardware design; databases; XML processing; scientific and numerical computing; graphical user interfaces; multimedia and 3D graphics programming; scripting; system administration; security. - Education: teaching introductory programming; parallel programming; mathematical proof; algebra. - Functional Pearls: elegant, instructive, and fun essays on functional programming. - Experience Reports: short papers that provide evidence that functional programming really works or describe obstacles that have kept it from working. If you are concerned about the appropriateness of some topic, do not hesitate to contact the program chair. Abbreviated instructions for authors ------------------------------------ - By Wednesday, March 16 2016, 15:00 (UTC), submit a full paper of at most 12 pages (6 pages for an Experience Report), in standard SIGPLAN conference format, including figures but ***excluding bibliography***. The deadlines will be strictly enforced and papers exceeding the page limits will be summarily rejected. ***ICFP 2016 will employ a lightweight double-blind reviewing process.*** To facilitate this, submitted papers must adhere to two rules: 1. ***author names and institutions must be omitted***, and 2. ***references to authors' own related work should be in the third person*** (e.g., not "We build on our previous work ..." but rather "We build on the work of ..."). The purpose of this process is to help the PC and external reviewers come to an initial judgement about the paper without bias, not to make it impossible for them to discover the authors if they were to try. Nothing should be done in the name of anonymity that weakens the submission or makes the job of reviewing the paper more difficult (e.g., important background references should not be omitted or anonymized). In addition, authors should feel free to disseminate their ideas or draft versions of their paper as they normally would. For instance, authors may post drafts of their papers on the web or give talks on their research ideas. We have put together a document answering frequently asked questions that should address many common concerns: http://conf.researchr.org/track/icfp-2016/icfp-2016-papers#Submission-and-Reviewing-FAQ (last updated February 8, 2016). - Authors have the option to attach supplementary material to a submission, on the understanding that reviewers may choose not to look at it. The material should be uploaded at submission time, as a single pdf or a tarball, not via a URL. This supplementary material may or may not be anonymized; if not anonymized, it will only be revealed to reviewers after they have submitted their review of your paper and learned your identity. - Each submission must adhere to SIGPLAN's republication policy, as explained on the web at: http://www.sigplan.org/Resources/Policies/Republication - Authors of resubmitted (but previously rejected) papers have the option to attach an annotated copy of the reviews of their previous submission(s), explaining how they have addressed these previous reviews in the present submission. If a reviewer identifies him/herself as a reviewer of this previous submission and wishes to see how his/her comments have been addressed, the program chair will communicate to this reviewer the annotated copy of his/her previous review. Otherwise, no reviewer will read the annotated copies of the previous reviews. Overall, a submission will be evaluated according to its relevance, correctness, significance, originality, and clarity. It should explain its contributions in both general and technical terms, clearly identifying what has been accomplished, explaining why it is significant, and comparing it with previous work. The technical content should be accessible to a broad audience. Functional Pearls and Experience Reports are separate categories of papers that need not report original research results and must be marked as such at the time of submission. Detailed guidelines on both categories are given below. Presentations will be videotaped and released online if the presenter consents. The proceedings will be freely available for download from the ACM Digital Library from at least one week before the start of the conference until two weeks after the conference. Formatting: Submissions must be in PDF format printable in black and white on US Letter sized paper and interpretable by Ghostscript. Papers must adhere to the standard SIGPLAN conference format: two columns, nine-point font on a ten-point baseline, with columns 20pc (3.33in) wide and 54pc (9in) tall, with a column gutter of 2pc (0.33in). A suitable document template for LaTeX is available at http://www.sigplan.org/Resources/Author/ Submission: Submissions will be accepted at https://icfp2016.hotcrp.com . Improved versions of a paper may be submitted at any point before the submission deadline using the same web interface. Author response: Authors will have a 72-hour period, starting at 15:00 UTC on Monday, 2 May, 2016, to read reviews and respond to them. ACM Author-Izer is a unique service that enables ACM authors to generate and post links on either their home page or institutional repository for visitors to download the definitive version of their articles from the ACM Digital Library at no charge. Downloads through Author-Izer links are captured in official ACM statistics, improving the accuracy of usage and impact measurements. Consistently linking the definitive version of ACM article should reduce user confusion over article versioning. After your article has been published and assigned to your ACM Author Profile page, please visit http://www.acm.org/publications/acm-author-izer-service to learn how to create your links for free downloads from the ACM DL. AUTHORS TAKE NOTE: The official publication date is the date the proceedings are made available in the ACM Digital Library. This date may be up to two weeks prior to the first day of your conference. The official publication date affects the deadline for any patent filings related to published work. Special categories of papers ---------------------------- In addition to research papers, ICFP solicits two kinds of papers that do not require original research contributions: Functional Pearls, which are full papers, and Experience Reports, which are limited to six pages. Authors submitting such papers may wish to consider the following advice. Functional Pearls ================= A Functional Pearl is an elegant essay about something related to functional programming. Examples include, but are not limited to: - a new and thought-provoking way of looking at an old idea - an instructive example of program calculation or proof - a nifty presentation of an old or new data structure - an interesting application of functional programming techniques - a novel use or exposition of functional programming in the classroom While pearls often demonstrate an idea through the development of a short program, there is no requirement or expectation that they do so. Thus, they encompass the notions of theoretical and educational pearls. Functional Pearls are valued as highly and judged as rigorously as ordinary papers, but using somewhat different criteria. In particular, a pearl is not required to report original research, but, it should be concise, instructive, and entertaining. Your pearl is likely to be rejected if your readers get bored, if the material gets too complicated, if too much specialized knowledge is needed, or if the writing is inelegant. The key to writing a good pearl is polishing. A submission you wish to have treated as a pearl must be marked as such on the submission web page, and should contain the words ``Functional Pearl'' somewhere in its title or subtitle. These steps will alert reviewers to use the appropriate evaluation criteria. Pearls will be combined with ordinary papers, however, for the purpose of computing the conference's acceptance rate. Experience Reports ================== The purpose of an Experience Report is to help create a body of published, refereed, citable evidence that functional programming really works ? or to describe what obstacles prevent it from working. Possible topics for an Experience Report include, but are not limited to: - insights gained from real-world projects using functional programming - comparison of functional programming with conventional programming in the context of an industrial project or a university curriculum - project-management, business, or legal issues encountered when using functional programming in a real-world project - curricular issues encountered when using functional programming in education - real-world constraints that created special challenges for an implementation of a functional language or for functional programming in general An Experience Report is distinguished from a normal ICFP paper by its title, by its length, and by the criteria used to evaluate it. - Both in the proceedings and in any citations, the title of each accepted Experience Report must begin with the words ``Experience Report'' followed by a colon. The acceptance rate for Experience Reports will be computed and reported separately from the rate for ordinary papers. - An Experience Report is at most six pages long. Each accepted Experience Report will be presented at the conference, but depending on the number of Experience Reports and regular papers accepted, authors of Experience reports may be asked to give shorter talks. - Because the purpose of Experience Reports is to enable our community to accumulate a body of evidence about the efficacy of functional programming, an acceptable Experience Report need not add to the body of knowledge of the functional-programming community by presenting novel results or conclusions. It is sufficient if the Report states a clear thesis and provides supporting evidence. The thesis must be relevant to ICFP, but it need not be novel. The program committee will accept or reject Experience Reports based on whether they judge the evidence to be convincing. Anecdotal evidence will be acceptable provided it is well argued and the author explains what efforts were made to gather as much evidence as possible. Typically, more convincing evidence is obtained from papers which show how functional programming was used than from papers which only say that functional programming was used. The most convincing evidence often includes comparisons of situations before and after the introduction or discontinuation of functional programming. Evidence drawn from a single person's experience may be sufficient, but more weight will be given to evidence drawn from the experience of groups of people. An Experience Report should be short and to the point: make a claim about how well functional programming worked on your project and why, and produce evidence to substantiate your claim. If functional programming worked for you in the same ways it has worked for others, you need only to summarize the results?the main part of your paper should discuss how well it worked and in what context. Most readers will not want to know all the details of your project and its implementation, but please characterize your project and its context well enough so that readers can judge to what degree your experience is relevant to their own projects. Be especially careful to highlight any unusual aspects of your project. Also keep in mind that specifics about your project are more valuable than generalities about functional programming; for example, it is more valuable to say that your team delivered its software a month ahead of schedule than it is to say that functional programming made your team more productive. If your paper not only describes experience but also presents new technical results, or if your experience refutes cherished beliefs of the functional-programming community, you may be better off submitting it as a full paper, which will be judged by the usual criteria of novelty, originality, and relevance. If you are unsure in which category to submit, the program chair will be happy to help you decide. Organizers ---------- General Co-Chairs: Jacques Garrigue (Nagoya University) Gabriele Keller (University of New South Wales) Program Chair: Eijiro Sumii (Tohoku University) Program Committee: Koen Claessen (Chalmers University of Technology) Joshua Dunfield (University of British Columbia, Canada) Matthew Fluet (Rochester Institute of Technology) Nate Foster (Cornell University) Dan Grossman (University of Washington, USA) Jurriaan Hage (Utrecht University) Roman Leshchinskiy (Standard Chartered Bank) Keisuke Nakano (The University of Electro-Communications) Aleksandar Nanevski (IMDEA Software Institute) Scott Owens (University of Kent) Sungwoo Park (Pohang University of Science and Technology) Amr Sabry (Indiana University) Tom Schrijvers (KU Leuven) Olin Shivers (Northeastern University) Walid Taha (Halmstad University) Dimitrios Vytiniotis (Microsoft Research, Cambridge) David Walker (Princeton University) Nobuko Yoshida (Imperial College London, UK) External Review Committee: See http://conf.researchr.org/committee/icfp-2016/icfp-2016-papers-external-review-committee . From kfollesdal at gmail.com Thu Mar 3 15:04:07 2016 From: kfollesdal at gmail.com (=?utf-8?Q?Kristoffer_F=C3=B8llesdal?=) Date: Thu, 3 Mar 2016 16:04:07 +0100 Subject: [Haskell-cafe] Function that put elements in Left or Right side of Either depending on type Message-ID: <53A78AC8-59C5-4F3E-A7F4-303E0BE3EC87@gmail.com> I want a function fun :: q -> Either a b where q is of type a or b. fun shall work in the following way fun x gives Left x if x :: a fun x gives Right x if x :: b Following is a more precise description of what I want. I have function fun1 and fun2 newtype Vec k b = V [(b,k)] deriving (Eq,Ord,Show) fun1 :: (Num k) => a -> Either a (Vec k a) fun1 = Left fun2 :: (Num k) => Vec k a -> Either a (Vec k a) fun2 = Right that work in the following way {- >>> fun1 6 Left 6 >>> fun2 (V[(6,1)]) Right (V [(6,1)]) -} I want a overloaded function ?fun' such that {- >>> fun 6 Left 6 >>> fun (V[(6,1)]) Right (V[(6,1)]) -} I have tried to use a type class to do this (see code below). But when I try >>> fun 6 I get the following error Could not deduce (Num a0) from the context (Num a, Fun a b v) bound by the inferred type for ?it?: (Num a, Fun a b v) => Either b (v b) at :70:1-5 The type variable ?a0? is ambiguous When checking that ?it? has the inferred type it :: forall a b (v :: * -> *). (Num a, Fun a b v) => Either b (v b) Probable cause: the inferred type is ambiguous Is the someone that have know how I can solve this? Kristoffer ??? CODE ??? {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE FlexibleInstances #-} newtype Vec k b = V [(b,k)] deriving (Eq,Ord,Show) fun1 :: (Num k) => a -> Either a (Vec k a) fun1 = Left fun2 :: (Num k) => Vec k a -> Either a (Vec k a) fun2 = Right class Fun a b v where fun :: a -> Either b (v b) instance (Num k) => Fun t t (Vec k) where fun = fun1 instance (Num k) => Fun (Vec k t) t (Vec k) where fun = fun2 From tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk Thu Mar 3 15:13:40 2016 From: tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk (Tom Ellis) Date: Thu, 3 Mar 2016 15:13:40 +0000 Subject: [Haskell-cafe] Function that put elements in Left or Right side of Either depending on type In-Reply-To: <53A78AC8-59C5-4F3E-A7F4-303E0BE3EC87@gmail.com> References: <53A78AC8-59C5-4F3E-A7F4-303E0BE3EC87@gmail.com> Message-ID: <20160303151339.GQ23479@weber> On Thu, Mar 03, 2016 at 04:04:07PM +0100, Kristoffer F?llesdal wrote: > I want a function fun :: q -> Either a b where q is of type a or b. fun shall work in the following way > > fun x gives Left x if x :: a > fun x gives Right x if x :: b I can't help saying again that, despite this being a fine thing to *want*, Haskell really doesn't do this kind of polymorphism very well. If you pursue this road much further you will end up with 1. a deeper understanding of how Haskell's typeclasses work and why what you are trying to do just doesn't work very well, but 2. no useful code If you want outcome 1 then feel free to keep going. If not I suggest you just use differently named functions for the 'a' and 'Vect k a' cases. In my experience it really is *by far* the simplest solution. Tom From mail at nh2.me Thu Mar 3 17:23:10 2016 From: mail at nh2.me (=?UTF-8?Q?Niklas_Hamb=c3=bcchen?=) Date: Thu, 3 Mar 2016 18:23:10 +0100 Subject: [Haskell-cafe] Order of Map.fromListWith Message-ID: <56D872FE.1070907@nh2.me> Does anybody know why for fromListWith, the arguments to the combining function seem flipped? > import Data.Map > fromListWith (++) [('a',[1]),('a',[2])] fromList [('a',[2,1])] I often use it to group things by some key, e.g. postsByUserId :: Map Int [Int] postsByUserId = fromListWith (++) [ (userId, [postId]) | (userId, postId) <- posts ] and regularly get tricked by the postIds being reversed in the result. This is especially unintuitive to me since: > foldl (++) [] [[1],[2]] [1,2] > foldr (++) [] [[1],[2]] [1,2] Any ideas? From victorsmiller at gmail.com Thu Mar 3 17:26:52 2016 From: victorsmiller at gmail.com (Victor Miller) Date: Thu, 3 Mar 2016 12:26:52 -0500 Subject: [Haskell-cafe] Local mirrors of hackage In-Reply-To: References: Message-ID: Hi John, I just got around to installing the downloaded hackage mirror, and I noticed that its structure is different than the one that I downloaded last June -- in the old one there are files 00-index.cache 00-index.tar and a bunch of subdirectories, one per package. Within each of those is a version subdirectory which contains a cabal file and a tar.gz file of the package files. In the new one there are files 00-checksums.bak 00-checksums.dat 00-index.tar.gz and a directory called package That directory contains directories called package-name-version and a corresponding file called package-name-version.tar.gz one for each package and version My version of cabal 1.22 doesn't understand that. Do I need a new version of cabal, or do I have to process the files somehow? Victor On Wed, Feb 24, 2016 at 4:45 PM, John Wiegley wrote: > >>>>> Victor Miller writes: > > > John, Thanks very much for hackage-mirror. I'm running it now and it > appears > > to be working as advertised. Thanks to everyone else who responded. > > I committed a fix very recently to the 'pipes' branch that you may need, > since > there is one package on Hackage that is missing and thus cannot be > downloaded. > > -- > John Wiegley GPG fingerprint = 4710 CF98 AF9B 327B B80F > http://newartisans.com 60E1 46C4 BD1A 7AC1 4BA2 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From plredmond at gmail.com Thu Mar 3 17:42:18 2016 From: plredmond at gmail.com (Patrick Redmond) Date: Thu, 3 Mar 2016 09:42:18 -0800 Subject: [Haskell-cafe] Order of Map.fromListWith In-Reply-To: <56D872FE.1070907@nh2.me> References: <56D872FE.1070907@nh2.me> Message-ID: It looks like fromListWith is indeed implemented with a left fold over insertWithKey, with the Map as the accumulator. However, in insertWithKey the value-combiner function has type 'k -> a -> k -> a' which means it can combine in either order (it doesn't have to do with the fold or iteration order at all). The docs say: If the key does exist, the function will insert the pair @(key,f key new_value old_value)@. This doesn't really answer the "why" part of your question, but explains why you get [2, 1] instead of the reverse. On Thursday, March 3, 2016, Niklas Hamb?chen wrote: > Does anybody know why for fromListWith, the arguments to the combining > function seem flipped? > > > import Data.Map > > fromListWith (++) [('a',[1]),('a',[2])] > > fromList [('a',[2,1])] > > I often use it to group things by some key, e.g. > > postsByUserId :: Map Int [Int] > postsByUserId = > fromListWith (++) [ (userId, [postId]) | (userId, postId) <- posts ] > > and regularly get tricked by the postIds being reversed in the result. > > This is especially unintuitive to me since: > > > foldl (++) [] [[1],[2]] > [1,2] > > foldr (++) [] [[1],[2]] > [1,2] > > Any ideas? > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From plredmond at gmail.com Thu Mar 3 17:44:14 2016 From: plredmond at gmail.com (Patrick Redmond) Date: Thu, 3 Mar 2016 09:44:14 -0800 Subject: [Haskell-cafe] Order of Map.fromListWith In-Reply-To: References: <56D872FE.1070907@nh2.me> Message-ID: Correction: "the combiner has type 'k -> a -> a -> a'" On Thursday, March 3, 2016, Patrick Redmond wrote: > It looks like fromListWith is indeed implemented with a left fold over > insertWithKey, with the Map as the accumulator. However, in insertWithKey > the value-combiner function has type 'k -> a -> k -> a' which means it can > combine in either order (it doesn't have to do with the fold or iteration > order at all). The docs say: > > If the key does exist, the function will insert the pair @(key,f key new_value old_value)@. > > > This doesn't really answer the "why" part of your question, but explains > why you get [2, 1] instead of the reverse. > > On Thursday, March 3, 2016, Niklas Hamb?chen > wrote: > >> Does anybody know why for fromListWith, the arguments to the combining >> function seem flipped? >> >> > import Data.Map >> > fromListWith (++) [('a',[1]),('a',[2])] >> >> fromList [('a',[2,1])] >> >> I often use it to group things by some key, e.g. >> >> postsByUserId :: Map Int [Int] >> postsByUserId = >> fromListWith (++) [ (userId, [postId]) | (userId, postId) <- posts ] >> >> and regularly get tricked by the postIds being reversed in the result. >> >> This is especially unintuitive to me since: >> >> > foldl (++) [] [[1],[2]] >> [1,2] >> > foldr (++) [] [[1],[2]] >> [1,2] >> >> Any ideas? >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From victorsmiller at gmail.com Thu Mar 3 18:47:29 2016 From: victorsmiller at gmail.com (Victor Miller) Date: Thu, 3 Mar 2016 13:47:29 -0500 Subject: [Haskell-cafe] Local mirrors of hackage In-Reply-To: References: Message-ID: Aha, I figured out the problem. I needed to add the lines remote-repo: myname:file://path-to-hackage remote-repo-cache: cache-file to my ~/.cabal/config Now it works fine. I wish that the instructions were a little less obscure. Victor On Thu, Mar 3, 2016 at 12:26 PM, Victor Miller wrote: > Hi John, I just got around to installing the downloaded hackage mirror, > and I noticed that its structure is different than the one that I > downloaded last June -- in the old one there are files > > 00-index.cache > 00-index.tar > and a bunch of subdirectories, one per package. Within each of those is a > version subdirectory which contains a cabal file and a tar.gz file of the > package files. > > In the new one there are files > 00-checksums.bak > 00-checksums.dat > 00-index.tar.gz > > and a directory called package > > That directory contains directories called package-name-version > and a corresponding file called package-name-version.tar.gz > > one for each package and version > > My version of cabal 1.22 doesn't understand that. Do I need a new version > of cabal, or do I have to process the files somehow? > > Victor > > > On Wed, Feb 24, 2016 at 4:45 PM, John Wiegley > wrote: > >> >>>>> Victor Miller writes: >> >> > John, Thanks very much for hackage-mirror. I'm running it now and it >> appears >> > to be working as advertised. Thanks to everyone else who responded. >> >> I committed a fix very recently to the 'pipes' branch that you may need, >> since >> there is one package on Hackage that is missing and thus cannot be >> downloaded. >> >> -- >> John Wiegley GPG fingerprint = 4710 CF98 AF9B 327B B80F >> http://newartisans.com 60E1 46C4 BD1A 7AC1 4BA2 >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From serg.foo at gmail.com Thu Mar 3 19:33:47 2016 From: serg.foo at gmail.com (Sergey Vinokurov) Date: Thu, 3 Mar 2016 21:33:47 +0200 Subject: [Haskell-cafe] Order of Map.fromListWith In-Reply-To: <56D872FE.1070907@nh2.me> References: <56D872FE.1070907@nh2.me> Message-ID: I am not 100% sure, but it seems to be the right optimization for the case where combining function is (++): prepending singleton lists is a lot cheaper than appending them to the end, in which case you'd get quadratic complexity. Sergey On Thu, Mar 3, 2016 at 7:23 PM, Niklas Hamb?chen wrote: > Does anybody know why for fromListWith, the arguments to the combining > function seem flipped? > > > import Data.Map > > fromListWith (++) [('a',[1]),('a',[2])] > > fromList [('a',[2,1])] > > I often use it to group things by some key, e.g. > > postsByUserId :: Map Int [Int] > postsByUserId = > fromListWith (++) [ (userId, [postId]) | (userId, postId) <- posts ] > > and regularly get tricked by the postIds being reversed in the result. > > This is especially unintuitive to me since: > > > foldl (++) [] [[1],[2]] > [1,2] > > foldr (++) [] [[1],[2]] > [1,2] > > Any ideas? > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe From ok at cs.otago.ac.nz Fri Mar 4 05:19:08 2016 From: ok at cs.otago.ac.nz (Richard A. O'Keefe) Date: Fri, 4 Mar 2016 18:19:08 +1300 Subject: [Haskell-cafe] Function that put elements in Left or Right side of Either depending on type In-Reply-To: <53A78AC8-59C5-4F3E-A7F4-303E0BE3EC87@gmail.com> References: <53A78AC8-59C5-4F3E-A7F4-303E0BE3EC87@gmail.com> Message-ID: On 4/03/16 4:04 am, Kristoffer F?llesdal wrote: > I want a function fun :: q -> Either a b where q is of type a or b. fun shall work in the following way > > fun x gives Left x if x :: a > fun x gives Right x if x :: b What does "fun 0 :: Either Int Int" do? From fumiexcel at gmail.com Fri Mar 4 06:01:29 2016 From: fumiexcel at gmail.com (Fumiaki Kinoshita) Date: Thu, 3 Mar 2016 22:01:29 -0800 Subject: [Haskell-cafe] Function that put elements in Left or Right side of Either depending on type In-Reply-To: <53A78AC8-59C5-4F3E-A7F4-303E0BE3EC87@gmail.com> References: <53A78AC8-59C5-4F3E-A7F4-303E0BE3EC87@gmail.com> Message-ID: You can use close type families to do the trick. Here's an example: {-# LANGUAGE ScopedTypeVariables, Rank2Types, DataKinds, TypeFamilies, PolyKinds, FlexibleContexts, MultiParamTypeClasses, FlexibleInstances #-} import Data.Proxy class ToEither a b k where type TheType a b k :: * toEither :: proxy k -> TheType a b k -> Either a b instance ToEither a b "Left" where type TheType a b "Left" = a toEither _ = Left instance ToEither a b "Right" where type TheType a b "Right" = b toEither _ = Right type family Select a b r where Select a a r = "ambiguous" Select a b a = "Left" Select a b b = "Right" Select x y z = "unknown" fun :: forall a b r. (ToEither a b (Select a b r), r ~ TheType a b (Select a b r)) => r -> Either a b fun = toEither (Proxy :: Proxy (Select a b r)) Note that fun doesn't work well without explicit type signatures. 2016-03-03 7:04 GMT-08:00 Kristoffer F?llesdal : > I want a function fun :: q -> Either a b where q is of type a or b. fun > shall work in the following way > > fun x gives Left x if x :: a > fun x gives Right x if x :: b > > Following is a more precise description of what I want. I have function > fun1 and fun2 > > newtype Vec k b = V [(b,k)] deriving (Eq,Ord,Show) > > fun1 :: (Num k) => a -> Either a (Vec k a) > fun1 = Left > > fun2 :: (Num k) => Vec k a -> Either a (Vec k a) > fun2 = Right > > that work in the following way > > {- > >>> fun1 6 > Left 6 > > >>> fun2 (V[(6,1)]) > Right (V [(6,1)]) > -} > > I want a overloaded function ?fun' such that > > {- > >>> fun 6 > Left 6 > > >>> fun (V[(6,1)]) > Right (V[(6,1)]) > -} > > I have tried to use a type class to do this (see code below). But when I > try > >>> fun 6 > > I get the following error > > Could not deduce (Num a0) > from the context (Num a, Fun a b v) > bound by the inferred type for ?it?: > (Num a, Fun a b v) => Either b (v b) > at :70:1-5 > The type variable ?a0? is ambiguous > When checking that ?it? has the inferred type > it :: forall a b (v :: * -> *). > (Num a, Fun a b v) => > Either b (v b) > Probable cause: the inferred type is ambiguous > > Is the someone that have know how I can solve this? > > Kristoffer > > ??? CODE ??? > > {-# LANGUAGE MultiParamTypeClasses #-} > {-# LANGUAGE FlexibleInstances #-} > > newtype Vec k b = V [(b,k)] deriving (Eq,Ord,Show) > > fun1 :: (Num k) => a -> Either a (Vec k a) > fun1 = Left > > fun2 :: (Num k) => Vec k a -> Either a (Vec k a) > fun2 = Right > > class Fun a b v where > fun :: a -> Either b (v b) > > instance (Num k) => Fun t t (Vec k) where > fun = fun1 > > instance (Num k) => Fun (Vec k t) t (Vec k) where > fun = fun2 > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From gracjanpolak at gmail.com Fri Mar 4 14:49:36 2016 From: gracjanpolak at gmail.com (Gracjan Polak) Date: Fri, 4 Mar 2016 15:49:36 +0100 Subject: [Haskell-cafe] Month in Haskell Mode February 2016 Message-ID: Welcome Haskell Mode users, Haskell Mode progress report for February 2016. For previous issue see January 2015 . Reddit discussion . What is Haskell Mode? Haskell Mode is an umbrella project for multiple Emacs tools for efficient Haskell development. Haskell Mode is an open source project developed by a group of volunteers constantly looking for contributions. For more information how to help see https://github.com/haskell/haskell-mode. Important developments Fontification received improvements so that it closer follows Haskell lexical rules. It was necessary to change to syntax-propertize-function available only starting with Emacs 24. There was already an improvement to how modules are shown: We also have a Twitter account: @HaskellMode . Follow us! Issues closed in February - Disable Indentation #90 - Break point highlighting #127 - Type query from up to date file information #185 - haskell-stylish-on-save with Yasnippet + ghc-mod sometimes removes import list #256 - haskell-indentation mode can't parse -XDoAndIfThenElse syntax #321 - haskell-indentation mode sometimes can't parse multiline string literals #324 - Compatibility with column-enforce-mode and long literate (latex-style) comments #331 - haskell-debug parse error #399 - Use preprocessor highlighting from cc-mode #521 - haskell-mode-contextual-space called on zero length identifier #572 - In 12.34e-56 (a single number) both . and - are colorized as operators #628 - haskell-doc-mode is not asynchronous wrt ghci process, unlike eldoc-mode #649 - Fix haskell-customize #667 - Use easy-mmode-defmap to define all keymaps #669 - Multi line string editing #727 - Implement backward-sexp #759 - haskell-stylish-on-save causes double saving #788 - haskell-mode becomes unresponsive when adding a language pragma #820 - Use flycheck to manage error and warning overlays #821 - [Discussion] Separation of concerns #836 - [Discussion] Perhaps tag a release? Monthly releases? #842 - Split up gifcasts.el and connect dependency to specific gifs in Makefile #848 - Can't press enter in haskell interactive mode #876 - haskell-process-load-or-reload and haskell-interactive-switch-back #955 - Font lock should support mixed Bird and Latex style literate Haskell sources #1038 - Use syntax-propertize-function #1039 - Highlight errors inside string literals #1040 - Default indentation mode ought to support and use Johan Tibell's style by default #1042 - Support spaces in project paths for haskell-process-load-file or haskell-process-load-or-reload with errors in source file #1107 - haskell-process-path-* now allowed to be lists #1112 - haskell-font-lock-symbols no longer works #1120 - Indenting data types seems broken and not configurable #1125 - Error: defcustom for ?haskell-indent-spaces? fails to specify type #1126 - Reconsider word breaks for haskell-cabal-mode #1146 - haskell-forward-sexp should signal scan-error at the end of list like forward-sexp #1148 - Syntax highlighting is broken for quasiquoted code #1155 - Font lock module qualification differently #1157 - HTML manual Retina resolution animated gifs #1160 - Completion function hangs in REPL in multi-line editing mode #1173 - [Discussion] Interactive mode improvements #1176 - Fontification is too inefficient #1177 Pull requests merged in February - Use syntax-propertize-function #1050 - Require at least Emacs 24.1 #1055 - Define haskell-package struct's slots #1083 - Detect comma style #1099 - Cleanup haskell-compat.el #1103 - Ignore stack and cabal files from hasktags #1118 - Remove suggested imports completely #1121 - Support spaces in project directories #1123 - Use condition-case-unless-debug #1124 - Fontify True/False in cabal mode #1127 - Fix snapshot build #1128 - Add indentation tests for constructor and deriving #1129 - Align data declaration contructors in indentation #1130 - Remove haskell-package.el #1132 - Docstrings and documentation for haskell-process-path-*. #1135 - Add front-sticky property to read-only text in REPL #1136 - Stylish haskell after save #1137 - Make all define-key calls use kbd #1139 - Use haskell-interactive-switch in process-load #1140 - Revert "Stylish haskell after save" #1142 - Make keymap definition more consistent #1143 - Remove some outdated code #1144 - Fix #1146 by treating . as punctuation #1149 - Add test for forward-sexp-function #1151 - Better string animation #1152 - Properly find begin of a quasiquote #1156 - Implement backward case in haskell-forward-sexp #1158 - Improve font-lock #1159 - HTML manual fixup machinery #1161 - Deriving indentatation test #1162 - Make RET in REPL create new prompt with blank input #1163 - Revert "Remove suggested imports completely" #1165 - Fix haskell-hoogle to work with buffer local var #1167 - Support simple completions in non-interactive context. Support keyword completions #1172 Contributors active in February Arthur Fayzrakhmanov (????? ????????????), Chris Done, Christoph Ruegge, Daniel Bergey, Daniel Selinger, Fice T, Gracjan Polak, Kamil Dworakowski, Karl Smeltzer, Mike Sperber, Sergey Vinokurov, issue-dispenser, mrBliss Contributing Haskell Mode needs volunteers like any other open source project. For more information see: https://github.com/haskell/haskell-mode/wiki Also drop by our IRC channel: #haskell-emacs at irc.freenode.net. Thanks! -------------- next part -------------- An HTML attachment was scrubbed... URL: From johannes.waldmann at htwk-leipzig.de Fri Mar 4 14:53:36 2016 From: johannes.waldmann at htwk-leipzig.de (Johannes Waldmann) Date: Fri, 4 Mar 2016 15:53:36 +0100 Subject: [Haskell-cafe] HasCallStack - runtime costs? Message-ID: <56D9A170.7070908@htwk-leipzig.de> Dear Cafe, the new (8.*) call stack feature https://downloads.haskell.org/~ghc/8.0.1-rc2/docs/html/users_guide/glasgow_exts.html#hascallstack is certainly nice for debugging during development. But how costly is it at runtime? I notice a 5 percent slowdown. That's not a problem if there's an easy way to switch this off for production (without changing the code). Related: how to make code that uses it, compile with older ghcs that don't have it. I made this hack: do not import GHC.Stack.Types, but instead {-# language CPP, MultiParamTypeClasses #-} #if (__GLASGOW_HASKELL__ < 710) {-# language NullaryTypeClasses #-} #endif module Stack ( HasCallStack ) where #if (__GLASGOW_HASKELL__ >= 800) import GHC.Stack.Types #else class HasCallStack instance HasCallStack #endif When I compile with 8.rc2, and change ">= 800" to ">= 900", I am getting the 5 percent speedup mentioned above. But does it really do what I hope it does (remove all runtime overhead that call stacks may have)? When I compile with 7.10.3, I am getting 5 .. 10 percent faster again. My code does nothing fancy (w.r.t. types and libraries), it just uses Data.IntMap heavily. And it has some class Semiring s where zero :: s one :: s plus :: HasCallStack => s -> s -> s times :: HasCallStack => s -> s -> s - J.W. From eric at seidel.io Fri Mar 4 16:30:55 2016 From: eric at seidel.io (Eric Seidel) Date: Fri, 04 Mar 2016 08:30:55 -0800 Subject: [Haskell-cafe] HasCallStack - runtime costs? In-Reply-To: <56D9A170.7070908@htwk-leipzig.de> References: <56D9A170.7070908@htwk-leipzig.de> Message-ID: <1457109055.4025540.539705690.74D753C4@webmail.messagingengine.com> On Fri, Mar 4, 2016, at 06:53, Johannes Waldmann wrote: > Dear Cafe, > > the new (8.*) call stack feature > https://downloads.haskell.org/~ghc/8.0.1-rc2/docs/html/users_guide/glasgow_exts.html#hascallstack > is certainly nice for debugging during development. > > But how costly is it at runtime? I notice a 5 percent slowdown. HasCallStack is really just a type class with a couple special rules for building dictionaries in GHC's constraint solver. So at runtime each function with a HasCallStack constraint takes an extra CallStack argument. I don't know how to quantify the performance implications beyond that, but you're right that HasCallStack is not free. > That's not a problem if there's an easy way to switch > this off for production (without changing the code). Since HasCallStack is not a feature of the RTS, but actually part of the generated code, there's not really an easy way to disable it without changing the code. As much as I dislike CPP, I think it's the best solution for a toggleable HasCallStack, something like #if DEBUG #define HASCALLSTACK (HasCallStack) #else #define HASCALLSTACK () #endif foo :: HASCALLSTACK => a -> b ought to work. > Related: how to make code that uses it, > compile with older ghcs that don't have it. > > I made this hack: do not import GHC.Stack.Types, but instead > > {-# language CPP, MultiParamTypeClasses #-} > > #if (__GLASGOW_HASKELL__ < 710) > {-# language NullaryTypeClasses #-} > #endif > > module Stack > ( HasCallStack ) > where > > #if (__GLASGOW_HASKELL__ >= 800) > import GHC.Stack.Types > #else > class HasCallStack > instance HasCallStack > #endif This might be a nice addition to the base-compat package. > When I compile with 8.rc2, and change ">= 800" to ">= 900", > I am getting the 5 percent speedup mentioned above. > > But does it really do what I hope it does > (remove all runtime overhead that call stacks may have)? It should remove all the overhead of call stacks for calling functions you wrote. If you import a function with a HasCallStack constraint there's no way to disable the overhead for that function (for good reason, it might use the CallStack!). > When I compile with 7.10.3, I am getting 5 .. 10 percent faster again. > > My code does nothing fancy (w.r.t. types and libraries), > it just uses Data.IntMap heavily. And it has some > > class Semiring s where > zero :: s > one :: s > plus :: HasCallStack => s -> s -> s > times :: HasCallStack => s -> s -> s I'm curious, why do plus and times take a CallStack? I wouldn't expect them to be partial, so it seems like unnecessary overhead. Eric From johannes.waldmann at htwk-leipzig.de Fri Mar 4 17:18:18 2016 From: johannes.waldmann at htwk-leipzig.de (Johannes Waldmann) Date: Fri, 4 Mar 2016 18:18:18 +0100 Subject: [Haskell-cafe] HasCallStack - runtime costs? Message-ID: <56D9C35A.8000600@htwk-leipzig.de> Thanks, Eric. > If you import a function with a HasCallStack constraint > there's no way to disable the overhead But then this means that each library should avoid these constraints? Or not, because this rightly scares away users from calling nontotal functions? > ... with a couple special rules for > building dictionaries in GHC's constraint solver. then activation of these special rules could be a compiler switch? Though it'd probably create a mess with separate compilation/linking. But switching via CPP will do the same. > class Semiring s where > plus :: HasCallStack => s -> s -> s > times :: HasCallStack => s -> s -> s > I'm curious, why do plus and times take a CallStack? because I want to (be able to) debug implementations. simplified example: {-# language ConstrainedClassMethods #-} import GHC.Stack.Types class C a where p :: a -> Int q :: HasCallStack => a -> Int instance C () where p x = error "huh" q x = error "huh" Calling q gives more information: *Main> p () *** Exception: huh CallStack (from HasCallStack): error, called at CS.hs:10:9 in main:Main *Main> q () *** Exception: huh CallStack (from HasCallStack): error, called at CS.hs:11:9 in main:Main q, called at :44:1 in interactive:Ghci1 it, called at :44:1 in interactive:Ghci1 I did not see another way than to change the type of the method in the class. (Which looks terrible of course.) - J. From lists at qseep.net Sat Mar 5 03:50:55 2016 From: lists at qseep.net (Lyle Kopnicky) Date: Fri, 4 Mar 2016 19:50:55 -0800 Subject: [Haskell-cafe] Accuracy of Data.Number.Fixed Message-ID: This does not seem right to me: Prelude Data.Number.Fixed> read "4.00" :: Fixed (EpsDiv10 (EpsDiv10 Eps1)) 4.00 Prelude Data.Number.Fixed> read "4.01" :: Fixed (EpsDiv10 (EpsDiv10 Eps1)) 4.00 Prelude Data.Number.Fixed> read "4.02" :: Fixed (EpsDiv10 (EpsDiv10 Eps1)) 4.03 Prelude Data.Number.Fixed> read "4.03" :: Fixed (EpsDiv10 (EpsDiv10 Eps1)) 4.04 Prelude Data.Number.Fixed> read "4.04" :: Fixed (EpsDiv10 (EpsDiv10 Eps1)) 4.05 Maybe I am misunderstanding the purpose of this library. I guess that "two digits" of precision means that it is accurate within +/- 0.01? I think that this library is meant for doing arbitrary-precision transcendental operations. But it would not be good as a model for something like currency. It's using ratios as an internal representation, and I'm not sure what ratios it's choosing, but I think I'd choose, say, 401/100 for the "4.01" representation. I guess it's picking a slightly smaller factor than that. The non-reversibility of read/show is somewhat disconcerting. I think I prefer the Decimal library for currency. Regards, Lyle -------------- next part -------------- An HTML attachment was scrubbed... URL: From jeffbrown.the at gmail.com Sat Mar 5 08:06:01 2016 From: jeffbrown.the at gmail.com (Jeffrey Brown) Date: Sat, 5 Mar 2016 00:06:01 -0800 Subject: [Haskell-cafe] Digraphs With Text: More flexible than graphs, eager to hear from you Message-ID: This is a demonstration of DWT, a data structure built from and more flexible than graphs. It is powered by the *wonderful* Functional Graph Library. We beseech your involvement! DWT is open-source and actively seeking co-developers. I would happily trade any and all the privilege of determining tasks, teaching haskell or math, learning anything, and receiving obligations. We surely have much knowledge to trade! Even just a "hey why don't you do [this]!" could be precious to me. This transcript makes tiny digressions about what monads make possible. > let g = empty :: Mindmap -- g is now an empty mindmap (which is a kind of graph). > g <- pure $ insStr "frog" g -- This inserts a string into g. > -- "g <- pure $" because we use the IO monad to redefine g. > -- Now g has one thing, the word frog: > v g $ nodes g -- This views every expression in g. (0,"0: frog") > -- The 0 before the comma is a count of how many expressions refer to that expression. None do, because none yet exist. Such contexts offer many possibilities for tracking where you are (the data) and how you got there (also kind of the data, and perhaps enabling a desirable kind of removal of self|redaction). > -- The second 0 is an FGL Node, the address of the string "frog". > -- Let's add more words: > g <- pure $ insStr "moist" g > g <- pure $ insStr "springy" g > -- Now g has three words: > v g $ nodes g (0,"0: frog") (0,"1: moist") (0,"2: springy") > -- Let's indicate that moist and springy are both qualities of frogs: > -- First, we'll create a template for relationships about qualities. > g <- pure $ insTplt "_ is a quality of _" g > v g $ nodes g (0,"0: frog") (0,"1: moist") (0,"2: springy") (0,":3 _ #(is a quality of) _") > -- The template has been inserted at node 3. Its address is preceded by a : to indicate that it is a template, as opposed to the string "_ is a quality of _". (That will seem more natural in the context of how relationships are displayed.) > -- Now we'll use the template at 3 to insert two relationships among the other nodes: > -- We could have added them in a single stage: > g <- pure $ fromRight $ insRel 3 [2,0] g >>= insRel 3 [1,0] > -- insRel 3 [1,0] inserts "moist is a quality of frog". > -- insRel 3 [2,0] inserts "springy is a quality of frog". > -- Both relationships use the template at node 3, and in both the second member is frog, at node 0. > -- Since the template at 3 relates 2 expressions, each list has length two. Templates can have any arity -- for instance, "_ does _ to _" has arity 3. > -- I used the monadic bind operator (>>=) because that way I only need to escape one Either monad (using fromRight) rather than two of them, one containing the other. > -- Inserting those two relationships worked: > v g $ nodes g (2,"0: frog") (1,"1: moist") (1,"2: springy") (2,":3 _ #(is a quality of) _") (0,"4:3 2: springy ##(is a quality of) 0: frog") (0,"5:3 1: moist ##(is a quality of) 0: frog") > -- When showing a relationship, the node (integer) listed first, before the :, is it's address, and the node listed after the : is the address of its template. > -- After the first two, any other node in a relationship is the address of the symbol(s) it appears just left of. > -- Notice that now the frog is in two relationships. One of those relationships involves springy, the other involves moist. > -- The # symbols are better explained later. > -- DWT can encode meta-statements, statements about other statements. As an example, next let's encode that maybe frogs are springy because they use rubber bands. > -- First we should insert a new string and a couple new templates for relationships. > g <- pure $ insTplt "maybe _ because _" g > g <- pure $ insStr "rubber bands" g > g <- pure $ insTplt "_ uses _" g > v g $ nodes g (2,"0: frog") (1,"1: moist") (1,"2: springy") (2,":3 _ #(is a quality of) _") (0,"4:3 2: springy ##(is a quality of) 0: frog") (0,"5:3 1: moist ##(is a quality of) 0: frog") (0,":6 #maybe _ #because _") (0,"7: rubber bands") (0,":8 _ #uses _") > -- Now we can encode the subexpression that frog uses rubber bands. > g <- pure $ fr $ insRel 8 [0,7] g > v g $ nodes g (3,"0: frog") (1,"1: moist") (1,"2: springy") (2,":3 _ #(is a quality of) _") (0,"4:3 2: springy ##(is a quality of) 0: frog") (0,"5:3 1: moist ##(is a quality of) 0: frog") (0,":6 #maybe _ #because _") (1,"7: rubber bands") (1,":8 _ #uses _") (0,"9:8 0: frog ##uses 7: rubber bands") > -- From those elements, we can encode that maybe frogs are springy because they use rubber bands. > g <- pure $ fr $ insRel 6 [4,9] g > v g $ nodes g (3,"0: frog") (1,"1: moist") (1,"2: springy") (2,":3 _ #(is a quality of) _") (1,"4:3 2: springy ##(is a quality of) 0: frog") (0,"5:3 1: moist ##(is a quality of) 0: frog") (1,":6 #maybe _ #because _") (1,"7: rubber bands") (1,":8 _ #uses _") (1,"9:8 0: frog ##uses 7: rubber bands") (0,"10:6 ####maybe 4:3 2: springy ##(is a quality of) 0: frog ####because 9:8 0: frog ##uses 7: rubber bands") At last I can explain the # symbols: They indicate how fast an expression binds. In the last, at node 10, the highest-level|slowest-binding relationship is "maybe _ because _". In the first _ of the maybe-because relationship is another relationship, one that binds faster and hence has fewer # symbols, between springy and frog. The strings "springy", "frog" and "rubber bands" can be thought of as atomic, "binding" even before the first-level relationships bind. This illustrates one of DWT's advantages over graphs. In a graph, an edge cannot be a member of another edge. By contrast, in DWT a relationship can involve other relationships. -- Jeffrey Benjamin Brown -------------- next part -------------- An HTML attachment was scrubbed... URL: From mgsloan at gmail.com Sat Mar 5 08:23:14 2016 From: mgsloan at gmail.com (Michael Sloan) Date: Sat, 5 Mar 2016 00:23:14 -0800 Subject: [Haskell-cafe] HasCallStack - runtime costs? In-Reply-To: <1457109055.4025540.539705690.74D753C4@webmail.messagingengine.com> References: <56D9A170.7070908@htwk-leipzig.de> <1457109055.4025540.539705690.74D753C4@webmail.messagingengine.com> Message-ID: On Fri, Mar 4, 2016 at 8:30 AM, Eric Seidel wrote: > On Fri, Mar 4, 2016, at 06:53, Johannes Waldmann wrote: > > Dear Cafe, > > > > the new (8.*) call stack feature > > > https://downloads.haskell.org/~ghc/8.0.1-rc2/docs/html/users_guide/glasgow_exts.html#hascallstack > > is certainly nice for debugging during development. > > > > But how costly is it at runtime? I notice a 5 percent slowdown. > > HasCallStack is really just a type class with a couple special rules for > building dictionaries in GHC's constraint solver. So at runtime each > function with a HasCallStack constraint takes an extra CallStack > argument. I don't know how to quantify the performance implications > beyond that, but you're right that HasCallStack is not free. Hmm, is it no longer an implicit parameter? I thought the new HasCallStack stuff was just a constraint synonym like type HasCallStack = (?callStack :: CallStack) For the most part the distinction doesn't matter, but it does when it comes to constraints in instance heads. The issue is that constraints are not solved at their callsites. Do we want `HasCallStack` to be able to be present in an instance head, and potentially get a location quite different from the actual use site? I would find this confusing, though sometimes helpful. Implicit parameters are a good match for this callstack stuff, because they have the restriction that they cannot be used as supeclass constraints. Does your work on the callstack stuff (thanks!) introduce backwards compatibility issues? I'm working on a library that will make extensive use of 7.10's implementation of callstacks. > > That's not a problem if there's an easy way to switch > > this off for production (without changing the code). > > Since HasCallStack is not a feature of the RTS, but actually part of the > generated code, there's not really an easy way to disable it without > changing the code. As much as I dislike CPP, I think it's the best > solution for a toggleable HasCallStack, something like > > #if DEBUG > #define HASCALLSTACK (HasCallStack) > #else > #define HASCALLSTACK () > #endif > > foo :: HASCALLSTACK => a -> b > > ought to work. > > > Related: how to make code that uses it, > > compile with older ghcs that don't have it. > > > > I made this hack: do not import GHC.Stack.Types, but instead > > > > {-# language CPP, MultiParamTypeClasses #-} > > > > #if (__GLASGOW_HASKELL__ < 710) > > {-# language NullaryTypeClasses #-} > > #endif > > > > module Stack > > ( HasCallStack ) > > where > > > > #if (__GLASGOW_HASKELL__ >= 800) > > import GHC.Stack.Types > > #else > > class HasCallStack > > instance HasCallStack > > #endif > > This might be a nice addition to the base-compat package. > > > When I compile with 8.rc2, and change ">= 800" to ">= 900", > > I am getting the 5 percent speedup mentioned above. > > > > But does it really do what I hope it does > > (remove all runtime overhead that call stacks may have)? > > It should remove all the overhead of call stacks for calling functions > you wrote. If you import a function with a HasCallStack constraint > there's no way to disable the overhead for that function (for good > reason, it might use the CallStack!). > > > When I compile with 7.10.3, I am getting 5 .. 10 percent faster again. > > > > My code does nothing fancy (w.r.t. types and libraries), > > it just uses Data.IntMap heavily. And it has some > > > > class Semiring s where > > zero :: s > > one :: s > > plus :: HasCallStack => s -> s -> s > > times :: HasCallStack => s -> s -> s > > I'm curious, why do plus and times take a CallStack? I wouldn't expect > them to be partial, so it seems like unnecessary overhead. > > Eric > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From imantc at gmail.com Sat Mar 5 08:26:01 2016 From: imantc at gmail.com (Imants Cekusins) Date: Sat, 5 Mar 2016 09:26:01 +0100 Subject: [Haskell-cafe] Accuracy of Data.Number.Fixed In-Reply-To: References: Message-ID: > I prefer the Decimal library for currency. here is another option to consider: data Cur = Eur | ... data Money = Mint Cur Int | Mtup Cur (Int,Int) precision::Cur -> Int precision Eur = 2 precision _ = 2 ? 10.02 would be: Mint Eur 1002 Mtup Eur (10,2) This adds overhead to computations. However precision and correct currency is guaranteed. -------------- next part -------------- An HTML attachment was scrubbed... URL: From jeffbrown.the at gmail.com Sat Mar 5 11:19:22 2016 From: jeffbrown.the at gmail.com (Jeffrey Brown) Date: Sat, 5 Mar 2016 03:19:22 -0800 Subject: [Haskell-cafe] Digraphs With Text: More flexible than graphs, eager to hear from you In-Reply-To: References: Message-ID: And it's on Github: https://github.com/JeffreyBenjaminBrown/digraphs-with-text On Sat, Mar 5, 2016 at 12:06 AM, Jeffrey Brown wrote: > This is a demonstration of DWT, a data structure built from and more > flexible than graphs. It is powered by the *wonderful* Functional Graph > Library. > > We beseech your involvement! DWT is open-source and actively seeking > co-developers. I would happily trade any and all the privilege of > determining tasks, teaching haskell or math, learning anything, and > receiving obligations. We surely have much knowledge to trade! Even just a > "hey why don't you do [this]!" could be precious to me. > > This transcript makes tiny digressions about what monads make possible. > > > let g = empty :: Mindmap -- g is now an empty mindmap (which is a kind > of graph). > > g <- pure $ insStr "frog" g -- This inserts a string into g. > > -- "g <- pure $" because we use the IO monad to redefine g. > > -- Now g has one thing, the word frog: > > v g $ nodes g -- This views every expression in g. > (0,"0: frog") > > -- The 0 before the comma is a count of how many expressions refer to > that expression. None do, because none yet exist. Such contexts offer many > possibilities for tracking where you are (the data) and how you got there > (also kind of the data, and perhaps enabling a desirable kind of removal of > self|redaction). > > -- The second 0 is an FGL Node, the address of the string "frog". > > -- Let's add more words: > > g <- pure $ insStr "moist" g > > g <- pure $ insStr "springy" g > > -- Now g has three words: > > v g $ nodes g > (0,"0: frog") > (0,"1: moist") > (0,"2: springy") > > -- Let's indicate that moist and springy are both qualities of frogs: > > -- First, we'll create a template for relationships about qualities. > > g <- pure $ insTplt "_ is a quality of _" g > > v g $ nodes g > (0,"0: frog") > (0,"1: moist") > (0,"2: springy") > (0,":3 _ #(is a quality of) _") > > -- The template has been inserted at node 3. Its address is preceded > by a : to indicate that it is a template, as opposed to the string "_ is a > quality of _". (That will seem more natural in the context of how > relationships are displayed.) > > -- Now we'll use the template at 3 to insert two relationships among the > other nodes: > > -- We could have added them in a single stage: > > g <- pure $ fromRight $ insRel 3 [2,0] g >>= insRel 3 [1,0] > > -- insRel 3 [1,0] inserts "moist is a quality of frog". > > -- insRel 3 [2,0] inserts "springy is a quality of frog". > > -- Both relationships use the template at node 3, and in both the > second member is frog, at node 0. > > -- Since the template at 3 relates 2 expressions, each list has length > two. Templates can have any arity -- for instance, "_ does _ to _" has > arity 3. > > -- I used the monadic bind operator (>>=) because that way I only need > to escape one Either monad (using fromRight) rather than two of them, one > containing the other. > > -- Inserting those two relationships worked: > > v g $ nodes g > (2,"0: frog") > (1,"1: moist") > (1,"2: springy") > (2,":3 _ #(is a quality of) _") > (0,"4:3 2: springy ##(is a quality of) 0: frog") > (0,"5:3 1: moist ##(is a quality of) 0: frog") > > -- When showing a relationship, the node (integer) listed first, > before the :, is it's address, and the node listed after the : is the > address of its template. > > -- After the first two, any other node in a relationship is the > address of the symbol(s) it appears just left of. > > -- Notice that now the frog is in two relationships. One of those > relationships involves springy, the other involves moist. > > -- The # symbols are better explained later. > > -- DWT can encode meta-statements, statements about other statements. As > an example, next let's encode that maybe frogs are springy because they use > rubber bands. > > -- First we should insert a new string and a couple new templates for > relationships. > > g <- pure $ insTplt "maybe _ because _" g > > g <- pure $ insStr "rubber bands" g > > g <- pure $ insTplt "_ uses _" g > > v g $ nodes g > (2,"0: frog") > (1,"1: moist") > (1,"2: springy") > (2,":3 _ #(is a quality of) _") > (0,"4:3 2: springy ##(is a quality of) 0: frog") > (0,"5:3 1: moist ##(is a quality of) 0: frog") > (0,":6 #maybe _ #because _") > (0,"7: rubber bands") > (0,":8 _ #uses _") > > -- Now we can encode the subexpression that frog uses rubber bands. > > g <- pure $ fr $ insRel 8 [0,7] g > > v g $ nodes g > (3,"0: frog") > (1,"1: moist") > (1,"2: springy") > (2,":3 _ #(is a quality of) _") > (0,"4:3 2: springy ##(is a quality of) 0: frog") > (0,"5:3 1: moist ##(is a quality of) 0: frog") > (0,":6 #maybe _ #because _") > (1,"7: rubber bands") > (1,":8 _ #uses _") > (0,"9:8 0: frog ##uses 7: rubber bands") > > -- From those elements, we can encode that maybe frogs are springy > because they use rubber bands. > > g <- pure $ fr $ insRel 6 [4,9] g > > v g $ nodes g > (3,"0: frog") > (1,"1: moist") > (1,"2: springy") > (2,":3 _ #(is a quality of) _") > (1,"4:3 2: springy ##(is a quality of) 0: frog") > (0,"5:3 1: moist ##(is a quality of) 0: frog") > (1,":6 #maybe _ #because _") > (1,"7: rubber bands") > (1,":8 _ #uses _") > (1,"9:8 0: frog ##uses 7: rubber bands") > (0,"10:6 ####maybe 4:3 2: springy ##(is a quality of) 0: frog ####because > 9:8 0: frog ##uses 7: rubber bands") > > At last I can explain the # symbols: They indicate how fast an expression > binds. In the last, at node 10, the highest-level|slowest-binding > relationship is "maybe _ because _". In the first _ of the maybe-because > relationship is another relationship, one that binds faster and hence has > fewer # symbols, between springy and frog. The strings "springy", "frog" > and "rubber bands" can be thought of as atomic, "binding" even before the > first-level relationships bind. > > This illustrates one of DWT's advantages over graphs. In a graph, an edge > cannot be a member of another edge. By contrast, in DWT a relationship can > involve other relationships. > > > -- > Jeffrey Benjamin Brown > -- Jeffrey Benjamin Brown -------------- next part -------------- An HTML attachment was scrubbed... URL: From mgsloan at gmail.com Sat Mar 5 11:46:18 2016 From: mgsloan at gmail.com (Michael Sloan) Date: Sat, 5 Mar 2016 03:46:18 -0800 Subject: [Haskell-cafe] HasCallStack - runtime costs? In-Reply-To: References: <56D9A170.7070908@htwk-leipzig.de> <1457109055.4025540.539705690.74D753C4@webmail.messagingengine.com> Message-ID: On Sat, Mar 5, 2016 at 12:23 AM, Michael Sloan wrote: > On Fri, Mar 4, 2016 at 8:30 AM, Eric Seidel wrote: > >> On Fri, Mar 4, 2016, at 06:53, Johannes Waldmann wrote: >> > Dear Cafe, >> > >> > the new (8.*) call stack feature >> > >> https://downloads.haskell.org/~ghc/8.0.1-rc2/docs/html/users_guide/glasgow_exts.html#hascallstack >> > is certainly nice for debugging during development. >> > >> > But how costly is it at runtime? I notice a 5 percent slowdown. >> >> HasCallStack is really just a type class with a couple special rules for >> building dictionaries in GHC's constraint solver. So at runtime each >> function with a HasCallStack constraint takes an extra CallStack >> argument. I don't know how to quantify the performance implications >> beyond that, but you're right that HasCallStack is not free. > > > Hmm, is it no longer an implicit parameter? I thought the new > HasCallStack stuff was just a constraint synonym like > > type HasCallStack = (?callStack :: CallStack) > > For the most part the distinction doesn't matter, but it does when it > comes to constraints in instance heads. The issue is that constraints > are not solved at their callsites. Do we want `HasCallStack` to be > able to be present in an instance head, and potentially get a location > quite different from the actual use site? I would find this confusing, > though sometimes helpful. > I realized I could answer my own questions simply by trying it out on GHC 8 RC2! instance HasCallStack => Read Void where read _ = prettyStack callStack ++ "\nCan't possibly read Void!" does indeed produce the error ? Illegal implicit parameter ??callStack::CallStack? ? In the context: HasCallStack While checking an instance declaration In the instance declaration for ?Read Void? Implicit parameters are a good match for this callstack stuff, because > they have the restriction that they cannot be used as supeclass > constraints. > > Does your work on the callstack stuff (thanks!) introduce backwards > compatibility issues? I'm working on a library that will make extensive > use of 7.10's implementation of callstacks. > I tried it out, and it does have compatibility with the implicit parameter still! Good stuff. However, I was making use of a potentially unintentional aspect of the 7.10 API, which is that `getCallStack` can be used in a record update of `CallStack`. This is useful for annotating callstacks with helpful debugging info, like the arguments used for an invocation. The existing format for the message works quite well for this, since it's just the function name. So, appending parameters results in "fn a1 a2 a3", etc. Is it too late in the GHC release cycle to have add an additional GHC.Stack.Internal module which enables modification of CallStack? I realize that it might be quite intentional that CallStack can't be modified, as that could make it less useful as a source of trustable diagnostic info. How about only exposing access to the top: getCallStackHeadMessage :: CallStack -> Maybe String setCallStackHeadMessage :: String -> CallStack modifyCallStackHeadMessage :: (String -> String) -> CallStack -> CallStack Or, if we're feeling lensy callStackHeadMessage :: Functor f => (String -> f String) -> (CallStack -> f CallStack) Since only the top can be modified, we can trust that the entries of the CallStack are accurate. > >> > That's not a problem if there's an easy way to switch >> > this off for production (without changing the code). >> >> Since HasCallStack is not a feature of the RTS, but actually part of the >> generated code, there's not really an easy way to disable it without >> changing the code. As much as I dislike CPP, I think it's the best >> solution for a toggleable HasCallStack, something like >> >> #if DEBUG >> #define HASCALLSTACK (HasCallStack) >> #else >> #define HASCALLSTACK () >> #endif >> >> foo :: HASCALLSTACK => a -> b >> >> ought to work. >> >> > Related: how to make code that uses it, >> > compile with older ghcs that don't have it. >> > >> > I made this hack: do not import GHC.Stack.Types, but instead >> > >> > {-# language CPP, MultiParamTypeClasses #-} >> > >> > #if (__GLASGOW_HASKELL__ < 710) >> > {-# language NullaryTypeClasses #-} >> > #endif >> > >> > module Stack >> > ( HasCallStack ) >> > where >> > >> > #if (__GLASGOW_HASKELL__ >= 800) >> > import GHC.Stack.Types >> > #else >> > class HasCallStack >> > instance HasCallStack >> > #endif >> >> This might be a nice addition to the base-compat package. >> >> > When I compile with 8.rc2, and change ">= 800" to ">= 900", >> > I am getting the 5 percent speedup mentioned above. >> > >> > But does it really do what I hope it does >> > (remove all runtime overhead that call stacks may have)? >> >> It should remove all the overhead of call stacks for calling functions >> you wrote. If you import a function with a HasCallStack constraint >> there's no way to disable the overhead for that function (for good >> reason, it might use the CallStack!). >> >> > When I compile with 7.10.3, I am getting 5 .. 10 percent faster again. >> > >> > My code does nothing fancy (w.r.t. types and libraries), >> > it just uses Data.IntMap heavily. And it has some >> > >> > class Semiring s where >> > zero :: s >> > one :: s >> > plus :: HasCallStack => s -> s -> s >> > times :: HasCallStack => s -> s -> s >> >> I'm curious, why do plus and times take a CallStack? I wouldn't expect >> them to be partial, so it seems like unnecessary overhead. >> >> Eric >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From hsyl20 at gmail.com Sat Mar 5 13:56:17 2016 From: hsyl20 at gmail.com (Sylvain Henry) Date: Sat, 5 Mar 2016 14:56:17 +0100 Subject: [Haskell-cafe] Reducing boilerplate Message-ID: Hi, To write FFI bindings, I use c-storable-deriving [1] to automatically derive CStorable instances for many data types (the only difference between Storable and CStorable is that CStorable provides default methods for types that have Generic instances): {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DeriveAnyClass #-} ... data X = X { fieldStatus :: Vector 24 Word8 , fieldPadding :: Word8 } deriving (Generic, CStorable) However I also need a Storable instance, hence I have to write (the "c*" methods are provided by CStorable): instance Storable X where peek = cPeek poke = cPoke alignment = cAlignment sizeOf = cSizeOf Is there a way to automatically generate this instance for every data that has an instance of CStorable? Ideally, I would like to say once and for all: instance CStorable a => Storable a where peek = cPeek poke = cPoke alignment = cAlignment sizeOf = cSizeOf As I don't think it is currently possible, would it be sensible to add the support for automatically derived instances attached to classes (as a GHC extension)? Regards, Sylvain [1] https://hackage.haskell.org/package/c-storable-deriving From eric at seidel.io Sat Mar 5 16:33:18 2016 From: eric at seidel.io (Eric Seidel) Date: Sat, 05 Mar 2016 08:33:18 -0800 Subject: [Haskell-cafe] HasCallStack - runtime costs? In-Reply-To: <56D9C35A.8000600@htwk-leipzig.de> References: <56D9C35A.8000600@htwk-leipzig.de> Message-ID: <1457195598.119962.540471226.08EB80D5@webmail.messagingengine.com> On Fri, Mar 4, 2016, at 09:18, Johannes Waldmann wrote: > > If you import a function with a HasCallStack constraint > > there's no way to disable the overhead > > But then this means that each library > should avoid these constraints? > > Or not, because this rightly scares away users > from calling nontotal functions? I think it's a matter of judgment. For non-recursive functions like head and tail, the overhead is probably not large enough to be noticeable. With recursive functions, on the other hand, the overhead compounds itself as you'll get a new callstack entry for each recursive call. So if you really want your recursive function to take a CallStack, you might refactor it so the recursion is handled by a helper function that doesn't take a CallStack. > > ... with a couple special rules for > > building dictionaries in GHC's constraint solver. > > then activation of these special rules could be a compiler switch? > Though it'd probably create a mess with separate compilation/linking. > But switching via CPP will do the same. Yes this would have (roughly) the same effect as my CPP suggestion, the problem being that you'd have to recompile every module that used HasCallStack. Eric From eric at seidel.io Sat Mar 5 16:50:56 2016 From: eric at seidel.io (Eric Seidel) Date: Sat, 05 Mar 2016 08:50:56 -0800 Subject: [Haskell-cafe] HasCallStack - runtime costs? In-Reply-To: References: <56D9A170.7070908@htwk-leipzig.de> <1457109055.4025540.539705690.74D753C4@webmail.messagingengine.com> Message-ID: <1457196656.123557.540482034.7B9DB8E2@webmail.messagingengine.com> On Sat, Mar 5, 2016, at 03:46, Michael Sloan wrote: > I tried it out, and it does have compatibility with the implicit > parameter > still! Good stuff. It is still an implicit parameter under the hood, but we're trying to hide it because we don't really care about the name of the implicit parameter. In a future release we may decide to replace the implicit parameter with a custom extension to the constraint solver, so I would avoid using the implicit parameter :) > However, I was making use of a potentially unintentional aspect > of the 7.10 API, which is that `getCallStack` can be used in a record > update of `CallStack`. This is useful for annotating callstacks with > helpful debugging info, like the arguments used for an invocation. > The existing format for the message works quite well for this, since > it's just the function name. So, appending parameters results in > "fn a1 a2 a3", etc. > > Is it too late in the GHC release cycle to have add an additional > GHC.Stack.Internal module which enables modification of CallStack? This is probably the main source of backwards-incompatiblity. CallStack is no longer a simple wrapper around a [(String,SrcLoc)], so the record update trick can't be done. Instead you should be able to extract the list as before with getCallStack, tweak it to your liking, and then make a new CallStack with GHC.Stack.fromCallSiteList (I'm not sure if that went in before RC2 but it is in the branch). The other backwards-incompatibility that springs to mind is that show{CallStack,SrcLoc} were renamed to pretty{CallStack,SrcLoc}. > Does your work on the callstack stuff (thanks!) introduce backwards > compatibility issues? I'm working on a library that will make extensive > use of 7.10's implementation of callstacks. Cool! Just be aware that 7.10's implementation had a nasty bug that broke the chain between a CallStack in the context and a use of the CallStack inside a let-binder. Eric From lists at qseep.net Sat Mar 5 18:26:21 2016 From: lists at qseep.net (Lyle Kopnicky) Date: Sat, 5 Mar 2016 10:26:21 -0800 Subject: [Haskell-cafe] Accuracy of Data.Number.Fixed In-Reply-To: References: Message-ID: Yes, that is similar to what the Decimal library does. It maintains a precision value and a scaled integer. So ? 10.02 could be represented as: Decimal 2 1002 It also has nice functions for dividing out currency into equal parts, or ratios, while preserving the property that the total of the parts should add up to the original value. I just thought it might be interesting to encode the precision in the type, and just use an integer in the representation. Then it's even more efficient at runtime. Maybe I'll write my own library. Or perhaps there's another one that does that already. The Data.Number.Fixed library encodes the precision in the type, but it uses rational number for the values, and only guarantees the precision within an epsilon range, so that "two digits of precision" means it could be +/- .01, which is not good for currency. On Sat, Mar 5, 2016 at 12:26 AM, Imants Cekusins wrote: > > I prefer the Decimal library for currency. > > here is another option to consider: > > data Cur = Eur | ... > data Money = Mint Cur Int | Mtup Cur (Int,Int) > > precision::Cur -> Int > precision Eur = 2 > precision _ = 2 > > ? 10.02 would be: > Mint Eur 1002 > Mtup Eur (10,2) > > This adds overhead to computations. However precision and correct currency > is guaranteed. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From frank at fstaals.net Sat Mar 5 18:37:48 2016 From: frank at fstaals.net (Frank Staals) Date: Sat, 05 Mar 2016 19:37:48 +0100 Subject: [Haskell-cafe] Accuracy of Data.Number.Fixed In-Reply-To: (Lyle Kopnicky's message of "Fri, 4 Mar 2016 19:50:55 -0800") References: Message-ID: Lyle Kopnicky writes: > This does not seem right to me: > > Prelude Data.Number.Fixed> read "4.00" :: Fixed (EpsDiv10 (EpsDiv10 Eps1)) > 4.00 > Prelude Data.Number.Fixed> read "4.01" :: Fixed (EpsDiv10 (EpsDiv10 Eps1)) > 4.00 > Prelude Data.Number.Fixed> read "4.02" :: Fixed (EpsDiv10 (EpsDiv10 Eps1)) > 4.03 > Prelude Data.Number.Fixed> read "4.03" :: Fixed (EpsDiv10 (EpsDiv10 Eps1)) > 4.04 > Prelude Data.Number.Fixed> read "4.04" :: Fixed (EpsDiv10 (EpsDiv10 Eps1)) > 4.05 Why not just use Data.Fixed from base? > import Data.Fixed > read "4.02" :: Fixed E2 > 4.02 -- - Frank From amindfv at gmail.com Sat Mar 5 19:34:51 2016 From: amindfv at gmail.com (amindfv at gmail.com) Date: Sat, 5 Mar 2016 14:34:51 -0500 Subject: [Haskell-cafe] Type-level list "elem" inference Message-ID: <46BED475-C4A2-4130-B71B-AE90C5F489C8@gmail.com> So I've got some code that looks like: {-# LANGUAGE DataKinds, UndecidableInstances, TypeFamilies, KindSignatures, TypeOperators #-} import Data.Proxy import GHC.TypeLits type family IsSubset (as :: [Symbol]) (bs :: [Symbol]) where IsSubset as bs = IsSubsetPrime as bs bs type family IsSubsetPrime (as :: [Symbol]) bs bs' where IsSubsetPrime as '[] bs' = 'False IsSubsetPrime '[] bs bs' = 'True IsSubsetPrime (a ': as) (a ': bs) bs' = IsSubsetPrime as bs' bs' IsSubsetPrime (a ': as) (b ': bs) bs' = IsSubsetPrime (a ': as) bs bs' This lets me write functions like: foo :: (IsSubset '["foo", "bar"] args ~ 'True) => Proxy args -> Int foo args = undefined I've also got a type family: type family IsElem (a :: Symbol) (bs :: [Symbol]) where IsElem a (a ': bs) = 'True IsElem a (b ': bs) = IsElem a bs IsElem a '[] = 'False This lets me write functions like: bar :: (IsElem "foo" args ~ 'True) => Proxy args -> Int bar args = undefined The problem comes when I want to use "bar args" in the definition of "foo args" -- even though it's clear to me that ["foo","bar"] being a subset of args implies that "foo" is an element of args, I haven't written "IsElem" or "IsSubset" in a way that it's clear to the compiler. Is there a way to write IsElem and IsSubset so they "compose"? Thanks! Tom From d.filonik at hdr.qut.edu.au Sun Mar 6 12:11:19 2016 From: d.filonik at hdr.qut.edu.au (Daniel Filonik) Date: Sun, 6 Mar 2016 12:11:19 +0000 Subject: [Haskell-cafe] GADTs and Exponentiated Functors Message-ID: Hi, I have been recently playing around with GADTs, using them to keep track of how many times a functor has been applied. This provides a solution to what seems to be a long standing problem, summarized here: https://byorgey.wordpress.com/2007/08/16/mapping-over-a-nested-functor/ If the nesting depth is part of the type, it is possible to apply fmap automatically as needed. This allows you to write fairly elegant expressions like: data Person = Person { name :: String, age :: Integer, gender :: String, status :: String } deriving Show let persons = fromList' [Person {name="Alice", age=20, gender="F", status="Good"}, Person {name="Bob", age=18, gender="M", status="Good"}, Person {name="Chuck", age=16, gender="M", status="Bad"}] :: NList N1 Person persons `select` age -- [20,18,16] persons `groupby` gender `select` age -- [[20],[18,16]] persons `groupby` gender `groupby` status `select` age -- [[[20]],[[18],[16]]] Note that "`select` age" works regardless of nesting depth. You can also append or remove nesting levels: persons `groupby` gender `select` age `produce` (\x -> [0..x]) -- [[[0..20]],[[0..18],[0..16]]] persons `groupby` gender `reduce` (sumof age) -- [20, 34] Would this kind of thing be of interest? The code is here: https://github.com/filonik/nlists Please feel free to suggest improvements. Cheers, Daniel -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at qseep.net Sun Mar 6 16:23:59 2016 From: lists at qseep.net (Lyle Kopnicky) Date: Sun, 6 Mar 2016 08:23:59 -0800 Subject: [Haskell-cafe] Accuracy of Data.Number.Fixed In-Reply-To: References: Message-ID: On Sat, Mar 5, 2016 at 10:37 AM, Frank Staals wrote: > Why not just use Data.Fixed from base? > > > import Data.Fixed > > read "4.02" :: Fixed E2 > > 4.02 > Thanks, I had overlooked that one. That is much more satisfyingly accurate for read/show reversibility. It also has the advantage of encoding the precision in the type. Oddly, it doesn't allow all precisions but just gives you a fixed set of them. Also, It doesn't provide any operations for converting between the precisions, rounding, or divvying out values in proportions without losing pieces of it. And it forces you to stick with Integer as the underlying representation, whereas Decimal lets you choose which sort of Integral to use. It's interesting that Data.Fixed uses a type class to encode the precision. I would have thought using a recursive type like Data.Number.Fixed would make the most sense (each type being defined to have a precision of a factor of 10 more than the preceding one), but now I wonder if there might be some loss of efficiency during conversion due to that. Overall I would go for the Decimal library for currency manipulation. It was clearly designed explicitly for that purpose. The only disadvantages are due to storing the precision in the value: potential inefficiency, and ease of accidentally doing arithmetic on values of two different precisions without explicit coercion. The advantages include being able to choose the underlying integral type, show/read reversibility, and the library operations for divvying up amounts into proportions while guaranteeing that the sum matches the original value. Not that one couldn't write operations to do the divvying, using Data.Fixed. Its constructor is exposed, so one can easily add new operations. Likewise, coercion operations could be added. -------------- next part -------------- An HTML attachment was scrubbed... URL: From amindfv at gmail.com Sun Mar 6 16:38:19 2016 From: amindfv at gmail.com (amindfv at gmail.com) Date: Sun, 6 Mar 2016 11:38:19 -0500 Subject: [Haskell-cafe] GADTs and Exponentiated Functors In-Reply-To: References: Message-ID: <62B6439D-D817-4A58-89C2-030A5B0399FE@gmail.com> Interesting! What's the reason you redefine the Piano numbers and hide the import of the ones from GHC. TypeLits? Tom > El 6 mar 2016, a las 07:11, Daniel Filonik escribi?: > > Hi, > > > I have been recently playing around with GADTs, using them to keep track of how many times a functor has been applied. This provides a solution to what seems to be a long standing problem, summarized here: > > > https://byorgey.wordpress.com/2007/08/16/mapping-over-a-nested-functor/ > > > If the nesting depth is part of the type, it is possible to apply fmap automatically as needed. This allows you to write fairly elegant expressions like: > > > data Person = Person { name :: String, age :: Integer, gender :: String, status :: String } deriving Show > > let persons = fromList' [Person {name="Alice", age=20, gender="F", status="Good"}, Person {name="Bob", age=18, gender="M", status="Good"}, Person {name="Chuck", age=16, gender="M", status="Bad"}] :: NList N1 Person > > persons `select` age > -- [20,18,16] > > > persons `groupby` gender `select` age > > -- [[20],[18,16]] > > > persons `groupby` gender `groupby` status `select` age > > -- [[[20]],[[18],[16]]] > > Note that "`select` age" works regardless of nesting depth. You can also append or remove nesting levels: > > persons `groupby` gender `select` age `produce` (\x -> [0..x]) > > -- [[[0..20]],[[0..18],[0..16]]] > > persons `groupby` gender `reduce` (sumof age) > > -- [20, 34] > > Would this kind of thing be of interest? The code is here: > > > https://github.com/filonik/nlists > > > Please feel free to suggest improvements. > > > Cheers, > > Daniel > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe -------------- next part -------------- An HTML attachment was scrubbed... URL: From d.filonik at hdr.qut.edu.au Sun Mar 6 17:13:36 2016 From: d.filonik at hdr.qut.edu.au (Daniel Filonik) Date: Sun, 6 Mar 2016 17:13:36 +0000 Subject: [Haskell-cafe] GADTs and Exponentiated Functors In-Reply-To: <62B6439D-D817-4A58-89C2-030A5B0399FE@gmail.com> References: , <62B6439D-D817-4A58-89C2-030A5B0399FE@gmail.com> Message-ID: I started out using TypeLits, but I was running into problems with GHC's solver along these lines: http://stackoverflow.com/questions/24734704/append-for-type-level-numbered-lists-with-typelits However, I would not rule out the possibility that this was due to misuse my behalf. If you know a way to make it work, that would be exactly the kind of feedback I am looking for! Also, I'd be curious if it is possible to write an instance of the general NFunctor for NList (which does not require explicit type annotations to work): class NFunctor t (m :: Peano) (n :: Peano) where pmap' :: (t (Succ m) a -> t m b) -> t (Succ n) a -> t n b zmap' :: (t m a -> t m b) -> t n a -> t n b smap' :: (t m a -> t (Succ m) b) -> t n a -> t (Succ n) b Cheers, Daniel ________________________________ From: amindfv at gmail.com Sent: Monday, March 7, 2016 2:38 AM To: Daniel Filonik Cc: haskell-cafe at haskell.org Subject: Re: [Haskell-cafe] GADTs and Exponentiated Functors Interesting! What's the reason you redefine the Piano numbers and hide the import of the ones from GHC. TypeLits? Tom El 6 mar 2016, a las 07:11, Daniel Filonik > escribi?: Hi, I have been recently playing around with GADTs, using them to keep track of how many times a functor has been applied. This provides a solution to what seems to be a long standing problem, summarized here: https://byorgey.wordpress.com/2007/08/16/mapping-over-a-nested-functor/ If the nesting depth is part of the type, it is possible to apply fmap automatically as needed. This allows you to write fairly elegant expressions like: data Person = Person { name :: String, age :: Integer, gender :: String, status :: String } deriving Show let persons = fromList' [Person {name="Alice", age=20, gender="F", status="Good"}, Person {name="Bob", age=18, gender="M", status="Good"}, Person {name="Chuck", age=16, gender="M", status="Bad"}] :: NList N1 Person persons `select` age -- [20,18,16] persons `groupby` gender `select` age -- [[20],[18,16]] persons `groupby` gender `groupby` status `select` age -- [[[20]],[[18],[16]]] Note that "`select` age" works regardless of nesting depth. You can also append or remove nesting levels: persons `groupby` gender `select` age `produce` (\x -> [0..x]) -- [[[0..20]],[[0..18],[0..16]]] persons `groupby` gender `reduce` (sumof age) -- [20, 34] Would this kind of thing be of interest? The code is here: https://github.com/filonik/nlists Please feel free to suggest improvements. Cheers, Daniel _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe at haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe -------------- next part -------------- An HTML attachment was scrubbed... URL: From ndtimofeev at gmail.com Sun Mar 6 17:29:30 2016 From: ndtimofeev at gmail.com (=?UTF-8?B?0J3QuNC60LjRgtCwINCi0LjQvNC+0YTQtdC10LI=?=) Date: Sun, 6 Mar 2016 20:29:30 +0300 Subject: [Haskell-cafe] PolyKind for Fixed and HasResolution from Data.Fixed Message-ID: Hi all! If we define HasResolution and Fixed like that: class HasResolution (a :: k) where resolution :: p a -> Integer newtype Fixed (a :: k) = Fixed Integer We can do something like that: instance KnownNat a => HasResolution a where resolution = natVal 2.3 :: Fixed 1 -- Timofeev N.D. -------------- next part -------------- An HTML attachment was scrubbed... URL: From adam at well-typed.com Sun Mar 6 20:10:48 2016 From: adam at well-typed.com (Adam Gundry) Date: Sun, 6 Mar 2016 20:10:48 +0000 Subject: [Haskell-cafe] Type-level list "elem" inference In-Reply-To: <46BED475-C4A2-4130-B71B-AE90C5F489C8@gmail.com> References: <46BED475-C4A2-4130-B71B-AE90C5F489C8@gmail.com> Message-ID: <56DC8EC8.1000902@well-typed.com> Hi Tom, One way is to write type families returning constraints, like this: type family IsSubset (as :: [Symbol]) (bs :: [Symbol]) :: Constraint where IsSubset '[] bs = () IsSubset (a ': as) bs = (IsElem a bs, IsSubset as bs) type family IsElem (a :: Symbol) (bs :: [Symbol]) :: Constraint where IsElem a (a ': bs) = () IsElem a (b ': bs) = IsElem a bs -- For bonus points in GHC 8.0: -- IsElem a '[] = TypeError (Text a :<>: Text " not an element!") Then you can write: foo :: IsSubset '["foo", "bar"] args => Proxy args -> Int foo args = bar args bar :: IsElem "foo" args => Proxy args -> Int bar args = undefined This is less expressive than your approach in other ways, though (e.g. one can't talk about negative constraints very easily). Hope this helps, Adam On 05/03/16 19:34, amindfv at gmail.com wrote: > So I've got some code that looks like: > > {-# LANGUAGE DataKinds, UndecidableInstances, TypeFamilies, KindSignatures, TypeOperators #-} > > import Data.Proxy > import GHC.TypeLits > > type family IsSubset (as :: [Symbol]) (bs :: [Symbol]) where > IsSubset as bs = IsSubsetPrime as bs bs > > type family IsSubsetPrime (as :: [Symbol]) bs bs' where > IsSubsetPrime as '[] bs' = 'False > IsSubsetPrime '[] bs bs' = 'True > IsSubsetPrime (a ': as) (a ': bs) bs' = > IsSubsetPrime as bs' bs' > IsSubsetPrime (a ': as) (b ': bs) bs' = IsSubsetPrime (a ': as) bs bs' > > > > This lets me write functions like: > > > foo :: (IsSubset '["foo", "bar"] args ~ 'True) => Proxy args -> Int > foo args = undefined > > > I've also got a type family: > > > type family IsElem (a :: Symbol) (bs :: [Symbol]) where > IsElem a (a ': bs) = 'True > IsElem a (b ': bs) = IsElem a bs > IsElem a '[] = 'False > > > This lets me write functions like: > > bar :: (IsElem "foo" args ~ 'True) => Proxy args -> Int > bar args = undefined > > > The problem comes when I want to use "bar args" in the definition of "foo args" -- even though it's clear to me that ["foo","bar"] being a subset of args implies that "foo" is an element of args, I haven't written "IsElem" or "IsSubset" in a way that it's clear to the compiler. > > Is there a way to write IsElem and IsSubset so they "compose"? > > Thanks! > Tom -- Adam Gundry, Haskell Consultant Well-Typed LLP, http://www.well-typed.com/ From blaze at ruddy.ru Mon Mar 7 06:53:56 2016 From: blaze at ruddy.ru (Andrey Sverdlichenko) Date: Mon, 07 Mar 2016 06:53:56 +0000 Subject: [Haskell-cafe] 1-to-many preprocessor in stack/Cabal builds Message-ID: Hi, I'm writing a package which uses custom preprocessor for creating some of the source files. It takes one IDL file as input and writes several .hs modules, depending on IDL contents. I need to compile this modules with a few normal ones and link them as a library, preferably with generated modules exposed. It doesn't look like a complex task and never was in with make/etc, but I run into some problems now. Obviously, cabal supports 1-to-1 preprocessors to create one Haskell module from one source file (alex, happy, etc), but I can't find anything for 1-to-many preprocessors. So, I decided to use hookedPrograms and hooks and do it myself. The call to preprocessor in the postConf hook worked just fine and created source files and module list. Cabal pre-* hooks seems to be right place to read this module list and use it, but are presenting two problems: can only modify other-modules, not exposed-modules, which is tolerable, and there is no access to build configuration. The latter is fatal, I need to know build dir to read module list. So I have to change action hooks. As the additional annoyance, there is absolutely no way to modify configuration once and for all, I have to override every single hook with the same "read module list and change config" wrapper. So, I have buildHook, copyHook and regHook replaced with wrappers which change PackageDescription parameter and call original function. Library is built and installed, but somewhere between build and copy actions there is still a message "Warning: modules not listed in foo.cabal for library component (add to other-modules)". I can't identify where it comes from. I'm using stack 1.0.4 to build this library, but all the problems seems to be cabal-related. Here is minimal example of what I ended up with: https://github.com/rblaze/cabal-hooks-sample Now I wonder if I missed an easier way to handle this code generation. If not, at least how to get rid of warning about missing modules between build and copy actions? -------------- next part -------------- An HTML attachment was scrubbed... URL: From d.filonik at hdr.qut.edu.au Mon Mar 7 07:53:31 2016 From: d.filonik at hdr.qut.edu.au (Daniel Filonik) Date: Mon, 7 Mar 2016 07:53:31 +0000 Subject: [Haskell-cafe] GADTs and Exponentiated Functors In-Reply-To: References: , <62B6439D-D817-4A58-89C2-030A5B0399FE@gmail.com>, Message-ID: Just a quick follow up to this, unless I am mistaken GHC TypeLits does not actually export constructors (Zero, Succ) for the Nat kind, does it? If it did that, of course I could just use those... FYI, I have cleaned up the example a bit, adding some applicative magic, it now looks like: data Person = Person { name :: String, age :: Integer, gender :: String, status :: String } deriving Show persons = fromList' [Person {name="Alice", age=20, gender="F", status="Good"}, Person {name="Bob", age=18, gender="M", status="Good"}, Person {name="Chuck", age=16, gender="M", status="Bad"}] :: NList N1 Person persons <$$> groupby (gender) <$$> orderby (age) <$$> select (age + 1) <$$> reduce (sum) -- [21,36] Or, if you are feeling more adventurous, you can do thing like: let abg = persons <$$> groupby (gender) <$$> select (age) in ((/) <$> (abg <$$> select(realToFrac)) <***> (abg <$$> reduce(mean))) [[1.0],[1.0588235294117647,0.9411764705882353]] All operations select/reduce/produce/filterby/orderby/groupby work on arbitrarily nested lists, making this very composable. Cheers, Daniel ________________________________ From: Daniel Filonik Sent: Monday, March 7, 2016 3:13 AM To: amindfv at gmail.com Cc: haskell-cafe at haskell.org Subject: Re: [Haskell-cafe] GADTs and Exponentiated Functors I started out using TypeLits, but I was running into problems with GHC's solver along these lines: http://stackoverflow.com/questions/24734704/append-for-type-level-numbered-lists-with-typelits However, I would not rule out the possibility that this was due to misuse my behalf. If you know a way to make it work, that would be exactly the kind of feedback I am looking for! Also, I'd be curious if it is possible to write an instance of the general NFunctor for NList (which does not require explicit type annotations to work): class NFunctor t (m :: Peano) (n :: Peano) where pmap' :: (t (Succ m) a -> t m b) -> t (Succ n) a -> t n b zmap' :: (t m a -> t m b) -> t n a -> t n b smap' :: (t m a -> t (Succ m) b) -> t n a -> t (Succ n) b Cheers, Daniel ________________________________ From: amindfv at gmail.com Sent: Monday, March 7, 2016 2:38 AM To: Daniel Filonik Cc: haskell-cafe at haskell.org Subject: Re: [Haskell-cafe] GADTs and Exponentiated Functors Interesting! What's the reason you redefine the Piano numbers and hide the import of the ones from GHC. TypeLits? Tom El 6 mar 2016, a las 07:11, Daniel Filonik > escribi?: Hi, I have been recently playing around with GADTs, using them to keep track of how many times a functor has been applied. This provides a solution to what seems to be a long standing problem, summarized here: https://byorgey.wordpress.com/2007/08/16/mapping-over-a-nested-functor/ If the nesting depth is part of the type, it is possible to apply fmap automatically as needed. This allows you to write fairly elegant expressions like: data Person = Person { name :: String, age :: Integer, gender :: String, status :: String } deriving Show let persons = fromList' [Person {name="Alice", age=20, gender="F", status="Good"}, Person {name="Bob", age=18, gender="M", status="Good"}, Person {name="Chuck", age=16, gender="M", status="Bad"}] :: NList N1 Person persons `select` age -- [20,18,16] persons `groupby` gender `select` age -- [[20],[18,16]] persons `groupby` gender `groupby` status `select` age -- [[[20]],[[18],[16]]] Note that "`select` age" works regardless of nesting depth. You can also append or remove nesting levels: persons `groupby` gender `select` age `produce` (\x -> [0..x]) -- [[[0..20]],[[0..18],[0..16]]] persons `groupby` gender `reduce` (sumof age) -- [20, 34] Would this kind of thing be of interest? The code is here: https://github.com/filonik/nlists Please feel free to suggest improvements. Cheers, Daniel _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe at haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe -------------- next part -------------- An HTML attachment was scrubbed... URL: From ezyang at mit.edu Mon Mar 7 07:55:49 2016 From: ezyang at mit.edu (Edward Z. Yang) Date: Sun, 06 Mar 2016 23:55:49 -0800 Subject: [Haskell-cafe] 1-to-many preprocessor in stack/Cabal builds In-Reply-To: References: Message-ID: <1457337159-sup-2173@sabre> Hello Andrey, I do not know what the right way to sovle your problem is, but if it is indeed the case that this cannot be done with Cabal, speaking as a Cabal developer, we definitely should try to fix this. A bug report would be much appreciated. > So, I have buildHook, copyHook and regHook replaced with wrappers which > change PackageDescription parameter and call original function. Library is > built and installed, but somewhere between build and copy actions there is > still a message "Warning: modules not listed in foo.cabal for library > component (add to other-modules)". I can't identify where it comes from. I'm pretty sure this message comes from Stack; src/Stack/Types/Package.hs. Cheers, Edward From svenpanne at gmail.com Mon Mar 7 08:19:33 2016 From: svenpanne at gmail.com (Sven Panne) Date: Mon, 7 Mar 2016 09:19:33 +0100 Subject: [Haskell-cafe] Trouble on Travis CI with recent cabal versions Message-ID: For my OpenGLRaw project, I'm using a .travis.yml generated by Herbert's https://github.com/hvr/multi-ghc-travis and the corresponding https://launchpad.net/~hvr/+archive/ubuntu/ghc PPA. Recently things broke on Travis CI, and there are a few strange things: * The cabal-install-head package seems to be based on cabal 1.23, which is older than cabal-install-1.24. Is this intended? * The OpenGLRaw package has no test suite, and this seems to be OK for cabal-install-head ( https://travis-ci.org/haskell-opengl/OpenGLRaw/jobs/114109605#L929), while cabal-install-1.24 fails in the "cabal test" step ( https://travis-ci.org/haskell-opengl/OpenGLRaw/jobs/114109606#L1022). This is a regression: I think that "cabal test" for a package without a test suite should be a no-op, at least that used to be the case. * Why does "cabal test" say "Re-configuring with test suites enabled. If this fails, please run configure manually." when "cabal configure" has already been run (including --enable-tests)? This looks like a bug... Cheers, S. -------------- next part -------------- An HTML attachment was scrubbed... URL: From olshanskydr at gmail.com Mon Mar 7 14:37:37 2016 From: olshanskydr at gmail.com (Dmitry Olshansky) Date: Mon, 7 Mar 2016 17:37:37 +0300 Subject: [Haskell-cafe] Tagged instances for Aeson overlapped Message-ID: Hello, I tried to compile my project with GHC 8 (from HEAD). And I got > ? Overlapping instances for > aeson-0.11.1.0:Data.Aeson.Types.Class.ToJSON > ... > arising from a use of ?serve? > Matching instances: > two instances involving out-of-scope types > instance aeson-0.11.1.0:Data.Aeson.Types.Class.ToJSON b => > aeson-0.11.1.0:Data.Aeson.Types.Class.ToJSON > (Data.Tagged.Tagged a b) > -- Defined in ?aeson-0.11.1.0:Data.Aeson.Types.Instances? > instance forall k x (r :: k). > aeson-0.11.1.0:Data.Aeson.Types.Class.ToJSON x => > aeson-0.11.1.0:Data.Aeson.Types.Class.ToJSON > (Data.Tagged.Tagged r x) One of instances should be removed probably. I suppose that instance for removing should be instance in Data.Tagged. But version in Aeson should be PolyKinded. What do you think? Best regards, Dmitry -------------- next part -------------- An HTML attachment was scrubbed... URL: From adam at bergmark.nl Mon Mar 7 15:24:22 2016 From: adam at bergmark.nl (Adam Bergmark) Date: Mon, 07 Mar 2016 07:24:22 -0800 Subject: [Haskell-cafe] Tagged instances for Aeson overlapped In-Reply-To: References: Message-ID: <56dd9ce26dbbbc3000000005@polymail.io> Whoops, didn?t reply-all! One instance is in Data.Aeson.Types.Instances, where are you getting the other one from? Adam Bergmark On Mon 07 Mar 2016 at 15:37 Dmitry Olshansky < mailto:Dmitry Olshansky > wrote: Hello, I tried to compile my project with GHC 8 (from HEAD). And I got ? ? ? Overlapping instances for aeson-0.11.1.0:Data.Aeson.Types.Class.ToJSON ... ?? ? ? ?arising from a use of ?serve? ? ? ? Matching instances: ? ? ? ? two instances involving out-of-scope types ? ? ? ? ? instance aeson-0.11.1.0:Data.Aeson.Types.Class.ToJSON b => ? ? ? ? ? ? ? ? ? ?aeson-0.11.1.0:Data.Aeson.Types.Class.ToJSON ? ? ? ? ? ? ? ? ? ? ?(Data.Tagged.Tagged a b) ? ? ? ? ? ? -- Defined in ?aeson-0.11.1.0:Data.Aeson.Types.Instances? ? ? ? ? ? instance forall k x (r :: k). ? ? ? ? ? ? ? ? ? ?aeson-0.11.1.0:Data.Aeson.Types.Class.ToJSON x => ? ? ? ? ? ? ? ? ? ?aeson-0.11.1.0:Data.Aeson.Types.Class.ToJSON ? ? ? ? ? ? ? ? ? ? ?(Data.Tagged.Tagged r x) One of instances should be removed probably.? I suppose that instance for removing should be?instance in Data.Tagged.? But version in Aeson should be PolyKinded. What do you think? Best regards, Dmitry? _______________________________________________ Haskell-Cafe mailing list mailto:Haskell-Cafe at haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe -------------- next part -------------- An HTML attachment was scrubbed... URL: From olshanskydr at gmail.com Mon Mar 7 15:26:31 2016 From: olshanskydr at gmail.com (Dmitry Olshansky) Date: Mon, 7 Mar 2016 18:26:31 +0300 Subject: [Haskell-cafe] Tagged instances for Aeson overlapped In-Reply-To: <56dd9ce26dbbbc3000000005@polymail.io> References: <56dd9ce26dbbbc3000000005@polymail.io> Message-ID: Whoops from me also... It was mine instance. Sorry for the noise. Thanks! 2016-03-07 18:24 GMT+03:00 Adam Bergmark : > > Whoops, didn?t reply-all! > > One instance is in Data.Aeson.Types.Instances, where are you getting the > other one from? > > Adam Bergmark > > > On Mon 07 Mar 2016 at 15:37 Dmitry Olshansky > wrote: > >> Hello, >> >> I tried to compile my project with GHC 8 (from HEAD). >> >> And I got >> >>> ? Overlapping instances for >>> aeson-0.11.1.0:Data.Aeson.Types.Class.ToJSON >>> ... >>> arising from a use of ?serve? >>> Matching instances: >>> two instances involving out-of-scope types >>> instance aeson-0.11.1.0:Data.Aeson.Types.Class.ToJSON b => >>> aeson-0.11.1.0:Data.Aeson.Types.Class.ToJSON >>> (Data.Tagged.Tagged a b) >>> -- Defined in ?aeson-0.11.1.0:Data.Aeson.Types.Instances? >>> instance forall k x (r :: k). >>> aeson-0.11.1.0:Data.Aeson.Types.Class.ToJSON x => >>> aeson-0.11.1.0:Data.Aeson.Types.Class.ToJSON >>> (Data.Tagged.Tagged r x) >> >> >> One of instances should be removed probably. >> I suppose that instance for removing should be instance in Data.Tagged. >> But version in Aeson should be PolyKinded. >> >> What do you think? >> >> Best regards, >> Dmitry >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From johannes.waldmann at htwk-leipzig.de Mon Mar 7 17:21:30 2016 From: johannes.waldmann at htwk-leipzig.de (Johannes Waldmann) Date: Mon, 7 Mar 2016 18:21:30 +0100 Subject: [Haskell-cafe] HasCallStack - runtime costs? Message-ID: <56DDB89A.1070206@htwk-leipzig.de> Eric wrote earlier: > If you import a function with a HasCallStack constraint > there's no way to disable the overhead ... > For non-recursive functions like head and tail, > the overhead is probably not large enough to be noticeable. Now I'm confused: should this mean that head and tail are "functions with a HasCallStack constraint"? If I ask ghci for their type, it just says head :: [a] -> a and that's also what's in the source https://downloads.haskell.org/~ghc/8.0.1-rc2/docs/html/libraries/base-4.9.0.0/src/GHC-List.html#head but the Callstack explanation in the user manual does show a different version of head https://downloads.haskell.org/~ghc/8.0.1-rc2/docs/html/users_guide/glasgow_exts.html#hascallstack I am not particularly concerned about head and tail here but generally about how to find out whether my code is taking a performance penalty. I think the documentation (user manual Section 9.31) is rather brief about the semantics. It speaks about solving "HasCallStack" constraints - but they could also be propagated? There is secondary documentation like https://ghc.haskell.org/trac/ghc/wiki/ExplicitCallStack but it does not tell what is actually implemented, or I don't see it. - J.W. From anselm.scholl at tu-harburg.de Mon Mar 7 18:02:55 2016 From: anselm.scholl at tu-harburg.de (Jonas Scholl) Date: Mon, 7 Mar 2016 19:02:55 +0100 Subject: [Haskell-cafe] HasCallStack - runtime costs? In-Reply-To: <56DDB89A.1070206@htwk-leipzig.de> References: <56DDB89A.1070206@htwk-leipzig.de> Message-ID: <56DDC24F.5080405@tu-harburg.de> I think the documentation for HasCallStack is not quite correct. As far as I understood, head and tail are not changed to contain call stacks as this would indeed carry a performance-penalty. Maybe the documentation should call the function myHead to distinguish it from the library function. The user-manual also uses errorWithCallStack, but I think base calls this function just error and adds errorWithoutStackTrace (at least thats what I find in https://downloads.haskell.org/~ghc/8.0.1-rc2/docs/html/libraries/base-4.9.0.0/src/GHC-Err.html). On 03/07/2016 06:21 PM, Johannes Waldmann wrote: > Eric wrote earlier: > >> If you import a function with a HasCallStack constraint >> there's no way to disable the overhead ... > >> For non-recursive functions like head and tail, >> the overhead is probably not large enough to be noticeable. > > Now I'm confused: should this mean that head and tail > are "functions with a HasCallStack constraint"? > If I ask ghci for their type, it just says head :: [a] -> a > and that's also what's in the source > https://downloads.haskell.org/~ghc/8.0.1-rc2/docs/html/libraries/base-4.9.0.0/src/GHC-List.html#head > but the Callstack explanation in the user manual > does show a different version of head > https://downloads.haskell.org/~ghc/8.0.1-rc2/docs/html/users_guide/glasgow_exts.html#hascallstack > > I am not particularly concerned about head and tail here > but generally about how to find out whether my code > is taking a performance penalty. > > I think the documentation (user manual Section 9.31) > is rather brief about the semantics. It speaks about > solving "HasCallStack" constraints - but they could also > be propagated? There is secondary documentation like > https://ghc.haskell.org/trac/ghc/wiki/ExplicitCallStack > but it does not tell what is actually implemented, > or I don't see it. > > - J.W. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 473 bytes Desc: OpenPGP digital signature URL: From eric at seidel.io Mon Mar 7 18:19:17 2016 From: eric at seidel.io (Eric Seidel) Date: Mon, 07 Mar 2016 10:19:17 -0800 Subject: [Haskell-cafe] HasCallStack - runtime costs? In-Reply-To: <56DDB89A.1070206@htwk-leipzig.de> References: <56DDB89A.1070206@htwk-leipzig.de> Message-ID: <1457374757.2673956.542100450.644D8D3A@webmail.messagingengine.com> On Mon, Mar 7, 2016, at 09:21, Johannes Waldmann wrote: > Eric wrote earlier: > > > If you import a function with a HasCallStack constraint > > there's no way to disable the overhead ... > > > For non-recursive functions like head and tail, > > the overhead is probably not large enough to be noticeable. > > Now I'm confused: should this mean that head and tail > are "functions with a HasCallStack constraint"? > If I ask ghci for their type, it just says head :: [a] -> a > and that's also what's in the source > https://downloads.haskell.org/~ghc/8.0.1-rc2/docs/html/libraries/base-4.9.0.0/src/GHC-List.html#head > but the Callstack explanation in the user manual > does show a different version of head > https://downloads.haskell.org/~ghc/8.0.1-rc2/docs/html/users_guide/glasgow_exts.html#hascallstack > > I am not particularly concerned about head and tail here > but generally about how to find out whether my code > is taking a performance penalty. > > I think the documentation (user manual Section 9.31) > is rather brief about the semantics. It speaks about > solving "HasCallStack" constraints - but they could also > be propagated? There is secondary documentation like > https://ghc.haskell.org/trac/ghc/wiki/ExplicitCallStack > but it does not tell what is actually implemented, > or I don't see it. I'm sorry for the confusion, to be clear a function only gets a call-stack if it has a HasCallStack constraint in its type. I used head as an example of a function that you might want to give a call-stack, but base *does not* do this at the moment. GHC will infer HasCallStack constraints for functions as it would infer class constraints, but I have a mostly-done patch to disable this inference for top-level functions, it should make it in to the final 8.0 release. I'll try to expand the documentation as well, perhaps some more examples would help? Thanks, Eric From blaze at ruddy.ru Mon Mar 7 18:45:56 2016 From: blaze at ruddy.ru (Andrey Sverdlichenko) Date: Mon, 07 Mar 2016 18:45:56 +0000 Subject: [Haskell-cafe] 1-to-many preprocessor in stack/Cabal builds In-Reply-To: <1457337159-sup-2173@sabre> References: <1457337159-sup-2173@sabre> Message-ID: Hi Edward, I can do with current Cabal, it is just a lot of boilerplate and inconvenience. What I would like to have as an ideal solution for my problem is a preprocessor interface similar to PPSuffixHandler, but with extra capabilities. It should receive one file as an input, but be able to generate multiple modules with the names of its own choosing. And I want the resulting modules to be added to all build steps automatically. So it should looks approximately like this: data SmartPreProcessor = SmartPreProcessor { platformIndependent :: Bool, runPreProcessor :: (FilePath, FilePath) -- Location of the source file relative to a base dir -> Verbosity -- verbosity -> FilePath -- output base dir -> IO [FilePath] -- output sources files. Should exit if the preprocessor fails } There may be design objections to such preprocessor, but again, this is an ideal solution to my problem. On Sun, Mar 6, 2016 at 11:55 PM Edward Z. Yang wrote: > Hello Andrey, > > I do not know what the right way to sovle your problem is, but if it is > indeed the case that this cannot be done with Cabal, speaking as a Cabal > developer, we definitely should try to fix this. A bug report > would be much appreciated. > > > So, I have buildHook, copyHook and regHook replaced with wrappers which > > change PackageDescription parameter and call original function. Library > is > > built and installed, but somewhere between build and copy actions there > is > > still a message "Warning: modules not listed in foo.cabal for library > > component (add to other-modules)". I can't identify where it comes from. > > I'm pretty sure this message comes from Stack; src/Stack/Types/Package.hs. > > Cheers, > Edward > -------------- next part -------------- An HTML attachment was scrubbed... URL: From qdunkan at gmail.com Mon Mar 7 19:35:31 2016 From: qdunkan at gmail.com (Evan Laforge) Date: Mon, 7 Mar 2016 11:35:31 -0800 Subject: [Haskell-cafe] implicit call stacks and calling function Message-ID: I noticed this when I started using the new implicit call stacks feature. I didn't bring it up because I figure it probably had a good reason and was too late to change anyway, but the recent talk about HasCallStack reminded me and I'm curious. When you do GHC.Stack.getCallStack you get a [(String, SrcPos)]. The SrcPos is the position of the calling function, but the String is the callee function. So you can't get the name of the calling function. Instead, you get the name of the function with the call stack annotation. That's not so useful because in say a logging function, I'm interested in the caller's name. I don't need the name of the logging function, it's just something boring like "info" or "warn"! When I switched from a custom preprocessor that sort of implemented SRCLOC_ANNOTATE, it was definitely nice to lose the custom local hackery, but not so nice to lose the caller's name. For tests I used an unsafe mutable global via unsafePerformIO, otherwise failed tests can't report the name of the failing test, but the hack doesn't work for logging. Is there a reason it was done the way it was, or a way to get the name of the calling function? From eric at seidel.io Mon Mar 7 19:46:55 2016 From: eric at seidel.io (Eric Seidel) Date: Mon, 07 Mar 2016 11:46:55 -0800 Subject: [Haskell-cafe] implicit call stacks and calling function In-Reply-To: References: Message-ID: <1457380015.2693038.542198882.14AFBAFC@webmail.messagingengine.com> On Mon, Mar 7, 2016, at 11:35, Evan Laforge wrote: > When you do GHC.Stack.getCallStack you get a [(String, SrcPos)]. The > SrcPos is the position of the calling function, but the String is the > callee function. So you can't get the name of the calling function. > Instead, you get the name of the function with the call stack > annotation. That's not so useful because in say a logging function, > I'm interested in the caller's name. I don't need the name of the > logging function, it's just something boring like "info" or "warn"! > > Is there a reason it was done the way it was, or a way to get the name > of the calling function? The reason we provide the name of the callee is that the standard format for a stack trace is callee+pos :) You point about wanting the caller's name too is well-taken though. In most languages you can just look at the next item in the stack to grab the caller, but with HasCallStack there may be no next item... I doubt it would be hard to add the caller's name too, I'd be happy to look into it post-ICFP. Would you mind filing a ticket? Eric From ezyang at mit.edu Mon Mar 7 22:44:45 2016 From: ezyang at mit.edu (Edward Z. Yang) Date: Mon, 07 Mar 2016 14:44:45 -0800 Subject: [Haskell-cafe] 1-to-many preprocessor in stack/Cabal builds In-Reply-To: References: <1457337159-sup-2173@sabre> Message-ID: <1457390301-sup-5385@sabre> OK. If there is a simple patch which can help support your use case better, we'd be happy to take it. However, I don't think a design like this is the right long term plan. The correct long term plan, I think, is to do something like ToolCabal and make it so that you can just plug in custom build rules of your own, which can include preprocessor processing. This will also fix some of our other problems, such as the fact that we repeatedly preprocess executables even when it's not necessary I'm hoping to take a crack at this at some point; hopefully your boilerplate will tide you until then. Edward Excerpts from Andrey Sverdlichenko's message of 2016-03-07 10:45:56 -0800: > Hi Edward, > > I can do with current Cabal, it is just a lot of boilerplate and > inconvenience. > What I would like to have as an ideal solution for my problem is a > preprocessor interface similar to PPSuffixHandler, but with extra > capabilities. > It should receive one file as an input, but be able to generate multiple > modules with the names of its own choosing. And I want the resulting > modules to be added to all build steps automatically. So it should looks > approximately like this: > > data SmartPreProcessor = SmartPreProcessor { > platformIndependent :: Bool, > runPreProcessor :: (FilePath, FilePath) -- Location of the source file > relative to a base dir > -> Verbosity -- verbosity > -> FilePath -- output base dir > -> IO [FilePath] -- output sources files. Should > exit if the preprocessor fails > } > > There may be design objections to such preprocessor, but again, this is an > ideal solution to my problem. > > On Sun, Mar 6, 2016 at 11:55 PM Edward Z. Yang wrote: > > > Hello Andrey, > > > > I do not know what the right way to sovle your problem is, but if it is > > indeed the case that this cannot be done with Cabal, speaking as a Cabal > > developer, we definitely should try to fix this. A bug report > > would be much appreciated. > > > > > So, I have buildHook, copyHook and regHook replaced with wrappers which > > > change PackageDescription parameter and call original function. Library > > is > > > built and installed, but somewhere between build and copy actions there > > is > > > still a message "Warning: modules not listed in foo.cabal for library > > > component (add to other-modules)". I can't identify where it comes from. > > > > I'm pretty sure this message comes from Stack; src/Stack/Types/Package.hs. > > > > Cheers, > > Edward > > From qdunkan at gmail.com Mon Mar 7 23:36:03 2016 From: qdunkan at gmail.com (Evan Laforge) Date: Mon, 7 Mar 2016 15:36:03 -0800 Subject: [Haskell-cafe] implicit call stacks and calling function In-Reply-To: <1457380015.2693038.542198882.14AFBAFC@webmail.messagingengine.com> References: <1457380015.2693038.542198882.14AFBAFC@webmail.messagingengine.com> Message-ID: On Mon, Mar 7, 2016 at 11:46 AM, Eric Seidel wrote: > The reason we provide the name of the callee is that the standard format > for a stack trace is callee+pos :) I guess it depends how you look at it. I'm used to caller + pos, e.g. in Java: java.lang.RuntimeException: blah blah at com...Caller.caller(Caller.java:494) at ... Or python: Traceback (most recent call last): File "t.py", line 2, in caller def caller(): callee() File "t.py", line 1, in callee def callee(): 1/0 ZeroDivisionError: integer division or modulo by zero The haskell version (reversed to match python) would be like: File "Caller.hs", line 6, in callee caller = callee 10 File "Caller.hs", line 9, in ?stack callee _n = mapM_ print (Stack.getCallStack ?stack) To me this seems off by one, line 6 is in 'caller', not 'callee'. > You point about wanting the caller's name too is well-taken though. In > most languages you can just look at the next item in the stack to grab > the caller, but with HasCallStack there may be no next item... I doubt > it would be hard to add the caller's name too, I'd be happy to look into > it post-ICFP. Would you mind filing a ticket? Done: https://ghc.haskell.org/trac/ghc/ticket/11686 In it I suggested adding a Stack.getFrames :: [Stack.Frame], Frame could then have callee and srcloc fields as per getCallStack's pairs, and add a caller field. Just a suggestion. Thanks so much! From eric at seidel.io Tue Mar 8 02:45:19 2016 From: eric at seidel.io (Eric Seidel) Date: Mon, 07 Mar 2016 18:45:19 -0800 Subject: [Haskell-cafe] implicit call stacks and calling function In-Reply-To: References: <1457380015.2693038.542198882.14AFBAFC@webmail.messagingengine.com> Message-ID: <1457405119.2779661.542547970.6950A0C4@webmail.messagingengine.com> On Mon, Mar 7, 2016, at 15:36, Evan Laforge wrote: > On Mon, Mar 7, 2016 at 11:46 AM, Eric Seidel wrote: > > The reason we provide the name of the callee is that the standard format > > for a stack trace is callee+pos :) > > I guess it depends how you look at it. I'm used to caller + pos, e.g. in > Java: > > java.lang.RuntimeException: blah blah > at com...Caller.caller(Caller.java:494) > at ... > > Or python: > > Traceback (most recent call last): > File "t.py", line 2, in caller > def caller(): callee() > File "t.py", line 1, in callee > def callee(): 1/0 > ZeroDivisionError: integer division or modulo by zero > > The haskell version (reversed to match python) would be like: > > File "Caller.hs", line 6, in callee > caller = callee 10 > File "Caller.hs", line 9, in ?stack > callee _n = mapM_ print (Stack.getCallStack ?stack) > > To me this seems off by one, line 6 is in 'caller', not 'callee'. Huh, you're quite right.. I remember checking python's formatting when I originally implemented the feature but I must have misread the stack.. From tomtau at connect.hku.hk Tue Mar 8 06:10:33 2016 From: tomtau at connect.hku.hk (Tomas Tauber) Date: Tue, 8 Mar 2016 14:10:33 +0800 Subject: [Haskell-cafe] Use cases of empty type classes Message-ID: Hi everyone, I have one question. What are current use cases of type classes with no methods? I saw early uses in type-level programming (e.g. HList [1]). In the OO world, interfaces with no methods are called marker interfaces -- their use cases range from things that could be done with datatype generic programming in Haskell (e.g. serialization) to metadata annotations (e.g. RandomAccess [2]). Regards, Tomas Tauber [1] http://okmij.org/ftp/Haskell/HList-ext.pdf [2] https://docs.oracle.com/javase/8/docs/api/java/util/RandomAccess.html From adam at bergmark.nl Tue Mar 8 11:36:34 2016 From: adam at bergmark.nl (Adam Bergmark) Date: Tue, 08 Mar 2016 03:36:34 -0800 Subject: [Haskell-cafe] Use cases of empty type classes In-Reply-To: References: Message-ID: <56deb7ee6dbbbc3000000006@polymail.io> I have two use cases for them In fay-jquery there?s an empty Selectable class that has instances for all elements that can be passed to the jQuery function, there is no need for methods since we in the background just pass the object along, but we want to make sure we don?t pass something nonsensical. In a rest API serving JSON you need ToJSON and FromJSON instances for each type, but since internal APIs may also use JSON it?s possible that you by accident pass a type that isn?t versioned and supposed to be included in the public API. There I can have an empty PublicApiType class with instances for all public types to give a type error if I pass something internal by mistake. /Adam Bergmark On Tue 08 Mar 2016 at 07:10 Tomas Tauber < mailto:Tomas Tauber > wrote: Hi everyone, I have one question. What are current use cases of type classes with no methods? I saw early uses in type-level programming (e.g. HList [1]). In the OO world, interfaces with no methods are called marker interfaces -- their use cases range from things that could be done with datatype generic programming in Haskell (e.g. serialization) to metadata annotations (e.g. RandomAccess [2]). Regards, Tomas Tauber [1] http://okmij.org/ftp/Haskell/HList-ext.pdf [2] https://docs.oracle.com/javase/8/docs/api/java/util/RandomAccess.html _______________________________________________ Haskell-Cafe mailing list mailto:Haskell-Cafe at haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe -------------- next part -------------- An HTML attachment was scrubbed... URL: From rpglover64 at gmail.com Tue Mar 8 14:58:30 2016 From: rpglover64 at gmail.com (Alex Rozenshteyn) Date: Tue, 08 Mar 2016 14:58:30 +0000 Subject: [Haskell-cafe] Use cases of empty type classes In-Reply-To: <56deb7ee6dbbbc3000000006@polymail.io> References: <56deb7ee6dbbbc3000000006@polymail.io> Message-ID: You can use them to claim something about multiple type classes at once, with some advantages over using ConstraintKinds for the same purpose: https://www.reddit.com/r/haskell/comments/49em92/haskells_typeclasses_we_can_do_better/d0rwvi8?context=2 On Tue, Mar 8, 2016 at 6:36 AM Adam Bergmark wrote: > I have two use cases for them > > > - In fay-jquery there?s an empty Selectable class that has instances > for all elements that can be passed to the jQuery function, there is no > need for methods since we in the background just pass the object along, but > we want to make sure we don?t pass something nonsensical. > - In a rest API serving JSON you need ToJSON and FromJSON instances > for each type, but since internal APIs may also use JSON it?s possible that > you by accident pass a type that isn?t versioned and supposed to be > included in the public API. There I can have an empty PublicApiType class > with instances for all public types to give a type error if I pass > something internal by mistake. > > > /Adam Bergmark > > > On Tue 08 Mar 2016 at 07:10 Tomas Tauber > wrote: > >> Hi everyone, >> >> I have one question. What are current use cases of type classes with no >> methods? >> >> I saw early uses in type-level programming (e.g. HList [1]). >> In the OO world, interfaces with no methods are called marker interfaces >> -- their use cases range from things that could be done with datatype >> generic programming in Haskell (e.g. serialization) to metadata annotations >> (e.g. RandomAccess [2]). >> >> Regards, >> >> Tomas Tauber >> >> >> [1] http://okmij.org/ftp/Haskell/HList-ext.pdf >> [2] https://docs.oracle.com/javase/8/docs/api/java/util/RandomAccess.html >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe >> > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From heraldhoi at gmail.com Tue Mar 8 15:48:37 2016 From: heraldhoi at gmail.com (Geraldus) Date: Tue, 08 Mar 2016 15:48:37 +0000 Subject: [Haskell-cafe] Use cases of empty type classes In-Reply-To: References: <56deb7ee6dbbbc3000000006@polymail.io> Message-ID: Thanks everybody. I found this helpful (: ??, 8 ???. 2016 ?. ? 19:58, Alex Rozenshteyn : > You can use them to claim something about multiple type classes at once, > with some advantages over using ConstraintKinds for the same purpose: > https://www.reddit.com/r/haskell/comments/49em92/haskells_typeclasses_we_can_do_better/d0rwvi8?context=2 > > > On Tue, Mar 8, 2016 at 6:36 AM Adam Bergmark wrote: > >> I have two use cases for them >> >> >> - In fay-jquery there?s an empty Selectable class that has instances >> for all elements that can be passed to the jQuery function, there is no >> need for methods since we in the background just pass the object along, but >> we want to make sure we don?t pass something nonsensical. >> - In a rest API serving JSON you need ToJSON and FromJSON instances >> for each type, but since internal APIs may also use JSON it?s possible that >> you by accident pass a type that isn?t versioned and supposed to be >> included in the public API. There I can have an empty PublicApiType class >> with instances for all public types to give a type error if I pass >> something internal by mistake. >> >> >> /Adam Bergmark >> >> >> On Tue 08 Mar 2016 at 07:10 Tomas Tauber > > wrote: >> >>> Hi everyone, >>> >>> I have one question. What are current use cases of type classes with no >>> methods? >>> >>> I saw early uses in type-level programming (e.g. HList [1]). >>> In the OO world, interfaces with no methods are called marker interfaces >>> -- their use cases range from things that could be done with datatype >>> generic programming in Haskell (e.g. serialization) to metadata annotations >>> (e.g. RandomAccess [2]). >>> >>> Regards, >>> >>> Tomas Tauber >>> >>> >>> [1] http://okmij.org/ftp/Haskell/HList-ext.pdf >>> [2] >>> https://docs.oracle.com/javase/8/docs/api/java/util/RandomAccess.html >>> _______________________________________________ >>> Haskell-Cafe mailing list >>> Haskell-Cafe at haskell.org >>> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe >>> >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe >> > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From d.filonik at hdr.qut.edu.au Tue Mar 8 21:34:53 2016 From: d.filonik at hdr.qut.edu.au (Daniel Filonik) Date: Tue, 8 Mar 2016 21:34:53 +0000 Subject: [Haskell-cafe] GADTs and Exponentiated Functors In-Reply-To: References: , <62B6439D-D817-4A58-89C2-030A5B0399FE@gmail.com>, , Message-ID: I have managed to pinpoint where my problems with GHC TypeLits came about. The following fails (btw. are there any guidelines for posting code on this mailing list?): type family NFunctorF f (n :: Nat) a where NFunctorF f 0 a = a NFunctorF f n a = f (NFunctorF f (n-1) a) data MkNFunctor f (n :: Nat) a where ZF :: a -> MkNFunctor f 0 a SF :: f (MkNFunctor f (n-1) a) -> MkNFunctor f n a class NConvertable f (n :: Nat) where fromNFunctor :: MkNFunctor f n a -> NFunctorF f n a toNFunctor :: NFunctorF f n a -> MkNFunctor f n a instance NConvertable f 0 where fromNFunctor (ZF x) = x toNFunctor x = ZF x instance (Functor f, NConvertable f (n-1)) => NConvertable f n where fromNFunctor (SF xs) = fmap fromNFunctor xs toNFunctor xs = SF (fmap toNFunctor xs) type NMaybe = MkNFunctor Maybe type NList = MkNFunctor [] With error: Couldn't match expected type `f (NFunctorF f (n - 1) a)' with actual type `NFunctorF f n a' Whereas this happily succeeds. type family NFunctorF f (n :: Peano) a where NFunctorF f Zero a = a NFunctorF f (Succ n) a = f (NFunctorF f n a) data MkNFunctor f (n :: Peano) a where ZF :: a -> MkNFunctor f Zero a SF :: f (MkNFunctor f n a) -> MkNFunctor f (Succ n) a class NConvertable f (n :: Peano) where fromNFunctor :: MkNFunctor f n a -> NFunctorF f n a toNFunctor :: NFunctorF f n a -> MkNFunctor f n a instance NConvertable f Zero where fromNFunctor (ZF x) = x toNFunctor x = ZF x instance (Functor f, NConvertable f n) => NConvertable f (Succ n) where fromNFunctor (SF xs) = fmap fromNFunctor xs toNFunctor xs = SF (fmap toNFunctor xs) type NMaybe = MkNFunctor Maybe type NList = MkNFunctor [] Is there any way to fix the first version? Cheers, Daniel ________________________________ From: Haskell-Cafe on behalf of Daniel Filonik Sent: Monday, March 7, 2016 5:53 PM To: amindfv at gmail.com Cc: haskell-cafe at haskell.org Subject: Re: [Haskell-cafe] GADTs and Exponentiated Functors Just a quick follow up to this, unless I am mistaken GHC TypeLits does not actually export constructors (Zero, Succ) for the Nat kind, does it? If it did that, of course I could just use those... FYI, I have cleaned up the example a bit, adding some applicative magic, it now looks like: data Person = Person { name :: String, age :: Integer, gender :: String, status :: String } deriving Show persons = fromList' [Person {name="Alice", age=20, gender="F", status="Good"}, Person {name="Bob", age=18, gender="M", status="Good"}, Person {name="Chuck", age=16, gender="M", status="Bad"}] :: NList N1 Person persons <$$> groupby (gender) <$$> orderby (age) <$$> select (age + 1) <$$> reduce (sum) -- [21,36] Or, if you are feeling more adventurous, you can do thing like: let abg = persons <$$> groupby (gender) <$$> select (age) in ((/) <$> (abg <$$> select(realToFrac)) <***> (abg <$$> reduce(mean))) [[1.0],[1.0588235294117647,0.9411764705882353]] All operations select/reduce/produce/filterby/orderby/groupby work on arbitrarily nested lists, making this very composable. Cheers, Daniel ________________________________ From: Daniel Filonik Sent: Monday, March 7, 2016 3:13 AM To: amindfv at gmail.com Cc: haskell-cafe at haskell.org Subject: Re: [Haskell-cafe] GADTs and Exponentiated Functors I started out using TypeLits, but I was running into problems with GHC's solver along these lines: http://stackoverflow.com/questions/24734704/append-for-type-level-numbered-lists-with-typelits However, I would not rule out the possibility that this was due to misuse my behalf. If you know a way to make it work, that would be exactly the kind of feedback I am looking for! Also, I'd be curious if it is possible to write an instance of the general NFunctor for NList (which does not require explicit type annotations to work): class NFunctor t (m :: Peano) (n :: Peano) where pmap' :: (t (Succ m) a -> t m b) -> t (Succ n) a -> t n b zmap' :: (t m a -> t m b) -> t n a -> t n b smap' :: (t m a -> t (Succ m) b) -> t n a -> t (Succ n) b Cheers, Daniel ________________________________ From: amindfv at gmail.com Sent: Monday, March 7, 2016 2:38 AM To: Daniel Filonik Cc: haskell-cafe at haskell.org Subject: Re: [Haskell-cafe] GADTs and Exponentiated Functors Interesting! What's the reason you redefine the Piano numbers and hide the import of the ones from GHC. TypeLits? Tom El 6 mar 2016, a las 07:11, Daniel Filonik > escribi?: Hi, I have been recently playing around with GADTs, using them to keep track of how many times a functor has been applied. This provides a solution to what seems to be a long standing problem, summarized here: https://byorgey.wordpress.com/2007/08/16/mapping-over-a-nested-functor/ If the nesting depth is part of the type, it is possible to apply fmap automatically as needed. This allows you to write fairly elegant expressions like: data Person = Person { name :: String, age :: Integer, gender :: String, status :: String } deriving Show let persons = fromList' [Person {name="Alice", age=20, gender="F", status="Good"}, Person {name="Bob", age=18, gender="M", status="Good"}, Person {name="Chuck", age=16, gender="M", status="Bad"}] :: NList N1 Person persons `select` age -- [20,18,16] persons `groupby` gender `select` age -- [[20],[18,16]] persons `groupby` gender `groupby` status `select` age -- [[[20]],[[18],[16]]] Note that "`select` age" works regardless of nesting depth. You can also append or remove nesting levels: persons `groupby` gender `select` age `produce` (\x -> [0..x]) -- [[[0..20]],[[0..18],[0..16]]] persons `groupby` gender `reduce` (sumof age) -- [20, 34] Would this kind of thing be of interest? The code is here: https://github.com/filonik/nlists Please feel free to suggest improvements. Cheers, Daniel _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe at haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe -------------- next part -------------- An HTML attachment was scrubbed... URL: From mitchellwrosen at gmail.com Tue Mar 8 23:59:22 2016 From: mitchellwrosen at gmail.com (Mitchell Rosen) Date: Tue, 8 Mar 2016 15:59:22 -0800 (PST) Subject: [Haskell-cafe] extensible effects + classy lenses Message-ID: <62275931-dc7a-420e-b3df-633a6cb3e29c@googlegroups.com> Hi all, I'm trying to combine an extensible effects style state with classy lenses. That is, instead of pinning the type of my state down, I'd like to only require the pieces I need. For example, {-# language FlexibleContexts #-} import Control.Monad.Freer import Control.Monad.Freer.State class HasInt s where getInt :: s -> Int foo :: (Member (State s) effs, HasInt s) => Eff effs Int foo = get However, this fails to typecheck: Overlapping instances for Member (State s0) effs Matching givens (or their superclasses): (Member (State s) effs) bound by the type signature for foo :: (Member (State s) effs, HasInt s) => Eff effs Int at example.hs:9:8-56 Matching instances: instance Data.Open.Union.Member' t r (Data.Open.Union.FindElem t r) => Member t r -- Defined in ?Data.Open.Union? (The choice depends on the instantiation of ?effs, s0?) In the ambiguity check for the type signature for ?foo?: foo :: forall (effs :: [* -> *]) s. (Member (State s) effs, HasInt s) => Eff effs Int To defer the ambiguity check to use sites, enable AllowAmbiguousTypes In the type signature for ?foo?: foo :: (Member (State s) effs, HasInt s) => Eff effs Int Is this a weakness of extensible effects, or is there another way to express this function? Thanks, Mitchell -------------- next part -------------- An HTML attachment was scrubbed... URL: From mitchellwrosen at gmail.com Wed Mar 9 00:02:13 2016 From: mitchellwrosen at gmail.com (Mitchell Rosen) Date: Tue, 8 Mar 2016 16:02:13 -0800 (PST) Subject: [Haskell-cafe] extensible effects + classy lenses In-Reply-To: <62275931-dc7a-420e-b3df-633a6cb3e29c@googlegroups.com> References: <62275931-dc7a-420e-b3df-633a6cb3e29c@googlegroups.com> Message-ID: Sorry, in "foo", the body should be "fmap getInt get". Still, same type error. On Tuesday, March 8, 2016 at 3:59:23 PM UTC-8, Mitchell Rosen wrote: > > Hi all, > > I'm trying to combine an extensible effects style state with classy > lenses. That is, instead of pinning the type of my state down, I'd like to > only require the pieces I need. > > For example, > > {-# language FlexibleContexts #-} > > import Control.Monad.Freer > import Control.Monad.Freer.State > > class HasInt s where > getInt :: s -> Int > > foo :: (Member (State s) effs, HasInt s) => Eff effs Int > foo = get > > However, this fails to typecheck: > > Overlapping instances for Member (State s0) effs > Matching givens (or their superclasses): > (Member (State s) effs) > bound by the type signature for > foo :: (Member (State s) effs, HasInt s) => Eff effs Int > at example.hs:9:8-56 > Matching instances: > instance Data.Open.Union.Member' > t r (Data.Open.Union.FindElem t r) => > Member t r > -- Defined in ?Data.Open.Union? > (The choice depends on the instantiation of ?effs, s0?) > In the ambiguity check for the type signature for ?foo?: > foo :: forall (effs :: [* -> *]) s. > (Member (State s) effs, HasInt s) => > Eff effs Int > To defer the ambiguity check to use sites, enable AllowAmbiguousTypes > In the type signature for ?foo?: > foo :: (Member (State s) effs, HasInt s) => Eff effs Int > > Is this a weakness of extensible effects, or is there another way to > express this function? > > Thanks, > Mitchell > -------------- next part -------------- An HTML attachment was scrubbed... URL: From vogt.adam at gmail.com Wed Mar 9 07:17:11 2016 From: vogt.adam at gmail.com (adam vogt) Date: Wed, 9 Mar 2016 02:17:11 -0500 Subject: [Haskell-cafe] extensible effects + classy lenses In-Reply-To: References: <62275931-dc7a-420e-b3df-633a6cb3e29c@googlegroups.com> Message-ID: Mitchell, You could pass in another argument that specifies which 's', which might not be as much of a pain if it was an implicit parameter like here: < http://lpaste.net/154303>. Another way to resolve the ambiguity would be to say that foo1 accesses first State in the list: type family OuterState xs where OuterState (State s ': rest) = s OuterState (x ': xs) = OuterState xs -- using ScopedTypeVariables foo1 :: forall r s. (OuterState r ~ s, Member (State s) r, HasInt s) => Eff r Int foo1 = getInt <$> (get :: Eff r s) But I think you probably should just pin down the state type you're accessing because you can have multiple `State s`and they don't get in each other?s way at all if they have different types. get2 :: Eff '[State Int, State Char] (Int,Char) get2 = do i <- get; c <- get; return (i,c) -- works just fine Regards, Adam On Tue, Mar 8, 2016 at 7:02 PM, Mitchell Rosen wrote: > Sorry, in "foo", the body should be "fmap getInt get". Still, same type > error. > > > On Tuesday, March 8, 2016 at 3:59:23 PM UTC-8, Mitchell Rosen wrote: >> >> Hi all, >> >> I'm trying to combine an extensible effects style state with classy >> lenses. That is, instead of pinning the type of my state down, I'd like to >> only require the pieces I need. >> >> For example, >> >> {-# language FlexibleContexts #-} >> >> import Control.Monad.Freer >> import Control.Monad.Freer.State >> >> class HasInt s where >> getInt :: s -> Int >> >> foo :: (Member (State s) effs, HasInt s) => Eff effs Int >> foo = get >> >> However, this fails to typecheck: >> >> Overlapping instances for Member (State s0) effs >> Matching givens (or their superclasses): >> (Member (State s) effs) >> bound by the type signature for >> foo :: (Member (State s) effs, HasInt s) => Eff effs >> Int >> at example.hs:9:8-56 >> Matching instances: >> instance Data.Open.Union.Member' >> t r (Data.Open.Union.FindElem t r) => >> Member t r >> -- Defined in ?Data.Open.Union? >> (The choice depends on the instantiation of ?effs, s0?) >> In the ambiguity check for the type signature for ?foo?: >> foo :: forall (effs :: [* -> *]) s. >> (Member (State s) effs, HasInt s) => >> Eff effs Int >> To defer the ambiguity check to use sites, enable AllowAmbiguousTypes >> In the type signature for ?foo?: >> foo :: (Member (State s) effs, HasInt s) => Eff effs Int >> >> Is this a weakness of extensible effects, or is there another way to >> express this function? >> >> Thanks, >> Mitchell >> > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From roma at ro-che.info Wed Mar 9 07:47:45 2016 From: roma at ro-che.info (Roman Cheplyaka) Date: Wed, 9 Mar 2016 09:47:45 +0200 Subject: [Haskell-cafe] extensible effects + classy lenses In-Reply-To: <62275931-dc7a-420e-b3df-633a6cb3e29c@googlegroups.com> References: <62275931-dc7a-420e-b3df-633a6cb3e29c@googlegroups.com> Message-ID: <56DFD521.2090909@ro-che.info> In show . read ambiguity, is it a weakness of show or read? :) This isn't a weakness of extensible effects per se; rather, this a consequence of extensible effects and classy lenses being too polymorphic, so that they can't be combined without a further disambiguation. In monad-classes, there is a 'Zoom' effect which, given a lens from 'big' into 'small', transforms State requests over 'small' into State effects over 'big'. If you work with only a handful of lenses but use them often, it may be worth considering. I also remember someone developing an EE library based on the ideas from monad-classes and mtlx, where you disambiguate every single effect with singleton types. But in general, for best experience, make one of those two things less polymorphic: mtl + classy lenses (Kmett's preferred way) or EE + monomorphic lenses (my preferred way). Roman On 03/09/2016 01:59 AM, Mitchell Rosen wrote: > Hi all, > > I'm trying to combine an extensible effects style state with classy > lenses. That is, instead of pinning the type of my state down, I'd like > to only require the pieces I need. > > For example, > > {-# language FlexibleContexts #-} > > import Control.Monad.Freer > import Control.Monad.Freer.State > > class HasInt s where > getInt :: s -> Int > > foo :: (Member (State s) effs, HasInt s) => Eff effs Int > foo = get > > However, this fails to typecheck: > > Overlapping instances for Member (State s0) effs > Matching givens (or their superclasses): > (Member (State s) effs) > bound by the type signature for > foo :: (Member (State s) effs, HasInt s) => Eff effs Int > at example.hs:9:8-56 > Matching instances: > instance Data.Open.Union.Member' > t r (Data.Open.Union.FindElem t r) => > Member t r > -- Defined in ?Data.Open.Union? > (The choice depends on the instantiation of ?effs, s0?) > In the ambiguity check for the type signature for ?foo?: > foo :: forall (effs :: [* -> *]) s. > (Member (State s) effs, HasInt s) => > Eff effs Int > To defer the ambiguity check to use sites, enable AllowAmbiguousTypes > In the type signature for ?foo?: > foo :: (Member (State s) effs, HasInt s) => Eff effs Int > > Is this a weakness of extensible effects, or is there another way to > express this function? > > Thanks, > Mitchell > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > From icfp.publicity at googlemail.com Wed Mar 9 08:08:51 2016 From: icfp.publicity at googlemail.com (Lindsey Kuper) Date: Wed, 9 Mar 2016 00:08:51 -0800 Subject: [Haskell-cafe] ICFP 2016 Call for Sponsorships Message-ID: ICFP 2016 The 21st ACM SIGPLAN International Conference on Functional Programming http://conf.researchr.org/home/icfp-2016 Call for Sponsorships Web version of this call for sponsorships: http://conf.researchr.org/info/icfp-2016/call-for-sponsorships ## Why Sponsor ICFP 2016? ICFP is the premier conference on functional programming languages, covering all aspects of theory, implementation, and application. Every year, we bring over 400 world-leading researchers, practitioners, and students together to discuss the latest findings, collaborate on new ideas, and meet new people. By sponsoring ICFP, your organization can demonstrate its commitment to supporting high quality research and to developing the next generation of functional programming experts. Most of our sponsorship funds are used to help students from around the world afford to attend the conference and get the most out of their experience. We believe that this commitment will pay dividends for our students, our sponsors, and the public good for years to come. ## Sponsorship Opportunities and Benefits Bronze: $500: Logo on website, poster at industrial reception, listed in proceedings. Silver: $2500: As above, plus: logo in proceedings, logo on publicity materials (e.g., posters, etc.) Gold: $5000: As above, plus: named supporter of industrial reception with opportunity to speak to the audience, and opportunity to include branded merchandise in participants? swag bag. Platinum: $10000: As above, plus: named supporter of whole event, logo on lanyards, badge ribbon, table/booth-like space available (in coffee break areas), other negotiated benefits (subject to ACM restrictions on commercial involvement). ## How to Become a Sponsor If you?re interested in becoming a sponsor, we?d love to hear from you. You can get in touch with our Industrial Relations Chair at ryan.trinkle at gmail.com. From kwangyul.seo at gmail.com Wed Mar 9 12:45:19 2016 From: kwangyul.seo at gmail.com (KwangYul Seo) Date: Wed, 9 Mar 2016 21:45:19 +0900 Subject: [Haskell-cafe] Use cases of empty type classes In-Reply-To: References: <56deb7ee6dbbbc3000000006@polymail.io> Message-ID: Hi, Simon Marlow's paper[1] introduces a type class named `Exception` which has no methods. Here `Exception` is defined as a synonym for `Typeable` and `Show`: class (Typeable a, Show a) => Exception a [1] "An Extensible Dynamically-Typed Hierarchy of Exceptions http://community.haskell.org/~simonmar/papers/ext-exceptions.pdf On Wed, Mar 9, 2016 at 12:48 AM, Geraldus wrote: > Thanks everybody. I found this helpful (: > > ??, 8 ???. 2016 ?. ? 19:58, Alex Rozenshteyn : > >> You can use them to claim something about multiple type classes at once, >> with some advantages over using ConstraintKinds for the same purpose: >> https://www.reddit.com/r/haskell/comments/49em92/haskells_typeclasses_we_can_do_better/d0rwvi8?context=2 >> >> >> On Tue, Mar 8, 2016 at 6:36 AM Adam Bergmark wrote: >> >>> I have two use cases for them >>> >>> >>> - In fay-jquery there?s an empty Selectable class that has instances >>> for all elements that can be passed to the jQuery function, there is no >>> need for methods since we in the background just pass the object along, but >>> we want to make sure we don?t pass something nonsensical. >>> - In a rest API serving JSON you need ToJSON and FromJSON instances >>> for each type, but since internal APIs may also use JSON it?s possible that >>> you by accident pass a type that isn?t versioned and supposed to be >>> included in the public API. There I can have an empty PublicApiType class >>> with instances for all public types to give a type error if I pass >>> something internal by mistake. >>> >>> >>> /Adam Bergmark >>> >>> >>> On Tue 08 Mar 2016 at 07:10 Tomas Tauber >> > wrote: >>> >>>> Hi everyone, >>>> >>>> I have one question. What are current use cases of type classes with no >>>> methods? >>>> >>>> I saw early uses in type-level programming (e.g. HList [1]). >>>> In the OO world, interfaces with no methods are called marker >>>> interfaces -- their use cases range from things that could be done with >>>> datatype generic programming in Haskell (e.g. serialization) to metadata >>>> annotations (e.g. RandomAccess [2]). >>>> >>>> Regards, >>>> >>>> Tomas Tauber >>>> >>>> >>>> [1] http://okmij.org/ftp/Haskell/HList-ext.pdf >>>> [2] >>>> https://docs.oracle.com/javase/8/docs/api/java/util/RandomAccess.html >>>> _______________________________________________ >>>> Haskell-Cafe mailing list >>>> Haskell-Cafe at haskell.org >>>> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe >>>> >>> >>> _______________________________________________ >>> Haskell-Cafe mailing list >>> Haskell-Cafe at haskell.org >>> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe >>> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe >> > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From amindfv at gmail.com Wed Mar 9 17:21:06 2016 From: amindfv at gmail.com (Tom Murphy) Date: Wed, 9 Mar 2016 12:21:06 -0500 Subject: [Haskell-cafe] Type equality with "forall" Message-ID: So I've written a library I'm pretty excited about, and there's just one type issue keeping it from all working! I've got a graph that represents functions and function composition, and I've written a class (pretty directly from Oleg's "TypeEq" work [0]) that tells whether two types are equal. The problem is it doesn't always say they're equal. Here's a simplified version that has the same issue: [pragmas [1]] data Fs a c where F :: (a -> c) -> Fs a c Compose :: forall a b c. Fs b c -> Fs a b -> Fs a c -- Type equality: class TEq x0 x1 y0 y1 (b :: Bool) | x0 x1 y0 y1 -> b where isEq :: Fs x0 x1 -> (y0 -> y1) -> String -- The case where the types are equal: instance {-# OVERLAPS #-} TEq x y x y 'True where isEq _ _ = "yes!" -- The case where they're unequal: instance (b ~ 'False) => TEq x0 x1 y0 y1 b where isEq (F _) = "no" isEq (Compose a b) f = "compose("++isEq a f++", "++isEq b f++")" When I try this on example programs, I see weird results: > isEq (F not) not "yes!" -- expected > isEq (Compose (F (\_->"")) (F not)) not "compose(no, no)" -- weird! I would expect the result of the second one to be "compose(no, yes!)". It seems to think that the (F not) in the Compose has a different type than (F not) not in a Compose. Anyone spot my problem? Thanks! Tom [0] http://okmij.org/ftp/Haskell/typeEQ.html [1] {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE FunctionalDependencies #-} {-# LANGUAGE GADTs, NoMonoLocalBinds #-} {-# LANGUAGE KindSignatures #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE Rank2Types #-} {-# LANGUAGE UndecidableInstances #-} -------------- next part -------------- An HTML attachment was scrubbed... URL: From vogt.adam at gmail.com Wed Mar 9 18:51:04 2016 From: vogt.adam at gmail.com (adam vogt) Date: Wed, 9 Mar 2016 13:51:04 -0500 Subject: [Haskell-cafe] Type equality with "forall" In-Reply-To: References: Message-ID: Hi Tom, It looks like after a type variable is hidden (existentially quantified is probably the term), you don't get it back to pick the more specific instance. Here's a shorter example than yours: {-# LANGUAGE FlexibleInstances, GADTs #-} class C a where c :: a -> String instance {-# OVERLAPPABLE #-} C a where c _ = "fallback" instance {-# OVERLAPS #-} C Char where c _ = "char" data T where T :: a -> T example = case T 'x' of T x -> c x -- prints "fallback" In this example you can change the T constructor to T :: C a => a -> T to get "char" printed, but I can't figure the equivalent of that for your class. The closest I can get is to store the Typeable dictionary with the Compose constructor which would let you return "yes" when the wrong instance is chosen. But then if you have Typeable you probably don't need overlapping instances. Regards, Adam On Wed, Mar 9, 2016 at 12:21 PM, Tom Murphy wrote: > So I've written a library I'm pretty excited about, and there's just one > type issue keeping it from all working! > > I've got a graph that represents functions and function composition, and > I've written a class (pretty directly from Oleg's "TypeEq" work [0]) that > tells whether two types are equal. The problem is it doesn't always say > they're equal. > > Here's a simplified version that has the same issue: > > > [pragmas [1]] > > data Fs a c where > F :: (a -> c) -> Fs a c > Compose :: forall a b c. Fs b c -> Fs a b -> Fs a c > > -- Type equality: > class TEq x0 x1 y0 y1 (b :: Bool) | x0 x1 y0 y1 -> b where > isEq :: Fs x0 x1 -> (y0 -> y1) -> String > > -- The case where the types are equal: > instance {-# OVERLAPS #-} TEq x y x y 'True where > isEq _ _ = "yes!" > > -- The case where they're unequal: > instance (b ~ 'False) => TEq x0 x1 y0 y1 b where > isEq (F _) = "no" > isEq (Compose a b) f = "compose("++isEq a f++", "++isEq b f++")" > > > > > > When I try this on example programs, I see weird results: > > > isEq (F not) not > "yes!" -- expected > > isEq (Compose (F (\_->"")) (F not)) not > "compose(no, no)" -- weird! > > I would expect the result of the second one to be "compose(no, yes!)". > > It seems to think that the (F not) in the Compose has a different type > than (F not) not in a Compose. > > Anyone spot my problem? > > Thanks! > Tom > > [0] http://okmij.org/ftp/Haskell/typeEQ.html > [1] > {-# LANGUAGE DataKinds #-} > {-# LANGUAGE FlexibleInstances #-} > {-# LANGUAGE FunctionalDependencies #-} > {-# LANGUAGE GADTs, NoMonoLocalBinds #-} > {-# LANGUAGE KindSignatures #-} > {-# LANGUAGE MultiParamTypeClasses #-} > {-# LANGUAGE Rank2Types #-} > {-# LANGUAGE UndecidableInstances #-} > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From amindfv at gmail.com Wed Mar 9 19:30:11 2016 From: amindfv at gmail.com (Tom Murphy) Date: Wed, 9 Mar 2016 14:30:11 -0500 Subject: [Haskell-cafe] Type equality with "forall" In-Reply-To: References: Message-ID: Thanks for the reply, Adam! It looks like the problem is the combination of existentials and overlapping instances (which don't behave sensibly together). Here's a new version (that also doesn't work!) but that I think is a lot closer -- this one uses type families instead of overlapping instances: [pragmas [0]] import Data.Proxy -- Same as before: data Fs a c where F :: (a -> c) -> Fs a c Compose :: forall a b c. Fs b c -> Fs a b -> Fs a c class TEq x0 x1 y0 y1 where isEq :: Fs x0 x1 -> (y0 -> y1) -> String instance ( flag ~ IEq (Fs x0 x1) (y0 -> y1) , TEq' x0 x1 y0 y1 flag ) => TEq x0 x1 y0 y1 where isEq = isEq' (Proxy::Proxy flag) type family IEq a b :: Bool where IEq (Fs x0 x1) (xo -> x1) = 'True IEq a b = 'False class TEq' x0 x1 y0 y1 (flag :: Bool) where isEq' :: Proxy flag -> (Fs x0 x1) -> (y0 -> y1) -> String instance TEq' x0 x1 y0 y1 'True where isEq' _ _ _ = "yes!" instance TEq' x0 x1 y0 y1 'False where isEq' _ (F _) _ = "no" -- isEq' _ (Compose a b) f = "compose("++isEq a f++", "++isEq b f++")" The problem is the last line -- the "hidden" type can't be inferred to be in TEq', although every type is in fact in TEq' Any more help would be very appreciated! Thanks, Tom [0] {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE FunctionalDependencies #-} {-# LANGUAGE GADTs, NoMonoLocalBinds #-} {-# LANGUAGE KindSignatures #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE Rank2Types #-} {-# LANGUAGE ScopedTypeVariables #-} -- new {-# LANGUAGE TypeFamilies #-} -- new {-# LANGUAGE UndecidableInstances #-} On Wed, Mar 9, 2016 at 1:51 PM, adam vogt wrote: > Hi Tom, > > It looks like after a type variable is hidden (existentially quantified is > probably the term), you don't get it back to pick the more specific > instance. Here's a shorter example than yours: > > {-# LANGUAGE FlexibleInstances, GADTs #-} > > class C a where c :: a -> String > > instance {-# OVERLAPPABLE #-} C a where c _ = "fallback" > instance {-# OVERLAPS #-} C Char where c _ = "char" > > data T where T :: a -> T > > example = case T 'x' of T x -> c x > -- prints "fallback" > > In this example you can change the T constructor to T :: C a => a -> T to > get "char" printed, but I can't figure the equivalent of that for your > class. The closest I can get is to store the Typeable dictionary with the > Compose constructor which would > let you return "yes" when the wrong instance is chosen. But then if you > have Typeable you probably don't need overlapping instances. > > Regards, > Adam > > > On Wed, Mar 9, 2016 at 12:21 PM, Tom Murphy wrote: > >> So I've written a library I'm pretty excited about, and there's just one >> type issue keeping it from all working! >> >> I've got a graph that represents functions and function composition, and >> I've written a class (pretty directly from Oleg's "TypeEq" work [0]) that >> tells whether two types are equal. The problem is it doesn't always say >> they're equal. >> >> Here's a simplified version that has the same issue: >> >> >> [pragmas [1]] >> >> data Fs a c where >> F :: (a -> c) -> Fs a c >> Compose :: forall a b c. Fs b c -> Fs a b -> Fs a c >> >> -- Type equality: >> class TEq x0 x1 y0 y1 (b :: Bool) | x0 x1 y0 y1 -> b where >> isEq :: Fs x0 x1 -> (y0 -> y1) -> String >> >> -- The case where the types are equal: >> instance {-# OVERLAPS #-} TEq x y x y 'True where >> isEq _ _ = "yes!" >> >> -- The case where they're unequal: >> instance (b ~ 'False) => TEq x0 x1 y0 y1 b where >> isEq (F _) = "no" >> isEq (Compose a b) f = "compose("++isEq a f++", "++isEq b f++")" >> >> >> >> >> >> When I try this on example programs, I see weird results: >> >> > isEq (F not) not >> "yes!" -- expected >> > isEq (Compose (F (\_->"")) (F not)) not >> "compose(no, no)" -- weird! >> >> I would expect the result of the second one to be "compose(no, yes!)". >> >> It seems to think that the (F not) in the Compose has a different type >> than (F not) not in a Compose. >> >> Anyone spot my problem? >> >> Thanks! >> Tom >> >> [0] http://okmij.org/ftp/Haskell/typeEQ.html >> [1] >> {-# LANGUAGE DataKinds #-} >> {-# LANGUAGE FlexibleInstances #-} >> {-# LANGUAGE FunctionalDependencies #-} >> {-# LANGUAGE GADTs, NoMonoLocalBinds #-} >> {-# LANGUAGE KindSignatures #-} >> {-# LANGUAGE MultiParamTypeClasses #-} >> {-# LANGUAGE Rank2Types #-} >> {-# LANGUAGE UndecidableInstances #-} >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From maksymilian.owsianny at gmail.com Wed Mar 9 21:15:42 2016 From: maksymilian.owsianny at gmail.com (Maksymilian Owsianny) Date: Wed, 9 Mar 2016 21:15:42 +0000 Subject: [Haskell-cafe] Materials on Compiling Functional Languages. Message-ID: Hi Cafe, I'm looking for materials on compiling functional languages. The materials that I was able to gather from the web were kind of all over the place, so I'm hoping someone could help me out with something more in order for a novice. Starting from something specific and simple so I could have something small and concrete to implement, play and ponder about. And then going forward with more advanced materials about different optimization strategies for eager and lazy languages or what could be achieved when limiting yourself only to a total language, etc. Cheers, Max. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gmizrahi22 at gmail.com Wed Mar 9 22:01:04 2016 From: gmizrahi22 at gmail.com (Gil Mizrahi) Date: Wed, 9 Mar 2016 22:01:04 +0000 (UTC) Subject: [Haskell-cafe] Materials on Compiling Functional Languages. References: Message-ID: Maksymilian Owsianny gmail.com> writes: > > Hi Cafe, > > I'm looking for materials on compiling functional languages. The > materials that I was able to gather from the web were kind of all over > the place, so I'm hoping someone could help me out with something more > in order for a novice. > > Starting from something specific and simple so I could have something > small and concrete to implement, play and ponder about. And then > going forward with more advanced materials about different > optimization strategies for eager and lazy languages or what could be > achieved when limiting yourself only to a total language, etc. > > Cheers, > Max. > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Hi Maksymilian, Here you'll find a (perhaps not so) short list I've accumulated: http://pastemarkdown.com/XUEvs and here it is in markdown format: - [Implementing a JIT Compiled Language with Haskell and LLVM](http://www.stephendiehl.com/llvm/) - [Write You a Haskell](http://dev.stephendiehl.com/fun/index.html) - [Theory and Implementation of a Functional Programming Language](http://www.rose-hulman.edu/mathjournal/archives/2000/vol1-n2/paper3/v1n2-3pd.pdf) - [Implementing Functional Programming Languages](http://research.microsoft.com/en-us/um/people/simonpj/papers/slpj-book-1987/slpj-book-1987.pdf) - SPJ - [Implementing Functional Langauges: a tutorial](http://research.microsoft.com/en-us/um/people/simonpj/Papers/pj-lester-book/) - SPJ - [Practical Implementation of a Dependently Typed Functional Programming Language | Brady](http://compsoc.dur.ac.uk/~ecb/proofread/thesis.pdf) - [PLAI](http://cs.brown.edu/~sk/Publications/Books/ProgLangs/2007-04-26/plai-2007-04-26.pdf) - [STG Machine](http://www.dcc.fc.up.pt/~pbv/aulas/linguagens/peytonjones92implementing.pdf) - [Typing Haskell in Haskell](http://web.cecs.pdx.edu/~mpj/thih/TypingHaskellInHaskell.html - [Practical type inference for arbitrary-rank types / SPJ et al.](http://research.microsoft.com/en-us/um/people/simonpj/papers/higher-rank/putting.pdf) - Compiling with Continuations - Appel - [PureScript Compiler](https://github.com/purescript/purescript) Cheers and good luck, Gil From yoyoyonny at gmail.com Thu Mar 10 09:06:45 2016 From: yoyoyonny at gmail.com (Jonne Ransijn) Date: Thu, 10 Mar 2016 10:06:45 +0100 Subject: [Haskell-cafe] Materials on Compiling Functional Languages. In-Reply-To: References: Message-ID: I would start simple by creating a Lisp compiler or low level interpreter, and am personally a great fan of https://github.com/openube/zozotez, but making a compiler for Haskell is of course way more difficult, productive and awesome. Gil came with some good links to help you with that. -------------- next part -------------- An HTML attachment was scrubbed... URL: From plredmond at gmail.com Thu Mar 10 12:25:23 2016 From: plredmond at gmail.com (Patrick Redmond) Date: Thu, 10 Mar 2016 07:25:23 -0500 Subject: [Haskell-cafe] Materials on Compiling Functional Languages. In-Reply-To: References: Message-ID: There's "write you a Haskell" but it's still in progress http://dev.stephendiehl.com/fun/index.html On Thursday, March 10, 2016, Jonne Ransijn wrote: > I would start simple by creating a Lisp compiler or low level interpreter, > and am personally a great fan of https://github.com/openube/zozotez, but > making a compiler for Haskell is of course way more difficult, productive > and awesome. Gil came with some good links to help you with that. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From maksymilian.owsianny at gmail.com Thu Mar 10 12:42:35 2016 From: maksymilian.owsianny at gmail.com (Maksymilian Owsianny) Date: Thu, 10 Mar 2016 12:42:35 +0000 Subject: [Haskell-cafe] Materials on Compiling Functional Languages. In-Reply-To: References: Message-ID: @Jonne Maybe I should have been a little more precise. I'm specifically interested in a compilation step, that is turning a AST of some functional language say untyped lambda calculus into a sequence of imperative instructions. And I'm looking for a somewhat structured materials on the subject. If I were to give an analogy it would be how you would teach someone about sorting algorithms. You would start with simple solutions that most people come up on their own, like insert or bubble sort. Then you go on about explaining problems with complexity of that solutions and you present slightly more complex but optimal algorithms like quick or merge sort. Then maybe you would give a proof that n log n is best you can do for comparison based solutions. Then you could ask what could be done if you remove that restriction, and so on... That way I could get a more complete understanding of the field. Where all I was able to fish from google were papers about (to continue the analogy) theoretical complexity of a sorting algorithm on a quantum computer or constant time improvements of a heap sort given architecture with SIMD instruction set. And of course given enough time I would be able to piece all that knowledge together, but I'm hoping someone could spare me that time. @Gil Thanks for suggestions, I was able to locate previously these series by Stephan Diehl and they are truly quality material, the only problem is that the first one deals with compiling an imperative language. So it is of great use as practical solution to llvm generation but doesn't really answers any of my theoretical questions about functional language compilation. The second one on the other hand deals with haskell so that's a bit of a jump already but also is still a work in progress and crucially doesn't yet have the chapters regarding compilation. As for others most of them are new to me so I guess I'll have to take a deeper look. Ultimately I wasn't really expecting to get all that knowledge on a silver platter. I guess I'll have to dig into all that literature until I'll come out enlightened, so really anything useful you can throw at me I'll be grateful for. Thanks, Max. -------------- next part -------------- An HTML attachment was scrubbed... URL: From matthewtpickering at gmail.com Thu Mar 10 13:28:31 2016 From: matthewtpickering at gmail.com (Matthew Pickering) Date: Thu, 10 Mar 2016 13:28:31 +0000 Subject: [Haskell-cafe] Materials on Compiling Functional Languages. In-Reply-To: References: Message-ID: Try to find "Implementing Functional Languages: A Tutorial" by Simon Peyton-Jones and David Lester. On Thu, Mar 10, 2016 at 12:42 PM, Maksymilian Owsianny wrote: > @Jonne > > Maybe I should have been a little more precise. I'm specifically > interested in a compilation step, that is turning a AST of some > functional language say untyped lambda calculus into a sequence of > imperative instructions. > > And I'm looking for a somewhat structured materials on the subject. > > If I were to give an analogy it would be how you would teach someone > about sorting algorithms. You would start with simple solutions that > most people come up on their own, like insert or bubble sort. Then you > go on about explaining problems with complexity of that solutions and > you present slightly more complex but optimal algorithms like quick or > merge sort. Then maybe you would give a proof that n log n is best you > can do for comparison based solutions. Then you could ask what could > be done if you remove that restriction, and so on... > > That way I could get a more complete understanding of the field. > > Where all I was able to fish from google were papers about (to > continue the analogy) theoretical complexity of a sorting algorithm on > a quantum computer or constant time improvements of a heap sort given > architecture with SIMD instruction set. > > And of course given enough time I would be able to piece all that > knowledge together, but I'm hoping someone could spare me that time. > > @Gil > > Thanks for suggestions, I was able to locate previously these series > by Stephan Diehl and they are truly quality material, the only problem > is that the first one deals with compiling an imperative language. So > it is of great use as practical solution to llvm generation but > doesn't really answers any of my theoretical questions about > functional language compilation. The second one on the other hand > deals with haskell so that's a bit of a jump already but also is still > a work in progress and crucially doesn't yet have the chapters > regarding compilation. As for others most of them are new to me so > I guess I'll have to take a deeper look. > > Ultimately I wasn't really expecting to get all that knowledge on > a silver platter. I guess I'll have to dig into all that literature > until I'll come out enlightened, so really anything useful you can > throw at me I'll be grateful for. > > Thanks, > Max. > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > From yoyoyonny at gmail.com Thu Mar 10 14:17:48 2016 From: yoyoyonny at gmail.com (Jonne Ransijn) Date: Thu, 10 Mar 2016 15:17:48 +0100 Subject: [Haskell-cafe] Materials on Compiling Functional Languages. In-Reply-To: References: Message-ID: @Matthew: Gil already provided a link for that, which appears to be the first result on Google aswell: http://research.microsoft.com/en-us/um/people/simonpj/Papers/pj-lester-book/ @Max: Haskell compilation is not really my area, but if a Lisp compiler seems too easy (And I have to say, it _is_ quite easy, and shouldn't take more than a couple of hours of coding), I would recommend starting by looking into the Haskell Core to find out what Haskell boils down to. From there you might be able to figure out how Haskell actually gets turned into iterative code. The links Gil provided really help with this aswell. This stackoverflow page contains some useful links and a compact explaination of the Haskell Core, and is a great introduction to the Haskell core. (Although it might be focused more around optimalization than it is about the core itself): http://stackoverflow.com/questions/6121146/reading-ghc-core Explaination from haskell.org: https://ghc.haskell.org/trac/ghc/wiki/Commentary/Compiler/CoreSynType PDF (As found on the above page): https://downloads.haskell.org/~ghc/6.12.2/docs/core.pdf Sorry if these links are not helping. I am still trying to figure out the Haskell Core myself. On Thu, Mar 10, 2016 at 2:28 PM, Matthew Pickering < matthewtpickering at gmail.com> wrote: > Try to find "Implementing Functional Languages: A Tutorial" by Simon > Peyton-Jones and David Lester. > > On Thu, Mar 10, 2016 at 12:42 PM, Maksymilian Owsianny > wrote: > > @Jonne > > > > Maybe I should have been a little more precise. I'm specifically > > interested in a compilation step, that is turning a AST of some > > functional language say untyped lambda calculus into a sequence of > > imperative instructions. > > > > And I'm looking for a somewhat structured materials on the subject. > > > > If I were to give an analogy it would be how you would teach someone > > about sorting algorithms. You would start with simple solutions that > > most people come up on their own, like insert or bubble sort. Then you > > go on about explaining problems with complexity of that solutions and > > you present slightly more complex but optimal algorithms like quick or > > merge sort. Then maybe you would give a proof that n log n is best you > > can do for comparison based solutions. Then you could ask what could > > be done if you remove that restriction, and so on... > > > > That way I could get a more complete understanding of the field. > > > > Where all I was able to fish from google were papers about (to > > continue the analogy) theoretical complexity of a sorting algorithm on > > a quantum computer or constant time improvements of a heap sort given > > architecture with SIMD instruction set. > > > > And of course given enough time I would be able to piece all that > > knowledge together, but I'm hoping someone could spare me that time. > > > > @Gil > > > > Thanks for suggestions, I was able to locate previously these series > > by Stephan Diehl and they are truly quality material, the only problem > > is that the first one deals with compiling an imperative language. So > > it is of great use as practical solution to llvm generation but > > doesn't really answers any of my theoretical questions about > > functional language compilation. The second one on the other hand > > deals with haskell so that's a bit of a jump already but also is still > > a work in progress and crucially doesn't yet have the chapters > > regarding compilation. As for others most of them are new to me so > > I guess I'll have to take a deeper look. > > > > Ultimately I wasn't really expecting to get all that knowledge on > > a silver platter. I guess I'll have to dig into all that literature > > until I'll come out enlightened, so really anything useful you can > > throw at me I'll be grateful for. > > > > Thanks, > > Max. > > > > > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe at haskell.org > > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jo at durchholz.org Thu Mar 10 16:02:39 2016 From: jo at durchholz.org (Joachim Durchholz) Date: Thu, 10 Mar 2016 17:02:39 +0100 Subject: [Haskell-cafe] Materials on Compiling Functional Languages. In-Reply-To: References: Message-ID: <56E19A9F.80403@durchholz.org> Am 10.03.2016 um 13:42 schrieb Maksymilian Owsianny: > I'm specifically > interested in a compilation step, that is turning a AST of some > functional language say untyped lambda calculus into a sequence of > imperative instructions. I was asking myself the same question. I can't offer structured material, but an insight I gained recently (old news to most people here I'm sure). The insight was that you don't compile code for the "this function is not being evaluated" case - that would be pointless because that case is handled by generic graph construction and you don't need code that's specific for the function. Instead, you generate code for the case that the function participates in being evaluated ("forced"). At least for me, that was one of those "a-ha" moments that told my why generating imperative code is even relevant for a language like Haskell. The standard case is where the top-level element of the function is a pattern match: You generate code for the match expressions, freely inline-expanding code from functions called from the match expressions. Same goes for the condition if the top-level element is an if expression. The right-hand sides of the pattern matches remain unevaluated, you generate code to construct graphs, because the compiler does not know which pattern will match. I'm pretty sure I'm missing a big part of the picture and that this model is just the starting point, but anyway, here it is :-) From kei at lanl.gov Thu Mar 10 17:04:51 2016 From: kei at lanl.gov (Kei Davis) Date: Thu, 10 Mar 2016 10:04:51 -0700 Subject: [Haskell-cafe] Materials on Compiling Functional Languages. (Gil Mizrahi) In-Reply-To: References: Message-ID: <56E1A933.4050305@lanl.gov> >> Hi Cafe, >> >> I'm looking for materials on compiling functional languages. The >> materials that I was able to gather from the web were kind of all over >> the place, so I'm hoping someone could help me out with something more >> in order for a novice. >> >> Starting from something specific and simple so I could have something >> small and concrete to implement, play and ponder about. And then >> going forward with more advanced materials about different >> optimization strategies for eager and lazy languages or what could be >> achieved when limiting yourself only to a total language, etc. >> >> Cheers, >> Max. >> >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe haskell.org >> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe >> > > Hi Maksymilian, > > Here you'll find a (perhaps not so) short list I've accumulated: > > http://pastemarkdown.com/XUEvs > > > and here it is in markdown format: > > - [Implementing a JIT Compiled Language with Haskell and > LLVM](http://www.stephendiehl.com/llvm/) > - [Write You a Haskell](http://dev.stephendiehl.com/fun/index.html) > - [Theory and Implementation of a Functional Programming > Language](http://www.rose-hulman.edu/mathjournal/archives/2000/vol1-n2/paper3/v1n2-3pd.pdf) > - [Implementing Functional Programming > Languages](http://research.microsoft.com/en-us/um/people/simonpj/papers/slpj-book-1987/slpj-book-1987.pdf) > - SPJ > - [Implementing Functional Langauges: a > tutorial](http://research.microsoft.com/en-us/um/people/simonpj/Papers/pj-lester-book/) > - SPJ > - [Practical Implementation of a Dependently Typed Functional Programming > Language | Brady](http://compsoc.dur.ac.uk/~ecb/proofread/thesis.pdf) > - > [PLAI](http://cs.brown.edu/~sk/Publications/Books/ProgLangs/2007-04-26/plai-2007-04-26.pdf) > - [STG > Machine](http://www.dcc.fc.up.pt/~pbv/aulas/linguagens/peytonjones92implementing.pdf) > - [Typing Haskell in > Haskell](http://web.cecs.pdx.edu/~mpj/thih/TypingHaskellInHaskell.html > - [Practical type inference for arbitrary-rank types / SPJ et > al.](http://research.microsoft.com/en-us/um/people/simonpj/papers/higher-rank/putting.pdf) > - Compiling with Continuations - Appel > - [PureScript Compiler](https://github.com/purescript/purescript) > > > Cheers and good luck, > Gil > Nice list Gil. We've recently implemented a pure FL compiler. We started with the "stock hardware" paper ([STG Machine] in Gil's list), but it's somewhat dated (e.g. they're still using a trampoline). Our main reference was the "fast curry" paper: http://community.haskell.org/~simonmar/papers/evalapplyjfp06.pdf Bernie Pope's MiniSTG is a useful learning tool based on that paper: https://wiki.haskell.org/Ministg Our type inferencer currently handles ADTs including unboxed types. I strongly recommend http://soft.vub.ac.be/~cfscholl/Capita-Selecta-2015/papers/2002%20Heeren.pdf supplemented by https://galois.com/wp-content/uploads/2014/08/pub_JL_UnboxedValuesAsFirstClassCitizens.pdf Then if you get serious [Typing Haskell in Haskell] in Gil's list. For compiling pattern matching we started with one of the [Implementing Functional ...] in Gil's list, then found some other references online (I don't know exactly which--I didn't implement that part). For a parallel implementation we started with http://community.haskell.org/~simonmar/papers/multiproc.pdf Then there are subsequent papers that can be found on SPJ's publication page. Hope this helps, it helped us! Kei -- Kei Davis Applied Computer Science Group CCS-7, Mail Stop B287 Los Alamos National Laboratory Los Alamos, NM 87545, U.S.A. From jgbailey at gmail.com Thu Mar 10 17:32:21 2016 From: jgbailey at gmail.com (Justin Bailey) Date: Thu, 10 Mar 2016 09:32:21 -0800 Subject: [Haskell-cafe] Materials on Compiling Functional Languages. In-Reply-To: References: Message-ID: Max, I had similar questions several years ago and was able to do a term project to answer them. I wrote a really simple compiler for a Haskell-like language called "habit". The code doesn't work anymore, but you can read my report here: https://github.com/m4dc4p/mil/blob/master/caffeine/report/report.pdf It covers translating an AST into x86, closure representation, among other topics. Under that directory you'll also find the source code to the compiler and a presentation I gave on it. On Thu, Mar 10, 2016 at 4:42 AM, Maksymilian Owsianny wrote: > @Jonne > > Maybe I should have been a little more precise. I'm specifically > interested in a compilation step, that is turning a AST of some > functional language say untyped lambda calculus into a sequence of > imperative instructions. > > And I'm looking for a somewhat structured materials on the subject. > > If I were to give an analogy it would be how you would teach someone > about sorting algorithms. You would start with simple solutions that > most people come up on their own, like insert or bubble sort. Then you > go on about explaining problems with complexity of that solutions and > you present slightly more complex but optimal algorithms like quick or > merge sort. Then maybe you would give a proof that n log n is best you > can do for comparison based solutions. Then you could ask what could > be done if you remove that restriction, and so on... > > That way I could get a more complete understanding of the field. > > Where all I was able to fish from google were papers about (to > continue the analogy) theoretical complexity of a sorting algorithm on > a quantum computer or constant time improvements of a heap sort given > architecture with SIMD instruction set. > > And of course given enough time I would be able to piece all that > knowledge together, but I'm hoping someone could spare me that time. > > @Gil > > Thanks for suggestions, I was able to locate previously these series > by Stephan Diehl and they are truly quality material, the only problem > is that the first one deals with compiling an imperative language. So > it is of great use as practical solution to llvm generation but > doesn't really answers any of my theoretical questions about > functional language compilation. The second one on the other hand > deals with haskell so that's a bit of a jump already but also is still > a work in progress and crucially doesn't yet have the chapters > regarding compilation. As for others most of them are new to me so > I guess I'll have to take a deeper look. > > Ultimately I wasn't really expecting to get all that knowledge on > a silver platter. I guess I'll have to dig into all that literature > until I'll come out enlightened, so really anything useful you can > throw at me I'll be grateful for. > > Thanks, > Max. > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > From mitchellwrosen at gmail.com Thu Mar 10 18:42:05 2016 From: mitchellwrosen at gmail.com (Mitchell Rosen) Date: Thu, 10 Mar 2016 10:42:05 -0800 (PST) Subject: [Haskell-cafe] Use cases of empty type classes In-Reply-To: References: Message-ID: <514c7ccb-bce6-4b4e-bd38-11dc2c7f8fd9@googlegroups.com> One empty typeclass I use often not only has no methods, but also has no members. class Void This is useful in type families that return Constraint, when you want to say this constraint is "unsatisfiable". I suppose returning something like "True ~ False" would also suffice, but isn't as pretty. On Monday, March 7, 2016 at 10:10:48 PM UTC-8, Tomas Tauber wrote: > > Hi everyone, > > I have one question. What are current use cases of type classes with no > methods? > > I saw early uses in type-level programming (e.g. HList [1]). > In the OO world, interfaces with no methods are called marker interfaces > -- their use cases range from things that could be done with datatype > generic programming in Haskell (e.g. serialization) to metadata annotations > (e.g. RandomAccess [2]). > > Regards, > > Tomas Tauber > > > [1] http://okmij.org/ftp/Haskell/HList-ext.pdf > [2] https://docs.oracle.com/javase/8/docs/api/java/util/RandomAccess.html > _______________________________________________ > Haskell-Cafe mailing list > Haskel... at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From hesselink at gmail.com Thu Mar 10 19:08:54 2016 From: hesselink at gmail.com (Erik Hesselink) Date: Thu, 10 Mar 2016 20:08:54 +0100 Subject: [Haskell-cafe] Use cases of empty type classes In-Reply-To: <514c7ccb-bce6-4b4e-bd38-11dc2c7f8fd9@googlegroups.com> References: <514c7ccb-bce6-4b4e-bd38-11dc2c7f8fd9@googlegroups.com> Message-ID: One nice trick for this is to return an equality involving type level strings: "Cannot satisfy FooBarBaz" ~ () In GHC 8, there will also be a type level function TypeError for this purpose [1]. Erik [1] https://downloads.haskell.org/~ghc/master/users-guide/glasgow_exts.html#custom-errors On 10 March 2016 at 19:42, Mitchell Rosen wrote: > One empty typeclass I use often not only has no methods, but also has no > members. > > class Void > > This is useful in type families that return Constraint, when you want to say > this constraint is "unsatisfiable". I suppose returning something like "True > ~ False" would also suffice, but isn't as pretty. > > On Monday, March 7, 2016 at 10:10:48 PM UTC-8, Tomas Tauber wrote: >> >> Hi everyone, >> >> I have one question. What are current use cases of type classes with no >> methods? >> >> I saw early uses in type-level programming (e.g. HList [1]). >> In the OO world, interfaces with no methods are called marker interfaces >> -- their use cases range from things that could be done with datatype >> generic programming in Haskell (e.g. serialization) to metadata annotations >> (e.g. RandomAccess [2]). >> >> Regards, >> >> Tomas Tauber >> >> >> [1] http://okmij.org/ftp/Haskell/HList-ext.pdf >> [2] https://docs.oracle.com/javase/8/docs/api/java/util/RandomAccess.html >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskel... at haskell.org >> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > From david.feuer at gmail.com Thu Mar 10 19:59:23 2016 From: david.feuer at gmail.com (David Feuer) Date: Thu, 10 Mar 2016 14:59:23 -0500 Subject: [Haskell-cafe] Use cases of empty type classes In-Reply-To: <514c7ccb-bce6-4b4e-bd38-11dc2c7f8fd9@googlegroups.com> References: <514c7ccb-bce6-4b4e-bd38-11dc2c7f8fd9@googlegroups.com> Message-ID: The constraints package currently uses class Any => Bottom where no :: Dict a It should probably actually use no :: a but that's a minor point. There are two ideas: 1. The class constraint Any is a stuck type family, so it's utterly impossible to create an instance of Bottom. Thus any entailment c :- Bottom implies that c is unsatisfiable. 2. There's an entailment bottom :: Bottom :- c bottom = Sub no On Thu, Mar 10, 2016 at 1:42 PM, Mitchell Rosen wrote: > One empty typeclass I use often not only has no methods, but also has no > members. > > class Void > > This is useful in type families that return Constraint, when you want to > say this constraint is "unsatisfiable". I suppose returning something like > "True ~ False" would also suffice, but isn't as pretty. > > On Monday, March 7, 2016 at 10:10:48 PM UTC-8, Tomas Tauber wrote: >> >> Hi everyone, >> >> I have one question. What are current use cases of type classes with no >> methods? >> >> I saw early uses in type-level programming (e.g. HList [1]). >> In the OO world, interfaces with no methods are called marker interfaces >> -- their use cases range from things that could be done with datatype >> generic programming in Haskell (e.g. serialization) to metadata annotations >> (e.g. RandomAccess [2]). >> >> Regards, >> >> Tomas Tauber >> >> >> [1] http://okmij.org/ftp/Haskell/HList-ext.pdf >> [2] https://docs.oracle.com/javase/8/docs/api/java/util/RandomAccess.html >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskel... at haskell.org >> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe >> > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ok at cs.otago.ac.nz Thu Mar 10 21:26:52 2016 From: ok at cs.otago.ac.nz (Richard A. O'Keefe) Date: Fri, 11 Mar 2016 10:26:52 +1300 Subject: [Haskell-cafe] Materials on Compiling Functional Languages. In-Reply-To: References: Message-ID: <16fdc86b-0b4d-afb4-fd13-f19d82ababf9@cs.otago.ac.nz> On 11/03/16 3:17 am, Jonne Ransijn wrote: > if a Lisp compiler seems too easy (And I have to say, it _is_ quite > easy, and shouldn't take more than a couple of hours of coding), Since you know so much about writing Lisp compilers, perhaps you can point me to something that explains how to implement Common Lisp function calls efficiently? There are &optional, &rest, and &key parameters to deal with, and when the compiler sees a call site, in general it hasn't a clue what the target is expecting (this is unlike optional and keyword parameters in Swift, for example). If it were just required, &optional, and &rest parameters, I could see how to do it, but throwing &key in makes it much harder. From konstantin.saveljev at gmail.com Fri Mar 11 07:35:34 2016 From: konstantin.saveljev at gmail.com (Konstantin Saveljev) Date: Fri, 11 Mar 2016 09:35:34 +0200 Subject: [Haskell-cafe] Zoom instance for Coroutine Message-ID: Hello, I am using monad-coroutine package and have something like Coroutine (Await Int) (State MyState) Int (simplified version, for example purpose). MyState is deeply nested and I do a lot of modifications in it. Previously (with different data types) I was able to use zoom from lens in order to simplify the typing/view of code which operates on some subtree of the state, e.g.: zoom (company.assets) $ do something.a = someComputation anotherthing.b = False this.that = "someString" The problem I am having is that I cannot come up with instance Zoom for the Coroutine and was wondering if anyone is able to help me with that? Best regards, Konstantin -------------- next part -------------- An HTML attachment was scrubbed... URL: From polux2001 at gmail.com Fri Mar 11 08:33:08 2016 From: polux2001 at gmail.com (Paul Brauner) Date: Fri, 11 Mar 2016 08:33:08 +0000 Subject: [Haskell-cafe] Materials on Compiling Functional Languages. In-Reply-To: <16fdc86b-0b4d-afb4-fd13-f19d82ababf9@cs.otago.ac.nz> References: <16fdc86b-0b4d-afb4-fd13-f19d82ababf9@cs.otago.ac.nz> Message-ID: There is part II of this set of slides by Xavier Leroy: http://gallium.inria.fr/~xleroy/mpri/2-4/. Paul On Thu, Mar 10, 2016 at 10:27 PM Richard A. O'Keefe wrote: > On 11/03/16 3:17 am, Jonne Ransijn wrote: > > if a Lisp compiler seems too easy (And I have to say, it _is_ quite > > easy, and shouldn't take more than a couple of hours of coding), > > Since you know so much about writing Lisp compilers, perhaps you can > point me to something that explains how to implement Common Lisp > function calls efficiently? There are &optional, &rest, and &key > parameters > to deal with, and when the compiler sees a call site, in general it hasn't > a > clue what the target is expecting (this is unlike optional and keyword > parameters in Swift, for example). If it were just required, &optional, > and > &rest parameters, I could see how to do it, but throwing &key in makes > it much harder. > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From marcin.jan.mrotek at gmail.com Fri Mar 11 08:53:42 2016 From: marcin.jan.mrotek at gmail.com (Marcin Mrotek) Date: Fri, 11 Mar 2016 09:53:42 +0100 Subject: [Haskell-cafe] Zoom instance for Coroutine In-Reply-To: References: Message-ID: Hello, Just a thought: maybe it would be easier to write a MFunctor ( https://hackage.haskell.org/package/mmorph-1.0.6/docs/Control-Monad-Morph.html) instance, and then use (hoist . zoom $ company.assets)? Best regards, Marcin Mrotek -------------- next part -------------- An HTML attachment was scrubbed... URL: From dct25-561bs at mythic-beasts.com Fri Mar 11 09:27:40 2016 From: dct25-561bs at mythic-beasts.com (David Turner) Date: Fri, 11 Mar 2016 09:27:40 +0000 Subject: [Haskell-cafe] GHC API arguments via cabal/stack? Message-ID: Hi all, I'm working on a little program that uses GHC as a library to do some static analysis on a project I'm working on. It runs things as far as the typechecker (so there's no Template Haskell remaining) and then does the analysis on the resulting AST. Here is how I'm calling GHC at the moment: runAnalyser :: FilePath -> [String] -> [String] -> IO [(Module, [Fact], [Assertion])] runAnalyser srcDir args modules = do defaultErrorHandler defaultFatalMessager defaultFlushOut $ do runGhc (Just libdir) $ do dflags <- getSessionDynFlags (dflags', leftover, warnings) <- parseDynamicFlagsCmdLine dflags (map noLoc $ args ++ modules) setSessionDynFlags dflags' setTargets =<< forM modules (\exampleModule -> guessTarget (exampleModuleFile srcDir exampleModule) Nothing) load LoadAllTargets execWriterT $ forM_ modules $ \exampleModule -> do modSum <- lift $ getModSummary $ mkModuleName exampleModule p <- lift $ parseModule modSum t <- lift $ typecheckModule p case tm_renamed_source t of Nothing -> return () Just (hsGroup, _, _, _) -> do assertions <- liftIO $ loadAssertions $ exampleModuleFile srcDir exampleModule let mod = ms_mod $ pm_mod_summary $ tm_parsed_module t tell [( mod , runFactM (moduleName mod) (facts hsGroup) , assertions)] The problem I'm currently facing is that this requires me to pass in the arguments to GHC, including where all the package databases are and all the package ids that stack has decided to use. So far, I've just copy-pasted this from the stack log and hard-coded it, but that's clearly not a good long-term solution. I've half-heartedly tried to fool stack into running my analyser as the compiler, but stack calls ghc more times than just the one call that I need the arguments from. I could make it pass through to the real ghc but this feels like piling hacks on top of hacks. I've also briefly contemplated using the Cabal library to read my .cabal file and work out what to do, but I'm unsure that this would work nicely under stack. At least, I'm not sure quite what to do with all the package databases and other stuff that stack does for you. Is there a sensible and robust way to get these args as stack would make them? Many thanks, David -------------- next part -------------- An HTML attachment was scrubbed... URL: From lukexipd at gmail.com Fri Mar 11 09:48:29 2016 From: lukexipd at gmail.com (Luke Iannini) Date: Fri, 11 Mar 2016 01:48:29 -0800 Subject: [Haskell-cafe] GHC API arguments via cabal/stack? In-Reply-To: References: Message-ID: Hi David, You can see how Halive does it here: https://github.com/lukexi/halive/blob/master/src/Halive/FindPackageDBs.hs#L56 https://github.com/lukexi/halive/blob/master/src/Halive/FindPackageDBs.hs#L65 basically just using "stack path". That'll at least get you the package dirs! I haven't needed to pass any package ids to make things work after that. The actual compilation code is here: https://github.com/lukexi/halive/blob/master/src/Halive/SubHalive.hs Cheers Luke On Fri, Mar 11, 2016 at 1:27 AM, David Turner wrote: > Hi all, > > I'm working on a little program that uses GHC as a library to do some > static analysis on a project I'm working on. It runs things as far as the > typechecker (so there's no Template Haskell remaining) and then does the > analysis on the resulting AST. > > Here is how I'm calling GHC at the moment: > > runAnalyser :: FilePath -> [String] -> [String] -> IO [(Module, [Fact], > [Assertion])] > runAnalyser srcDir args modules = do > defaultErrorHandler defaultFatalMessager defaultFlushOut $ do > runGhc (Just libdir) $ do > dflags <- getSessionDynFlags > (dflags', leftover, warnings) <- parseDynamicFlagsCmdLine dflags > (map noLoc $ args ++ modules) > setSessionDynFlags dflags' > setTargets =<< forM modules (\exampleModule -> > guessTarget (exampleModuleFile srcDir exampleModule) Nothing) > load LoadAllTargets > > execWriterT $ forM_ modules $ \exampleModule -> do > modSum <- lift $ getModSummary $ mkModuleName exampleModule > p <- lift $ parseModule modSum > t <- lift $ typecheckModule p > case tm_renamed_source t of > Nothing -> return () > Just (hsGroup, _, _, _) -> do > assertions <- liftIO $ loadAssertions > $ exampleModuleFile srcDir exampleModule > let mod = ms_mod $ pm_mod_summary $ tm_parsed_module t > tell [( mod > , runFactM (moduleName mod) (facts hsGroup) > , assertions)] > > > The problem I'm currently facing is that this requires me to pass in the > arguments to GHC, including where all the package databases are and all the > package ids that stack has decided to use. So far, I've just copy-pasted > this from the stack log and hard-coded it, but that's clearly not a good > long-term solution. > > I've half-heartedly tried to fool stack into running my analyser as the > compiler, but stack calls ghc more times than just the one call that I need > the arguments from. I could make it pass through to the real ghc but this > feels like piling hacks on top of hacks. > > I've also briefly contemplated using the Cabal library to read my .cabal > file and work out what to do, but I'm unsure that this would work nicely > under stack. At least, I'm not sure quite what to do with all the package > databases and other stuff that stack does for you. > > Is there a sensible and robust way to get these args as stack would make > them? > > Many thanks, > > David > > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From daniel.trstenjak at gmail.com Fri Mar 11 10:16:43 2016 From: daniel.trstenjak at gmail.com (Daniel Trstenjak) Date: Fri, 11 Mar 2016 11:16:43 +0100 Subject: [Haskell-cafe] GHC API arguments via cabal/stack? In-Reply-To: References: Message-ID: <20160311101643.GA13294@octa> Hi David, > I've also briefly contemplated using the Cabal library to read my .cabal file > and work out what to do, but I'm unsure that this would work nicely under > stack. At least, I'm not sure quite what to do with all the package databases > and other stuff that stack does for you. There's cabal-cargs[1] to extract the relevant info for ghc from a cabal file. I don't know how much work it would be to make it stack aware/compatible. Greetings, Daniel [1] https://github.com/dan-t/cabal-cargs From dxld at darkboxed.org Fri Mar 11 12:30:02 2016 From: dxld at darkboxed.org (Daniel =?iso-8859-1?Q?Gr=F6ber?=) Date: Fri, 11 Mar 2016 13:30:02 +0100 Subject: [Haskell-cafe] GHC API arguments via cabal/stack? In-Reply-To: References: Message-ID: <20160311123002.GA18853@grml> On Fri, Mar 11, 2016 at 09:27:40AM +0000, David Turner wrote: > I've also briefly contemplated using the Cabal library to read my .cabal > file and work out what to do, but I'm unsure that this would work nicely > under stack. At least, I'm not sure quite what to do with all the package > databases and other stuff that stack does for you. Using the Cabal library to do this works very well in general, we do this in ghc-mod these days. The only way I've seen problems creep up so far is if cabal-install is linked against a different version of Cabal than your program. If your analysis program doesn't have to work on the same cabal dist directory as cabal-install (like ghc-mod does) then that's a non problem though. Anyways we've wrapped all the ugly stuff to work around this problem into a library called cabal-helper: http://hackage.haskell.org/package/cabal-helper/docs/Distribution-Helper.html Here's a little example program using that library which should do what you want: ``` import System.Environment import System.Directory import System.Process import Distribution.Helper import Data.Char import Data.List main = do [project_dir] <- getArgs setCurrentDirectory project_dir dist_dir <- dropWhileEnd isSpace <$> readProcess "stack" ["path", "--dist-dir"] "" print =<< (runQuery (defaultQueryEnv "." dist_dir) $ ghcOptions) ``` --Daniel -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: From han.joosten.han at gmail.com Fri Mar 11 15:56:57 2016 From: han.joosten.han at gmail.com (Han Joosten) Date: Fri, 11 Mar 2016 16:56:57 +0100 Subject: [Haskell-cafe] Prelude.head: empty list Message-ID: In a rather large program I made some changes, and now I get the runtime error: ampersand.exe: Prelude.head: empty list Of course I know that head is partial, and should be used with care. It is used many times (we have 100+ modules in the program). Is there an elegant way to get some information about where the specific call to head is being made? Thanks! -------------- next part -------------- An HTML attachment was scrubbed... URL: From mantkiew at gsd.uwaterloo.ca Fri Mar 11 16:10:24 2016 From: mantkiew at gsd.uwaterloo.ca (=?UTF-8?Q?Micha=C5=82_Antkiewicz?=) Date: Fri, 11 Mar 2016 11:10:24 -0500 Subject: [Haskell-cafe] Prelude.head: empty list In-Reply-To: References: Message-ID: No. See a discussion and some explanations inside. https://www.reddit.com/r/haskell/comments/441e3s/how_to_use_the_implicit_error_locations_and_stack/ Unfortunately, you can only look at the diff with the version before the error occured and perform impact analysis. Micha? From anselm.scholl at tu-harburg.de Fri Mar 11 16:13:15 2016 From: anselm.scholl at tu-harburg.de (Jonas Scholl) Date: Fri, 11 Mar 2016 17:13:15 +0100 Subject: [Haskell-cafe] Prelude.head: empty list In-Reply-To: References: Message-ID: <56E2EE9B.8000701@tu-harburg.de> Which version of GHC are you using? If you are using 7.10.3, you can use implicit parameters to get the caller of head (this should be enough to narrow down the problem to one module and then add more debugging information there). Or you could compile a profiling version of your executable and use +RTS -xc (I think), which should print a stack trace on any thrown exception (also for exceptions which are later caught). Then the last trace should be for head. To use implicit parameters, you need: {-# LANGUAGE ImplicitParams #-} import GHC.Stack (CallStack, showCallStack) head' :: (?callStack :: CallStack) => [a] -> a head' (x:_) = x head' [] = error $ "head': empty list" ++ "\nCallStack: " ++ showCallStack ?callStack Then replace every use of head by head'. If you need more than one stack frame, just add (?callStack :: CallStack) to the constraints of the calling function and GHC should add another stack frame. On 03/11/2016 04:56 PM, Han Joosten wrote: > In a rather large program I made some changes, and now I get the runtime > error: > > ampersand.exe: Prelude.head: empty list > > Of course I know that head is partial, and should be used with care. It > is used many times (we have 100+ modules in the program). Is there an > elegant way to get some information about where the specific call to > head is being made? > > Thanks! > > > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 473 bytes Desc: OpenPGP digital signature URL: From aeyakovenko at gmail.com Fri Mar 11 16:43:16 2016 From: aeyakovenko at gmail.com (Anatoly Yakovenko) Date: Fri, 11 Mar 2016 08:43:16 -0800 Subject: [Haskell-cafe] Prelude.head: empty list In-Reply-To: <56E2EE9B.8000701@tu-harburg.de> References: <56E2EE9B.8000701@tu-harburg.de> Message-ID: +RTS -xc has worked for me, https://wiki.haskell.org/Debugging On Fri, Mar 11, 2016 at 8:13 AM, Jonas Scholl wrote: > Which version of GHC are you using? If you are using 7.10.3, you can use > implicit parameters to get the caller of head (this should be enough to > narrow down the problem to one module and then add more debugging > information there). Or you could compile a profiling version of your > executable and use +RTS -xc (I think), which should print a stack trace > on any thrown exception (also for exceptions which are later caught). > Then the last trace should be for head. > > To use implicit parameters, you need: > > {-# LANGUAGE ImplicitParams #-} > import GHC.Stack (CallStack, showCallStack) > > head' :: (?callStack :: CallStack) => [a] -> a > head' (x:_) = x > head' [] = error $ "head': empty list" ++ "\nCallStack: > " ++ showCallStack ?callStack > > Then replace every use of head by head'. If you need more than one stack > frame, just add (?callStack :: CallStack) to the constraints of the > calling function and GHC should add another stack frame. > > On 03/11/2016 04:56 PM, Han Joosten wrote: >> In a rather large program I made some changes, and now I get the runtime >> error: >> >> ampersand.exe: Prelude.head: empty list >> >> Of course I know that head is partial, and should be used with care. It >> is used many times (we have 100+ modules in the program). Is there an >> elegant way to get some information about where the specific call to >> head is being made? >> >> Thanks! >> >> >> >> >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe >> > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > From qdunkan at gmail.com Fri Mar 11 17:34:31 2016 From: qdunkan at gmail.com (Evan Laforge) Date: Fri, 11 Mar 2016 09:34:31 -0800 Subject: [Haskell-cafe] Prelude.head: empty list In-Reply-To: References: Message-ID: On Fri, Mar 11, 2016 at 7:56 AM, Han Joosten wrote: > Of course I know that head is partial, and should be used with care. How about never? I do fine with either case and a Maybe-returning variant. So if I see that error it's definitely library code... which unfortunately has happened a few times. I wish library authors went with "never" as well! From david.feuer at gmail.com Fri Mar 11 18:13:48 2016 From: david.feuer at gmail.com (David Feuer) Date: Fri, 11 Mar 2016 13:13:48 -0500 Subject: [Haskell-cafe] MPTC vs. constructor class Message-ID: I've been messing around with type-aligned sequences for a while, and I'm currently exploring the design space of classes for them. The type-aligned package uses this: class TASequence s where tempty :: s c x x Source tsingleton :: c x y -> s c x y -- can default to tsingleton = ( <| tempty ) -- but doesn't for some reason (><) :: s c x y -> s c y z -> s c x z tviewl :: s c x y -> TAViewL s c x y tviewr :: s c x y -> TAViewR s c x y (|>) :: s c x y -> c y z -> s c x z (<|) :: c x y -> s c y z -> s c x z tmap :: (forall x y. c x y -> d x y) -> s c x y -> s d x y An obvious (to me) improvement is to add TAFunctor, TAFoldable, and TATraversable classes, make TASequence a subclass of TATraversable, and remove tmap from TASequence. That's one pleasant direction. Another class expressing some of these ideas: class Category s => TASequence' s c | s -> c where tviewl :: s x y -> TAViewL s c x y tviewr :: s x y -> TAViewR s c x y (|>) :: s x y -> c y z -> s x z (<|) :: c x y -> s y z -> s x z This variant actually offers all the functionality of the original except tmap, which it has no way to talk about whatsoever. The Category s constraint allows id to replace tempty and (>>>) to replace (><). I really like this aspect. Unfortunately, losing tmap et al sucks. It's possible to glue that on to the original TASequence using Data.Constraint: class ForallF Category s => TASequence s where ... but then accessing the Category instances requires mucking about with (\\) and instF and throwing a bunch of explicit type signatures around. Is there any good "design pattern" to resolve this conflict? David Feuer From b at chreekat.net Fri Mar 11 18:17:01 2016 From: b at chreekat.net (Bryan Richter) Date: Fri, 11 Mar 2016 10:17:01 -0800 Subject: [Haskell-cafe] Prelude.head: empty list In-Reply-To: <56E2EE9B.8000701@tu-harburg.de> References: <56E2EE9B.8000701@tu-harburg.de> Message-ID: <20160311181701.GA18524@fuzzbomb> On Fri, Mar 11, 2016 at 05:13:15PM +0100, Jonas Scholl wrote: > Which version of GHC are you using? If you are using 7.10.3, you can use > implicit parameters to get the caller of head (this should be enough to > narrow down the problem to one module and then add more debugging > information there). Or you could compile a profiling version of your > executable and use +RTS -xc (I think), which should print a stack trace > on any thrown exception (also for exceptions which are later caught). > Then the last trace should be for head. > > To use implicit parameters, you need: > > {-# LANGUAGE ImplicitParams #-} > import GHC.Stack (CallStack, showCallStack) > > head' :: (?callStack :: CallStack) => [a] -> a > head' (x:_) = x > head' [] = error $ "head': empty list" ++ "\nCallStack: > " ++ showCallStack ?callStack > > Then replace every use of head by head'. If you need more than one stack > frame, just add (?callStack :: CallStack) to the constraints of the > calling function and GHC should add another stack frame. I'd like to add a link to https://hackage.haskell.org/package/located-base, which adds callstacks to a lot of partial functions. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 801 bytes Desc: Digital signature URL: From marcin.jan.mrotek at gmail.com Fri Mar 11 18:18:56 2016 From: marcin.jan.mrotek at gmail.com (Marcin Mrotek) Date: Fri, 11 Mar 2016 19:18:56 +0100 Subject: [Haskell-cafe] Prelude.head: empty list In-Reply-To: References: Message-ID: Could you perhaps change every `head` to a pattern match with `[] -> error "impossible, because..."` to see what impossible happened? It could help when some other impossible happens later. Other than that, located-base that Bryan Richter mentioned looks useful too. Best regards, Marcin Mrotek From fa-ml at ariis.it Fri Mar 11 18:26:47 2016 From: fa-ml at ariis.it (Francesco Ariis) Date: Fri, 11 Mar 2016 19:26:47 +0100 Subject: [Haskell-cafe] Prelude.head: empty list In-Reply-To: References: Message-ID: <20160311182647.GA8308@casa.casa> On Fri, Mar 11, 2016 at 04:56:57PM +0100, Han Joosten wrote: > In a rather large program I made some changes, and now I get the runtime > error: > > ampersand.exe: Prelude.head: empty list > > Of course I know that head is partial, and should be used with care. It is > used many times (we have 100+ modules in the program). Is there an elegant > way to get some information about where the specific call to head is being > made? > > Thanks! I scanned previous replies and didn't see it mentioned, maybe you can abuse C preprocessor to shadow `head` and insert a __LINE__ on pattern matching []? From anselm.scholl at tu-harburg.de Fri Mar 11 19:07:17 2016 From: anselm.scholl at tu-harburg.de (Jonas Scholl) Date: Fri, 11 Mar 2016 20:07:17 +0100 Subject: [Haskell-cafe] Prelude.head: empty list In-Reply-To: <20160311182647.GA8308@casa.casa> References: <20160311182647.GA8308@casa.casa> Message-ID: <56E31765.5070501@tu-harburg.de> You mean like this? default-extensions: CPP cpp-options: -Dhead=(foldr(const)(error("head:\x20\x65mpty\x20list\x20in\x20"++__FILE__++":"++show(__LINE__))).(take$1)) Yes, it is a little bit ugly as I am unable to convince cabal to skip the spaces, so I just avoided them. And build an ugly inline-definition of head. Maybe having a head' function taking a line number and the file would help :) But it should work, if it is not too much broken my my mail-client. The define should be on one long line. On 03/11/2016 07:26 PM, Francesco Ariis wrote: > On Fri, Mar 11, 2016 at 04:56:57PM +0100, Han Joosten wrote: >> In a rather large program I made some changes, and now I get the runtime >> error: >> >> ampersand.exe: Prelude.head: empty list >> >> Of course I know that head is partial, and should be used with care. It is >> used many times (we have 100+ modules in the program). Is there an elegant >> way to get some information about where the specific call to head is being >> made? >> >> Thanks! > > I scanned previous replies and didn't see it mentioned, maybe you can > abuse C preprocessor to shadow `head` and insert a __LINE__ on > pattern matching []? > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 473 bytes Desc: OpenPGP digital signature URL: From lsp at informatik.uni-kiel.de Sat Mar 12 00:16:43 2016 From: lsp at informatik.uni-kiel.de (lennart spitzner) Date: Sat, 12 Mar 2016 01:16:43 +0100 Subject: [Haskell-cafe] Prelude.head: empty list In-Reply-To: <20160311181701.GA18524@fuzzbomb> References: <56E2EE9B.8000701@tu-harburg.de> <20160311181701.GA18524@fuzzbomb> Message-ID: <56E35FEB.7070604@informatik.uni-kiel.de> As it has not been mentioned yet, i may also point out http://hackage.haskell.org/package/safe-0.3.9/docs/Safe.html#v:headNote never use head, sparingly use headNote with unique notes. On 11/03/16 19:17, Bryan Richter wrote: > On Fri, Mar 11, 2016 at 05:13:15PM +0100, Jonas Scholl wrote: >> Which version of GHC are you using? If you are using 7.10.3, you can use >> implicit parameters to get the caller of head (this should be enough to >> narrow down the problem to one module and then add more debugging >> information there). Or you could compile a profiling version of your >> executable and use +RTS -xc (I think), which should print a stack trace >> on any thrown exception (also for exceptions which are later caught). >> Then the last trace should be for head. >> >> To use implicit parameters, you need: >> >> {-# LANGUAGE ImplicitParams #-} >> import GHC.Stack (CallStack, showCallStack) >> >> head' :: (?callStack :: CallStack) => [a] -> a >> head' (x:_) = x >> head' [] = error $ "head': empty list" ++ "\nCallStack: >> " ++ showCallStack ?callStack >> >> Then replace every use of head by head'. If you need more than one stack >> frame, just add (?callStack :: CallStack) to the constraints of the >> calling function and GHC should add another stack frame. > > I'd like to add a link to > https://hackage.haskell.org/package/located-base, which adds > callstacks to a lot of partial functions. > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > From lambda.fairy at gmail.com Sat Mar 12 03:28:58 2016 From: lambda.fairy at gmail.com (Chris Wong) Date: Sat, 12 Mar 2016 16:28:58 +1300 Subject: [Haskell-cafe] Prelude.head: empty list In-Reply-To: <56E31765.5070501@tu-harburg.de> References: <20160311182647.GA8308@casa.casa> <56E31765.5070501@tu-harburg.de> Message-ID: On Sat, Mar 12, 2016 at 8:07 AM, Jonas Scholl wrote: > You mean like this? > > default-extensions: CPP > cpp-options: > -Dhead=(foldr(const)(error("head:\x20\x65mpty\x20list\x20in\x20"++__FILE__++":"++show(__LINE__))).(take$1)) That's pretty cool! By the way: can the (take$1) be removed? foldr should be lazy enough already. -- Chris Wong (https://lambda.xyz) "I had not the vaguest idea what this meant and when I could not remember the words, my tutor threw the book at my head, which did not stimulate my intellect in any way." -- Bertrand Russell From codygman.consulting at gmail.com Sat Mar 12 04:54:43 2016 From: codygman.consulting at gmail.com (Cody Goodman) Date: Fri, 11 Mar 2016 22:54:43 -0600 Subject: [Haskell-cafe] Can't get any memory profile data Message-ID: Here is the command line log of my attempt following real world haskell's memory profiling example: src ? stack exec -- ghc --version The Glorious Glasgow Haskell Compilation System, version 7.10.3 src ? cat Main.hs module Main where main :: IO () main = do let x = {-# SCC sum #-}sum [1..500] print x {-# SCC helloworld #-} putStrLn "hello world" src ? stack exec -- ghc -O2 --make Main.hs -prof -auto-all -caf-all -fforce-recomp [1 of 1] Compiling Main ( Main.hs, Main.o ) Linking Main ... src ? ./Main +RTS -hc -p 125250 hello world src ? cat Main.hp JOB "Main +RTS -hc -p" DATE "Fri Mar 11 22:51 2016" SAMPLE_UNIT "seconds" VALUE_UNIT "bytes" BEGIN_SAMPLE 0.00 END_SAMPLE 0.00 BEGIN_SAMPLE 0.00 END_SAMPLE 0.00 -------------- next part -------------- An HTML attachment was scrubbed... URL: From ezyang at mit.edu Sat Mar 12 05:32:50 2016 From: ezyang at mit.edu (Edward Z. Yang) Date: Fri, 11 Mar 2016 21:32:50 -0800 Subject: [Haskell-cafe] Can't get any memory profile data In-Reply-To: References: Message-ID: <1457760680-sup-6773@sabre> The program is running too quickly for any profiling to occur. You can tell with the RTS option -S and looking to see if major collections occur. Try increasing the amount of computation. Edward Excerpts from Cody Goodman's message of 2016-03-11 20:54:43 -0800: > Here is the command line log of my attempt following real world haskell's > memory profiling example: > > src ? stack exec -- ghc --version > The Glorious Glasgow Haskell Compilation System, version 7.10.3 > src ? cat Main.hs > module Main where > > main :: IO () > main = do > let x = {-# SCC sum #-}sum [1..500] > print x > {-# SCC helloworld #-} putStrLn "hello world" > src ? stack exec -- ghc -O2 --make Main.hs -prof -auto-all -caf-all > -fforce-recomp > [1 of 1] Compiling Main ( Main.hs, Main.o ) > Linking Main ... > src ? ./Main +RTS -hc -p > 125250 > hello world > src ? cat Main.hp > JOB "Main +RTS -hc -p" > DATE "Fri Mar 11 22:51 2016" > SAMPLE_UNIT "seconds" > VALUE_UNIT "bytes" > BEGIN_SAMPLE 0.00 > END_SAMPLE 0.00 > BEGIN_SAMPLE 0.00 > END_SAMPLE 0.00 From dct25-561bs at mythic-beasts.com Sat Mar 12 08:29:39 2016 From: dct25-561bs at mythic-beasts.com (David Turner) Date: Sat, 12 Mar 2016 08:29:39 +0000 Subject: [Haskell-cafe] GHC API arguments via cabal/stack? In-Reply-To: <20160311123002.GA18853@grml> References: <20160311123002.GA18853@grml> Message-ID: Cabal-helper looks like just the ticket, thanks! On 11 Mar 2016 12:32, "Daniel Gr?ber" wrote: > On Fri, Mar 11, 2016 at 09:27:40AM +0000, David Turner wrote: > > I've also briefly contemplated using the Cabal library to read my .cabal > > file and work out what to do, but I'm unsure that this would work nicely > > under stack. At least, I'm not sure quite what to do with all the package > > databases and other stuff that stack does for you. > > Using the Cabal library to do this works very well in general, we do > this in ghc-mod these days. The only way I've seen problems creep up > so far is if cabal-install is linked against a different version of > Cabal than your program. If your analysis program doesn't have to work > on the same cabal dist directory as cabal-install (like ghc-mod does) > then that's a non problem though. > > Anyways we've wrapped all the ugly stuff to work around this problem > into a library called cabal-helper: > > http://hackage.haskell.org/package/cabal-helper/docs/Distribution-Helper.html > > Here's a little example program using that library which should do > what you want: > > ``` > import System.Environment > import System.Directory > import System.Process > import Distribution.Helper > import Data.Char > import Data.List > > main = do > [project_dir] <- getArgs > setCurrentDirectory project_dir > dist_dir <- dropWhileEnd isSpace <$> readProcess "stack" ["path", > "--dist-dir"] "" > print =<< (runQuery (defaultQueryEnv "." dist_dir) $ ghcOptions) > > ``` > > --Daniel -------------- next part -------------- An HTML attachment was scrubbed... URL: From matthewtpickering at gmail.com Sat Mar 12 08:38:42 2016 From: matthewtpickering at gmail.com (Matthew Pickering) Date: Sat, 12 Mar 2016 08:38:42 +0000 Subject: [Haskell-cafe] GHC API arguments via cabal/stack? In-Reply-To: References: Message-ID: It is quite hacky but if I want to get access to a typechecked module, I usually modify haddock and then invoke my analysis with "cabal haddock --haddock-options="--my-flag". That saves me the pain of having the deal with manually getting the paths to this stuff. On Fri, Mar 11, 2016 at 9:27 AM, David Turner wrote: > Hi all, > > I'm working on a little program that uses GHC as a library to do some static > analysis on a project I'm working on. It runs things as far as the > typechecker (so there's no Template Haskell remaining) and then does the > analysis on the resulting AST. > > Here is how I'm calling GHC at the moment: > > runAnalyser :: FilePath -> [String] -> [String] -> IO [(Module, [Fact], > [Assertion])] > runAnalyser srcDir args modules = do > defaultErrorHandler defaultFatalMessager defaultFlushOut $ do > runGhc (Just libdir) $ do > dflags <- getSessionDynFlags > (dflags', leftover, warnings) <- parseDynamicFlagsCmdLine dflags > (map noLoc $ args ++ modules) > setSessionDynFlags dflags' > setTargets =<< forM modules (\exampleModule -> > guessTarget (exampleModuleFile srcDir exampleModule) Nothing) > load LoadAllTargets > > execWriterT $ forM_ modules $ \exampleModule -> do > modSum <- lift $ getModSummary $ mkModuleName exampleModule > p <- lift $ parseModule modSum > t <- lift $ typecheckModule p > case tm_renamed_source t of > Nothing -> return () > Just (hsGroup, _, _, _) -> do > assertions <- liftIO $ loadAssertions > $ exampleModuleFile srcDir exampleModule > let mod = ms_mod $ pm_mod_summary $ tm_parsed_module t > tell [( mod > , runFactM (moduleName mod) (facts hsGroup) > , assertions)] > > > The problem I'm currently facing is that this requires me to pass in the > arguments to GHC, including where all the package databases are and all the > package ids that stack has decided to use. So far, I've just copy-pasted > this from the stack log and hard-coded it, but that's clearly not a good > long-term solution. > > I've half-heartedly tried to fool stack into running my analyser as the > compiler, but stack calls ghc more times than just the one call that I need > the arguments from. I could make it pass through to the real ghc but this > feels like piling hacks on top of hacks. > > I've also briefly contemplated using the Cabal library to read my .cabal > file and work out what to do, but I'm unsure that this would work nicely > under stack. At least, I'm not sure quite what to do with all the package > databases and other stuff that stack does for you. > > Is there a sensible and robust way to get these args as stack would make > them? > > Many thanks, > > David > > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > From d.filonik at hdr.qut.edu.au Sat Mar 12 15:53:35 2016 From: d.filonik at hdr.qut.edu.au (Daniel Filonik) Date: Sat, 12 Mar 2016 15:53:35 +0000 Subject: [Haskell-cafe] GADTs and Exponentiated Functors In-Reply-To: References: , <62B6439D-D817-4A58-89C2-030A5B0399FE@gmail.com>, , , Message-ID: Nobody has an idea on how to make the TypeLits version work? Cheers, Daniel ________________________________ From: Haskell-Cafe on behalf of Daniel Filonik Sent: Wednesday, March 9, 2016 7:34 AM To: haskell-cafe at haskell.org Subject: Re: [Haskell-cafe] GADTs and Exponentiated Functors I have managed to pinpoint where my problems with GHC TypeLits came about. The following fails (btw. are there any guidelines for posting code on this mailing list?): type family NFunctorF f (n :: Nat) a where NFunctorF f 0 a = a NFunctorF f n a = f (NFunctorF f (n-1) a) data MkNFunctor f (n :: Nat) a where ZF :: a -> MkNFunctor f 0 a SF :: f (MkNFunctor f (n-1) a) -> MkNFunctor f n a class NConvertable f (n :: Nat) where fromNFunctor :: MkNFunctor f n a -> NFunctorF f n a toNFunctor :: NFunctorF f n a -> MkNFunctor f n a instance NConvertable f 0 where fromNFunctor (ZF x) = x toNFunctor x = ZF x instance (Functor f, NConvertable f (n-1)) => NConvertable f n where fromNFunctor (SF xs) = fmap fromNFunctor xs toNFunctor xs = SF (fmap toNFunctor xs) type NMaybe = MkNFunctor Maybe type NList = MkNFunctor [] With error: Couldn't match expected type `f (NFunctorF f (n - 1) a)' with actual type `NFunctorF f n a' Whereas this happily succeeds. type family NFunctorF f (n :: Peano) a where NFunctorF f Zero a = a NFunctorF f (Succ n) a = f (NFunctorF f n a) data MkNFunctor f (n :: Peano) a where ZF :: a -> MkNFunctor f Zero a SF :: f (MkNFunctor f n a) -> MkNFunctor f (Succ n) a class NConvertable f (n :: Peano) where fromNFunctor :: MkNFunctor f n a -> NFunctorF f n a toNFunctor :: NFunctorF f n a -> MkNFunctor f n a instance NConvertable f Zero where fromNFunctor (ZF x) = x toNFunctor x = ZF x instance (Functor f, NConvertable f n) => NConvertable f (Succ n) where fromNFunctor (SF xs) = fmap fromNFunctor xs toNFunctor xs = SF (fmap toNFunctor xs) type NMaybe = MkNFunctor Maybe type NList = MkNFunctor [] Is there any way to fix the first version? Cheers, Daniel ________________________________ From: Haskell-Cafe on behalf of Daniel Filonik Sent: Monday, March 7, 2016 5:53 PM To: amindfv at gmail.com Cc: haskell-cafe at haskell.org Subject: Re: [Haskell-cafe] GADTs and Exponentiated Functors Just a quick follow up to this, unless I am mistaken GHC TypeLits does not actually export constructors (Zero, Succ) for the Nat kind, does it? If it did that, of course I could just use those... FYI, I have cleaned up the example a bit, adding some applicative magic, it now looks like: data Person = Person { name :: String, age :: Integer, gender :: String, status :: String } deriving Show persons = fromList' [Person {name="Alice", age=20, gender="F", status="Good"}, Person {name="Bob", age=18, gender="M", status="Good"}, Person {name="Chuck", age=16, gender="M", status="Bad"}] :: NList N1 Person persons <$$> groupby (gender) <$$> orderby (age) <$$> select (age + 1) <$$> reduce (sum) -- [21,36] Or, if you are feeling more adventurous, you can do thing like: let abg = persons <$$> groupby (gender) <$$> select (age) in ((/) <$> (abg <$$> select(realToFrac)) <***> (abg <$$> reduce(mean))) [[1.0],[1.0588235294117647,0.9411764705882353]] All operations select/reduce/produce/filterby/orderby/groupby work on arbitrarily nested lists, making this very composable. Cheers, Daniel ________________________________ From: Daniel Filonik Sent: Monday, March 7, 2016 3:13 AM To: amindfv at gmail.com Cc: haskell-cafe at haskell.org Subject: Re: [Haskell-cafe] GADTs and Exponentiated Functors I started out using TypeLits, but I was running into problems with GHC's solver along these lines: http://stackoverflow.com/questions/24734704/append-for-type-level-numbered-lists-with-typelits However, I would not rule out the possibility that this was due to misuse my behalf. If you know a way to make it work, that would be exactly the kind of feedback I am looking for! Also, I'd be curious if it is possible to write an instance of the general NFunctor for NList (which does not require explicit type annotations to work): class NFunctor t (m :: Peano) (n :: Peano) where pmap' :: (t (Succ m) a -> t m b) -> t (Succ n) a -> t n b zmap' :: (t m a -> t m b) -> t n a -> t n b smap' :: (t m a -> t (Succ m) b) -> t n a -> t (Succ n) b Cheers, Daniel ________________________________ From: amindfv at gmail.com Sent: Monday, March 7, 2016 2:38 AM To: Daniel Filonik Cc: haskell-cafe at haskell.org Subject: Re: [Haskell-cafe] GADTs and Exponentiated Functors Interesting! What's the reason you redefine the Piano numbers and hide the import of the ones from GHC. TypeLits? Tom El 6 mar 2016, a las 07:11, Daniel Filonik > escribi?: Hi, I have been recently playing around with GADTs, using them to keep track of how many times a functor has been applied. This provides a solution to what seems to be a long standing problem, summarized here: https://byorgey.wordpress.com/2007/08/16/mapping-over-a-nested-functor/ If the nesting depth is part of the type, it is possible to apply fmap automatically as needed. This allows you to write fairly elegant expressions like: data Person = Person { name :: String, age :: Integer, gender :: String, status :: String } deriving Show let persons = fromList' [Person {name="Alice", age=20, gender="F", status="Good"}, Person {name="Bob", age=18, gender="M", status="Good"}, Person {name="Chuck", age=16, gender="M", status="Bad"}] :: NList N1 Person persons `select` age -- [20,18,16] persons `groupby` gender `select` age -- [[20],[18,16]] persons `groupby` gender `groupby` status `select` age -- [[[20]],[[18],[16]]] Note that "`select` age" works regardless of nesting depth. You can also append or remove nesting levels: persons `groupby` gender `select` age `produce` (\x -> [0..x]) -- [[[0..20]],[[0..18],[0..16]]] persons `groupby` gender `reduce` (sumof age) -- [20, 34] Would this kind of thing be of interest? The code is here: https://github.com/filonik/nlists Please feel free to suggest improvements. Cheers, Daniel _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe at haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe -------------- next part -------------- An HTML attachment was scrubbed... URL: From carter.schonwald at gmail.com Sat Mar 12 18:07:41 2016 From: carter.schonwald at gmail.com (Carter Schonwald) Date: Sat, 12 Mar 2016 13:07:41 -0500 Subject: [Haskell-cafe] GADTs and Exponentiated Functors In-Reply-To: References: <62B6439D-D817-4A58-89C2-030A5B0399FE@gmail.com> Message-ID: https://hackage.haskell.org/package/ghc-typelits-natnormalise can let you get pretty far, though it triggers a lotta rebuilds :) On Sat, Mar 12, 2016 at 10:53 AM, Daniel Filonik wrote: > Nobody has an idea on how to make the TypeLits version work? > > Cheers, > Daniel > ------------------------------ > *From:* Haskell-Cafe on behalf of > Daniel Filonik > *Sent:* Wednesday, March 9, 2016 7:34 AM > *To:* haskell-cafe at haskell.org > > *Subject:* Re: [Haskell-cafe] GADTs and Exponentiated Functors > > > I have managed to pinpoint where my problems with GHC TypeLits came about. > The following fails (btw. are there any guidelines for posting code on this > mailing list?): > > > type family NFunctorF f (n :: Nat) a where > NFunctorF f 0 a = a > NFunctorF f n a = f (NFunctorF f (n-1) a) > > data MkNFunctor f (n :: Nat) a where > ZF :: a -> MkNFunctor f 0 a > SF :: f (MkNFunctor f (n-1) a) -> MkNFunctor f n a > > class NConvertable f (n :: Nat) where > fromNFunctor :: MkNFunctor f n a -> NFunctorF f n a > toNFunctor :: NFunctorF f n a -> MkNFunctor f n a > > instance NConvertable f 0 where > fromNFunctor (ZF x) = x > toNFunctor x = ZF x > > instance (Functor f, NConvertable f (n-1)) => NConvertable f n where > fromNFunctor (SF xs) = fmap fromNFunctor xs > toNFunctor xs = SF (fmap toNFunctor xs) > > type NMaybe = MkNFunctor Maybe > type NList = MkNFunctor [] > > > > With error: > > > Couldn't match expected type `f (NFunctorF f (n - 1) a)' > with actual type `NFunctorF f n a' > > > > Whereas this happily succeeds. > > > type family NFunctorF f (n :: Peano) a where > NFunctorF f Zero a = a > NFunctorF f (Succ n) a = f (NFunctorF f n a) > > data MkNFunctor f (n :: Peano) a where > ZF :: a -> MkNFunctor f Zero a > SF :: f (MkNFunctor f n a) -> MkNFunctor f (Succ n) a > > class NConvertable f (n :: Peano) where > fromNFunctor :: MkNFunctor f n a -> NFunctorF f n a > toNFunctor :: NFunctorF f n a -> MkNFunctor f n a > > instance NConvertable f Zero where > fromNFunctor (ZF x) = x > toNFunctor x = ZF x > > instance (Functor f, NConvertable f n) => NConvertable f (Succ n) where > fromNFunctor (SF xs) = fmap fromNFunctor xs > toNFunctor xs = SF (fmap toNFunctor xs) > > type NMaybe = MkNFunctor Maybe > type NList = MkNFunctor [] > > > Is there any way to fix the first version? > > Cheers, > > Daniel > > > ------------------------------ > *From:* Haskell-Cafe on behalf of > Daniel Filonik > *Sent:* Monday, March 7, 2016 5:53 PM > *To:* amindfv at gmail.com > *Cc:* haskell-cafe at haskell.org > *Subject:* Re: [Haskell-cafe] GADTs and Exponentiated Functors > > > Just a quick follow up to this, unless I am mistaken GHC TypeLits does not > actually export constructors (Zero, Succ) for the Nat kind, does it? If it > did that, of course I could just use those... > > > FYI, I have cleaned up the example a bit, adding some applicative magic, > it now looks like: > > > data Person = Person { name :: String, age :: Integer, gender :: String, > status :: String } deriving Show > > persons = fromList' [Person {name="Alice", age=20, gender="F", > status="Good"}, Person {name="Bob", age=18, gender="M", status="Good"}, > Person {name="Chuck", age=16, gender="M", status="Bad"}] :: NList N1 Person > > persons <$$> groupby (gender) <$$> orderby (age) <$$> select (age + 1) > <$$> reduce (sum) > > -- [21,36] > > > Or, if you are feeling more adventurous, you can do thing like: > > > let abg = persons <$$> groupby (gender) <$$> select (age) in ((/) <$> (abg > <$$> select(realToFrac)) <***> (abg <$$> reduce(mean))) > [[1.0],[1.0588235294117647,0.9411764705882353]] > > > All operations select/reduce/produce/filterby/orderby/groupby work on > arbitrarily nested lists, making this very composable. > > > Cheers, > > Daniel > > > ------------------------------ > *From:* Daniel Filonik > *Sent:* Monday, March 7, 2016 3:13 AM > *To:* amindfv at gmail.com > *Cc:* haskell-cafe at haskell.org > *Subject:* Re: [Haskell-cafe] GADTs and Exponentiated Functors > > > I started out using TypeLits, but I was running into problems with GHC's > solver along these lines: > > > > http://stackoverflow.com/questions/24734704/append-for-type-level-numbered-lists-with-typelits > > > However, I would not rule out the possibility that this was due to misuse > my behalf. If you know a way to make it work, that would be exactly the > kind of feedback I am looking for! > > > Also, I'd be curious if it is possible to write an instance of the general > NFunctor for NList (which does not require explicit type annotations to > work): > > > class NFunctor t (m :: Peano) (n :: Peano) where > pmap' :: (t (Succ m) a -> t m b) -> t (Succ n) a -> t n b > zmap' :: (t m a -> t m b) -> t n a -> t n b > smap' :: (t m a -> t (Succ m) b) -> t n a -> t (Succ n) b > > Cheers, > > Daniel > ------------------------------ > *From:* amindfv at gmail.com > *Sent:* Monday, March 7, 2016 2:38 AM > *To:* Daniel Filonik > *Cc:* haskell-cafe at haskell.org > *Subject:* Re: [Haskell-cafe] GADTs and Exponentiated Functors > > Interesting! What's the reason you redefine the Piano numbers and hide the > import of the ones from GHC. TypeLits? > > Tom > > > El 6 mar 2016, a las 07:11, Daniel Filonik > escribi?: > > Hi, > > > I have been recently playing around with GADTs, using them to keep track > of how many times a functor has been applied. This provides a solution to > what seems to be a long standing problem, summarized here: > > > https://byorgey.wordpress.com/2007/08/16/mapping-over-a-nested-functor/ > > > If the nesting depth is part of the type, it is possible to apply fmap > automatically as needed. This allows you to write fairly elegant > expressions like: > > > data Person = Person { name :: String, age :: Integer, gender :: String, > status :: String } deriving Show > > > let persons = fromList' [Person {name="Alice", age=20, gender="F", status= > "Good"}, Person {name="Bob", age=18, gender="M", status="Good"}, Person > {name="Chuck", age=16, gender="M", status="Bad"}] :: NList N1 Person > > > persons `select` age > > -- [20,18,16] > > > persons `groupby` gender `select` age > > -- [[20],[18,16]] > > > persons `groupby` gender `groupby` status `select` age > > -- [[[20]],[[18],[16]]] > > > Note that "`select` age" works regardless of nesting depth. You can also > append or remove nesting levels: > > > persons `groupby` gender `select` age `produce` (\x -> [0..x]) > -- [[[0..20]],[[0..18],[0..16]]] > > > persons `groupby` gender `reduce` (sumof age) > > -- [20, 34] > > > Would this kind of thing be of interest? The code is here: > > > https://github.com/filonik/nlists > > > Please feel free to suggest improvements. > > > Cheers, > > Daniel > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From harendra.kumar at gmail.com Sun Mar 13 12:10:51 2016 From: harendra.kumar at gmail.com (Harendra Kumar) Date: Sun, 13 Mar 2016 17:40:51 +0530 Subject: [Haskell-cafe] Module name to package name index Message-ID: Is there something available which can answer questions like this - what all packages on Hackage export "Data.List" module? Another useful question could be - what all packages export symbol named 'x'? Hackage search or hoogle are not helpful in providing a precise answer to these. I am assuming that related functionality usually lands up in the same part of the module namespace. This fact can help us in discovering related or alternative packages or functions available in a given area. For example when I am looking for list related functions I can search for who all exports "Data.List". I guess creating such an index should not be difficult. All the necessary information is available in the packages' .cabal files, we just need to extract it and create a module name to package name index. -harendra -------------- next part -------------- An HTML attachment was scrubbed... URL: From michael at snoyman.com Sun Mar 13 14:20:40 2016 From: michael at snoyman.com (Michael Snoyman) Date: Sun, 13 Mar 2016 14:20:40 +0000 Subject: [Haskell-cafe] Module name to package name index In-Reply-To: References: Message-ID: You can see a list of all modules for each Stackage snapshot, eg https://www.stackage.org/lts-5.7/docs On Sun, Mar 13, 2016, 2:11 PM Harendra Kumar wrote: > Is there something available which can answer questions like this - what > all packages on Hackage export "Data.List" module? Another useful question > could be - what all packages export symbol named 'x'? Hackage search or > hoogle are not helpful in providing a precise answer to these. > > I am assuming that related functionality usually lands up in the same part > of the module namespace. This fact can help us in discovering related or > alternative packages or functions available in a given area. For example > when I am looking for list related functions I can search for who all > exports "Data.List". > > I guess creating such an index should not be difficult. All the necessary > information is available in the packages' .cabal files, we just need to > extract it and create a module name to package name index. > > -harendra > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From harendra.kumar at gmail.com Sun Mar 13 17:52:24 2016 From: harendra.kumar at gmail.com (Harendra Kumar) Date: Sun, 13 Mar 2016 23:22:24 +0530 Subject: [Haskell-cafe] Module name to package name index In-Reply-To: References: Message-ID: That's cool! That's what I wanted. I wish we could have the same thing available on Hackage as well. Some of the packages (NLP related) that I was looking at are only available on Hackage. -harendra On Sun, Mar 13, 2016 at 7:50 PM, Michael Snoyman wrote: > You can see a list of all modules for each Stackage snapshot, eg > > https://www.stackage.org/lts-5.7/docs > > On Sun, Mar 13, 2016, 2:11 PM Harendra Kumar > wrote: > >> Is there something available which can answer questions like this - what >> all packages on Hackage export "Data.List" module? Another useful question >> could be - what all packages export symbol named 'x'? Hackage search or >> hoogle are not helpful in providing a precise answer to these. >> >> I am assuming that related functionality usually lands up in the same >> part of the module namespace. This fact can help us in discovering related >> or alternative packages or functions available in a given area. For example >> when I am looking for list related functions I can search for who all >> exports "Data.List". >> >> I guess creating such an index should not be difficult. All the necessary >> information is available in the packages' .cabal files, we just need to >> extract it and create a module name to package name index. >> >> -harendra >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From m.farkasdyck at gmail.com Sun Mar 13 19:05:01 2016 From: m.farkasdyck at gmail.com (M Farkas-Dyck) Date: Sun, 13 Mar 2016 11:05:01 -0800 Subject: [Haskell-cafe] =?utf-8?q?ANNOUNCE=3A_Frown=2C_Ralf_Hinze=27s_LALR?= =?utf-8?q?=28k=29_parser_generator_for_Haskell=2C_now_slightly_upk?= =?utf-8?b?ZXB0IOKYug==?= Message-ID: Some years ago, Ralf Hinze wrote this parser generator [0], and i have since been using it, so i cleaned it up and uploaded it to Hackage as "frown" [1]. My repo is here: https://github.com/strake/frown [0] http://www.cs.ox.ac.uk/ralf.hinze/frown/ [1] https://hackage.haskell.org/package/frown From han.joosten.han at gmail.com Mon Mar 14 12:27:26 2016 From: han.joosten.han at gmail.com (Han Joosten) Date: Mon, 14 Mar 2016 13:27:26 +0100 Subject: [Haskell-cafe] Prelude.head: empty list In-Reply-To: References: <20160311182647.GA8308@casa.casa> <56E31765.5070501@tu-harburg.de> Message-ID: Thanks all! Plenty good options, fortunately I found my bug pretty fast by simple code inspection :)) 2016-03-12 4:28 GMT+01:00 Chris Wong : > On Sat, Mar 12, 2016 at 8:07 AM, Jonas Scholl > wrote: > > You mean like this? > > > > default-extensions: CPP > > cpp-options: > > > -Dhead=(foldr(const)(error("head:\x20\x65mpty\x20list\x20in\x20"++__FILE__++":"++show(__LINE__))).(take$1)) > > That's pretty cool! > > By the way: can the (take$1) be removed? foldr should be lazy enough > already. > > -- > Chris Wong (https://lambda.xyz) > > "I had not the vaguest idea what this meant and when I could not > remember the words, my tutor threw the book at my head, which did not > stimulate my intellect in any way." -- Bertrand Russell > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From clintonmead at gmail.com Mon Mar 14 13:01:57 2016 From: clintonmead at gmail.com (Clinton Mead) Date: Tue, 15 Mar 2016 00:01:57 +1100 Subject: [Haskell-cafe] Prelude.head: empty list In-Reply-To: References: <20160311182647.GA8308@casa.casa> <56E31765.5070501@tu-harburg.de> Message-ID: Just thinking out loud here, but could one write their own Prelude which just imports hiding (head), adds a new definition of head, and reexports the lot. Then add this new Prelude higher in the search path perhaps? On Monday, 14 March 2016, Han Joosten wrote: > Thanks all! Plenty good options, fortunately I found my bug pretty fast by > simple code inspection :)) > > 2016-03-12 4:28 GMT+01:00 Chris Wong >: > >> On Sat, Mar 12, 2016 at 8:07 AM, Jonas Scholl >> > > wrote: >> > You mean like this? >> > >> > default-extensions: CPP >> > cpp-options: >> > >> -Dhead=(foldr(const)(error("head:\x20\x65mpty\x20list\x20in\x20"++__FILE__++":"++show(__LINE__))).(take$1)) >> >> That's pretty cool! >> >> By the way: can the (take$1) be removed? foldr should be lazy enough >> already. >> >> -- >> Chris Wong (https://lambda.xyz) >> >> "I had not the vaguest idea what this meant and when I could not >> remember the words, my tutor threw the book at my head, which did not >> stimulate my intellect in any way." -- Bertrand Russell >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> >> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From adam at bergmark.nl Mon Mar 14 13:12:23 2016 From: adam at bergmark.nl (Adam Bergmark) Date: Mon, 14 Mar 2016 06:12:23 -0700 Subject: [Haskell-cafe] Prelude.head: empty list In-Reply-To: References: Message-ID: <56e6b7fc253e133900000001@polymail.io> Yes you can define your own Prelude. You can?t shadow modules but you can depend on a package providing a custom prelude while not explicitly depending on base. On Mon 14 Mar 2016 at 14:01 Clinton Mead < mailto:Clinton Mead > wrote: Just thinking out loud here, but could one write their own Prelude which just imports hiding (head), adds a new definition of head, and reexports the lot. Then add this new Prelude higher in the search path perhaps? On Monday, 14 March 2016, Han Joosten < mailto:han.joosten.han at gmail.com > wrote: Thanks all! Plenty good options, fortunately I found my bug pretty fast by simple code inspection :)) _______________________________________________ Haskell-Cafe mailing list mailto:Haskell-Cafe at haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe 2016-03-12 4:28 GMT+01:00 Chris Wong < javascript:_e(%7B%7D,'cvml','lambda.fairy at gmail.com'); > : On Sat, Mar 12, 2016 at 8:07 AM, Jonas Scholl < javascript:_e(%7B%7D,'cvml','anselm.scholl at tu-harburg.de'); > wrote: > You mean like this? > >? ?default-extensions:? CPP >? ?cpp-options: > -Dhead=(foldr(const)(error("head:\x20\x65mpty\x20list\x20in\x20"++__FILE__++":"++show(__LINE__))).(take$1)) That's pretty cool! By the way: can the (take$1) be removed? foldr should be lazy enough already. -- Chris Wong ( https://lambda.xyz ) "I had not the vaguest idea what this meant and when I could not remember the words, my tutor threw the book at my head, which did not stimulate my intellect in any way." -- Bertrand Russell _______________________________________________ Haskell-Cafe mailing list javascript:_e(%7B%7D,'cvml','Haskell-Cafe at haskell.org'); http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe -------------- next part -------------- An HTML attachment was scrubbed... URL: From ozgun.ataman at soostone.com Mon Mar 14 18:20:15 2016 From: ozgun.ataman at soostone.com (Ozgun Ataman) Date: Mon, 14 Mar 2016 14:20:15 -0400 Subject: [Haskell-cafe] ANN: katip - a new structured logging framework for Haskell Message-ID: Fellow Haskellers, We're delighted to release a new logging framework today called "katip", centered around the idea of making it easy to include contextual data in individual log items in the form of structured fields. Katip has become, rather quickly, our go-to logging library at Soostone, included in everything from simple ad-hoc scripts to production systems under load. You can find katip on both Hackage[1] and Github[2]. The core library has also been added to Stackage nightly, though the ElasticSearch backend is waiting on a dependency conflict on aeson. We hope you find it useful and look forward to any contributions or feedback! [1] http://hackage.haskell.org/package/katip [2] https://github.com/Soostone/katip As a little summary, here's the features checklist from the README: * *Structured:* Logs are structured, meaning they can be individually tagged with key value data (JSON Objects). This helps you add critical details to log messages before you need them so that when you do, they are available. Katip exposes a typeclass for log payloads so that you can use rich, domain-specific Haskell types to add context that will be automatically merged in with existing log context. * *Easy to Integration:* Katip was designed to be easily integrated into existing monads. By using typeclasses for logging facilities, individual subsystems and even libraries can easily add their own namespacing and context without having any knowledge of their logging environment. * *Practical Use:* Katip comes with a set of convenience facilities built-in, so it can be used without much headache even in small projects. * A `Handle` backend for logging to files in simple settings. * A `AnyLogPayload` key-value type that makes it easy to log structured columns on the fly without having to define new data types. * A `Monadic` interface where logging namespace can be obtained from the monad context. * Multiple variants of the fundamental logging functions for optionally including fields and line-number information. * *Extensible:* Can be easily extended (even at runtime) to output to multiple backends at once (known as scribes). See `katip-elasticsearch` as an example. Backends for other forms of storage are trivial to write, including both hosted database systems and SaaS logging providers. * *Debug-Friendly:* Critical details for monitoring production systems such as host, PID, thread id, module and line location are automatically captured. User-specified attributes such as environment (e.g. Production, Test, Dev) and system name are also captured. * *Configurable:* Can be adjusted on a per-scribe basis both with verbosity and severity. * *Verbosity* dictates how much of the log structure should actually get logged. In code you can capture highly detailed metadata and decide how much of that gets emitted to each backend. * *Severity* AKA "log level" is specified with each message and individual scribes can decide whether or not to record that severity. It is even possible to at runtime swap out and replace loggers, allowing for swapping in verbose debug logging at runtime if you want. * *Battle-Tested:* Katip has been integrated into several production systems since 2015 and has logged hundreds of millions of messages to files and ElasticSearch. -------------- next part -------------- An HTML attachment was scrubbed... URL: From wojciech.danilo at gmail.com Mon Mar 14 18:44:40 2016 From: wojciech.danilo at gmail.com (Wojciech Danilo) Date: Mon, 14 Mar 2016 18:44:40 +0000 Subject: [Haskell-cafe] ANN: katip - a new structured logging framework for Haskell In-Reply-To: References: Message-ID: Hello! It's always good to know new ways to log things in Haskell because the old-fasioned logger is just pain in the code. Anyway I was writing an modern extensible logger some time ago and a lot of people are currently using it. Would you be so nice and take a look here ( https://github.com/wdanilo/haskell-logger ) and tell if Katip has all the features of Haskell-Logger or if there atre other features not covered by it? I would love to see even a very small comparison :) All the best, Wojciech pon., 14.03.2016 o 19:20 u?ytkownik Ozgun Ataman napisa?: > Fellow Haskellers, > > We're delighted to release a new logging framework today called "katip", > centered around the idea of making it easy to include contextual data in > individual log items in the form of structured fields. Katip has become, > rather quickly, our go-to logging library at Soostone, included in > everything from simple ad-hoc scripts to production systems under load. > > You can find katip on both Hackage[1] and Github[2]. The core library has > also been added to Stackage nightly, though the ElasticSearch backend is > waiting on a dependency conflict on aeson. We hope you find it useful and > look forward to any contributions or feedback! > > [1] http://hackage.haskell.org/package/katip > [2] https://github.com/Soostone/katip > > > As a little summary, here's the features checklist from the README: > > * *Structured:* Logs are structured, meaning they can be individually > tagged with key value data (JSON Objects). This helps you add > critical details to log messages before you need them so that when > you do, they are available. Katip exposes a typeclass for log > payloads so that you can use rich, domain-specific Haskell types to > add context that will be automatically merged in with existing log > context. > > * *Easy to Integration:* Katip was designed to be easily integrated > into existing monads. By using typeclasses for logging facilities, > individual subsystems and even libraries can easily add their own > namespacing and context without having any knowledge of their > logging environment. > > * *Practical Use:* Katip comes with a set of convenience facilities > built-in, so it can be used without much headache even in small > projects. > > * A `Handle` backend for logging to files in simple settings. > > * A `AnyLogPayload` key-value type that makes it easy to log > structured columns on the fly without having to define new data > types. > > * A `Monadic` interface where logging namespace can be obtained > from the monad context. > > * Multiple variants of the fundamental logging functions for > optionally including fields and line-number information. > > * *Extensible:* Can be easily extended (even at runtime) to output to > multiple backends at once (known as scribes). See > `katip-elasticsearch` as an example. Backends for other forms of > storage are trivial to write, including both hosted database systems > and SaaS logging providers. > > * *Debug-Friendly:* Critical details for monitoring production systems > such as host, PID, thread id, module and line location are > automatically captured. User-specified attributes such as > environment (e.g. Production, Test, Dev) and system name are also > captured. > > * *Configurable:* Can be adjusted on a per-scribe basis both with > verbosity and severity. > > * *Verbosity* dictates how much of the log structure should > actually get logged. In code you can capture highly detailed > metadata and decide how much of that gets emitted to each backend. > > * *Severity* AKA "log level" is specified with each message and > individual scribes can decide whether or not to record that > severity. It is even possible to at runtime swap out and replace > loggers, allowing for swapping in verbose debug logging at runtime > if you want. > > * *Battle-Tested:* Katip has been integrated into several production > systems since 2015 and has logged hundreds of millions of messages > to files and ElasticSearch. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From capn.freako at gmail.com Mon Mar 14 20:06:38 2016 From: capn.freako at gmail.com (David Banas) Date: Mon, 14 Mar 2016 13:06:38 -0700 Subject: [Haskell-cafe] Foldable/Traversable and Applicative/Monoid? In-Reply-To: References: Message-ID: Hi David, Thanks so much for the two proposed exercises, and very sorry to have taken so long to respond to them. I?ve constructed my responses in the form of an IHaskell notebook, and made that notebook available, here: https://htmlpreview.github.io/?https://github.com/capn-freako/Haskell_Misc/blob/master/Applicative_Monoid_traverse_foldMap.html#davids_proposed_exercises Thanks, -db On Feb 5, 2016, at 11:20 AM, David Feuer wrote: > It's not so much that it's *necessary* as that it's *possible*. The existence of two functions in Data.Traversable explains both of the superclasses of Traversable: > > fmapDefault :: Traversable t => (a -> b) -> t a -> t b > > foldMapDefault :: (Traversable t, Monoid m) => (a -> m) -> t a -> m > > Each of these is written using only traverse, and they can be used to define fmap and foldMap for types when you've written traverse. > > Hint: Consider traversing using the following applicative functors: > > newtype Const a b = Const a > instance Monoid a => Applicative (Const a) > > newtype Identity a = Identity a > instance Applicative Identity > > On Feb 5, 2016 1:45 PM, "David Banas" wrote: > Hi all, > > I don't understand why Foldable is a necessary super-class of Traversable, and I suspect that the Applicative/Monoid duality, which I've just begun discovering in the literature, has something to do with why that is so. > > Can anyone give me a hint, without giving me the answer? > > Thanks! > -db > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From blamario at ciktel.net Mon Mar 14 22:34:43 2016 From: blamario at ciktel.net (=?UTF-8?Q?Mario_Bla=c5=beevi=c4=87?=) Date: Mon, 14 Mar 2016 18:34:43 -0400 Subject: [Haskell-cafe] Zoom instance for Coroutine In-Reply-To: References: Message-ID: <56E73C83.5050102@ciktel.net> On 03/11/2016 02:35 AM, Konstantin Saveljev wrote: > Hello, > > I am using monad-coroutine > package and have > something like Coroutine (Await Int) (State MyState) Int (simplified > version, for example purpose). > > MyState is deeply nested and I do a lot of modifications in it. > Previously (with different data types) I was able to use zoom from > lens in order to simplify > the typing/view of code which operates on some subtree of the state, e.g.: > > |zoom (company.assets) $ dosomething.a = someComputation anotherthing.b > = False this.that = "someString" | > The problem I am having is that I cannot come up with instance > Zoom for the Coroutine and was wondering if anyone is able to help me > with that? I don't know if it gets you instance Zoom, but you can combine zoom with mapMonad to dive into a field of your state. https://hackage.haskell.org/package/monad-coroutine-0.9.0.2/docs/Control-Monad-Coroutine.html#v:mapMonad From alex at slab.org Wed Mar 16 17:34:28 2016 From: alex at slab.org (alex) Date: Wed, 16 Mar 2016 17:34:28 +0000 Subject: [Haskell-cafe] GHCi on Pi Zero Message-ID: Hi all, I'm struggling with getting a working ghci on the Raspberry Pi Zero. I managed to get a ghc with ghci installed via jessie-backports, but when I run ghci from the commandline I simply get a "Illegal instruction" message. Has anyone had more luck, or does anyone have ideas / tips? Best wishes alex -- http://yaxu.org/ From prolepsis at gmail.com Wed Mar 16 21:59:28 2016 From: prolepsis at gmail.com (Al Matthews) Date: Wed, 16 Mar 2016 21:59:28 +0000 Subject: [Haskell-cafe] GHCi on Pi Zero In-Reply-To: References: Message-ID: Not a thoroughly curated response here but Arch is supportive of both arm and Haskell. https://archlinuxarm.org/platforms/armv6/raspberry-pi https://wiki.archlinux.org/index.php/Raspberry_Pi Could be tipsworthy. Arch usu runs ahead to GHC 10. On Wed, Mar 16, 2016, 13:34 alex wrote: > Hi all, > > I'm struggling with getting a working ghci on the Raspberry Pi Zero. > > I managed to get a ghc with ghci installed via jessie-backports, but > when I run ghci from the commandline I simply get a "Illegal > instruction" message. > > Has anyone had more luck, or does anyone have ideas / tips? > > Best wishes > > alex > > -- > http://yaxu.org/ > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > -- Alfred S Matthews +1 337 214 4688 -------------- next part -------------- An HTML attachment was scrubbed... URL: From fr33domlover at riseup.net Wed Mar 16 23:56:05 2016 From: fr33domlover at riseup.net (fr33domlover) Date: Thu, 17 Mar 2016 01:56:05 +0200 Subject: [Haskell-cafe] Link error Message-ID: Hello, I'm getting this when trying to build the tests of the 'ssh' package: -------------------------------------------------------------------- ssh-0.3.2: build (lib + test) Preprocessing library ssh-0.3.2... In-place registering ssh-0.3.2... Preprocessing test suite 'ssh-test' for ssh-0.3.2... [2 of 2] Compiling Main ( test/test.hs, .stack-work/dist/x86_64-linux/Cabal-1.22.5.0/build/ssh-test/ssh-test-tmp/Main.o ) /usr/bin/ld: .stack-work/dist/x86_64-linux/Cabal-1.22.5.0/build/ssh-test/ssh-test-tmp/EmbedTree.dyn_o: relocation R_X86_64_PC32 against symbol `EmbedTree_zdfLiftEntryzuzdclift_closure' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: final link failed: Bad value collect2: error: ld returned 1 exit status Progress: 1/2 -- While building package ssh-0.3.2 using: /home/fr33domlover/.stack/setup-exe-cache/x86_64-linux/setup-Simple-Cabal-1.22.5.0-ghc-7.10.3 --builddir=.stack-work/dist/x86_64-linux/Cabal-1.22.5.0 build lib:ssh test:ssh-test --ghc-options " -ddump-hi -ddump-to-file" Process exited with code: ExitFailure 1 -------------------------------------------------------------------- Other people don't get this error. What does it mean, how do I start to debug and fix it? Thanks in advance for any clue! --fr33 -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 801 bytes Desc: not available URL: From pin.terminator at gmail.com Thu Mar 17 02:58:06 2016 From: pin.terminator at gmail.com (Krisztian Pinter) Date: Thu, 17 Mar 2016 03:58:06 +0100 Subject: [Haskell-cafe] Odd list comprehension behaviour Message-ID: Hello, I noticed some odd behaviour with list comprehensions. [1..1] == [1] BUT [1,1..1] == [1..] I noticed this while writing a Clean program, but it seems Haskell inherited this as well. In the case of integer lists with step size >= 0 the up_list function[1] is used: up_list :: Integer -> Integer -> Integer -> [Integer] up_list x0 delta lim = go (x0 :: Integer) where go x | x > lim = [] | otherwise = x : go (x+delta) In the case of [1,1..1] x0 == lim, so go will recurse infinitely, producing an infinite list. I think the reasonable behaviour would be [1,1..1] == [1]. Is there a reason it doesn't work like this? [1] http://hackage.haskell.org/package/base-4.8.2.0/docs/src/GHC.Enum.html#up_list Thanks, Kriszti?n -------------- next part -------------- An HTML attachment was scrubbed... URL: From kiss.csongor.kiss at gmail.com Thu Mar 17 03:10:52 2016 From: kiss.csongor.kiss at gmail.com (Kiss Csongor) Date: Thu, 17 Mar 2016 03:10:52 +0000 Subject: [Haskell-cafe] Odd list comprehension behaviour In-Reply-To: References: Message-ID: <77C22187-6A7A-493E-AB9F-BDBF233CEAAA@gmail.com> The syntax [a, b..c] in general produces a list which starts with ?a", followed by ?b", going up until reaching (possibly including) c in step sizes of (b - a). (For simplicity?s sake, I only described non-decreasing lists) So it is logical that a step size of 0 produces an infinite list, when [1,1..1] is given. Notice that [1,1..1] is not the same as [1..], but "repeat 1?. Csongor > On 17 Mar 2016, at 02:58, Krisztian Pinter wrote: > > Hello, > > I noticed some odd behaviour with list comprehensions. > > [1..1] == [1] > BUT > [1,1..1] == [1..] > > I noticed this while writing a Clean program, but it seems Haskell inherited this as well. > In the case of integer lists with step size >= 0 the up_list function[1] is used: > > up_list :: Integer -> Integer -> Integer -> [Integer] > up_list x0 delta lim = go (x0 :: Integer) > where > go x | x > lim = [] > | otherwise = x : go (x+delta) > > In the case of [1,1..1] x0 == lim, so go will recurse infinitely, producing an infinite list. > > I think the reasonable behaviour would be [1,1..1] == [1]. Is there a reason it doesn't work like this? > > [1] http://hackage.haskell.org/package/base-4.8.2.0/docs/src/GHC.Enum.html#up_list > > Thanks, > Kriszti?n > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe -------------- next part -------------- An HTML attachment was scrubbed... URL: From number.dot.ten at gmail.com Thu Mar 17 03:13:46 2016 From: number.dot.ten at gmail.com (Jesse Frankley) Date: Wed, 16 Mar 2016 20:13:46 -0700 Subject: [Haskell-cafe] Odd list comprehension behaviour In-Reply-To: <77C22187-6A7A-493E-AB9F-BDBF233CEAAA@gmail.com> References: <77C22187-6A7A-493E-AB9F-BDBF233CEAAA@gmail.com> Message-ID: This can be seen with [1,1..2], [1,1..3], etc. On Wed, Mar 16, 2016 at 8:10 PM, Kiss Csongor wrote: > The syntax [a, b..c] in general produces a list which starts with ?a", > followed by ?b", going > up until reaching (possibly including) c in step sizes of (b - a). > (For simplicity?s sake, I only described non-decreasing lists) > > So it is logical that a step size of 0 produces an infinite list, when > [1,1..1] is given. > Notice that [1,1..1] is not the same as [1..], but "repeat 1?. > > Csongor > > On 17 Mar 2016, at 02:58, Krisztian Pinter > wrote: > > Hello, > > I noticed some odd behaviour with list comprehensions. > > [1..1] == [1] > BUT > [1,1..1] == [1..] > > I noticed this while writing a Clean program, but it seems Haskell > inherited this as well. > In the case of integer lists with step size >= 0 the up_list function[1] > is used: > > up_list :: Integer -> Integer -> Integer -> [Integer] > up_list x0 delta lim = go (x0 :: Integer) > where > go x | x > lim = [] > | otherwise = x : go (x+delta) > > In the case of [1,1..1] x0 == lim, so go will recurse infinitely, > producing an infinite list. > > I think the reasonable behaviour would be [1,1..1] == [1]. Is there a > reason it doesn't work like this? > > [1] > http://hackage.haskell.org/package/base-4.8.2.0/docs/src/GHC.Enum.html#up_list > > Thanks, > Kriszti?n > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From hyarion at iinet.net.au Thu Mar 17 03:20:48 2016 From: hyarion at iinet.net.au (Ben) Date: Thu, 17 Mar 2016 14:20:48 +1100 Subject: [Haskell-cafe] Odd list comprehension behaviour In-Reply-To: Message-ID: If you actually evaulate?[1,1..1] == [1..] in a GHCI prompt it will tell you False immediately. :) [1..] evaluates to ?[1, 2, 3, 4, 5, 6, ... etc ... [1,1..1] evaluates to [1, 1, 1, 1, 1, 1 ... etc ... The syntax where you give 2 elements before the .. is intended to resemble this style of shorthand for lists: [1, 2, 3, 4, ...10]. The idea is that Haskell should take the two elements as "example elements" showing the pattern you want. So [1,1..] is saying you want a list that starts at 1, then has 1, and continues on like that; you're specifying a step size of *zero*, not of 1. You can step 1 by 0 an infinite number of times without exceeding 1, so [1,1..1] should not be finite. -- Ben ----- Original Message ----- From: "Krisztian Pinter" To: Cc: Sent:Thu, 17 Mar 2016 03:58:06 +0100 Subject:[Haskell-cafe] Odd list comprehension behaviour Hello, I noticed some odd behaviour with list comprehensions. [1..1] == [1]BUT[1,1..1] == [1..] I noticed this while writing a Clean program, but it seems Haskell inherited this as well.In the case of integer lists with step size >= 0 the up_list function[1] is used: up_list :: Integer -> Integer -> Integer -> [Integer]up_list x0 delta lim = go (x0 :: Integer)? ? ? ? ? ? ? ? ? ? where? ? ? ? ? ? ? ? ? ? ? ? go x | x > lim ? = []? ? ? ? ? ? ? ? ? ? ? ? ? ? ?| otherwise = x : go (x+delta) In the case of [1,1..1] x0 == lim, so go will recurse infinitely, producing an infinite list. I think the reasonable behaviour would be [1,1..1] == [1]. Is there a reason it doesn't work like this? [1]?http://hackage.haskell.org/package/base-4.8.2.0/docs/src/GHC.Enum.html#up_list [1] Thanks,Kriszti?n Links: ------ [1] http://hackage.haskell.org/package/base-4.8.2.0/docs/src/GHC.Enum.html#up_list -------------- next part -------------- An HTML attachment was scrubbed... URL: From fa-ml at ariis.it Thu Mar 17 03:26:34 2016 From: fa-ml at ariis.it (Francesco Ariis) Date: Thu, 17 Mar 2016 04:26:34 +0100 Subject: [Haskell-cafe] Odd list comprehension behaviour In-Reply-To: References: Message-ID: <20160317032634.GA1494@casa.casa> On Thu, Mar 17, 2016 at 03:58:06AM +0100, Krisztian Pinter wrote: > Hello, > > I noticed some odd behaviour with list comprehensions. > > [1..1] == [1] > BUT > [1,1..1] == [1..] Hello Krisztian, from the Haskell report (enumFromThenTo is longhand for [a,b..c] notation) [1]: The sequence enumFromThenTo e1 e2 e3 is the list [e1,e1+i,e1+2i,...e3], where the increment, i, is e2-e1. If the increment is positive or zero, the list terminates when the next element would be greater than e3; the list is empty if e1 > e3. If the increment is negative, the list terminates when the next element would be less than e3; the list is empty if e1 < e3. The important bit being "the list terminates when the next element would be greater than e3". Unfortunate in my opinion (I agree with you the fact that `[1..1] /= [1,1..1]` is puzzling), but specs compliant -F [1] https://www.haskell.org/onlinereport/basic.html -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: From ok at cs.otago.ac.nz Thu Mar 17 03:44:12 2016 From: ok at cs.otago.ac.nz (Richard A. O'Keefe) Date: Thu, 17 Mar 2016 16:44:12 +1300 Subject: [Haskell-cafe] Odd list comprehension behaviour In-Reply-To: References: Message-ID: <2453d8b9-ee6a-e791-8245-e8bb3e48a639@cs.otago.ac.nz> On 17/03/16 3:58 pm, Krisztian Pinter wrote: > I think the reasonable behaviour would be [1,1..1] == [1]. Is there a > reason it doesn't work like this? That's arguably *a* reasonable behaviour, but I'm not sure it's *the* reasonable behaviour. Another reasonable behaviour would be a run-time error for [X,X..Y] whatever Y is. And to my mind, what Haskell actually does, while not as programmer-friendly as a run-time error would be, is reasonable because consistent. In R, > seq(from=1, to=2, by=0) Error in seq.default(from = 1, to = 2, by = 0) : invalid (to - from)/by in seq(.) > seq(from=1, to=1, by=0) [1] 1 I find this behaviour in R inconsistent and confusing. At least in Haskell [1,1..N] gives the same answer for any N >= 1. From tanuki at gmail.com Thu Mar 17 04:17:28 2016 From: tanuki at gmail.com (Theodore Lief Gannon) Date: Wed, 16 Mar 2016 21:17:28 -0700 Subject: [Haskell-cafe] Link error In-Reply-To: <20160316235054.26E0FBD977@haskell.org> References: <20160316235054.26E0FBD977@haskell.org> Message-ID: >EmbedTree_zdfLiftEntryzuzdclift_closure I've seen something like this before -- I think the 'zd' and 'zu' in there are supposed to be formatting tokens, %zd and %zu, for architecture-aware data sizing. I ran into this while building the Haskell GTK bindings on Windows, and IIRC it was caused by GHC 7.8 bundling an older GCC. -------------- next part -------------- An HTML attachment was scrubbed... URL: From targen at gmail.com Thu Mar 17 04:27:39 2016 From: targen at gmail.com (=?UTF-8?Q?Manuel_G=C3=B3mez?=) Date: Wed, 16 Mar 2016 23:57:39 -0430 Subject: [Haskell-cafe] Odd list comprehension behaviour In-Reply-To: <20160317032634.GA1494@casa.casa> References: <20160317032634.GA1494@casa.casa> Message-ID: On Wed, Mar 16, 2016 at 10:56 PM, Francesco Ariis wrote: > from the Haskell report (enumFromThenTo is longhand for [a,b..c] > notation) [1]: > > The sequence enumFromThenTo e1 e2 e3 is the list [e1,e1+i,e1+2i,...e3], > where the increment, i, is e2-e1. If the increment is positive or zero, > the list terminates when the next element would be greater than e3; the > list is empty if e1 > e3. If the increment is negative, the list > terminates when the next element would be less than e3; the list is > empty if e1 < e3. > > The important bit being "the list terminates when the next element would > be greater than e3". Unfortunate in my opinion (I agree with you the > fact that `[1..1] /= [1,1..1]` is puzzling), but specs compliant > > [1] https://www.haskell.org/onlinereport/basic.html I'm not necessarily proposing this, but would it not be also reasonable for this to read "the list terminates when the current element equals e3 or the next element would be greater than e3"? It's slightly more wordy, but it captures the intuition that [a,b..c] ends at c. From alexanderaltman at me.com Thu Mar 17 04:36:50 2016 From: alexanderaltman at me.com (Alexander Altman) Date: Wed, 16 Mar 2016 21:36:50 -0700 Subject: [Haskell-cafe] Link error Message-ID: This is actually nothing at all to do with formatting; instead it?s what?s known as Z-encoding: see https://ghc.haskell.org/trac/ghc/wiki/Commentary/Compiler/SymbolNames for details. > > > EmbedTree_zdfLiftEntryzuzdclift_closure > > > I've seen something like this before -- I think the 'zd' and 'zu' in there > are supposed to be formatting tokens, %zd and %zu, for architecture-aware > data sizing. I ran into this while building the Haskell GTK bindings on > Windows, and IIRC it was caused by GHC 7.8 bundling an older GCC. > From ok at cs.otago.ac.nz Thu Mar 17 04:48:40 2016 From: ok at cs.otago.ac.nz (Richard A. O'Keefe) Date: Thu, 17 Mar 2016 17:48:40 +1300 Subject: [Haskell-cafe] Odd list comprehension behaviour In-Reply-To: References: <20160317032634.GA1494@casa.casa> Message-ID: On 17/03/16 5:27 pm, Manuel G?mez wrote: > I'm not necessarily proposing this, but would it not be also > reasonable for this to read "the list terminates when the current > element equals e3 or the next element would be greater than e3"? It's > slightly more wordy, but it captures the intuition that [a,b..c] ends > at c. From experience in other programming languages, I don't have that intuition. Indeed, from experience in Haskell, I don't expect [a,b..c] to end at c. [1,3..6] ends at 5, not 6. From fa-ml at ariis.it Thu Mar 17 05:44:33 2016 From: fa-ml at ariis.it (Francesco Ariis) Date: Thu, 17 Mar 2016 06:44:33 +0100 Subject: [Haskell-cafe] Odd list comprehension behaviour In-Reply-To: References: <20160317032634.GA1494@casa.casa> Message-ID: <20160317054433.GA3849@casa.casa> On Wed, Mar 16, 2016 at 11:57:39PM -0430, Manuel G?mez wrote: > On Wed, Mar 16, 2016 at 10:56 PM, Francesco Ariis wrote: > > The important bit being "the list terminates when the next element would > > be greater than e3". Unfortunate in my opinion (I agree with you the > > fact that `[1..1] /= [1,1..1]` is puzzling), but specs compliant > > > > [1] https://www.haskell.org/onlinereport/basic.html > > I'm not necessarily proposing this, but would it not be also > reasonable for this to read "the list terminates when the current > element equals e3 or the next element would be greater than e3"? It's > slightly more wordy, but it captures the intuition that [a,b..c] ends > at c. Exactly! I am now tempted to fire in haskell-prime. From targen at gmail.com Thu Mar 17 06:25:00 2016 From: targen at gmail.com (=?UTF-8?Q?Manuel_G=C3=B3mez?=) Date: Thu, 17 Mar 2016 01:55:00 -0430 Subject: [Haskell-cafe] Odd list comprehension behaviour In-Reply-To: References: <20160317032634.GA1494@casa.casa> Message-ID: > On 17/03/16 5:27 pm, Manuel G?mez wrote: > I'm not necessarily proposing this, but would it not be also > reasonable for this to read "the list terminates when the current > element equals e3 or the next element would be greater than e3"? It's > slightly more wordy, but it captures the intuition that [a,b..c] ends > at c. On Thu, Mar 17, 2016 at 12:18 AM, Richard A. O'Keefe wrote: > From experience in other programming languages, I don't have that intuition. > Indeed, from experience in Haskell, I don't expect [a,b..c] to end at c. > [1,3..6] ends at 5, not 6. I apologize ? I believe I failed to convey what I tried to say. Perhaps I should instead have said ?ends at c at the furthest?. The intuition I refer to is that c is a possibly included bound for the list [a,b..c], so that the list [a,b..c] certainly shall not have any element beyond c, but if it does actually get to c, that?s where it ends. In that sense I find it natural that [1,3..6] ends at 5: otherwise it would have elements beyond 6, namely 7. [0,2..6], on the other hand, ends at 6, and indeed does not have any element beyond 6. [6,6..6] would have the initial 6, and then it should have no other element beyond 6, so it should in fact equal [6] under this intuition. From harendra.kumar at gmail.com Thu Mar 17 07:59:28 2016 From: harendra.kumar at gmail.com (Harendra Kumar) Date: Thu, 17 Mar 2016 13:29:28 +0530 Subject: [Haskell-cafe] Lightweight Unicode normalization library Message-ID: I looked around and found only one package, text-icu which provides unicode normalization operations and a lot more. But text-icu depends on the icu library being installed on the system. We would prefer to avoid dependency on the icu library. Is there a lightweight alternative which does not depend on icu? It could be a pure Haskell package or bindings to a lightweight C library where the library is small and shipped with the package itself. I wonder if there is a need for unicode normalization operations in GHC code itself? If so how does it handle that? I found a lightweight C library (https://github.com/JuliaLang/utf8proc) for normalization and case folding used by the Julia lang project. If there is no other option I am considering creating bindings to this library. Any pointers, thoughts? Thanks, Harendra -------------- next part -------------- An HTML attachment was scrubbed... URL: From k-bx at k-bx.com Thu Mar 17 12:30:06 2016 From: k-bx at k-bx.com (Kostiantyn Rybnikov) Date: Thu, 17 Mar 2016 14:30:06 +0200 Subject: [Haskell-cafe] Prelude.head: empty list In-Reply-To: References: Message-ID: Always using `headNote` from `safe` package works good enough usually. On Fri, Mar 11, 2016 at 5:56 PM, Han Joosten wrote: > In a rather large program I made some changes, and now I get the runtime > error: > > ampersand.exe: Prelude.head: empty list > > Of course I know that head is partial, and should be used with care. It is > used many times (we have 100+ modules in the program). Is there an elegant > way to get some information about where the specific call to head is being > made? > > Thanks! > > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From yoyoyonny at gmail.com Thu Mar 17 12:44:51 2016 From: yoyoyonny at gmail.com (Jonne Ransijn) Date: Thu, 17 Mar 2016 13:44:51 +0100 Subject: [Haskell-cafe] Prelude.head: empty list In-Reply-To: References: Message-ID: https://wiki.haskell.org/Debugging has some useful tips for debugging in general. -------------- next part -------------- An HTML attachment was scrubbed... URL: From ollie at ocharles.org.uk Thu Mar 17 12:46:47 2016 From: ollie at ocharles.org.uk (Oliver Charles) Date: Thu, 17 Mar 2016 12:46:47 +0000 Subject: [Haskell-cafe] Stuck on a type family problem where kind inference fails Message-ID: Hi all, This is a little tricky to explain, so bear with me. I'm working on some code that roughly models a PostgreSQL schema. Users begin by defining their tables as Haskell records, parametrized over some f :: k -> *, and use a special Col type family that applies some normalisation: data Table f = Table { tableId :: Col f ('NotNullable 'DBInt) , tableX :: Col f ('Nullable 'DBString) } is one such example. The idea behind Col is that sometimes we don't need information about the "full type" when we know more about f. One such choice of f is Expr, which corresponds to expressions inside a query. In this case, I would desire tableId :: Col Expr ('NotNullable 'DBInt) = tableId :: Expr 'DBInt tableX :: Col Expr ('Nullable 'DBString) = tableX :: Expr ('Nullable 'DBString) Notice here that if you use 'NotNullable, then this information is erased - but it's important if the column is 'Nullable. However, I'm struggling to work out any way to actually pull this off in the general case. Here's what I've been attempting: {-# LANGUAGE FunctionalDependencies #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE KindSignatures #-} {-# LANGUAGE PolyKinds #-} {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE UndecidableInstances #-} {-# LANGUAGE ScopedTypeVariables #-} module ExprTest where import Data.Singletons import Data.Singletons.Prelude hiding (Null) import Data.Singletons.TH data Expr (a :: k) data MyExprSym :: TyFun k * -> * type instance Apply MyExprSym (x :: k) = Expr x $(singletons [d| data Null a = Nullable a | NotNullable a |]) $(promote [d| notNullableType k (NotNullable a) = baseType k a nullableType k (Nullable a) = baseType (k . Nullable) a baseType k a = k a |]) So far, this seems to work well. If I ask GHCI: *ExprTest> :kind! Apply (Apply NullableTypeSym0 MyExprSym) ('Nullable 'DBString) Apply (Apply NullableTypeSym0 MyExprSym) ('Nullable 'DBString) :: * = Expr ('Nullable 'DBString) *ExprTest> :kind! Apply (Apply NotNullableTypeSym0 MyExprSym) ('NotNullable 'DBInt) Apply (Apply NotNullableTypeSym0 MyExprSym) ('NotNullable 'DBInt) :: * = Expr 'DBInt This is exactly what I want, but note that I had to choose the necessary symbols NullableTypeSym0 and NotNullableTypeSym0. I would like to calculate those symbols from the column type itself. Looking at the kinds of these symbols though, they are both different: *ExprTest> :kind! NotNullableTypeSym0 NotNullableTypeSym0 :: TyFun (TyFun k1 k -> *) (TyFun (Null k1) k -> *) -> * = NotNullableTypeSym0 *ExprTest> :kind! NullableTypeSym0 NullableTypeSym0 :: TyFun (TyFun (Null k1) k -> *) (TyFun (Null k1) k -> *) -> * = NullableTypeSym0 So I can't see a way to write a single type family that returns them. To summarise, I'd like a way to write this following instance for Col: type instance Col Expr x = Apply (Apply ?? MyExprSym) x such that Col Expr ('Nullable a) = Expr ('Nullable a') and Col Expr ('NotNullable a) = Expr a but I cannot work out how to write the placeholder ?? above. One attempt is type family ExprTyfun (col :: colK) :: TyFun (TyFun k * -> *) (TyFun j * -> *) -> * type instance ExprTyfun ('NotNullable a) = NotNullableTypeSym0 type instance ExprTyfun ('Nullable a) = NullableTypeSym0 But neither of these instances actually normalise as I'd like, presumably because of k and j being forall'd in the return type: *ExprTest> :set -fprint-explicit-kinds *ExprTest> :kind! ExprTyfun ('Nullable 'DBInt) ExprTyfun ('Nullable 'DBInt) :: TyFun (TyFun k * -> *) (TyFun k1 * -> *) -> * = ExprTyfun k k1 (Null DBType) ('Nullable DBType 'DBInt) *ExprTest> :kind! ExprTyfun ('NotNullable 'DBInt) ExprTyfun ('NotNullable 'DBInt) :: TyFun (TyFun k * -> *) (TyFun k1 * -> *) -> * = ExprTyfun k k1 (Null DBType) ('NotNullable DBType 'DBInt) *ExprTest> :i ExprTyfun type family ExprTyfun (k :: BOX) (j :: BOX) (colK :: BOX) (col :: colK) :: TyFun (TyFun k * -> *) (TyFun j * -> *) -> * -- Defined at src/Opaleye/TF/ExprTest.hs:39:1 type instance ExprTyfun (Null k) (Null k) (Null k1) ('Nullable k1 a) = NullableTypeSym0 * k -- Defined at src/Opaleye/TF/ExprTest.hs:41:1 type instance ExprTyfun k (Null k) (Null k1) ('NotNullable k1 a) = NotNullableTypeSym0 * k -- Defined at src/Opaleye/TF/ExprTest.hs:40:1 I'd also like to point out that in my full code the types to Col can be a lot bigger, and I'd like to not assume any ordering. For example, here's a possible type: userId :: Col f ('Column "id" ('NotNullable ('HasDefault 'DBInt))) In this case Col Expr ('Column "id" ('NotNullable ('HasDefault 'DBInt))) = Expr 'DBInt I hope this question is understandable! Please let me know if there's anything I can do to provide more clarity. - Ollie -------------- next part -------------- An HTML attachment was scrubbed... URL: From sniperrifle2004 at gmail.com Thu Mar 17 13:16:11 2016 From: sniperrifle2004 at gmail.com (Wilfried van Asten) Date: Thu, 17 Mar 2016 13:16:11 +0000 Subject: [Haskell-cafe] Odd list comprehension behaviour In-Reply-To: <20160317054433.GA3849@casa.casa> References: <20160317032634.GA1494@casa.casa> <20160317054433.GA3849@casa.casa> Message-ID: I haven't found a clear and reasonable example yet, but I am certain that a non default enumFromThenTo could generate the bound several times (or only one time), and then later on generate a next that is higher (I think that modulo arithmetic in enumFromThenTo might do it?). This would certainly be unorthodox, but it is hypothetically possible. In this case the stop only when the bound would be exceeded next is more reasonable in my opinion. Kind regards, Wilfried van Asten Op do 17 mrt. 2016 om 06:48 schreef Francesco Ariis : > On Wed, Mar 16, 2016 at 11:57:39PM -0430, Manuel G?mez wrote: > > On Wed, Mar 16, 2016 at 10:56 PM, Francesco Ariis > wrote: > > > The important bit being "the list terminates when the next element > would > > > be greater than e3". Unfortunate in my opinion (I agree with you the > > > fact that `[1..1] /= [1,1..1]` is puzzling), but specs compliant > > > > > > [1] https://www.haskell.org/onlinereport/basic.html > > > > I'm not necessarily proposing this, but would it not be also > > reasonable for this to read "the list terminates when the current > > element equals e3 or the next element would be greater than e3"? It's > > slightly more wordy, but it captures the intuition that [a,b..c] ends > > at c. > > Exactly! I am now tempted to fire in haskell-prime. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk Thu Mar 17 18:28:39 2016 From: tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk (Tom Ellis) Date: Thu, 17 Mar 2016 18:28:39 +0000 Subject: [Haskell-cafe] Odd list comprehension behaviour In-Reply-To: References: Message-ID: <20160317182838.GM25143@weber> On Thu, Mar 17, 2016 at 03:58:06AM +0100, Krisztian Pinter wrote: > I noticed some odd behaviour with list comprehensions. > > [1..1] == [1] > BUT > [1,1..1] == [1..] I think list enumerations are one of those things that would not make it into Haskell today, if we were inventing it from scratch. My (perhaps minority) opinion is that they should be avoided. Tom From eir at cis.upenn.edu Thu Mar 17 19:05:45 2016 From: eir at cis.upenn.edu (Richard Eisenberg) Date: Thu, 17 Mar 2016 15:05:45 -0400 Subject: [Haskell-cafe] Stuck on a type family problem where kind inference fails In-Reply-To: References: Message-ID: Interesting use case! You need a higher-rank kind. All the typey stuff is getting in the way of understanding. I've implemented what you want at the term level: > data Null a = Nullable a | NotNullable a > > notNullableType :: (forall a. a -> Type) -> Null a -> Type > notNullableType k (NotNullable a) = baseType k a > > nullableType :: (forall a. a -> Type) -> Null a -> Type > nullableType k (Nullable a) = baseType (k . Nullable) a > > baseType :: (forall a. a -> Type) -> forall b. b -> Type > baseType k a = k a > > exprTyFun :: Null b -> (forall a. a -> Type) -> Null b -> Type > exprTyFun (NotNullable _) = notNullableType > exprTyFun (Nullable _) = nullableType It's critical that notNullableType and nullableType have the same type, which is achievable only with higher-rank types. Happily, GHC 8.0 comes equipped with higher-rank kinds. `singletons` doesn't yet build on 8.0, but it will in the future, for a sufficiently expansive definition of future. Christiaan Baaij is working on this, but I've been all-consumed by getting GHC 8 out and haven't given Christiaan's contributions the attention they deserve. So: all in good time! I hope this answers your question. Richard On Mar 17, 2016, at 8:46 AM, Oliver Charles wrote: > Hi all, > > This is a little tricky to explain, so bear with me. I'm working on some code that roughly models a PostgreSQL schema. Users begin by defining their tables as Haskell records, parametrized over some f :: k -> *, and use a special Col type family that applies some normalisation: > > data Table f = Table { tableId :: Col f ('NotNullable 'DBInt) > , tableX :: Col f ('Nullable 'DBString) } > > is one such example. > > The idea behind Col is that sometimes we don't need information about the "full type" when we know more about f. > > One such choice of f is Expr, which corresponds to expressions inside a query. In this case, I would desire > > tableId :: Col Expr ('NotNullable 'DBInt) = tableId :: Expr 'DBInt > tableX :: Col Expr ('Nullable 'DBString) = tableX :: Expr ('Nullable 'DBString) > > Notice here that if you use 'NotNullable, then this information is erased - but it's important if the column is 'Nullable. > > However, I'm struggling to work out any way to actually pull this off in the general case. Here's what I've been attempting: > > {-# LANGUAGE FunctionalDependencies #-} > {-# LANGUAGE FlexibleInstances #-} > {-# LANGUAGE RankNTypes #-} > {-# LANGUAGE MultiParamTypeClasses #-} > {-# LANGUAGE DataKinds #-} > {-# LANGUAGE TypeOperators #-} > {-# LANGUAGE TypeFamilies #-} > {-# LANGUAGE KindSignatures #-} > {-# LANGUAGE PolyKinds #-} > {-# LANGUAGE TemplateHaskell #-} > {-# LANGUAGE GADTs #-} > {-# LANGUAGE UndecidableInstances #-} > {-# LANGUAGE ScopedTypeVariables #-} > > module ExprTest where > > import Data.Singletons > import Data.Singletons.Prelude hiding (Null) > import Data.Singletons.TH > > data Expr (a :: k) > > data MyExprSym :: TyFun k * -> * > type instance Apply MyExprSym (x :: k) = Expr x > > $(singletons [d| > data Null a = Nullable a | NotNullable a > |]) > > $(promote [d| > notNullableType k (NotNullable a) = baseType k a > nullableType k (Nullable a) = baseType (k . Nullable) a > baseType k a = k a > |]) > > So far, this seems to work well. If I ask GHCI: > > *ExprTest> :kind! Apply (Apply NullableTypeSym0 MyExprSym) ('Nullable 'DBString) > Apply (Apply NullableTypeSym0 MyExprSym) ('Nullable 'DBString) :: * > = Expr ('Nullable 'DBString) > > *ExprTest> :kind! Apply (Apply NotNullableTypeSym0 MyExprSym) ('NotNullable 'DBInt) > Apply (Apply NotNullableTypeSym0 MyExprSym) ('NotNullable 'DBInt) :: * > = Expr 'DBInt > > This is exactly what I want, but note that I had to choose the necessary symbols NullableTypeSym0 and NotNullableTypeSym0. I would like to calculate those symbols from the column type itself. Looking at the kinds of these symbols though, they are both different: > > *ExprTest> :kind! NotNullableTypeSym0 > NotNullableTypeSym0 :: TyFun > (TyFun k1 k -> *) (TyFun (Null k1) k -> *) > -> * > = NotNullableTypeSym0 > *ExprTest> :kind! NullableTypeSym0 > NullableTypeSym0 :: TyFun > (TyFun (Null k1) k -> *) (TyFun (Null k1) k -> *) > -> * > = NullableTypeSym0 > > So I can't see a way to write a single type family that returns them. > > > To summarise, I'd like a way to write this following instance for Col: > > type instance Col Expr x = Apply (Apply ?? MyExprSym) x > > such that > > Col Expr ('Nullable a) = Expr ('Nullable a') and > Col Expr ('NotNullable a) = Expr a > > but I cannot work out how to write the placeholder ?? above. > > One attempt is > > type family ExprTyfun (col :: colK) :: TyFun (TyFun k * -> *) (TyFun j * -> *) -> * > type instance ExprTyfun ('NotNullable a) = NotNullableTypeSym0 > type instance ExprTyfun ('Nullable a) = NullableTypeSym0 > > But neither of these instances actually normalise as I'd like, presumably because of k and j being forall'd in the return type: > > *ExprTest> :set -fprint-explicit-kinds > > > *ExprTest> :kind! ExprTyfun ('Nullable 'DBInt) > ExprTyfun ('Nullable 'DBInt) :: TyFun > (TyFun k * -> *) (TyFun k1 * -> *) > -> * > = ExprTyfun k k1 (Null DBType) ('Nullable DBType 'DBInt) > > > *ExprTest> :kind! ExprTyfun ('NotNullable 'DBInt) > ExprTyfun ('NotNullable 'DBInt) :: TyFun > (TyFun k * -> *) (TyFun k1 * -> *) > -> * > = ExprTyfun k k1 (Null DBType) ('NotNullable DBType 'DBInt) > > > *ExprTest> :i ExprTyfun > type family ExprTyfun (k :: BOX) > (j :: BOX) > (colK :: BOX) > (col :: colK) :: > TyFun (TyFun k * -> *) (TyFun j * -> *) -> * > -- Defined at src/Opaleye/TF/ExprTest.hs:39:1 > type instance ExprTyfun > (Null k) (Null k) (Null k1) ('Nullable k1 a) > = NullableTypeSym0 * k > -- Defined at src/Opaleye/TF/ExprTest.hs:41:1 > type instance ExprTyfun k (Null k) (Null k1) ('NotNullable k1 a) > = NotNullableTypeSym0 * k > -- Defined at src/Opaleye/TF/ExprTest.hs:40:1 > > > I'd also like to point out that in my full code the types to Col can be a lot bigger, and I'd like to not assume any ordering. For example, here's a possible type: > > userId :: Col f ('Column "id" ('NotNullable ('HasDefault 'DBInt))) > > In this case Col Expr ('Column "id" ('NotNullable ('HasDefault 'DBInt))) = Expr 'DBInt > > I hope this question is understandable! Please let me know if there's anything I can do to provide more clarity. > > - Ollie > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe -------------- next part -------------- An HTML attachment was scrubbed... URL: From ollie at ocharles.org.uk Thu Mar 17 20:12:09 2016 From: ollie at ocharles.org.uk (Oliver Charles) Date: Thu, 17 Mar 2016 20:12:09 +0000 Subject: [Haskell-cafe] Stuck on a type family problem where kind inference fails In-Reply-To: References: Message-ID: Your term level stuff is exactly what I got to - a need for rank-2 type.. Err, kinds! I was trying to do that within a class but gave up on GHC 7. Great to hear GHC 8 will get me there, is there anything I can look at in the mean time? I don't need singletons entirely, so I'm happy to reimplement small parts. - Ollie On Thu, 17 Mar 2016 7:05 pm Richard Eisenberg, wrote: > Interesting use case! > > You need a higher-rank kind. > > All the typey stuff is getting in the way of understanding. I've > implemented what you want at the term level: > > data Null a = Nullable a | NotNullable a > > notNullableType :: (forall a. a -> Type) -> Null a -> Type > > notNullableType k (NotNullable a) = baseType k a > > nullableType :: (forall a. a -> Type) -> Null a -> Type > > nullableType k (Nullable a) = baseType (k . Nullable) a > > baseType :: (forall a. a -> Type) -> forall b. b -> Type > > baseType k a = k a > > exprTyFun :: Null b -> (forall a. a -> Type) -> Null b -> Type > exprTyFun (NotNullable _) = notNullableType > exprTyFun (Nullable _) = nullableType > > > It's critical that notNullableType and nullableType have the same type, > which is achievable only with higher-rank types. > > Happily, GHC 8.0 comes equipped with higher-rank kinds. `singletons` > doesn't yet build on 8.0, but it will in the future, for a sufficiently > expansive definition of future. Christiaan Baaij is working on this, but > I've been all-consumed by getting GHC 8 out and haven't given Christiaan's > contributions the attention they deserve. So: all in good time! > > I hope this answers your question. > > Richard > > On Mar 17, 2016, at 8:46 AM, Oliver Charles wrote: > > Hi all, > > This is a little tricky to explain, so bear with me. I'm working on some > code that roughly models a PostgreSQL schema. Users begin by defining their > tables as Haskell records, parametrized over some f :: k -> *, and use a > special Col type family that applies some normalisation: > > data Table f = Table { tableId :: Col f ('NotNullable 'DBInt) > , tableX :: Col f ('Nullable 'DBString) } > > is one such example. > > The idea behind Col is that sometimes we don't need information about the > "full type" when we know more about f. > > One such choice of f is Expr, which corresponds to expressions inside a > query. In this case, I would desire > > tableId :: Col Expr ('NotNullable 'DBInt) = tableId :: Expr 'DBInt > tableX :: Col Expr ('Nullable 'DBString) = tableX :: Expr ('Nullable > 'DBString) > > Notice here that if you use 'NotNullable, then this information is erased > - but it's important if the column is 'Nullable. > > However, I'm struggling to work out any way to actually pull this off in > the general case. Here's what I've been attempting: > > {-# LANGUAGE FunctionalDependencies #-} > {-# LANGUAGE FlexibleInstances #-} > {-# LANGUAGE RankNTypes #-} > {-# LANGUAGE MultiParamTypeClasses #-} > {-# LANGUAGE DataKinds #-} > {-# LANGUAGE TypeOperators #-} > {-# LANGUAGE TypeFamilies #-} > {-# LANGUAGE KindSignatures #-} > {-# LANGUAGE PolyKinds #-} > {-# LANGUAGE TemplateHaskell #-} > {-# LANGUAGE GADTs #-} > {-# LANGUAGE UndecidableInstances #-} > {-# LANGUAGE ScopedTypeVariables #-} > > module ExprTest where > > import Data.Singletons > import Data.Singletons.Prelude hiding (Null) > import Data.Singletons.TH > > data Expr (a :: k) > > data MyExprSym :: TyFun k * -> * > type instance Apply MyExprSym (x :: k) = Expr x > > $(singletons [d| > data Null a = Nullable a | NotNullable a > |]) > > $(promote [d| > notNullableType k (NotNullable a) = baseType k a > nullableType k (Nullable a) = baseType (k . Nullable) a > baseType k a = k a > |]) > > So far, this seems to work well. If I ask GHCI: > > *ExprTest> :kind! Apply (Apply NullableTypeSym0 MyExprSym) ('Nullable > 'DBString) > Apply (Apply NullableTypeSym0 MyExprSym) ('Nullable 'DBString) :: * > = Expr ('Nullable 'DBString) > > *ExprTest> :kind! Apply (Apply NotNullableTypeSym0 MyExprSym) > ('NotNullable 'DBInt) > Apply (Apply NotNullableTypeSym0 MyExprSym) ('NotNullable 'DBInt) :: * > = Expr 'DBInt > > This is exactly what I want, but note that I had to choose the necessary > symbols NullableTypeSym0 and NotNullableTypeSym0. I would like to > calculate those symbols from the column type itself. Looking at the kinds > of these symbols though, they are both different: > > *ExprTest> :kind! NotNullableTypeSym0 > NotNullableTypeSym0 :: TyFun > (TyFun k1 k -> *) (TyFun (Null k1) k -> *) > -> * > = NotNullableTypeSym0 > *ExprTest> :kind! NullableTypeSym0 > NullableTypeSym0 :: TyFun > (TyFun (Null k1) k -> *) (TyFun (Null k1) k -> *) > -> * > = NullableTypeSym0 > > So I can't see a way to write a single type family that returns them. > > > To summarise, I'd like a way to write this following instance for Col: > > type instance Col Expr x = Apply (Apply ?? MyExprSym) x > > such that > > Col Expr ('Nullable a) = Expr ('Nullable a') and > Col Expr ('NotNullable a) = Expr a > > but I cannot work out how to write the placeholder ?? above. > > One attempt is > > type family ExprTyfun (col :: colK) :: TyFun (TyFun k * -> *) (TyFun j * > -> *) -> * > type instance ExprTyfun ('NotNullable a) = NotNullableTypeSym0 > type instance ExprTyfun ('Nullable a) = NullableTypeSym0 > > But neither of these instances actually normalise as I'd like, presumably > because of k and j being forall'd in the return type: > > *ExprTest> :set -fprint-explicit-kinds > > > *ExprTest> :kind! ExprTyfun ('Nullable 'DBInt) > ExprTyfun ('Nullable 'DBInt) :: TyFun > (TyFun k * -> *) (TyFun k1 * -> *) > -> * > = ExprTyfun k k1 (Null DBType) ('Nullable DBType 'DBInt) > > > *ExprTest> :kind! ExprTyfun ('NotNullable 'DBInt) > ExprTyfun ('NotNullable 'DBInt) :: TyFun > (TyFun k * -> *) (TyFun k1 * -> *) > -> * > = ExprTyfun k k1 (Null DBType) ('NotNullable DBType 'DBInt) > > > *ExprTest> :i ExprTyfun > type family ExprTyfun (k :: BOX) > (j :: BOX) > (colK :: BOX) > (col :: colK) :: > TyFun (TyFun k * -> *) (TyFun j * -> *) -> * > -- Defined at src/Opaleye/TF/ExprTest.hs:39:1 > type instance ExprTyfun > (Null k) (Null k) (Null k1) ('Nullable k1 a) > = NullableTypeSym0 * k > -- Defined at src/Opaleye/TF/ExprTest.hs:41:1 > type instance ExprTyfun k (Null k) (Null k1) ('NotNullable k1 a) > = NotNullableTypeSym0 * k > -- Defined at src/Opaleye/TF/ExprTest.hs:40:1 > > > I'd also like to point out that in my full code the types to Col can be a > lot bigger, and I'd like to not assume any ordering. For example, here's a > possible type: > > userId :: Col f ('Column "id" ('NotNullable ('HasDefault 'DBInt))) > > In this case Col Expr ('Column "id" ('NotNullable ('HasDefault 'DBInt))) > = Expr 'DBInt > > I hope this question is understandable! Please let me know if there's > anything I can do to provide more clarity. > > - Ollie > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From eir at cis.upenn.edu Thu Mar 17 20:26:30 2016 From: eir at cis.upenn.edu (Richard Eisenberg) Date: Thu, 17 Mar 2016 16:26:30 -0400 Subject: [Haskell-cafe] Stuck on a type family problem where kind inference fails In-Reply-To: References: Message-ID: <45E0231D-8895-42F5-A0C9-97EA2C8395A7@cis.upenn.edu> Bah. I've just tried to mock something up, but GHC 8 doesn't support higher-rank kinds in type families. They work fine in datatypes and classes, but not in type families. I know exactly why this is failing, and I'm pretty sure I know how to fix it, but it's certainly not going to make it for GHC 8 -- there's a significant engineering hurdle before we can allow type family arguments' kinds to be fancy. Sorry to disappoint here. Perhaps there's a way to work around the problem, maybe by burying the higher-rank kind under a newtype or some similar trick. Just to show what I tried: > import Data.Kind > > data TyFun :: * -> * -> * > type a ~> b = TyFun a b -> * > > type family (f :: a ~> b) @@ (x :: a) :: b > > data Null a = Nullable a | NotNullable a > > type family ((f :: b ~> c) ? (g :: a ~> b)) (x :: a) :: c where > (f ? g) x = f @@ (g @@ x) > > type family BaseType (k :: forall a. a ~> Type) (x :: b) :: Type where -- this fails :( > -- BaseType k x = (@@) k x (By the way, Type and * are synonyms in GHC 8. There's no rhyme nor reason for why I used both in this example.) Richard On Mar 17, 2016, at 4:12 PM, Oliver Charles wrote: > Your term level stuff is exactly what I got to - a need for rank-2 type.. Err, kinds! I was trying to do that within a class but gave up on GHC 7. Great to hear GHC 8 will get me there, is there anything I can look at in the mean time? I don't need singletons entirely, so I'm happy to reimplement small parts. > > - Ollie > > > On Thu, 17 Mar 2016 7:05 pm Richard Eisenberg, wrote: > Interesting use case! > > You need a higher-rank kind. > > All the typey stuff is getting in the way of understanding. I've implemented what you want at the term level: > > >> data Null a = Nullable a | NotNullable a >> > >> notNullableType :: (forall a. a -> Type) -> Null a -> Type > >> notNullableType k (NotNullable a) = baseType k a >> > >> nullableType :: (forall a. a -> Type) -> Null a -> Type > >> nullableType k (Nullable a) = baseType (k . Nullable) a >> > >> baseType :: (forall a. a -> Type) -> forall b. b -> Type > >> baseType k a = k a >> > >> exprTyFun :: Null b -> (forall a. a -> Type) -> Null b -> Type >> exprTyFun (NotNullable _) = notNullableType >> exprTyFun (Nullable _) = nullableType > > > It's critical that notNullableType and nullableType have the same type, which is achievable only with higher-rank types. > > Happily, GHC 8.0 comes equipped with higher-rank kinds. `singletons` doesn't yet build on 8.0, but it will in the future, for a sufficiently expansive definition of future. Christiaan Baaij is working on this, but I've been all-consumed by getting GHC 8 out and haven't given Christiaan's contributions the attention they deserve. So: all in good time! > > I hope this answers your question. > > Richard > > On Mar 17, 2016, at 8:46 AM, Oliver Charles wrote: > >> Hi all, >> >> This is a little tricky to explain, so bear with me. I'm working on some code that roughly models a PostgreSQL schema. Users begin by defining their tables as Haskell records, parametrized over some f :: k -> *, and use a special Col type family that applies some normalisation: >> >> data Table f = Table { tableId :: Col f ('NotNullable 'DBInt) >> , tableX :: Col f ('Nullable 'DBString) } >> >> is one such example. >> >> The idea behind Col is that sometimes we don't need information about the "full type" when we know more about f. >> >> One such choice of f is Expr, which corresponds to expressions inside a query. In this case, I would desire >> >> tableId :: Col Expr ('NotNullable 'DBInt) = tableId :: Expr 'DBInt >> tableX :: Col Expr ('Nullable 'DBString) = tableX :: Expr ('Nullable 'DBString) >> >> Notice here that if you use 'NotNullable, then this information is erased - but it's important if the column is 'Nullable. >> >> However, I'm struggling to work out any way to actually pull this off in the general case. Here's what I've been attempting: >> >> {-# LANGUAGE FunctionalDependencies #-} >> {-# LANGUAGE FlexibleInstances #-} >> {-# LANGUAGE RankNTypes #-} >> {-# LANGUAGE MultiParamTypeClasses #-} >> {-# LANGUAGE DataKinds #-} >> {-# LANGUAGE TypeOperators #-} >> {-# LANGUAGE TypeFamilies #-} >> {-# LANGUAGE KindSignatures #-} >> {-# LANGUAGE PolyKinds #-} >> {-# LANGUAGE TemplateHaskell #-} >> {-# LANGUAGE GADTs #-} >> {-# LANGUAGE UndecidableInstances #-} >> {-# LANGUAGE ScopedTypeVariables #-} >> >> module ExprTest where >> >> import Data.Singletons >> import Data.Singletons.Prelude hiding (Null) >> import Data.Singletons.TH >> >> data Expr (a :: k) >> >> data MyExprSym :: TyFun k * -> * >> type instance Apply MyExprSym (x :: k) = Expr x >> >> $(singletons [d| >> data Null a = Nullable a | NotNullable a >> |]) >> >> $(promote [d| >> notNullableType k (NotNullable a) = baseType k a >> nullableType k (Nullable a) = baseType (k . Nullable) a >> baseType k a = k a >> |]) >> >> So far, this seems to work well. If I ask GHCI: >> >> *ExprTest> :kind! Apply (Apply NullableTypeSym0 MyExprSym) ('Nullable 'DBString) >> Apply (Apply NullableTypeSym0 MyExprSym) ('Nullable 'DBString) :: * >> = Expr ('Nullable 'DBString) >> >> *ExprTest> :kind! Apply (Apply NotNullableTypeSym0 MyExprSym) ('NotNullable 'DBInt) >> Apply (Apply NotNullableTypeSym0 MyExprSym) ('NotNullable 'DBInt) :: * >> = Expr 'DBInt >> >> This is exactly what I want, but note that I had to choose the necessary symbols NullableTypeSym0 and NotNullableTypeSym0. I would like to calculate those symbols from the column type itself. Looking at the kinds of these symbols though, they are both different: >> >> *ExprTest> :kind! NotNullableTypeSym0 >> NotNullableTypeSym0 :: TyFun >> (TyFun k1 k -> *) (TyFun (Null k1) k -> *) >> -> * >> = NotNullableTypeSym0 >> *ExprTest> :kind! NullableTypeSym0 >> NullableTypeSym0 :: TyFun >> (TyFun (Null k1) k -> *) (TyFun (Null k1) k -> *) >> -> * >> = NullableTypeSym0 >> >> So I can't see a way to write a single type family that returns them. >> >> >> To summarise, I'd like a way to write this following instance for Col: >> >> type instance Col Expr x = Apply (Apply ?? MyExprSym) x >> >> such that >> >> Col Expr ('Nullable a) = Expr ('Nullable a') and >> Col Expr ('NotNullable a) = Expr a >> >> but I cannot work out how to write the placeholder ?? above. >> >> One attempt is >> >> type family ExprTyfun (col :: colK) :: TyFun (TyFun k * -> *) (TyFun j * -> *) -> * >> type instance ExprTyfun ('NotNullable a) = NotNullableTypeSym0 >> type instance ExprTyfun ('Nullable a) = NullableTypeSym0 >> >> But neither of these instances actually normalise as I'd like, presumably because of k and j being forall'd in the return type: >> >> *ExprTest> :set -fprint-explicit-kinds >> >> >> *ExprTest> :kind! ExprTyfun ('Nullable 'DBInt) >> ExprTyfun ('Nullable 'DBInt) :: TyFun >> (TyFun k * -> *) (TyFun k1 * -> *) >> -> * >> = ExprTyfun k k1 (Null DBType) ('Nullable DBType 'DBInt) >> >> >> *ExprTest> :kind! ExprTyfun ('NotNullable 'DBInt) >> ExprTyfun ('NotNullable 'DBInt) :: TyFun >> (TyFun k * -> *) (TyFun k1 * -> *) >> -> * >> = ExprTyfun k k1 (Null DBType) ('NotNullable DBType 'DBInt) >> >> >> *ExprTest> :i ExprTyfun >> type family ExprTyfun (k :: BOX) >> (j :: BOX) >> (colK :: BOX) >> (col :: colK) :: >> TyFun (TyFun k * -> *) (TyFun j * -> *) -> * >> -- Defined at src/Opaleye/TF/ExprTest.hs:39:1 >> type instance ExprTyfun >> (Null k) (Null k) (Null k1) ('Nullable k1 a) >> = NullableTypeSym0 * k >> -- Defined at src/Opaleye/TF/ExprTest.hs:41:1 >> type instance ExprTyfun k (Null k) (Null k1) ('NotNullable k1 a) >> = NotNullableTypeSym0 * k >> -- Defined at src/Opaleye/TF/ExprTest.hs:40:1 >> >> >> I'd also like to point out that in my full code the types to Col can be a lot bigger, and I'd like to not assume any ordering. For example, here's a possible type: >> >> userId :: Col f ('Column "id" ('NotNullable ('HasDefault 'DBInt))) >> >> In this case Col Expr ('Column "id" ('NotNullable ('HasDefault 'DBInt))) = Expr 'DBInt >> >> I hope this question is understandable! Please let me know if there's anything I can do to provide more clarity. >> >> - Ollie > >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ollie at ocharles.org.uk Thu Mar 17 20:29:36 2016 From: ollie at ocharles.org.uk (Oliver Charles) Date: Thu, 17 Mar 2016 20:29:36 +0000 Subject: [Haskell-cafe] Stuck on a type family problem where kind inference fails In-Reply-To: <45E0231D-8895-42F5-A0C9-97EA2C8395A7@cis.upenn.edu> References: <45E0231D-8895-42F5-A0C9-97EA2C8395A7@cis.upenn.edu> Message-ID: Rats. Shall I open something in Trac? On Thu, 17 Mar 2016 8:26 pm Richard Eisenberg, wrote: > Bah. I've just tried to mock something up, but GHC 8 doesn't support > higher-rank kinds in type families. They work fine in datatypes and > classes, but not in type families. I know exactly why this is failing, and > I'm pretty sure I know how to fix it, but it's certainly not going to make > it for GHC 8 -- there's a significant engineering hurdle before we can > allow type family arguments' kinds to be fancy. > > Sorry to disappoint here. Perhaps there's a way to work around the > problem, maybe by burying the higher-rank kind under a newtype or some > similar trick. > > Just to show what I tried: > > import Data.Kind > > data TyFun :: * -> * -> * > type a ~> b = TyFun a b -> * > > type family (f :: a ~> b) @@ (x :: a) :: b > > > data Null a = Nullable a | NotNullable a > > type family ((f :: b ~> c) ? (g :: a ~> b)) (x :: a) :: c where > (f ? g) x = f @@ (g @@ x) > > type family BaseType (k :: forall a. a ~> Type) (x :: b) :: Type where > -- this fails :( > -- BaseType k x = (@@) k x > > > (By the way, Type and * are synonyms in GHC 8. There's no rhyme nor reason > for why I used both in this example.) > > Richard > > On Mar 17, 2016, at 4:12 PM, Oliver Charles wrote: > > Your term level stuff is exactly what I got to - a need for rank-2 type.. > Err, kinds! I was trying to do that within a class but gave up on GHC 7. > Great to hear GHC 8 will get me there, is there anything I can look at in > the mean time? I don't need singletons entirely, so I'm happy to > reimplement small parts. > > - Ollie > > On Thu, 17 Mar 2016 7:05 pm Richard Eisenberg, wrote: > >> Interesting use case! >> >> You need a higher-rank kind. >> >> All the typey stuff is getting in the way of understanding. I've >> implemented what you want at the term level: >> >> data Null a = Nullable a | NotNullable a >> >> notNullableType :: (forall a. a -> Type) -> Null a -> Type >> >> notNullableType k (NotNullable a) = baseType k a >> >> nullableType :: (forall a. a -> Type) -> Null a -> Type >> >> nullableType k (Nullable a) = baseType (k . Nullable) a >> >> baseType :: (forall a. a -> Type) -> forall b. b -> Type >> >> baseType k a = k a >> >> exprTyFun :: Null b -> (forall a. a -> Type) -> Null b -> Type >> exprTyFun (NotNullable _) = notNullableType >> exprTyFun (Nullable _) = nullableType >> >> >> It's critical that notNullableType and nullableType have the same type, >> which is achievable only with higher-rank types. >> >> Happily, GHC 8.0 comes equipped with higher-rank kinds. `singletons` >> doesn't yet build on 8.0, but it will in the future, for a sufficiently >> expansive definition of future. Christiaan Baaij is working on this, but >> I've been all-consumed by getting GHC 8 out and haven't given Christiaan's >> contributions the attention they deserve. So: all in good time! >> >> I hope this answers your question. >> >> Richard >> >> On Mar 17, 2016, at 8:46 AM, Oliver Charles >> wrote: >> >> Hi all, >> >> This is a little tricky to explain, so bear with me. I'm working on some >> code that roughly models a PostgreSQL schema. Users begin by defining their >> tables as Haskell records, parametrized over some f :: k -> *, and use a >> special Col type family that applies some normalisation: >> >> data Table f = Table { tableId :: Col f ('NotNullable 'DBInt) >> , tableX :: Col f ('Nullable 'DBString) } >> >> is one such example. >> >> The idea behind Col is that sometimes we don't need information about >> the "full type" when we know more about f. >> >> One such choice of f is Expr, which corresponds to expressions inside a >> query. In this case, I would desire >> >> tableId :: Col Expr ('NotNullable 'DBInt) = tableId :: Expr 'DBInt >> tableX :: Col Expr ('Nullable 'DBString) = tableX :: Expr ('Nullable >> 'DBString) >> >> Notice here that if you use 'NotNullable, then this information is >> erased - but it's important if the column is 'Nullable. >> >> However, I'm struggling to work out any way to actually pull this off in >> the general case. Here's what I've been attempting: >> >> {-# LANGUAGE FunctionalDependencies #-} >> {-# LANGUAGE FlexibleInstances #-} >> {-# LANGUAGE RankNTypes #-} >> {-# LANGUAGE MultiParamTypeClasses #-} >> {-# LANGUAGE DataKinds #-} >> {-# LANGUAGE TypeOperators #-} >> {-# LANGUAGE TypeFamilies #-} >> {-# LANGUAGE KindSignatures #-} >> {-# LANGUAGE PolyKinds #-} >> {-# LANGUAGE TemplateHaskell #-} >> {-# LANGUAGE GADTs #-} >> {-# LANGUAGE UndecidableInstances #-} >> {-# LANGUAGE ScopedTypeVariables #-} >> >> module ExprTest where >> >> import Data.Singletons >> import Data.Singletons.Prelude hiding (Null) >> import Data.Singletons.TH >> >> data Expr (a :: k) >> >> data MyExprSym :: TyFun k * -> * >> type instance Apply MyExprSym (x :: k) = Expr x >> >> $(singletons [d| >> data Null a = Nullable a | NotNullable a >> |]) >> >> $(promote [d| >> notNullableType k (NotNullable a) = baseType k a >> nullableType k (Nullable a) = baseType (k . Nullable) a >> baseType k a = k a >> |]) >> >> So far, this seems to work well. If I ask GHCI: >> >> *ExprTest> :kind! Apply (Apply NullableTypeSym0 MyExprSym) ('Nullable >> 'DBString) >> Apply (Apply NullableTypeSym0 MyExprSym) ('Nullable 'DBString) :: * >> = Expr ('Nullable 'DBString) >> >> *ExprTest> :kind! Apply (Apply NotNullableTypeSym0 MyExprSym) >> ('NotNullable 'DBInt) >> Apply (Apply NotNullableTypeSym0 MyExprSym) ('NotNullable 'DBInt) :: * >> = Expr 'DBInt >> >> This is exactly what I want, but note that I had to choose the necessary >> symbols NullableTypeSym0 and NotNullableTypeSym0. I would like to >> calculate those symbols from the column type itself. Looking at the kinds >> of these symbols though, they are both different: >> >> *ExprTest> :kind! NotNullableTypeSym0 >> NotNullableTypeSym0 :: TyFun >> (TyFun k1 k -> *) (TyFun (Null k1) k -> *) >> -> * >> = NotNullableTypeSym0 >> *ExprTest> :kind! NullableTypeSym0 >> NullableTypeSym0 :: TyFun >> (TyFun (Null k1) k -> *) (TyFun (Null k1) k -> *) >> -> * >> = NullableTypeSym0 >> >> So I can't see a way to write a single type family that returns them. >> >> >> To summarise, I'd like a way to write this following instance for Col: >> >> type instance Col Expr x = Apply (Apply ?? MyExprSym) x >> >> such that >> >> Col Expr ('Nullable a) = Expr ('Nullable a') and >> Col Expr ('NotNullable a) = Expr a >> >> but I cannot work out how to write the placeholder ?? above. >> >> One attempt is >> >> type family ExprTyfun (col :: colK) :: TyFun (TyFun k * -> *) (TyFun j * >> -> *) -> * >> type instance ExprTyfun ('NotNullable a) = NotNullableTypeSym0 >> type instance ExprTyfun ('Nullable a) = NullableTypeSym0 >> >> But neither of these instances actually normalise as I'd like, presumably >> because of k and j being forall'd in the return type: >> >> *ExprTest> :set -fprint-explicit-kinds >> >> >> *ExprTest> :kind! ExprTyfun ('Nullable 'DBInt) >> ExprTyfun ('Nullable 'DBInt) :: TyFun >> (TyFun k * -> *) (TyFun k1 * -> *) >> -> * >> = ExprTyfun k k1 (Null DBType) ('Nullable DBType 'DBInt) >> >> >> *ExprTest> :kind! ExprTyfun ('NotNullable 'DBInt) >> ExprTyfun ('NotNullable 'DBInt) :: TyFun >> (TyFun k * -> *) (TyFun k1 * -> *) >> -> * >> = ExprTyfun k k1 (Null DBType) ('NotNullable DBType 'DBInt) >> >> >> *ExprTest> :i ExprTyfun >> type family ExprTyfun (k :: BOX) >> (j :: BOX) >> (colK :: BOX) >> (col :: colK) :: >> TyFun (TyFun k * -> *) (TyFun j * -> *) -> * >> -- Defined at src/Opaleye/TF/ExprTest.hs:39:1 >> type instance ExprTyfun >> (Null k) (Null k) (Null k1) ('Nullable k1 a) >> = NullableTypeSym0 * k >> -- Defined at src/Opaleye/TF/ExprTest.hs:41:1 >> type instance ExprTyfun k (Null k) (Null k1) ('NotNullable k1 a) >> = NotNullableTypeSym0 * k >> -- Defined at src/Opaleye/TF/ExprTest.hs:40:1 >> >> >> I'd also like to point out that in my full code the types to Col can be >> a lot bigger, and I'd like to not assume any ordering. For example, here's >> a possible type: >> >> userId :: Col f ('Column "id" ('NotNullable ('HasDefault 'DBInt))) >> >> In this case Col Expr ('Column "id" ('NotNullable ('HasDefault 'DBInt))) >> = Expr 'DBInt >> >> I hope this question is understandable! Please let me know if there's >> anything I can do to provide more clarity. >> >> - Ollie >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe >> >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From nicu.ionita at acons.at Thu Mar 17 21:19:29 2016 From: nicu.ionita at acons.at (Nicu Ionita) Date: Thu, 17 Mar 2016 22:19:29 +0100 Subject: [Haskell-cafe] Trying desperately to make a c library binding on Windows Message-ID: <56EB1F61.3090103@acons.at> Hi all, I am really stuck with my try to make a Haskell binding for the library bayesopt on Windows. In theory it looks all simple, just put some lines in the cabal configuration file: ... extra-lib-dirs: /path/to/the/lib -- contains the file libbayesopt.a extra-libraries: bayesopt ... But whatever I tried, I can't step over the configuration phase, coz I get (I'm compiling with stack): Configuring BaseOh-0.1.0.0... setup-Simple-Cabal-1.22.5.0-x86_64-windows-ghc-7.10.3.exe: Missing dependency on a foreign library: * Missing C library: /j/BO/lib/libbayesopt.a This problem can usually be solved by installing the system package that provides this library (you may need the "-dev" version). If the library is already installed but in a non-standard location then you can use the flags --extra-include-dirs= and --extra-lib-dirs= to specify where it is. If I comment those lines out, then the configure phase succeeds, the library is compiled (i.e. my binding library), but a test executable in the same project does of course not compile, as symbols are missing: ... In-place registering BaseOh-0.1.0.0... Preprocessing executable 'test' for BaseOh-0.1.0.0... [1 of 2] Compiling Optimisation.Stochastic.BayesOpt ( src\Optimisation\Stochasti c\BayesOpt.hs, .stack-work\dist\x86_64-windows\Cabal-1.22.5.0\build\test\test-tm p\Optimisation\Stochastic\BayesOpt.o ) ghc.exe: unable to load package `BaseOh-0.1.0.0' ghc.exe: J:\Projects\BaseOh\.stack-work\dist\x86_64-windows\Cabal-1.22.5.0\build \HSBaseOh-0.1.0.0-GdNObdePATgDIW1I2OVwEc.o: unknown symbol `initialize_parameter s_to_default' -- While building package BaseOh-0.1.0.0 using: ... Does somebody have some idea, what is going on? I am on Win 7, using stack (configured for lts-4.2) under MinGW. (I'm using inline-c to make the bindings, and the same trick for include - include-dirs: ... - worked fine.) Thanks, and sorry for the longer email. Nicu From nicu.ionita at acons.at Thu Mar 17 22:50:53 2016 From: nicu.ionita at acons.at (Nicu Ionita) Date: Thu, 17 Mar 2016 23:50:53 +0100 Subject: [Haskell-cafe] Trying desperately to make a c library binding on Windows In-Reply-To: References: <56EB1F61.3090103@acons.at> Message-ID: <56EB34CD.3020900@acons.at> Am 17.03.2016 um 23:24 schrieb Theodore Lief Gannon: > > I am on Win 7, using stack (configured for lts-4.2) under MinGW. > > Stack itself provides MSYS2/MinGW during builds on Windows. Do you > mean you have an independent MinGW shell that you're opening, and then > running stack from there? Yes, I work under the git bash (git for Windows comes with an own msys). > If so, assuming you're not already using this flag, try: > > stack build --skip-msys Just tried that now, same result. > > This tells stack that it's already running inside a unix-style shell, > and shouldn't assert its related path overrides. > > Beyond that, it would help to have more information about exactly > where everything is and how it's being built/invoked/etc. Project is under: J:\Projects\BaseOh Library is under: J:\BO\lib and is called: libbayesopt.a (under bash they are called /j/Projects/BaseOh and /j/BO/lib, needless to say I tried those too, but they are not found, as the programs know only Windows style paths). So beeing under the git bash in the project directory, I type: > stack build or even: > stack build --extra-lib-dirs=j:\\BO\\lib But in both cases, if the line "extra-libraries: bayesopt" is present in the cabal file, then configure does not work (message below). Inbetween I upgraded stack (now is version 1.0.4.2 x86_64). When I try to build, I get the message: Continuing despite missing tool: msys2 after which the build continues and brings exactly the same failures. > > On Thu, Mar 17, 2016 at 2:19 PM, Nicu Ionita > wrote: > > Hi all, > > I am really stuck with my try to make a Haskell binding for the > library bayesopt on Windows. > In theory it looks all simple, just put some lines in the cabal > configuration file: > > ... > extra-lib-dirs: /path/to/the/lib -- contains the file > libbayesopt.a > extra-libraries: bayesopt > ... > > But whatever I tried, I can't step over the configuration phase, > coz I get (I'm compiling with stack): > > Configuring BaseOh-0.1.0.0... > setup-Simple-Cabal-1.22.5.0-x86_64-windows-ghc-7.10.3.exe: Missing > dependency > on a foreign library: > * Missing C library: /j/BO/lib/libbayesopt.a > This problem can usually be solved by installing the system > package that > provides this library (you may need the "-dev" version). If the > library is > already installed but in a non-standard location then you can use > the flags > --extra-include-dirs= and --extra-lib-dirs= to specify where it is. > > If I comment those lines out, then the configure phase succeeds, > the library is compiled (i.e. my binding library), but a test > executable in the same project does of course not compile, as > symbols are missing: > > ... > In-place registering BaseOh-0.1.0.0... > Preprocessing executable 'test' for BaseOh-0.1.0.0... > [1 of 2] Compiling Optimisation.Stochastic.BayesOpt ( > src\Optimisation\Stochasti > c\BayesOpt.hs, > .stack-work\dist\x86_64-windows\Cabal-1.22.5.0\build\test\test-tm > p\Optimisation\Stochastic\BayesOpt.o ) > ghc.exe: unable to load package `BaseOh-0.1.0.0' > ghc.exe: > J:\Projects\BaseOh\.stack-work\dist\x86_64-windows\Cabal-1.22.5.0\build > \HSBaseOh-0.1.0.0-GdNObdePATgDIW1I2OVwEc.o: unknown symbol > `initialize_parameter > s_to_default' > > -- While building package BaseOh-0.1.0.0 using: > ... > > Does somebody have some idea, what is going on? > > I am on Win 7, using stack (configured for lts-4.2) under MinGW. > (I'm using inline-c to make the bindings, and the same trick for > include - include-dirs: ... - worked fine.) > > Thanks, and sorry for the longer email. > Nicu > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > > From nicu.ionita at acons.at Thu Mar 17 23:05:31 2016 From: nicu.ionita at acons.at (Nicu Ionita) Date: Fri, 18 Mar 2016 00:05:31 +0100 Subject: [Haskell-cafe] Trying desperately to make a c library binding on Windows In-Reply-To: <56EB34CD.3020900@acons.at> References: <56EB1F61.3090103@acons.at> <56EB34CD.3020900@acons.at> Message-ID: <56EB383B.4080003@acons.at> What I don't understand is why the stack message sounds: If the library is already installed but in a non-standard location then you can use the flags --extra-include-dirs= and --extra-lib-dirs= to specify where it is. Why would be an include directory necessary, if I only miss the library? I understand that the includes are needed to compile the (generated) C sources, but why needed to link? Or is maybe just a typo in the stack message? Nicu Am 17.03.2016 um 23:50 schrieb Nicu Ionita: > Am 17.03.2016 um 23:24 schrieb Theodore Lief Gannon: >> > I am on Win 7, using stack (configured for lts-4.2) under MinGW. >> >> Stack itself provides MSYS2/MinGW during builds on Windows. Do you >> mean you have an independent MinGW shell that you're opening, and >> then running stack from there? > > Yes, I work under the git bash (git for Windows comes with an own msys). > >> If so, assuming you're not already using this flag, try: >> >> stack build --skip-msys > > Just tried that now, same result. >> >> This tells stack that it's already running inside a unix-style shell, >> and shouldn't assert its related path overrides. >> >> Beyond that, it would help to have more information about exactly >> where everything is and how it's being built/invoked/etc. > > Project is under: > J:\Projects\BaseOh > > Library is under: > J:\BO\lib > > and is called: libbayesopt.a > > (under bash they are called /j/Projects/BaseOh and /j/BO/lib, needless > to say I tried those too, but they are not found, as the programs know > only Windows style paths). > > So beeing under the git bash in the project directory, I type: > > stack build > > or even: > > stack build --extra-lib-dirs=j:\\BO\\lib > > But in both cases, if the line "extra-libraries: bayesopt" is present > in the cabal file, then configure does not work (message below). > > Inbetween I upgraded stack (now is version 1.0.4.2 x86_64). When I try > to build, I get the message: > > Continuing despite missing tool: msys2 > > after which the build continues and brings exactly the same failures. > >> >> On Thu, Mar 17, 2016 at 2:19 PM, Nicu Ionita > > wrote: >> >> Hi all, >> >> I am really stuck with my try to make a Haskell binding for the >> library bayesopt on Windows. >> In theory it looks all simple, just put some lines in the cabal >> configuration file: >> >> ... >> extra-lib-dirs: /path/to/the/lib -- contains the file >> libbayesopt.a >> extra-libraries: bayesopt >> ... >> >> But whatever I tried, I can't step over the configuration phase, >> coz I get (I'm compiling with stack): >> >> Configuring BaseOh-0.1.0.0... >> setup-Simple-Cabal-1.22.5.0-x86_64-windows-ghc-7.10.3.exe: Missing >> dependency >> on a foreign library: >> * Missing C library: /j/BO/lib/libbayesopt.a >> This problem can usually be solved by installing the system >> package that >> provides this library (you may need the "-dev" version). If the >> library is >> already installed but in a non-standard location then you can use >> the flags >> --extra-include-dirs= and --extra-lib-dirs= to specify where it is. >> >> If I comment those lines out, then the configure phase succeeds, >> the library is compiled (i.e. my binding library), but a test >> executable in the same project does of course not compile, as >> symbols are missing: >> >> ... >> In-place registering BaseOh-0.1.0.0... >> Preprocessing executable 'test' for BaseOh-0.1.0.0... >> [1 of 2] Compiling Optimisation.Stochastic.BayesOpt ( >> src\Optimisation\Stochasti >> c\BayesOpt.hs, >> .stack-work\dist\x86_64-windows\Cabal-1.22.5.0\build\test\test-tm >> p\Optimisation\Stochastic\BayesOpt.o ) >> ghc.exe: unable to load package `BaseOh-0.1.0.0' >> ghc.exe: >> J:\Projects\BaseOh\.stack-work\dist\x86_64-windows\Cabal-1.22.5.0\build >> \HSBaseOh-0.1.0.0-GdNObdePATgDIW1I2OVwEc.o: unknown symbol >> `initialize_parameter >> s_to_default' >> >> -- While building package BaseOh-0.1.0.0 using: >> ... >> >> Does somebody have some idea, what is going on? >> >> I am on Win 7, using stack (configured for lts-4.2) under MinGW. >> (I'm using inline-c to make the bindings, and the same trick for >> include - include-dirs: ... - worked fine.) >> >> Thanks, and sorry for the longer email. >> Nicu >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe >> >> > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe From ok at cs.otago.ac.nz Thu Mar 17 23:17:04 2016 From: ok at cs.otago.ac.nz (Richard A. O'Keefe) Date: Fri, 18 Mar 2016 12:17:04 +1300 Subject: [Haskell-cafe] Odd list comprehension behaviour In-Reply-To: References: <20160317032634.GA1494@casa.casa> Message-ID: <9e45922f-23ed-a3e6-e2bc-6d35aca913bb@cs.otago.ac.nz> On 17/03/16 7:25 pm, Manuel G?mez wrote: > Perhaps I should instead have said ?ends at c at the furthest?. > > The intuition I refer to is that c is a possibly included bound for > the list [a,b..c], so that the list [a,b..c] certainly shall not have > any element beyond c, but if it does actually get to c, that?s where > it ends. That's closer to other languages, but the bit "if it does actually get to c, that's where it ends" is smuggled in from somewhere. For cases where a and b are different, you don't *need* that bit; it's easier to understand without the extra cruft. For cases where a and b are equal, it's magic, come from nowhere, just to bodge in a finite answer for one special case. Let me rephrase that. To me, that "if it does actually get to c" bit is NOT a consequence of my understanding of the general rules for enumeration in Haskell, they are a complicating ADDITION to those rules just for a case that I would be very upset to see happening in code of mine. I mean, this is an *extremely* special case. [1.0,1.0..x] :: [Double is an infinite list for ALL x >= 1.0 in Haskell; you want to change this to be [1.0] if x happens to be the very special case 1.0, and I do not understand why. Why is [1.0,1.0..1.0+epsilon] being infinite, [1.0,1.0,..1.0-epsilon] being empty, but [1.0,1.0..1.0] having one element USEFUL? (And while you are at it, explain your reasoning for [x,x..negate x] when x is 0.0.) > [6,6..6] would have the initial 6, and then it should have no other > element beyond 6, so it should in fact equal [6] under this intuition. But [6,6,6,6,6,6,6,6,6,6,6....] ALSO has no other element beyond 6. "Not going beyond 6" is one thing, "stopping exactly at 6" is another. From ollie at ocharles.org.uk Fri Mar 18 00:40:49 2016 From: ollie at ocharles.org.uk (Oliver Charles) Date: Fri, 18 Mar 2016 00:40:49 +0000 Subject: [Haskell-cafe] Stuck on a type family problem where kind inference fails In-Reply-To: References: <45E0231D-8895-42F5-A0C9-97EA2C8395A7@cis.upenn.edu> Message-ID: I have just found https://ghc.haskell.org/trac/ghc/ticket/11635 - is that perhaps the same thing? On Thu, Mar 17, 2016 at 8:29 PM Oliver Charles wrote: > Rats. Shall I open something in Trac? > > On Thu, 17 Mar 2016 8:26 pm Richard Eisenberg, wrote: > >> Bah. I've just tried to mock something up, but GHC 8 doesn't support >> higher-rank kinds in type families. They work fine in datatypes and >> classes, but not in type families. I know exactly why this is failing, and >> I'm pretty sure I know how to fix it, but it's certainly not going to make >> it for GHC 8 -- there's a significant engineering hurdle before we can >> allow type family arguments' kinds to be fancy. >> >> Sorry to disappoint here. Perhaps there's a way to work around the >> problem, maybe by burying the higher-rank kind under a newtype or some >> similar trick. >> >> Just to show what I tried: >> >> import Data.Kind >> >> data TyFun :: * -> * -> * >> type a ~> b = TyFun a b -> * >> >> type family (f :: a ~> b) @@ (x :: a) :: b >> >> >> data Null a = Nullable a | NotNullable a >> >> type family ((f :: b ~> c) ? (g :: a ~> b)) (x :: a) :: c where >> (f ? g) x = f @@ (g @@ x) >> >> type family BaseType (k :: forall a. a ~> Type) (x :: b) :: Type where >> -- this fails :( >> -- BaseType k x = (@@) k x >> >> >> (By the way, Type and * are synonyms in GHC 8. There's no rhyme nor >> reason for why I used both in this example.) >> >> Richard >> >> On Mar 17, 2016, at 4:12 PM, Oliver Charles >> wrote: >> >> Your term level stuff is exactly what I got to - a need for rank-2 type.. >> Err, kinds! I was trying to do that within a class but gave up on GHC 7. >> Great to hear GHC 8 will get me there, is there anything I can look at in >> the mean time? I don't need singletons entirely, so I'm happy to >> reimplement small parts. >> >> - Ollie >> >> On Thu, 17 Mar 2016 7:05 pm Richard Eisenberg, wrote: >> >>> Interesting use case! >>> >>> You need a higher-rank kind. >>> >>> All the typey stuff is getting in the way of understanding. I've >>> implemented what you want at the term level: >>> >>> data Null a = Nullable a | NotNullable a >>> >>> notNullableType :: (forall a. a -> Type) -> Null a -> Type >>> >>> notNullableType k (NotNullable a) = baseType k a >>> >>> nullableType :: (forall a. a -> Type) -> Null a -> Type >>> >>> nullableType k (Nullable a) = baseType (k . Nullable) a >>> >>> baseType :: (forall a. a -> Type) -> forall b. b -> Type >>> >>> baseType k a = k a >>> >>> exprTyFun :: Null b -> (forall a. a -> Type) -> Null b -> Type >>> exprTyFun (NotNullable _) = notNullableType >>> exprTyFun (Nullable _) = nullableType >>> >>> >>> It's critical that notNullableType and nullableType have the same type, >>> which is achievable only with higher-rank types. >>> >>> Happily, GHC 8.0 comes equipped with higher-rank kinds. `singletons` >>> doesn't yet build on 8.0, but it will in the future, for a sufficiently >>> expansive definition of future. Christiaan Baaij is working on this, but >>> I've been all-consumed by getting GHC 8 out and haven't given Christiaan's >>> contributions the attention they deserve. So: all in good time! >>> >>> I hope this answers your question. >>> >>> Richard >>> >>> On Mar 17, 2016, at 8:46 AM, Oliver Charles >>> wrote: >>> >>> Hi all, >>> >>> This is a little tricky to explain, so bear with me. I'm working on some >>> code that roughly models a PostgreSQL schema. Users begin by defining their >>> tables as Haskell records, parametrized over some f :: k -> *, and use >>> a special Col type family that applies some normalisation: >>> >>> data Table f = Table { tableId :: Col f ('NotNullable 'DBInt) >>> , tableX :: Col f ('Nullable 'DBString) } >>> >>> is one such example. >>> >>> The idea behind Col is that sometimes we don't need information about >>> the "full type" when we know more about f. >>> >>> One such choice of f is Expr, which corresponds to expressions inside a >>> query. In this case, I would desire >>> >>> tableId :: Col Expr ('NotNullable 'DBInt) = tableId :: Expr 'DBInt >>> tableX :: Col Expr ('Nullable 'DBString) = tableX :: Expr ('Nullable >>> 'DBString) >>> >>> Notice here that if you use 'NotNullable, then this information is >>> erased - but it's important if the column is 'Nullable. >>> >>> However, I'm struggling to work out any way to actually pull this off in >>> the general case. Here's what I've been attempting: >>> >>> {-# LANGUAGE FunctionalDependencies #-} >>> {-# LANGUAGE FlexibleInstances #-} >>> {-# LANGUAGE RankNTypes #-} >>> {-# LANGUAGE MultiParamTypeClasses #-} >>> {-# LANGUAGE DataKinds #-} >>> {-# LANGUAGE TypeOperators #-} >>> {-# LANGUAGE TypeFamilies #-} >>> {-# LANGUAGE KindSignatures #-} >>> {-# LANGUAGE PolyKinds #-} >>> {-# LANGUAGE TemplateHaskell #-} >>> {-# LANGUAGE GADTs #-} >>> {-# LANGUAGE UndecidableInstances #-} >>> {-# LANGUAGE ScopedTypeVariables #-} >>> >>> module ExprTest where >>> >>> import Data.Singletons >>> import Data.Singletons.Prelude hiding (Null) >>> import Data.Singletons.TH >>> >>> data Expr (a :: k) >>> >>> data MyExprSym :: TyFun k * -> * >>> type instance Apply MyExprSym (x :: k) = Expr x >>> >>> $(singletons [d| >>> data Null a = Nullable a | NotNullable a >>> |]) >>> >>> $(promote [d| >>> notNullableType k (NotNullable a) = baseType k a >>> nullableType k (Nullable a) = baseType (k . Nullable) a >>> baseType k a = k a >>> |]) >>> >>> So far, this seems to work well. If I ask GHCI: >>> >>> *ExprTest> :kind! Apply (Apply NullableTypeSym0 MyExprSym) ('Nullable >>> 'DBString) >>> Apply (Apply NullableTypeSym0 MyExprSym) ('Nullable 'DBString) :: * >>> = Expr ('Nullable 'DBString) >>> >>> *ExprTest> :kind! Apply (Apply NotNullableTypeSym0 MyExprSym) >>> ('NotNullable 'DBInt) >>> Apply (Apply NotNullableTypeSym0 MyExprSym) ('NotNullable 'DBInt) :: * >>> = Expr 'DBInt >>> >>> This is exactly what I want, but note that I had to choose the necessary >>> symbols NullableTypeSym0 and NotNullableTypeSym0. I would like to >>> calculate those symbols from the column type itself. Looking at the kinds >>> of these symbols though, they are both different: >>> >>> *ExprTest> :kind! NotNullableTypeSym0 >>> NotNullableTypeSym0 :: TyFun >>> (TyFun k1 k -> *) (TyFun (Null k1) k -> *) >>> -> * >>> = NotNullableTypeSym0 >>> *ExprTest> :kind! NullableTypeSym0 >>> NullableTypeSym0 :: TyFun >>> (TyFun (Null k1) k -> *) (TyFun (Null k1) k -> *) >>> -> * >>> = NullableTypeSym0 >>> >>> So I can't see a way to write a single type family that returns them. >>> >>> >>> To summarise, I'd like a way to write this following instance for Col: >>> >>> type instance Col Expr x = Apply (Apply ?? MyExprSym) x >>> >>> such that >>> >>> Col Expr ('Nullable a) = Expr ('Nullable a') and >>> Col Expr ('NotNullable a) = Expr a >>> >>> but I cannot work out how to write the placeholder ?? above. >>> >>> One attempt is >>> >>> type family ExprTyfun (col :: colK) :: TyFun (TyFun k * -> *) (TyFun j * >>> -> *) -> * >>> type instance ExprTyfun ('NotNullable a) = NotNullableTypeSym0 >>> type instance ExprTyfun ('Nullable a) = NullableTypeSym0 >>> >>> But neither of these instances actually normalise as I'd like, >>> presumably because of k and j being forall'd in the return type: >>> >>> *ExprTest> :set -fprint-explicit-kinds >>> >>> >>> *ExprTest> :kind! ExprTyfun ('Nullable 'DBInt) >>> ExprTyfun ('Nullable 'DBInt) :: TyFun >>> (TyFun k * -> *) (TyFun k1 * -> *) >>> -> * >>> = ExprTyfun k k1 (Null DBType) ('Nullable DBType 'DBInt) >>> >>> >>> *ExprTest> :kind! ExprTyfun ('NotNullable 'DBInt) >>> ExprTyfun ('NotNullable 'DBInt) :: TyFun >>> (TyFun k * -> *) (TyFun k1 * -> *) >>> -> * >>> = ExprTyfun k k1 (Null DBType) ('NotNullable DBType 'DBInt) >>> >>> >>> *ExprTest> :i ExprTyfun >>> type family ExprTyfun (k :: BOX) >>> (j :: BOX) >>> (colK :: BOX) >>> (col :: colK) :: >>> TyFun (TyFun k * -> *) (TyFun j * -> *) -> * >>> -- Defined at src/Opaleye/TF/ExprTest.hs:39:1 >>> type instance ExprTyfun >>> (Null k) (Null k) (Null k1) ('Nullable k1 a) >>> = NullableTypeSym0 * k >>> -- Defined at src/Opaleye/TF/ExprTest.hs:41:1 >>> type instance ExprTyfun k (Null k) (Null k1) ('NotNullable k1 a) >>> = NotNullableTypeSym0 * k >>> -- Defined at src/Opaleye/TF/ExprTest.hs:40:1 >>> >>> >>> I'd also like to point out that in my full code the types to Col can be >>> a lot bigger, and I'd like to not assume any ordering. For example, here's >>> a possible type: >>> >>> userId :: Col f ('Column "id" ('NotNullable ('HasDefault 'DBInt))) >>> >>> In this case Col Expr ('Column "id" ('NotNullable ('HasDefault >>> 'DBInt))) = Expr 'DBInt >>> >>> I hope this question is understandable! Please let me know if there's >>> anything I can do to provide more clarity. >>> >>> - Ollie >>> >>> _______________________________________________ >>> Haskell-Cafe mailing list >>> Haskell-Cafe at haskell.org >>> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe >>> >>> >>> >> -------------- next part -------------- An HTML attachment was scrubbed... URL: From eir at cis.upenn.edu Thu Mar 17 21:42:20 2016 From: eir at cis.upenn.edu (Richard Eisenberg) Date: Thu, 17 Mar 2016 17:42:20 -0400 Subject: [Haskell-cafe] Stuck on a type family problem where kind inference fails In-Reply-To: References: <45E0231D-8895-42F5-A0C9-97EA2C8395A7@cis.upenn.edu> Message-ID: Yes, please do, with your use case. These examples are very helpful! Thanks, Richard On Mar 17, 2016, at 4:29 PM, Oliver Charles wrote: > Rats. Shall I open something in Trac? > > > On Thu, 17 Mar 2016 8:26 pm Richard Eisenberg, wrote: > Bah. I've just tried to mock something up, but GHC 8 doesn't support higher-rank kinds in type families. They work fine in datatypes and classes, but not in type families. I know exactly why this is failing, and I'm pretty sure I know how to fix it, but it's certainly not going to make it for GHC 8 -- there's a significant engineering hurdle before we can allow type family arguments' kinds to be fancy. > > Sorry to disappoint here. Perhaps there's a way to work around the problem, maybe by burying the higher-rank kind under a newtype or some similar trick. > > Just to show what I tried: > >> import Data.Kind >> >> data TyFun :: * -> * -> * >> type a ~> b = TyFun a b -> * >> >> type family (f :: a ~> b) @@ (x :: a) :: b > >> >> data Null a = Nullable a | NotNullable a >> > >> type family ((f :: b ~> c) ? (g :: a ~> b)) (x :: a) :: c where >> (f ? g) x = f @@ (g @@ x) >> >> type family BaseType (k :: forall a. a ~> Type) (x :: b) :: Type where -- this fails :( >> -- BaseType k x = (@@) k x > > (By the way, Type and * are synonyms in GHC 8. There's no rhyme nor reason for why I used both in this example.) > > Richard > > On Mar 17, 2016, at 4:12 PM, Oliver Charles wrote: > >> Your term level stuff is exactly what I got to - a need for rank-2 type.. Err, kinds! I was trying to do that within a class but gave up on GHC 7. Great to hear GHC 8 will get me there, is there anything I can look at in the mean time? I don't need singletons entirely, so I'm happy to reimplement small parts. >> >> - Ollie >> >> >> On Thu, 17 Mar 2016 7:05 pm Richard Eisenberg, wrote: >> Interesting use case! >> >> You need a higher-rank kind. >> >> All the typey stuff is getting in the way of understanding. I've implemented what you want at the term level: >> >> >>> data Null a = Nullable a | NotNullable a >>> >> >>> notNullableType :: (forall a. a -> Type) -> Null a -> Type >> >>> notNullableType k (NotNullable a) = baseType k a >>> >> >>> nullableType :: (forall a. a -> Type) -> Null a -> Type >> >>> nullableType k (Nullable a) = baseType (k . Nullable) a >>> >> >>> baseType :: (forall a. a -> Type) -> forall b. b -> Type >> >>> baseType k a = k a >>> >> >>> exprTyFun :: Null b -> (forall a. a -> Type) -> Null b -> Type >>> exprTyFun (NotNullable _) = notNullableType >>> exprTyFun (Nullable _) = nullableType >> >> >> It's critical that notNullableType and nullableType have the same type, which is achievable only with higher-rank types. >> >> Happily, GHC 8.0 comes equipped with higher-rank kinds. `singletons` doesn't yet build on 8.0, but it will in the future, for a sufficiently expansive definition of future. Christiaan Baaij is working on this, but I've been all-consumed by getting GHC 8 out and haven't given Christiaan's contributions the attention they deserve. So: all in good time! >> >> I hope this answers your question. >> >> Richard >> >> On Mar 17, 2016, at 8:46 AM, Oliver Charles wrote: >> >>> Hi all, >>> >>> This is a little tricky to explain, so bear with me. I'm working on some code that roughly models a PostgreSQL schema. Users begin by defining their tables as Haskell records, parametrized over some f :: k -> *, and use a special Col type family that applies some normalisation: >>> >>> data Table f = Table { tableId :: Col f ('NotNullable 'DBInt) >>> , tableX :: Col f ('Nullable 'DBString) } >>> >>> is one such example. >>> >>> The idea behind Col is that sometimes we don't need information about the "full type" when we know more about f. >>> >>> One such choice of f is Expr, which corresponds to expressions inside a query. In this case, I would desire >>> >>> tableId :: Col Expr ('NotNullable 'DBInt) = tableId :: Expr 'DBInt >>> tableX :: Col Expr ('Nullable 'DBString) = tableX :: Expr ('Nullable 'DBString) >>> >>> Notice here that if you use 'NotNullable, then this information is erased - but it's important if the column is 'Nullable. >>> >>> However, I'm struggling to work out any way to actually pull this off in the general case. Here's what I've been attempting: >>> >>> {-# LANGUAGE FunctionalDependencies #-} >>> {-# LANGUAGE FlexibleInstances #-} >>> {-# LANGUAGE RankNTypes #-} >>> {-# LANGUAGE MultiParamTypeClasses #-} >>> {-# LANGUAGE DataKinds #-} >>> {-# LANGUAGE TypeOperators #-} >>> {-# LANGUAGE TypeFamilies #-} >>> {-# LANGUAGE KindSignatures #-} >>> {-# LANGUAGE PolyKinds #-} >>> {-# LANGUAGE TemplateHaskell #-} >>> {-# LANGUAGE GADTs #-} >>> {-# LANGUAGE UndecidableInstances #-} >>> {-# LANGUAGE ScopedTypeVariables #-} >>> >>> module ExprTest where >>> >>> import Data.Singletons >>> import Data.Singletons.Prelude hiding (Null) >>> import Data.Singletons.TH >>> >>> data Expr (a :: k) >>> >>> data MyExprSym :: TyFun k * -> * >>> type instance Apply MyExprSym (x :: k) = Expr x >>> >>> $(singletons [d| >>> data Null a = Nullable a | NotNullable a >>> |]) >>> >>> $(promote [d| >>> notNullableType k (NotNullable a) = baseType k a >>> nullableType k (Nullable a) = baseType (k . Nullable) a >>> baseType k a = k a >>> |]) >>> >>> So far, this seems to work well. If I ask GHCI: >>> >>> *ExprTest> :kind! Apply (Apply NullableTypeSym0 MyExprSym) ('Nullable 'DBString) >>> Apply (Apply NullableTypeSym0 MyExprSym) ('Nullable 'DBString) :: * >>> = Expr ('Nullable 'DBString) >>> >>> *ExprTest> :kind! Apply (Apply NotNullableTypeSym0 MyExprSym) ('NotNullable 'DBInt) >>> Apply (Apply NotNullableTypeSym0 MyExprSym) ('NotNullable 'DBInt) :: * >>> = Expr 'DBInt >>> >>> This is exactly what I want, but note that I had to choose the necessary symbols NullableTypeSym0 and NotNullableTypeSym0. I would like to calculate those symbols from the column type itself. Looking at the kinds of these symbols though, they are both different: >>> >>> *ExprTest> :kind! NotNullableTypeSym0 >>> NotNullableTypeSym0 :: TyFun >>> (TyFun k1 k -> *) (TyFun (Null k1) k -> *) >>> -> * >>> = NotNullableTypeSym0 >>> *ExprTest> :kind! NullableTypeSym0 >>> NullableTypeSym0 :: TyFun >>> (TyFun (Null k1) k -> *) (TyFun (Null k1) k -> *) >>> -> * >>> = NullableTypeSym0 >>> >>> So I can't see a way to write a single type family that returns them. >>> >>> >>> To summarise, I'd like a way to write this following instance for Col: >>> >>> type instance Col Expr x = Apply (Apply ?? MyExprSym) x >>> >>> such that >>> >>> Col Expr ('Nullable a) = Expr ('Nullable a') and >>> Col Expr ('NotNullable a) = Expr a >>> >>> but I cannot work out how to write the placeholder ?? above. >>> >>> One attempt is >>> >>> type family ExprTyfun (col :: colK) :: TyFun (TyFun k * -> *) (TyFun j * -> *) -> * >>> type instance ExprTyfun ('NotNullable a) = NotNullableTypeSym0 >>> type instance ExprTyfun ('Nullable a) = NullableTypeSym0 >>> >>> But neither of these instances actually normalise as I'd like, presumably because of k and j being forall'd in the return type: >>> >>> *ExprTest> :set -fprint-explicit-kinds >>> >>> >>> *ExprTest> :kind! ExprTyfun ('Nullable 'DBInt) >>> ExprTyfun ('Nullable 'DBInt) :: TyFun >>> (TyFun k * -> *) (TyFun k1 * -> *) >>> -> * >>> = ExprTyfun k k1 (Null DBType) ('Nullable DBType 'DBInt) >>> >>> >>> *ExprTest> :kind! ExprTyfun ('NotNullable 'DBInt) >>> ExprTyfun ('NotNullable 'DBInt) :: TyFun >>> (TyFun k * -> *) (TyFun k1 * -> *) >>> -> * >>> = ExprTyfun k k1 (Null DBType) ('NotNullable DBType 'DBInt) >>> >>> >>> *ExprTest> :i ExprTyfun >>> type family ExprTyfun (k :: BOX) >>> (j :: BOX) >>> (colK :: BOX) >>> (col :: colK) :: >>> TyFun (TyFun k * -> *) (TyFun j * -> *) -> * >>> -- Defined at src/Opaleye/TF/ExprTest.hs:39:1 >>> type instance ExprTyfun >>> (Null k) (Null k) (Null k1) ('Nullable k1 a) >>> = NullableTypeSym0 * k >>> -- Defined at src/Opaleye/TF/ExprTest.hs:41:1 >>> type instance ExprTyfun k (Null k) (Null k1) ('NotNullable k1 a) >>> = NotNullableTypeSym0 * k >>> -- Defined at src/Opaleye/TF/ExprTest.hs:40:1 >>> >>> >>> I'd also like to point out that in my full code the types to Col can be a lot bigger, and I'd like to not assume any ordering. For example, here's a possible type: >>> >>> userId :: Col f ('Column "id" ('NotNullable ('HasDefault 'DBInt))) >>> >>> In this case Col Expr ('Column "id" ('NotNullable ('HasDefault 'DBInt))) = Expr 'DBInt >>> >>> I hope this question is understandable! Please let me know if there's anything I can do to provide more clarity. >>> >>> - Ollie >> >>> _______________________________________________ >>> Haskell-Cafe mailing list >>> Haskell-Cafe at haskell.org >>> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From eir at cis.upenn.edu Fri Mar 18 14:26:37 2016 From: eir at cis.upenn.edu (Richard Eisenberg) Date: Fri, 18 Mar 2016 10:26:37 -0400 Subject: [Haskell-cafe] Stuck on a type family problem where kind inference fails In-Reply-To: References: <45E0231D-8895-42F5-A0C9-97EA2C8395A7@cis.upenn.edu> Message-ID: <7A1B5B01-C31D-4F2D-B161-1C8B72F55A6A@cis.upenn.edu> Perhaps. On further consideration, this problem may not be as hard as I thought. I may get a chance to look into it today. On Mar 17, 2016, at 8:40 PM, Oliver Charles wrote: > I have just found https://ghc.haskell.org/trac/ghc/ticket/11635 - is that perhaps the same thing? > > On Thu, Mar 17, 2016 at 8:29 PM Oliver Charles wrote: > Rats. Shall I open something in Trac? > > > On Thu, 17 Mar 2016 8:26 pm Richard Eisenberg, wrote: > Bah. I've just tried to mock something up, but GHC 8 doesn't support higher-rank kinds in type families. They work fine in datatypes and classes, but not in type families. I know exactly why this is failing, and I'm pretty sure I know how to fix it, but it's certainly not going to make it for GHC 8 -- there's a significant engineering hurdle before we can allow type family arguments' kinds to be fancy. > > Sorry to disappoint here. Perhaps there's a way to work around the problem, maybe by burying the higher-rank kind under a newtype or some similar trick. > > Just to show what I tried: > >> import Data.Kind >> >> data TyFun :: * -> * -> * >> type a ~> b = TyFun a b -> * >> >> type family (f :: a ~> b) @@ (x :: a) :: b > >> >> data Null a = Nullable a | NotNullable a >> > >> type family ((f :: b ~> c) ? (g :: a ~> b)) (x :: a) :: c where >> (f ? g) x = f @@ (g @@ x) >> >> type family BaseType (k :: forall a. a ~> Type) (x :: b) :: Type where -- this fails :( >> -- BaseType k x = (@@) k x > > (By the way, Type and * are synonyms in GHC 8. There's no rhyme nor reason for why I used both in this example.) > > Richard > > On Mar 17, 2016, at 4:12 PM, Oliver Charles wrote: > >> Your term level stuff is exactly what I got to - a need for rank-2 type.. Err, kinds! I was trying to do that within a class but gave up on GHC 7. Great to hear GHC 8 will get me there, is there anything I can look at in the mean time? I don't need singletons entirely, so I'm happy to reimplement small parts. >> >> - Ollie >> >> >> On Thu, 17 Mar 2016 7:05 pm Richard Eisenberg, wrote: >> Interesting use case! >> >> You need a higher-rank kind. >> >> All the typey stuff is getting in the way of understanding. I've implemented what you want at the term level: >> >> >>> data Null a = Nullable a | NotNullable a >>> >> >>> notNullableType :: (forall a. a -> Type) -> Null a -> Type >> >>> notNullableType k (NotNullable a) = baseType k a >>> >> >>> nullableType :: (forall a. a -> Type) -> Null a -> Type >> >>> nullableType k (Nullable a) = baseType (k . Nullable) a >>> >> >>> baseType :: (forall a. a -> Type) -> forall b. b -> Type >> >>> baseType k a = k a >>> >> >>> exprTyFun :: Null b -> (forall a. a -> Type) -> Null b -> Type >>> exprTyFun (NotNullable _) = notNullableType >>> exprTyFun (Nullable _) = nullableType >> >> >> It's critical that notNullableType and nullableType have the same type, which is achievable only with higher-rank types. >> >> Happily, GHC 8.0 comes equipped with higher-rank kinds. `singletons` doesn't yet build on 8.0, but it will in the future, for a sufficiently expansive definition of future. Christiaan Baaij is working on this, but I've been all-consumed by getting GHC 8 out and haven't given Christiaan's contributions the attention they deserve. So: all in good time! >> >> I hope this answers your question. >> >> Richard >> >> On Mar 17, 2016, at 8:46 AM, Oliver Charles wrote: >> >>> Hi all, >>> >>> This is a little tricky to explain, so bear with me. I'm working on some code that roughly models a PostgreSQL schema. Users begin by defining their tables as Haskell records, parametrized over some f :: k -> *, and use a special Col type family that applies some normalisation: >>> >>> data Table f = Table { tableId :: Col f ('NotNullable 'DBInt) >>> , tableX :: Col f ('Nullable 'DBString) } >>> >>> is one such example. >>> >>> The idea behind Col is that sometimes we don't need information about the "full type" when we know more about f. >>> >>> One such choice of f is Expr, which corresponds to expressions inside a query. In this case, I would desire >>> >>> tableId :: Col Expr ('NotNullable 'DBInt) = tableId :: Expr 'DBInt >>> tableX :: Col Expr ('Nullable 'DBString) = tableX :: Expr ('Nullable 'DBString) >>> >>> Notice here that if you use 'NotNullable, then this information is erased - but it's important if the column is 'Nullable. >>> >>> However, I'm struggling to work out any way to actually pull this off in the general case. Here's what I've been attempting: >>> >>> {-# LANGUAGE FunctionalDependencies #-} >>> {-# LANGUAGE FlexibleInstances #-} >>> {-# LANGUAGE RankNTypes #-} >>> {-# LANGUAGE MultiParamTypeClasses #-} >>> {-# LANGUAGE DataKinds #-} >>> {-# LANGUAGE TypeOperators #-} >>> {-# LANGUAGE TypeFamilies #-} >>> {-# LANGUAGE KindSignatures #-} >>> {-# LANGUAGE PolyKinds #-} >>> {-# LANGUAGE TemplateHaskell #-} >>> {-# LANGUAGE GADTs #-} >>> {-# LANGUAGE UndecidableInstances #-} >>> {-# LANGUAGE ScopedTypeVariables #-} >>> >>> module ExprTest where >>> >>> import Data.Singletons >>> import Data.Singletons.Prelude hiding (Null) >>> import Data.Singletons.TH >>> >>> data Expr (a :: k) >>> >>> data MyExprSym :: TyFun k * -> * >>> type instance Apply MyExprSym (x :: k) = Expr x >>> >>> $(singletons [d| >>> data Null a = Nullable a | NotNullable a >>> |]) >>> >>> $(promote [d| >>> notNullableType k (NotNullable a) = baseType k a >>> nullableType k (Nullable a) = baseType (k . Nullable) a >>> baseType k a = k a >>> |]) >>> >>> So far, this seems to work well. If I ask GHCI: >>> >>> *ExprTest> :kind! Apply (Apply NullableTypeSym0 MyExprSym) ('Nullable 'DBString) >>> Apply (Apply NullableTypeSym0 MyExprSym) ('Nullable 'DBString) :: * >>> = Expr ('Nullable 'DBString) >>> >>> *ExprTest> :kind! Apply (Apply NotNullableTypeSym0 MyExprSym) ('NotNullable 'DBInt) >>> Apply (Apply NotNullableTypeSym0 MyExprSym) ('NotNullable 'DBInt) :: * >>> = Expr 'DBInt >>> >>> This is exactly what I want, but note that I had to choose the necessary symbols NullableTypeSym0 and NotNullableTypeSym0. I would like to calculate those symbols from the column type itself. Looking at the kinds of these symbols though, they are both different: >>> >>> *ExprTest> :kind! NotNullableTypeSym0 >>> NotNullableTypeSym0 :: TyFun >>> (TyFun k1 k -> *) (TyFun (Null k1) k -> *) >>> -> * >>> = NotNullableTypeSym0 >>> *ExprTest> :kind! NullableTypeSym0 >>> NullableTypeSym0 :: TyFun >>> (TyFun (Null k1) k -> *) (TyFun (Null k1) k -> *) >>> -> * >>> = NullableTypeSym0 >>> >>> So I can't see a way to write a single type family that returns them. >>> >>> >>> To summarise, I'd like a way to write this following instance for Col: >>> >>> type instance Col Expr x = Apply (Apply ?? MyExprSym) x >>> >>> such that >>> >>> Col Expr ('Nullable a) = Expr ('Nullable a') and >>> Col Expr ('NotNullable a) = Expr a >>> >>> but I cannot work out how to write the placeholder ?? above. >>> >>> One attempt is >>> >>> type family ExprTyfun (col :: colK) :: TyFun (TyFun k * -> *) (TyFun j * -> *) -> * >>> type instance ExprTyfun ('NotNullable a) = NotNullableTypeSym0 >>> type instance ExprTyfun ('Nullable a) = NullableTypeSym0 >>> >>> But neither of these instances actually normalise as I'd like, presumably because of k and j being forall'd in the return type: >>> >>> *ExprTest> :set -fprint-explicit-kinds >>> >>> >>> *ExprTest> :kind! ExprTyfun ('Nullable 'DBInt) >>> ExprTyfun ('Nullable 'DBInt) :: TyFun >>> (TyFun k * -> *) (TyFun k1 * -> *) >>> -> * >>> = ExprTyfun k k1 (Null DBType) ('Nullable DBType 'DBInt) >>> >>> >>> *ExprTest> :kind! ExprTyfun ('NotNullable 'DBInt) >>> ExprTyfun ('NotNullable 'DBInt) :: TyFun >>> (TyFun k * -> *) (TyFun k1 * -> *) >>> -> * >>> = ExprTyfun k k1 (Null DBType) ('NotNullable DBType 'DBInt) >>> >>> >>> *ExprTest> :i ExprTyfun >>> type family ExprTyfun (k :: BOX) >>> (j :: BOX) >>> (colK :: BOX) >>> (col :: colK) :: >>> TyFun (TyFun k * -> *) (TyFun j * -> *) -> * >>> -- Defined at src/Opaleye/TF/ExprTest.hs:39:1 >>> type instance ExprTyfun >>> (Null k) (Null k) (Null k1) ('Nullable k1 a) >>> = NullableTypeSym0 * k >>> -- Defined at src/Opaleye/TF/ExprTest.hs:41:1 >>> type instance ExprTyfun k (Null k) (Null k1) ('NotNullable k1 a) >>> = NotNullableTypeSym0 * k >>> -- Defined at src/Opaleye/TF/ExprTest.hs:40:1 >>> >>> >>> I'd also like to point out that in my full code the types to Col can be a lot bigger, and I'd like to not assume any ordering. For example, here's a possible type: >>> >>> userId :: Col f ('Column "id" ('NotNullable ('HasDefault 'DBInt))) >>> >>> In this case Col Expr ('Column "id" ('NotNullable ('HasDefault 'DBInt))) = Expr 'DBInt >>> >>> I hope this question is understandable! Please let me know if there's anything I can do to provide more clarity. >>> >>> - Ollie >> >>> _______________________________________________ >>> Haskell-Cafe mailing list >>> Haskell-Cafe at haskell.org >>> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From eir at cis.upenn.edu Fri Mar 18 15:28:44 2016 From: eir at cis.upenn.edu (Richard Eisenberg) Date: Fri, 18 Mar 2016 11:28:44 -0400 Subject: [Haskell-cafe] Stuck on a type family problem where kind inference fails In-Reply-To: <7A1B5B01-C31D-4F2D-B161-1C8B72F55A6A@cis.upenn.edu> References: <45E0231D-8895-42F5-A0C9-97EA2C8395A7@cis.upenn.edu> <7A1B5B01-C31D-4F2D-B161-1C8B72F55A6A@cis.upenn.edu> Message-ID: Well, the issue as reported is now fixed (validating soon; barring disaster, will push today). But it doesn't fully solve the problem because my fix allows you to declare a higher-kinded type family but not to write higher-kinded type family equations. To do this requires proper bidirectional type-checking in types. GHC 8 actually has some degree of bidirectional type-checking in types, but not quite enough to pull this off. No real barriers here, just engineering time that I don't currently have. However, even if we had all the bidirectional type-checking and the ability to define higher-kinded type family equations, it *still* wouldn't work for you because the defunctionalization trick would fail. Defunctionalizing a higher-kinded type family requires impredicativity. (Think of the instantiation of the kind variables on the Apply function.) I'm not going to touch type-level impredicativity until term-level impredicativity is all sorted, and that is far from happening. The silver lining here is that I have an approach to unsaturated type functions (summarized in the conclusion to my paper about promoting functions to type families that describes the defunctionalization trick) in mind that will obviate the need for defunctionalization. My guess is that unsaturated type functions will be available before impredicativity, but I can't be sure. So, unbeknownst to you, your example requires a fair bit of research to be done before it can be written, in Haskell at least. Richard On Mar 18, 2016, at 10:26 AM, Richard Eisenberg wrote: > Perhaps. On further consideration, this problem may not be as hard as I thought. I may get a chance to look into it today. > > On Mar 17, 2016, at 8:40 PM, Oliver Charles wrote: > >> I have just found https://ghc.haskell.org/trac/ghc/ticket/11635 - is that perhaps the same thing? >> >> On Thu, Mar 17, 2016 at 8:29 PM Oliver Charles wrote: >> Rats. Shall I open something in Trac? >> >> >> On Thu, 17 Mar 2016 8:26 pm Richard Eisenberg, wrote: >> Bah. I've just tried to mock something up, but GHC 8 doesn't support higher-rank kinds in type families. They work fine in datatypes and classes, but not in type families. I know exactly why this is failing, and I'm pretty sure I know how to fix it, but it's certainly not going to make it for GHC 8 -- there's a significant engineering hurdle before we can allow type family arguments' kinds to be fancy. >> >> Sorry to disappoint here. Perhaps there's a way to work around the problem, maybe by burying the higher-rank kind under a newtype or some similar trick. >> >> Just to show what I tried: >> >>> import Data.Kind >>> >>> data TyFun :: * -> * -> * >>> type a ~> b = TyFun a b -> * >>> >>> type family (f :: a ~> b) @@ (x :: a) :: b >> >>> >>> data Null a = Nullable a | NotNullable a >>> >> >>> type family ((f :: b ~> c) ? (g :: a ~> b)) (x :: a) :: c where >>> (f ? g) x = f @@ (g @@ x) >>> >>> type family BaseType (k :: forall a. a ~> Type) (x :: b) :: Type where -- this fails :( >>> -- BaseType k x = (@@) k x >> >> (By the way, Type and * are synonyms in GHC 8. There's no rhyme nor reason for why I used both in this example.) >> >> Richard >> >> On Mar 17, 2016, at 4:12 PM, Oliver Charles wrote: >> >>> Your term level stuff is exactly what I got to - a need for rank-2 type.. Err, kinds! I was trying to do that within a class but gave up on GHC 7. Great to hear GHC 8 will get me there, is there anything I can look at in the mean time? I don't need singletons entirely, so I'm happy to reimplement small parts. >>> >>> - Ollie >>> >>> >>> On Thu, 17 Mar 2016 7:05 pm Richard Eisenberg, wrote: >>> Interesting use case! >>> >>> You need a higher-rank kind. >>> >>> All the typey stuff is getting in the way of understanding. I've implemented what you want at the term level: >>> >>> >>>> data Null a = Nullable a | NotNullable a >>>> >>> >>>> notNullableType :: (forall a. a -> Type) -> Null a -> Type >>> >>>> notNullableType k (NotNullable a) = baseType k a >>>> >>> >>>> nullableType :: (forall a. a -> Type) -> Null a -> Type >>> >>>> nullableType k (Nullable a) = baseType (k . Nullable) a >>>> >>> >>>> baseType :: (forall a. a -> Type) -> forall b. b -> Type >>> >>>> baseType k a = k a >>>> >>> >>>> exprTyFun :: Null b -> (forall a. a -> Type) -> Null b -> Type >>>> exprTyFun (NotNullable _) = notNullableType >>>> exprTyFun (Nullable _) = nullableType >>> >>> >>> It's critical that notNullableType and nullableType have the same type, which is achievable only with higher-rank types. >>> >>> Happily, GHC 8.0 comes equipped with higher-rank kinds. `singletons` doesn't yet build on 8.0, but it will in the future, for a sufficiently expansive definition of future. Christiaan Baaij is working on this, but I've been all-consumed by getting GHC 8 out and haven't given Christiaan's contributions the attention they deserve. So: all in good time! >>> >>> I hope this answers your question. >>> >>> Richard >>> >>> On Mar 17, 2016, at 8:46 AM, Oliver Charles wrote: >>> >>>> Hi all, >>>> >>>> This is a little tricky to explain, so bear with me. I'm working on some code that roughly models a PostgreSQL schema. Users begin by defining their tables as Haskell records, parametrized over some f :: k -> *, and use a special Col type family that applies some normalisation: >>>> >>>> data Table f = Table { tableId :: Col f ('NotNullable 'DBInt) >>>> , tableX :: Col f ('Nullable 'DBString) } >>>> >>>> is one such example. >>>> >>>> The idea behind Col is that sometimes we don't need information about the "full type" when we know more about f. >>>> >>>> One such choice of f is Expr, which corresponds to expressions inside a query. In this case, I would desire >>>> >>>> tableId :: Col Expr ('NotNullable 'DBInt) = tableId :: Expr 'DBInt >>>> tableX :: Col Expr ('Nullable 'DBString) = tableX :: Expr ('Nullable 'DBString) >>>> >>>> Notice here that if you use 'NotNullable, then this information is erased - but it's important if the column is 'Nullable. >>>> >>>> However, I'm struggling to work out any way to actually pull this off in the general case. Here's what I've been attempting: >>>> >>>> {-# LANGUAGE FunctionalDependencies #-} >>>> {-# LANGUAGE FlexibleInstances #-} >>>> {-# LANGUAGE RankNTypes #-} >>>> {-# LANGUAGE MultiParamTypeClasses #-} >>>> {-# LANGUAGE DataKinds #-} >>>> {-# LANGUAGE TypeOperators #-} >>>> {-# LANGUAGE TypeFamilies #-} >>>> {-# LANGUAGE KindSignatures #-} >>>> {-# LANGUAGE PolyKinds #-} >>>> {-# LANGUAGE TemplateHaskell #-} >>>> {-# LANGUAGE GADTs #-} >>>> {-# LANGUAGE UndecidableInstances #-} >>>> {-# LANGUAGE ScopedTypeVariables #-} >>>> >>>> module ExprTest where >>>> >>>> import Data.Singletons >>>> import Data.Singletons.Prelude hiding (Null) >>>> import Data.Singletons.TH >>>> >>>> data Expr (a :: k) >>>> >>>> data MyExprSym :: TyFun k * -> * >>>> type instance Apply MyExprSym (x :: k) = Expr x >>>> >>>> $(singletons [d| >>>> data Null a = Nullable a | NotNullable a >>>> |]) >>>> >>>> $(promote [d| >>>> notNullableType k (NotNullable a) = baseType k a >>>> nullableType k (Nullable a) = baseType (k . Nullable) a >>>> baseType k a = k a >>>> |]) >>>> >>>> So far, this seems to work well. If I ask GHCI: >>>> >>>> *ExprTest> :kind! Apply (Apply NullableTypeSym0 MyExprSym) ('Nullable 'DBString) >>>> Apply (Apply NullableTypeSym0 MyExprSym) ('Nullable 'DBString) :: * >>>> = Expr ('Nullable 'DBString) >>>> >>>> *ExprTest> :kind! Apply (Apply NotNullableTypeSym0 MyExprSym) ('NotNullable 'DBInt) >>>> Apply (Apply NotNullableTypeSym0 MyExprSym) ('NotNullable 'DBInt) :: * >>>> = Expr 'DBInt >>>> >>>> This is exactly what I want, but note that I had to choose the necessary symbols NullableTypeSym0 and NotNullableTypeSym0. I would like to calculate those symbols from the column type itself. Looking at the kinds of these symbols though, they are both different: >>>> >>>> *ExprTest> :kind! NotNullableTypeSym0 >>>> NotNullableTypeSym0 :: TyFun >>>> (TyFun k1 k -> *) (TyFun (Null k1) k -> *) >>>> -> * >>>> = NotNullableTypeSym0 >>>> *ExprTest> :kind! NullableTypeSym0 >>>> NullableTypeSym0 :: TyFun >>>> (TyFun (Null k1) k -> *) (TyFun (Null k1) k -> *) >>>> -> * >>>> = NullableTypeSym0 >>>> >>>> So I can't see a way to write a single type family that returns them. >>>> >>>> >>>> To summarise, I'd like a way to write this following instance for Col: >>>> >>>> type instance Col Expr x = Apply (Apply ?? MyExprSym) x >>>> >>>> such that >>>> >>>> Col Expr ('Nullable a) = Expr ('Nullable a') and >>>> Col Expr ('NotNullable a) = Expr a >>>> >>>> but I cannot work out how to write the placeholder ?? above. >>>> >>>> One attempt is >>>> >>>> type family ExprTyfun (col :: colK) :: TyFun (TyFun k * -> *) (TyFun j * -> *) -> * >>>> type instance ExprTyfun ('NotNullable a) = NotNullableTypeSym0 >>>> type instance ExprTyfun ('Nullable a) = NullableTypeSym0 >>>> >>>> But neither of these instances actually normalise as I'd like, presumably because of k and j being forall'd in the return type: >>>> >>>> *ExprTest> :set -fprint-explicit-kinds >>>> >>>> >>>> *ExprTest> :kind! ExprTyfun ('Nullable 'DBInt) >>>> ExprTyfun ('Nullable 'DBInt) :: TyFun >>>> (TyFun k * -> *) (TyFun k1 * -> *) >>>> -> * >>>> = ExprTyfun k k1 (Null DBType) ('Nullable DBType 'DBInt) >>>> >>>> >>>> *ExprTest> :kind! ExprTyfun ('NotNullable 'DBInt) >>>> ExprTyfun ('NotNullable 'DBInt) :: TyFun >>>> (TyFun k * -> *) (TyFun k1 * -> *) >>>> -> * >>>> = ExprTyfun k k1 (Null DBType) ('NotNullable DBType 'DBInt) >>>> >>>> >>>> *ExprTest> :i ExprTyfun >>>> type family ExprTyfun (k :: BOX) >>>> (j :: BOX) >>>> (colK :: BOX) >>>> (col :: colK) :: >>>> TyFun (TyFun k * -> *) (TyFun j * -> *) -> * >>>> -- Defined at src/Opaleye/TF/ExprTest.hs:39:1 >>>> type instance ExprTyfun >>>> (Null k) (Null k) (Null k1) ('Nullable k1 a) >>>> = NullableTypeSym0 * k >>>> -- Defined at src/Opaleye/TF/ExprTest.hs:41:1 >>>> type instance ExprTyfun k (Null k) (Null k1) ('NotNullable k1 a) >>>> = NotNullableTypeSym0 * k >>>> -- Defined at src/Opaleye/TF/ExprTest.hs:40:1 >>>> >>>> >>>> I'd also like to point out that in my full code the types to Col can be a lot bigger, and I'd like to not assume any ordering. For example, here's a possible type: >>>> >>>> userId :: Col f ('Column "id" ('NotNullable ('HasDefault 'DBInt))) >>>> >>>> In this case Col Expr ('Column "id" ('NotNullable ('HasDefault 'DBInt))) = Expr 'DBInt >>>> >>>> I hope this question is understandable! Please let me know if there's anything I can do to provide more clarity. >>>> >>>> - Ollie >>> >>>> _______________________________________________ >>>> Haskell-Cafe mailing list >>>> Haskell-Cafe at haskell.org >>>> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe >>> >> > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe -------------- next part -------------- An HTML attachment was scrubbed... URL: From ollie at ocharles.org.uk Fri Mar 18 15:37:40 2016 From: ollie at ocharles.org.uk (Oliver Charles) Date: Fri, 18 Mar 2016 15:37:40 +0000 Subject: [Haskell-cafe] Stuck on a type family problem where kind inference fails In-Reply-To: References: <45E0231D-8895-42F5-A0C9-97EA2C8395A7@cis.upenn.edu> <7A1B5B01-C31D-4F2D-B161-1C8B72F55A6A@cis.upenn.edu> Message-ID: Fascinating! The mentions of bidirectional type checking remind me of this recent paper - Sound and Complete Bidirectional Typechecking for Higher-Rank Polymorphism and Indexed Types - is this similar to what would be required in GHC? The suffix of "for higher-rank polymorphism" makes me wonder if this doesn't require solving impredicativity, as that seems like a massive can of worms. I'll read the conclusion of your paper again to see if I can learn more about that wrt GHC 8. I'd love to donate some engineering resources, but I have a feeling this might all be a little over my head. Anyway, thanks for the discussion - it's been very interesting, even if the outcome is perhaps slightly disappointing in the immediate. Of course, there are other approaches I can take if I add a few more limitations, such as only working for one specific ordering of "features" (e.g., columns of kind (Column (Null (Default k)))), and that's what I've switched over to for now. - Ollie On Fri, Mar 18, 2016 at 3:28 PM Richard Eisenberg wrote: > Well, the issue as reported is now fixed (validating soon; barring > disaster, will push today). > > But it doesn't fully solve the problem because my fix allows you to > declare a higher-kinded type family but not to write higher-kinded type > family equations. To do this requires proper bidirectional type-checking in > types. GHC 8 actually has some degree of bidirectional type-checking in > types, but not quite enough to pull this off. No real barriers here, just > engineering time that I don't currently have. However, even if we had all > the bidirectional type-checking and the ability to define higher-kinded > type family equations, it *still* wouldn't work for you because the > defunctionalization trick would fail. Defunctionalizing a higher-kinded > type family requires impredicativity. (Think of the instantiation of the > kind variables on the Apply function.) I'm not going to touch type-level > impredicativity until term-level impredicativity is all sorted, and that is > far from happening. > > The silver lining here is that I have an approach to unsaturated type > functions (summarized in the conclusion to my paper about promoting > functions to type families that describes the defunctionalization trick) in > mind that will obviate the need for defunctionalization. My guess is that > unsaturated type functions will be available before impredicativity, but I > can't be sure. > > So, unbeknownst to you, your example requires a fair bit of research to be > done before it can be written, in Haskell at least. > > Richard > > On Mar 18, 2016, at 10:26 AM, Richard Eisenberg wrote: > > Perhaps. On further consideration, this problem may not be as hard as I > thought. I may get a chance to look into it today. > > On Mar 17, 2016, at 8:40 PM, Oliver Charles wrote: > > I have just found https://ghc.haskell.org/trac/ghc/ticket/11635 - is that > perhaps the same thing? > > On Thu, Mar 17, 2016 at 8:29 PM Oliver Charles > wrote: > >> Rats. Shall I open something in Trac? >> >> On Thu, 17 Mar 2016 8:26 pm Richard Eisenberg, wrote: >> >>> Bah. I've just tried to mock something up, but GHC 8 doesn't support >>> higher-rank kinds in type families. They work fine in datatypes and >>> classes, but not in type families. I know exactly why this is failing, and >>> I'm pretty sure I know how to fix it, but it's certainly not going to make >>> it for GHC 8 -- there's a significant engineering hurdle before we can >>> allow type family arguments' kinds to be fancy. >>> >>> Sorry to disappoint here. Perhaps there's a way to work around the >>> problem, maybe by burying the higher-rank kind under a newtype or some >>> similar trick. >>> >>> Just to show what I tried: >>> >>> import Data.Kind >>> >>> data TyFun :: * -> * -> * >>> type a ~> b = TyFun a b -> * >>> >>> type family (f :: a ~> b) @@ (x :: a) :: b >>> >>> >>> data Null a = Nullable a | NotNullable a >>> >>> type family ((f :: b ~> c) ? (g :: a ~> b)) (x :: a) :: c where >>> (f ? g) x = f @@ (g @@ x) >>> >>> type family BaseType (k :: forall a. a ~> Type) (x :: b) :: Type where >>> -- this fails :( >>> -- BaseType k x = (@@) k x >>> >>> >>> (By the way, Type and * are synonyms in GHC 8. There's no rhyme nor >>> reason for why I used both in this example.) >>> >>> Richard >>> >>> On Mar 17, 2016, at 4:12 PM, Oliver Charles >>> wrote: >>> >>> Your term level stuff is exactly what I got to - a need for rank-2 >>> type.. Err, kinds! I was trying to do that within a class but gave up on >>> GHC 7. Great to hear GHC 8 will get me there, is there anything I can look >>> at in the mean time? I don't need singletons entirely, so I'm happy to >>> reimplement small parts. >>> >>> - Ollie >>> >>> On Thu, 17 Mar 2016 7:05 pm Richard Eisenberg, >>> wrote: >>> >>>> Interesting use case! >>>> >>>> You need a higher-rank kind. >>>> >>>> All the typey stuff is getting in the way of understanding. I've >>>> implemented what you want at the term level: >>>> >>>> data Null a = Nullable a | NotNullable a >>>> >>>> notNullableType :: (forall a. a -> Type) -> Null a -> Type >>>> >>>> notNullableType k (NotNullable a) = baseType k a >>>> >>>> nullableType :: (forall a. a -> Type) -> Null a -> Type >>>> >>>> nullableType k (Nullable a) = baseType (k . Nullable) a >>>> >>>> baseType :: (forall a. a -> Type) -> forall b. b -> Type >>>> >>>> baseType k a = k a >>>> >>>> exprTyFun :: Null b -> (forall a. a -> Type) -> Null b -> Type >>>> exprTyFun (NotNullable _) = notNullableType >>>> exprTyFun (Nullable _) = nullableType >>>> >>>> >>>> It's critical that notNullableType and nullableType have the same type, >>>> which is achievable only with higher-rank types. >>>> >>>> Happily, GHC 8.0 comes equipped with higher-rank kinds. `singletons` >>>> doesn't yet build on 8.0, but it will in the future, for a sufficiently >>>> expansive definition of future. Christiaan Baaij is working on this, but >>>> I've been all-consumed by getting GHC 8 out and haven't given Christiaan's >>>> contributions the attention they deserve. So: all in good time! >>>> >>>> I hope this answers your question. >>>> >>>> Richard >>>> >>>> On Mar 17, 2016, at 8:46 AM, Oliver Charles >>>> wrote: >>>> >>>> Hi all, >>>> >>>> This is a little tricky to explain, so bear with me. I'm working on >>>> some code that roughly models a PostgreSQL schema. Users begin by defining >>>> their tables as Haskell records, parametrized over some f :: k -> *, >>>> and use a special Col type family that applies some normalisation: >>>> >>>> data Table f = Table { tableId :: Col f ('NotNullable 'DBInt) >>>> , tableX :: Col f ('Nullable 'DBString) } >>>> >>>> is one such example. >>>> >>>> The idea behind Col is that sometimes we don't need information about >>>> the "full type" when we know more about f. >>>> >>>> One such choice of f is Expr, which corresponds to expressions inside >>>> a query. In this case, I would desire >>>> >>>> tableId :: Col Expr ('NotNullable 'DBInt) = tableId :: Expr 'DBInt >>>> tableX :: Col Expr ('Nullable 'DBString) = tableX :: Expr ('Nullable >>>> 'DBString) >>>> >>>> Notice here that if you use 'NotNullable, then this information is >>>> erased - but it's important if the column is 'Nullable. >>>> >>>> However, I'm struggling to work out any way to actually pull this off >>>> in the general case. Here's what I've been attempting: >>>> >>>> {-# LANGUAGE FunctionalDependencies #-} >>>> {-# LANGUAGE FlexibleInstances #-} >>>> {-# LANGUAGE RankNTypes #-} >>>> {-# LANGUAGE MultiParamTypeClasses #-} >>>> {-# LANGUAGE DataKinds #-} >>>> {-# LANGUAGE TypeOperators #-} >>>> {-# LANGUAGE TypeFamilies #-} >>>> {-# LANGUAGE KindSignatures #-} >>>> {-# LANGUAGE PolyKinds #-} >>>> {-# LANGUAGE TemplateHaskell #-} >>>> {-# LANGUAGE GADTs #-} >>>> {-# LANGUAGE UndecidableInstances #-} >>>> {-# LANGUAGE ScopedTypeVariables #-} >>>> >>>> module ExprTest where >>>> >>>> import Data.Singletons >>>> import Data.Singletons.Prelude hiding (Null) >>>> import Data.Singletons.TH >>>> >>>> data Expr (a :: k) >>>> >>>> data MyExprSym :: TyFun k * -> * >>>> type instance Apply MyExprSym (x :: k) = Expr x >>>> >>>> $(singletons [d| >>>> data Null a = Nullable a | NotNullable a >>>> |]) >>>> >>>> $(promote [d| >>>> notNullableType k (NotNullable a) = baseType k a >>>> nullableType k (Nullable a) = baseType (k . Nullable) a >>>> baseType k a = k a >>>> |]) >>>> >>>> So far, this seems to work well. If I ask GHCI: >>>> >>>> *ExprTest> :kind! Apply (Apply NullableTypeSym0 MyExprSym) ('Nullable >>>> 'DBString) >>>> Apply (Apply NullableTypeSym0 MyExprSym) ('Nullable 'DBString) :: * >>>> = Expr ('Nullable 'DBString) >>>> >>>> *ExprTest> :kind! Apply (Apply NotNullableTypeSym0 MyExprSym) >>>> ('NotNullable 'DBInt) >>>> Apply (Apply NotNullableTypeSym0 MyExprSym) ('NotNullable 'DBInt) :: * >>>> = Expr 'DBInt >>>> >>>> This is exactly what I want, but note that I had to choose the >>>> necessary symbols NullableTypeSym0 and NotNullableTypeSym0. I would >>>> like to calculate those symbols from the column type itself. Looking at the >>>> kinds of these symbols though, they are both different: >>>> >>>> *ExprTest> :kind! NotNullableTypeSym0 >>>> NotNullableTypeSym0 :: TyFun >>>> (TyFun k1 k -> *) (TyFun (Null k1) k -> *) >>>> -> * >>>> = NotNullableTypeSym0 >>>> *ExprTest> :kind! NullableTypeSym0 >>>> NullableTypeSym0 :: TyFun >>>> (TyFun (Null k1) k -> *) (TyFun (Null k1) k -> *) >>>> -> * >>>> = NullableTypeSym0 >>>> >>>> So I can't see a way to write a single type family that returns them. >>>> >>>> >>>> To summarise, I'd like a way to write this following instance for Col: >>>> >>>> type instance Col Expr x = Apply (Apply ?? MyExprSym) x >>>> >>>> such that >>>> >>>> Col Expr ('Nullable a) = Expr ('Nullable a') and >>>> Col Expr ('NotNullable a) = Expr a >>>> >>>> but I cannot work out how to write the placeholder ?? above. >>>> >>>> One attempt is >>>> >>>> type family ExprTyfun (col :: colK) :: TyFun (TyFun k * -> *) (TyFun j >>>> * -> *) -> * >>>> type instance ExprTyfun ('NotNullable a) = NotNullableTypeSym0 >>>> type instance ExprTyfun ('Nullable a) = NullableTypeSym0 >>>> >>>> But neither of these instances actually normalise as I'd like, >>>> presumably because of k and j being forall'd in the return type: >>>> >>>> *ExprTest> :set -fprint-explicit-kinds >>>> >>>> >>>> *ExprTest> :kind! ExprTyfun ('Nullable 'DBInt) >>>> ExprTyfun ('Nullable 'DBInt) :: TyFun >>>> (TyFun k * -> *) (TyFun k1 * -> *) >>>> -> * >>>> = ExprTyfun k k1 (Null DBType) ('Nullable DBType 'DBInt) >>>> >>>> >>>> *ExprTest> :kind! ExprTyfun ('NotNullable 'DBInt) >>>> ExprTyfun ('NotNullable 'DBInt) :: TyFun >>>> (TyFun k * -> *) (TyFun k1 * -> *) >>>> -> * >>>> = ExprTyfun k k1 (Null DBType) ('NotNullable DBType 'DBInt) >>>> >>>> >>>> *ExprTest> :i ExprTyfun >>>> type family ExprTyfun (k :: BOX) >>>> (j :: BOX) >>>> (colK :: BOX) >>>> (col :: colK) :: >>>> TyFun (TyFun k * -> *) (TyFun j * -> *) -> * >>>> -- Defined at src/Opaleye/TF/ExprTest.hs:39:1 >>>> type instance ExprTyfun >>>> (Null k) (Null k) (Null k1) ('Nullable k1 a) >>>> = NullableTypeSym0 * k >>>> -- Defined at src/Opaleye/TF/ExprTest.hs:41:1 >>>> type instance ExprTyfun k (Null k) (Null k1) ('NotNullable k1 a) >>>> = NotNullableTypeSym0 * k >>>> -- Defined at src/Opaleye/TF/ExprTest.hs:40:1 >>>> >>>> >>>> I'd also like to point out that in my full code the types to Col can >>>> be a lot bigger, and I'd like to not assume any ordering. For example, >>>> here's a possible type: >>>> >>>> userId :: Col f ('Column "id" ('NotNullable ('HasDefault 'DBInt))) >>>> >>>> In this case Col Expr ('Column "id" ('NotNullable ('HasDefault >>>> 'DBInt))) = Expr 'DBInt >>>> >>>> I hope this question is understandable! Please let me know if there's >>>> anything I can do to provide more clarity. >>>> >>>> - Ollie >>>> >>>> _______________________________________________ >>>> Haskell-Cafe mailing list >>>> Haskell-Cafe at haskell.org >>>> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe >>>> >>>> >>>> >>> > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dominic at steinitz.org Fri Mar 18 16:43:22 2016 From: dominic at steinitz.org (Dominic Steinitz) Date: Fri, 18 Mar 2016 16:43:22 +0000 Subject: [Haskell-cafe] GHC Performance Regression Message-ID: <713BD82A-7460-4600-84B8-885FC615F4B6@steinitz.org> Some time ago I wrote a little test program for random number generation. Under 7.8.3 I get > Total time 9.03s ( 9.15s elapsed) Under 7.10.3 I get > Total time 24.773s ( 25.288s elapsed) Now of course it could be the libraries that I am using rather than GHC itself so I have tried to make them as similar as possible. For 7.8.3 I have > build-depends: base ==4.7.0.1, > mtl ==2.1.3.1, > primitive == 0.6, > mwc-random == 0.13.3.2, > vector == 0.10.12.3, > random ==1.1, > random-fu == 0.2.6.2, > random-source == 0.3.0.6 For 7.10.3 I have > build-depends: base ==4.8.2.0, > mtl ==2.2, > primitive == 0.6, > mwc-random == 0.13.3.2, > vector == 0.10.12.3, > random ==1.1, > random-fu == 0.2.6.2, > random-source == 0.3.0.6 So the only differences are in mtl and base. I don?t seem to be able to coax cabal into using mtl-2.2 for 7.8.3 with all the other required libraries. > dominic at ghcPerformance:~$ cabal install 'random-source ==0.3.0.6' 'random-fu ==0.2.6.2' 'random ==1.1' 'primitive ==0.6' 'mwc-random ==0.13.3.2' 'mtl ==2.2' 'vector ==0.10.12.3' --with-ghc=ghc-7.10.3 > Resolving dependencies... > All the requested packages are already installed: > mtl-2.2 > mwc-random-0.13.3.2 > primitive-0.6 > random-1.1 > random-fu-0.2.6.2 > random-source-0.3.0.6 > vector-0.10.12.3 > Use --reinstall if you want to reinstall anyway. > dominic at ghcPerformance:~$ cabal install 'random-source ==0.3.0.6' 'random-fu ==0.2.6.2' 'random ==1.1' 'primitive ==0.6' 'mwc-random ==0.13.3.2' 'mtl ==2.2' 'vector ==0.10.12.3' --with-ghc=ghc-7.8.3 > Resolving dependencies... > cabal: Could not resolve dependencies: > trying: random-source-0.3.0.6/installed-70e... (user goal) > next goal: mtl (user goal) > rejecting: mtl-2.2.1, 2.2.0.1 (global constraint requires ==2.2) > rejecting: mtl-2.2/installed-cc5..., 2.2 (conflict: random-source => > mtl==2.1.3.1/installed-8bc...) > rejecting: mtl-2.1.3.1/installed-8bc..., 2.1.3.1, 2.1.2, 2.1.1, 2.1, 2.0.1.1, > 2.0.1.0, 2.0.0.0, 1.1.1.1, 1.1.1.0, 1.1.0.2, 1.1.0.1, 1.1.0.0, 1.0 (global > constraint requires ==2.2) > Backjump limit reached (change with --max-backjumps). Cabal seems to be telling me that random-source-0.3.0.6 is the problem but if I look at the constraints for that package here https://hackage.haskell.org/package/random-source then I see > mtl (>=1 && <3) I am not sure how to proceed from here. Should I raise an issue on the GHC bug tracker? I?d like to solve this myself but I don?t want to start building versions of ghc to see which change caused the regression without first eliminating mtl. Any ideas would be gratefully received. Dominic Steinitz dominic at steinitz.org http://idontgetoutmuch.wordpress.com > {-# LANGUAGE TemplateHaskell #-} > {-# LANGUAGE GADTs #-} > {-# LANGUAGE FlexibleInstances #-} > > import Data.Random > import Data.Random.Source > import qualified System.Random.MWC as MWC > import Control.Monad.Reader > import Control.Monad.Primitive > > $(monadRandom [d| > instance (PrimMonad m, s ~ PrimState m) => MonadRandom (ReaderT (MWC.Gen s) m) where > getRandomWord16 = ask >>= lift . MWC.uniform > getRandomWord32 = ask >>= lift . MWC.uniform > getRandomWord64 = ask >>= lift . MWC.uniform > |]) > > testUniform :: MonadRandom m => Int -> m [Double] > testUniform n = replicateM (fromIntegral n) (sample stdUniform) > > n :: Int > n = 10^7 > > main :: IO () > main = do > seed <- MWC.create > xs <- runReaderT (testUniform n) seed > print (sum xs / fromIntegral n) This cabal file will build this on 7.8.3 > name: PerfTest8 > version: 0.1.0.0 > homepage: TBD > license: MIT > author: Dominic Steinitz > maintainer: idontgetoutmuch at gmail.com > category: System > build-type: Simple > cabal-version: >=1.10 > > executable Random8 > main-is: TestMwcViaRandomSource.hs > build-depends: base ==4.7.0.1, > mtl ==2.1.3.1, > primitive == 0.6, > mwc-random == 0.13.3.2, > vector == 0.10.12.3, > random ==1.1, > random-fu == 0.2.6.2, > random-source == 0.3.0.6 > default-language: Haskell2010 This cabal file will build this on 7.10.3 > name: PerfTest10 > version: 0.1.0.0 > homepage: TBD > license: MIT > author: Dominic Steinitz > maintainer: idontgetoutmuch at gmail.com > category: System > build-type: Simple > cabal-version: >=1.10 > > executable Random10 > main-is: TestMwcViaRandomSource.hs > build-depends: base ==4.8.2.0, > mtl ==2.2, > primitive == 0.6, > mwc-random == 0.13.3.2, > vector == 0.10.12.3, > random ==1.1, > random-fu == 0.2.6.2, > random-source == 0.3.0.6 > default-language: Haskell2010 -------------- next part -------------- An HTML attachment was scrubbed... URL: From eir at cis.upenn.edu Fri Mar 18 20:44:44 2016 From: eir at cis.upenn.edu (Richard Eisenberg) Date: Fri, 18 Mar 2016 16:44:44 -0400 Subject: [Haskell-cafe] Calling Haskellers to Bryn Mawr & Haverford Message-ID: Anyone who has probed deeply (or at all!) into the delay behind the release of GHC 8.0 may have come across protestations from me that I'm on a job search and have been struggling to find the time to finish off the last few show-stopper bugs. That search has now come to a very happy conclusion, and so I'm writing to share the news: I will be starting as an Assistant Professor at Bryn Mawr College this fall. In my role there, I'm expecting to introduce a new course (or two) on functional programming using Haskell (though the emphasis would be more on pure, strongly typed functional programming than on Haskell, per se), as well as to continue to pursue my research interests in the design and implementation of functional languages along with the requisite type theory. Undergrads will feature prominently in my research efforts, joining my research lab and collaborating on research papers. That's where you come in. Are you, reading this list, a high school student? (Or perhaps an undergrad looking for a change?) Do you know a Haskeller who is? Then come to Bryn Mawr and work with me to design the functional language of the future. "But wait!" many of you might say, "isn't Bryn Mawr only for women?" Yes, indeed it is. However, right down the street is Haverford College, a co-ed school. Haverford and Bryn Mawr share a close relationship, with regular free transportation (< 10 mins) between the schools and very frequent cross-registration for courses. Haverford students even sometimes declare their major at Bryn Mawr and vice versa. The CS departments regularly coordinate in deciding which courses to offer and when, in order to allow students to access the resources of both colleges. So, for you young men out there, I'll rephrase: Are you, reading this list, a high school student? (Or perhaps an undergrad looking for a change?) Do you know a Haskeller who is? Then come to Haverford (or Swarthmore, or University of Pennsylvania) and work with me to design the functional language of the future. I've included Swarthmore and UPenn (where I'm finishing my dissertation) above as members of the Quaker Consortium, where students have cross-registration privileges. Swarthmore is also in the Tri-College Consortium with Bryn Mawr, which also allows easier inter-college research experiences. Swarthmore students can get to Bryn Mawr via free van service (~25 mins) and UPenn students can get to Bryn Mawr via 20 minutes on SEPTA regional rail (these links are admittedly less convenient than the Haverford bus). Of course, I'm happy to answer questions. Though, being new to Bryn Mawr, I may have to refer you to others to get the answers! Hope to see you on campus! Richard -------------- next part -------------- An HTML attachment was scrubbed... URL: From nicu.ionita at acons.at Fri Mar 18 20:53:21 2016 From: nicu.ionita at acons.at (Nicu Ionita) Date: Fri, 18 Mar 2016 21:53:21 +0100 Subject: [Haskell-cafe] Trying desperately to make a c library binding on Windows - solved! In-Reply-To: <56EB383B.4080003@acons.at> References: <56EB1F61.3090103@acons.at> <56EB34CD.3020900@acons.at> <56EB383B.4080003@acons.at> Message-ID: <56EC6AC1.5030001@acons.at> This was really dumb. My MinGW was just a 32 bit installation, but the stack is version 1.0.4.2 x86_64, so (I guess) the default arch of the project is x86_64. The extra-lib-dirs & extra-libraries were ok, but trhu the filters of stack I could not see that ld ignored the incompatible libraries. So it looked (even with --verbose) like the libraries were not found, when in fact they were just incompatible. Now at least this is clarified. Sorry for the noise. Nicu Am 18.03.2016 um 00:05 schrieb Nicu Ionita: > What I don't understand is why the stack message sounds: > > If the library is already installed but in a non-standard location > then you can use the flags > --extra-include-dirs= and --extra-lib-dirs= to specify where it is. > > Why would be an include directory necessary, if I only miss the > library? I understand that the includes are needed to compile the > (generated) C sources, but why needed to link? Or is maybe just a typo > in the stack message? > > Nicu > > Am 17.03.2016 um 23:50 schrieb Nicu Ionita: >> Am 17.03.2016 um 23:24 schrieb Theodore Lief Gannon: >>> > I am on Win 7, using stack (configured for lts-4.2) under MinGW. >>> >>> Stack itself provides MSYS2/MinGW during builds on Windows. Do you >>> mean you have an independent MinGW shell that you're opening, and >>> then running stack from there? >> >> Yes, I work under the git bash (git for Windows comes with an own msys). >> >>> If so, assuming you're not already using this flag, try: >>> >>> stack build --skip-msys >> >> Just tried that now, same result. >>> >>> This tells stack that it's already running inside a unix-style >>> shell, and shouldn't assert its related path overrides. >>> >>> Beyond that, it would help to have more information about exactly >>> where everything is and how it's being built/invoked/etc. >> >> Project is under: >> J:\Projects\BaseOh >> >> Library is under: >> J:\BO\lib >> >> and is called: libbayesopt.a >> >> (under bash they are called /j/Projects/BaseOh and /j/BO/lib, >> needless to say I tried those too, but they are not found, as the >> programs know only Windows style paths). >> >> So beeing under the git bash in the project directory, I type: >> > stack build >> >> or even: >> > stack build --extra-lib-dirs=j:\\BO\\lib >> >> But in both cases, if the line "extra-libraries: bayesopt" is present >> in the cabal file, then configure does not work (message below). >> >> Inbetween I upgraded stack (now is version 1.0.4.2 x86_64). When I >> try to build, I get the message: >> >> Continuing despite missing tool: msys2 >> >> after which the build continues and brings exactly the same failures. >> >>> >>> On Thu, Mar 17, 2016 at 2:19 PM, Nicu Ionita >> > wrote: >>> >>> Hi all, >>> >>> I am really stuck with my try to make a Haskell binding for the >>> library bayesopt on Windows. >>> In theory it looks all simple, just put some lines in the cabal >>> configuration file: >>> >>> ... >>> extra-lib-dirs: /path/to/the/lib -- contains the file >>> libbayesopt.a >>> extra-libraries: bayesopt >>> ... >>> >>> But whatever I tried, I can't step over the configuration phase, >>> coz I get (I'm compiling with stack): >>> >>> Configuring BaseOh-0.1.0.0... >>> setup-Simple-Cabal-1.22.5.0-x86_64-windows-ghc-7.10.3.exe: Missing >>> dependency >>> on a foreign library: >>> * Missing C library: /j/BO/lib/libbayesopt.a >>> This problem can usually be solved by installing the system >>> package that >>> provides this library (you may need the "-dev" version). If the >>> library is >>> already installed but in a non-standard location then you can use >>> the flags >>> --extra-include-dirs= and --extra-lib-dirs= to specify where it is. >>> >>> If I comment those lines out, then the configure phase succeeds, >>> the library is compiled (i.e. my binding library), but a test >>> executable in the same project does of course not compile, as >>> symbols are missing: >>> >>> ... >>> In-place registering BaseOh-0.1.0.0... >>> Preprocessing executable 'test' for BaseOh-0.1.0.0... >>> [1 of 2] Compiling Optimisation.Stochastic.BayesOpt ( >>> src\Optimisation\Stochasti >>> c\BayesOpt.hs, >>> .stack-work\dist\x86_64-windows\Cabal-1.22.5.0\build\test\test-tm >>> p\Optimisation\Stochastic\BayesOpt.o ) >>> ghc.exe: unable to load package `BaseOh-0.1.0.0' >>> ghc.exe: >>> J:\Projects\BaseOh\.stack-work\dist\x86_64-windows\Cabal-1.22.5.0\build >>> \HSBaseOh-0.1.0.0-GdNObdePATgDIW1I2OVwEc.o: unknown symbol >>> `initialize_parameter >>> s_to_default' >>> >>> -- While building package BaseOh-0.1.0.0 using: >>> ... >>> >>> Does somebody have some idea, what is going on? >>> >>> I am on Win 7, using stack (configured for lts-4.2) under MinGW. >>> (I'm using inline-c to make the bindings, and the same trick for >>> include - include-dirs: ... - worked fine.) >>> >>> Thanks, and sorry for the longer email. >>> Nicu >>> _______________________________________________ >>> Haskell-Cafe mailing list >>> Haskell-Cafe at haskell.org >>> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe >>> >>> >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe From mantkiew at gsd.uwaterloo.ca Fri Mar 18 21:40:06 2016 From: mantkiew at gsd.uwaterloo.ca (=?UTF-8?Q?Micha=C5=82_Antkiewicz?=) Date: Fri, 18 Mar 2016 17:40:06 -0400 Subject: [Haskell-cafe] Trying desperately to make a c library binding on Windows - solved! In-Reply-To: <56EC6AC1.5030001@acons.at> References: <56EB1F61.3090103@acons.at> <56EB34CD.3020900@acons.at> <56EB383B.4080003@acons.at> <56EC6AC1.5030001@acons.at> Message-ID: I always use the MSYS/MinGW provided with stack. It has pacman and everything so there's no need to have a custom installation of MSYS (which I used to do before). You can start the shell using the script mingw64_shell.bat located in C:\Users\\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512 Glad it worked out. -- Micha? On Fri, Mar 18, 2016 at 4:53 PM, Nicu Ionita wrote: > This was really dumb. > > My MinGW was just a 32 bit installation, but the stack is version 1.0.4.2 > x86_64, so (I guess) the default arch of the project is x86_64. > > The extra-lib-dirs & extra-libraries were ok, but trhu the filters of stack > I could not see that ld ignored the incompatible libraries. So it looked > (even with --verbose) like the libraries were not found, when in fact they > were just incompatible. > > Now at least this is clarified. > > Sorry for the noise. > > Nicu > > Am 18.03.2016 um 00:05 schrieb Nicu Ionita: >> >> What I don't understand is why the stack message sounds: >> >> If the library is already installed but in a non-standard location then >> you can use the flags >> --extra-include-dirs= and --extra-lib-dirs= to specify where it is. >> >> Why would be an include directory necessary, if I only miss the library? I >> understand that the includes are needed to compile the (generated) C >> sources, but why needed to link? Or is maybe just a typo in the stack >> message? >> >> Nicu >> >> Am 17.03.2016 um 23:50 schrieb Nicu Ionita: >>> >>> Am 17.03.2016 um 23:24 schrieb Theodore Lief Gannon: >>>> >>>> > I am on Win 7, using stack (configured for lts-4.2) under MinGW. >>>> >>>> Stack itself provides MSYS2/MinGW during builds on Windows. Do you mean >>>> you have an independent MinGW shell that you're opening, and then running >>>> stack from there? >>> >>> >>> Yes, I work under the git bash (git for Windows comes with an own msys). >>> >>>> If so, assuming you're not already using this flag, try: >>>> >>>> stack build --skip-msys >>> >>> >>> Just tried that now, same result. >>>> >>>> >>>> This tells stack that it's already running inside a unix-style shell, >>>> and shouldn't assert its related path overrides. >>>> >>>> Beyond that, it would help to have more information about exactly where >>>> everything is and how it's being built/invoked/etc. >>> >>> >>> Project is under: >>> J:\Projects\BaseOh >>> >>> Library is under: >>> J:\BO\lib >>> >>> and is called: libbayesopt.a >>> >>> (under bash they are called /j/Projects/BaseOh and /j/BO/lib, needless to >>> say I tried those too, but they are not found, as the programs know only >>> Windows style paths). >>> >>> So beeing under the git bash in the project directory, I type: >>> > stack build >>> >>> or even: >>> > stack build --extra-lib-dirs=j:\\BO\\lib >>> >>> But in both cases, if the line "extra-libraries: bayesopt" is present in >>> the cabal file, then configure does not work (message below). >>> >>> Inbetween I upgraded stack (now is version 1.0.4.2 x86_64). When I try to >>> build, I get the message: >>> >>> Continuing despite missing tool: msys2 >>> >>> after which the build continues and brings exactly the same failures. >>> >>>> >>>> On Thu, Mar 17, 2016 at 2:19 PM, Nicu Ionita >>> > wrote: >>>> >>>> Hi all, >>>> >>>> I am really stuck with my try to make a Haskell binding for the >>>> library bayesopt on Windows. >>>> In theory it looks all simple, just put some lines in the cabal >>>> configuration file: >>>> >>>> ... >>>> extra-lib-dirs: /path/to/the/lib -- contains the file >>>> libbayesopt.a >>>> extra-libraries: bayesopt >>>> ... >>>> >>>> But whatever I tried, I can't step over the configuration phase, >>>> coz I get (I'm compiling with stack): >>>> >>>> Configuring BaseOh-0.1.0.0... >>>> setup-Simple-Cabal-1.22.5.0-x86_64-windows-ghc-7.10.3.exe: Missing >>>> dependency >>>> on a foreign library: >>>> * Missing C library: /j/BO/lib/libbayesopt.a >>>> This problem can usually be solved by installing the system >>>> package that >>>> provides this library (you may need the "-dev" version). If the >>>> library is >>>> already installed but in a non-standard location then you can use >>>> the flags >>>> --extra-include-dirs= and --extra-lib-dirs= to specify where it is. >>>> >>>> If I comment those lines out, then the configure phase succeeds, >>>> the library is compiled (i.e. my binding library), but a test >>>> executable in the same project does of course not compile, as >>>> symbols are missing: >>>> >>>> ... >>>> In-place registering BaseOh-0.1.0.0... >>>> Preprocessing executable 'test' for BaseOh-0.1.0.0... >>>> [1 of 2] Compiling Optimisation.Stochastic.BayesOpt ( >>>> src\Optimisation\Stochasti >>>> c\BayesOpt.hs, >>>> .stack-work\dist\x86_64-windows\Cabal-1.22.5.0\build\test\test-tm >>>> p\Optimisation\Stochastic\BayesOpt.o ) >>>> ghc.exe: unable to load package `BaseOh-0.1.0.0' >>>> ghc.exe: >>>> J:\Projects\BaseOh\.stack-work\dist\x86_64-windows\Cabal-1.22.5.0\build >>>> \HSBaseOh-0.1.0.0-GdNObdePATgDIW1I2OVwEc.o: unknown symbol >>>> `initialize_parameter >>>> s_to_default' >>>> >>>> -- While building package BaseOh-0.1.0.0 using: >>>> ... >>>> >>>> Does somebody have some idea, what is going on? >>>> >>>> I am on Win 7, using stack (configured for lts-4.2) under MinGW. >>>> (I'm using inline-c to make the bindings, and the same trick for >>>> include - include-dirs: ... - worked fine.) >>>> >>>> Thanks, and sorry for the longer email. >>>> Nicu >>>> _______________________________________________ >>>> Haskell-Cafe mailing list >>>> Haskell-Cafe at haskell.org >>>> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe >>>> >>>> >>> >>> _______________________________________________ >>> Haskell-Cafe mailing list >>> Haskell-Cafe at haskell.org >>> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe >> >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe From me at alang.ca Fri Mar 18 21:46:21 2016 From: me at alang.ca (Alex Lang) Date: Fri, 18 Mar 2016 14:46:21 -0700 Subject: [Haskell-cafe] CUFP 2016 Call for Presentations Message-ID: Apologies for any duplicates you may receive. http://cufp.org/2016/call-for-presentations.html ====================================================================== CUFP 2016 Call for Presentations Commercial Users of Functional Programming 2016 Sponsored by SIGPLAN Co-located with ICFP 2016 Nara, Japan September 22-24 Talk Proposal Submission Deadline: 24 June 2016 CUFP 2016 Presentation Submission Form: http://goo.gl/forms/gWDSoKfizW The annual CUFP event is a place where people can see how others are using functional programming to solve real world problems; where practitioners meet and collaborate; where language designers and users can share ideas about the future of their favorite language; and where one can learn practical techniques and approaches for putting functional programming to work. ====================================================================== Giving a CUFP Talk If you have experience using functional languages in a practical setting, we invite you to submit a proposal to give a talk at the event. We're looking for two kinds of talks: Retrospective talks are typically 25 minutes long. Now that CUFP has run for more than a decade, we intend to invite past speakers to share what they?ve learned after a decade spent as commercial users of functional programming. We will favour experience reports that include technical content. Technical talks are also 25 minutes long, and should focus on teaching the audience something about a particular technique or methodology, from the point of view of someone who has seen it play out in practice. These talks could cover anything from techniques for building functional concurrent applications, to managing dynamic reconfigurations, to design recipes for using types effectively in large-scale applications. While these talks will often be based on a particular language, they should be accessible to a broad range of programmers. We strongly encourage submissions from people in communities that are underrepresented in functional programming, including but not limited to women; people of color; people in gender, sexual and romantic minorities; people with disabilities; people residing in Asia, Africa, or Latin America; and people who have never presented at a conference before. We recognize that inclusion is an important part of our mission to promote functional programming. So that CUFP can be a safe environment in which participants openly exchange ideas, we abide by the SIGPLAN Conference Anti-Harassment Policy ( http://www.sigplan.org/Resources/Policies/Anti-harassment). If you are interested in offering a talk, or nominating someone to do so, please submit your presentation before 24 June 2016 via the CUFP 2016 Presentation Submission Form (http://goo.gl/forms/gWDSoKfizW) You do not need to submit a paper, just a short proposal for your talk. There will be a short scribe's report of the presentations and discussions but not of the details of individual talks, as the meeting is intended to be more of a discussion forum than a technical interchange. Nevertheless, presentations will be recorded and presenters will be expected to sign an ACM copyright release form. Note that we will need all presenters to register for the CUFP workshop and travel to Japan at their own expense. There are some funds available to would-be presenters who require assistance in this respect. ====================================================================== Program Committee Katie Ots (Facebook), co-chair Alex Lang (Tsuru Capital), co-chair R?nar ?li Bjarnason (Verizon Labs) Mark Hibberd (Ambiata) Mirai Ikebuchi (Nagoya University) Paul Khuong (AppNexus) Carin Meier (Cognitect) Kenji Rikitake (Kenji Rikitake Professional Engineer's Office) ====================================================================== More information For more information on CUFP, including videos of presentations from previous years, take a look at the CUFP website at http://cufp.org. Note that presenters, like other attendees, will need to register for the event. Acceptance and rejection letters will be sent out by July 15th. ====================================================================== Guidance on giving a great CUFP talk Focus on the interesting bits: Think about what will distinguish your talk, and what will engage the audience, and focus there. There are a number of places to look for those interesting bits. Setting: FP is pretty well-established in some areas, including formal verification, financial processing, and server-side web services. An unusual setting can be a source of interest. If you're deploying FP-based mobile UIs or building servers on oil rigs, then the challenges of that scenario are worth focusing on. Did FP help or hinder in adapting to the setting? Technology: The CUFP audience is hungry to learn about how FP techniques work in practice. What design patterns have you applied, and to what areas? Did you use functional reactive programming for user interfaces, or DSLs for playing chess, or fault-tolerant actors for large-scale geological data processing? Teach us something about the techniques you used, and why we should consider using them ourselves. Getting things done: How did you deal with large-scale software development in the absence of pre-existing support tools that are often expected in larger commercial environments (IDEs, coverage tools, debuggers, profilers) and without larger, proven bodies of libraries? Did you hit any brick walls that required support from the community? Don't just be a cheerleader: It's easy to write a rah-rah talk about how well FP worked for you, but CUFP is more interesting when the talks also cover what doesn't work. Even when the results were all great, you should spend more time on the challenges along the way than on the parts that went smoothly. -------------- next part -------------- An HTML attachment was scrubbed... URL: From nicu.ionita at acons.at Fri Mar 18 22:17:01 2016 From: nicu.ionita at acons.at (Nicu Ionita) Date: Fri, 18 Mar 2016 23:17:01 +0100 Subject: [Haskell-cafe] Trying desperately to make a c library binding on Windows - solved! In-Reply-To: References: <56EB1F61.3090103@acons.at> <56EB34CD.3020900@acons.at> <56EB383B.4080003@acons.at> <56EC6AC1.5030001@acons.at> Message-ID: <56EC7E5D.3080306@acons.at> Thanks for this information, didn't know it, I will begin to work like this too. Beeing the first time when I try to link to external C libs I guess there will be more to learn anyway :-) Nicu Am 18.03.2016 um 22:40 schrieb Micha? Antkiewicz: > I always use the MSYS/MinGW provided with stack. It has pacman and > everything so there's no need to have a custom installation of MSYS > (which I used to do before). > > You can start the shell using the script > > mingw64_shell.bat > > located in > > C:\Users\\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512 > > Glad it worked out. > -- > Micha? > > > On Fri, Mar 18, 2016 at 4:53 PM, Nicu Ionita wrote: >> This was really dumb. >> >> My MinGW was just a 32 bit installation, but the stack is version 1.0.4.2 >> x86_64, so (I guess) the default arch of the project is x86_64. >> >> The extra-lib-dirs & extra-libraries were ok, but trhu the filters of stack >> I could not see that ld ignored the incompatible libraries. So it looked >> (even with --verbose) like the libraries were not found, when in fact they >> were just incompatible. >> >> Now at least this is clarified. >> >> Sorry for the noise. >> >> Nicu >> >> Am 18.03.2016 um 00:05 schrieb Nicu Ionita: >>> What I don't understand is why the stack message sounds: >>> >>> If the library is already installed but in a non-standard location then >>> you can use the flags >>> --extra-include-dirs= and --extra-lib-dirs= to specify where it is. >>> >>> Why would be an include directory necessary, if I only miss the library? I >>> understand that the includes are needed to compile the (generated) C >>> sources, but why needed to link? Or is maybe just a typo in the stack >>> message? >>> >>> Nicu >>> >>> Am 17.03.2016 um 23:50 schrieb Nicu Ionita: >>>> Am 17.03.2016 um 23:24 schrieb Theodore Lief Gannon: >>>>>> I am on Win 7, using stack (configured for lts-4.2) under MinGW. >>>>> Stack itself provides MSYS2/MinGW during builds on Windows. Do you mean >>>>> you have an independent MinGW shell that you're opening, and then running >>>>> stack from there? >>>> >>>> Yes, I work under the git bash (git for Windows comes with an own msys). >>>> >>>>> If so, assuming you're not already using this flag, try: >>>>> >>>>> stack build --skip-msys >>>> >>>> Just tried that now, same result. >>>>> >>>>> This tells stack that it's already running inside a unix-style shell, >>>>> and shouldn't assert its related path overrides. >>>>> >>>>> Beyond that, it would help to have more information about exactly where >>>>> everything is and how it's being built/invoked/etc. >>>> >>>> Project is under: >>>> J:\Projects\BaseOh >>>> >>>> Library is under: >>>> J:\BO\lib >>>> >>>> and is called: libbayesopt.a >>>> >>>> (under bash they are called /j/Projects/BaseOh and /j/BO/lib, needless to >>>> say I tried those too, but they are not found, as the programs know only >>>> Windows style paths). >>>> >>>> So beeing under the git bash in the project directory, I type: >>>>> stack build >>>> or even: >>>>> stack build --extra-lib-dirs=j:\\BO\\lib >>>> But in both cases, if the line "extra-libraries: bayesopt" is present in >>>> the cabal file, then configure does not work (message below). >>>> >>>> Inbetween I upgraded stack (now is version 1.0.4.2 x86_64). When I try to >>>> build, I get the message: >>>> >>>> Continuing despite missing tool: msys2 >>>> >>>> after which the build continues and brings exactly the same failures. >>>> >>>>> On Thu, Mar 17, 2016 at 2:19 PM, Nicu Ionita >>>> > wrote: >>>>> >>>>> Hi all, >>>>> >>>>> I am really stuck with my try to make a Haskell binding for the >>>>> library bayesopt on Windows. >>>>> In theory it looks all simple, just put some lines in the cabal >>>>> configuration file: >>>>> >>>>> ... >>>>> extra-lib-dirs: /path/to/the/lib -- contains the file >>>>> libbayesopt.a >>>>> extra-libraries: bayesopt >>>>> ... >>>>> >>>>> But whatever I tried, I can't step over the configuration phase, >>>>> coz I get (I'm compiling with stack): >>>>> >>>>> Configuring BaseOh-0.1.0.0... >>>>> setup-Simple-Cabal-1.22.5.0-x86_64-windows-ghc-7.10.3.exe: Missing >>>>> dependency >>>>> on a foreign library: >>>>> * Missing C library: /j/BO/lib/libbayesopt.a >>>>> This problem can usually be solved by installing the system >>>>> package that >>>>> provides this library (you may need the "-dev" version). If the >>>>> library is >>>>> already installed but in a non-standard location then you can use >>>>> the flags >>>>> --extra-include-dirs= and --extra-lib-dirs= to specify where it is. >>>>> >>>>> If I comment those lines out, then the configure phase succeeds, >>>>> the library is compiled (i.e. my binding library), but a test >>>>> executable in the same project does of course not compile, as >>>>> symbols are missing: >>>>> >>>>> ... >>>>> In-place registering BaseOh-0.1.0.0... >>>>> Preprocessing executable 'test' for BaseOh-0.1.0.0... >>>>> [1 of 2] Compiling Optimisation.Stochastic.BayesOpt ( >>>>> src\Optimisation\Stochasti >>>>> c\BayesOpt.hs, >>>>> .stack-work\dist\x86_64-windows\Cabal-1.22.5.0\build\test\test-tm >>>>> p\Optimisation\Stochastic\BayesOpt.o ) >>>>> ghc.exe: unable to load package `BaseOh-0.1.0.0' >>>>> ghc.exe: >>>>> J:\Projects\BaseOh\.stack-work\dist\x86_64-windows\Cabal-1.22.5.0\build >>>>> \HSBaseOh-0.1.0.0-GdNObdePATgDIW1I2OVwEc.o: unknown symbol >>>>> `initialize_parameter >>>>> s_to_default' >>>>> >>>>> -- While building package BaseOh-0.1.0.0 using: >>>>> ... >>>>> >>>>> Does somebody have some idea, what is going on? >>>>> >>>>> I am on Win 7, using stack (configured for lts-4.2) under MinGW. >>>>> (I'm using inline-c to make the bindings, and the same trick for >>>>> include - include-dirs: ... - worked fine.) >>>>> >>>>> Thanks, and sorry for the longer email. >>>>> Nicu >>>>> _______________________________________________ >>>>> Haskell-Cafe mailing list >>>>> Haskell-Cafe at haskell.org >>>>> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe >>>>> >>>>> >>>> _______________________________________________ >>>> Haskell-Cafe mailing list >>>> Haskell-Cafe at haskell.org >>>> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe >>> >>> _______________________________________________ >>> Haskell-Cafe mailing list >>> Haskell-Cafe at haskell.org >>> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe From targen at gmail.com Fri Mar 18 23:30:37 2016 From: targen at gmail.com (=?UTF-8?Q?Manuel_G=C3=B3mez?=) Date: Fri, 18 Mar 2016 19:00:37 -0430 Subject: [Haskell-cafe] Odd list comprehension behaviour In-Reply-To: <9e45922f-23ed-a3e6-e2bc-6d35aca913bb@cs.otago.ac.nz> References: <20160317032634.GA1494@casa.casa> <9e45922f-23ed-a3e6-e2bc-6d35aca913bb@cs.otago.ac.nz> Message-ID: On Thu, Mar 17, 2016 at 6:47 PM, Richard A. O'Keefe wrote: > Let me rephrase that. To me, that "if it does actually get to c" bit is > NOT a consequence of my understanding of the general rules for > enumeration in Haskell, they are a complicating ADDITION to those rules > just for a case that I would be very upset to see happening in code of mine. Indeed! I agree completely that this is not consistent with the current rules in Haskell, and I agree completely that this is a complicating addition to those rules that is in no way derived from the way things currently work or from some clear greater principle. > I mean, this is an *extremely* special case. [1.0,1.0..x] :: [Double > is an infinite list for ALL x >= 1.0 in Haskell; you want to change this > to be [1.0] if x happens to be the very special case 1.0, and I do > not understand why. Why is [1.0,1.0..1.0+epsilon] being infinite, > [1.0,1.0,..1.0-epsilon] being empty, but [1.0,1.0..1.0] having one > element USEFUL? (And while you are at it, explain your reasoning > for [x,x..negate x] when x is 0.0.) To be clear: I?m not proposing this, I?m just exploring how such a rule may be specified. Although my current intuition agrees with the original post?s stated intuition in that I was surprised to find [1,1..1] is not finite, I personally don?t think it?s necessarily better to have an intuitive rule: I generally favor rules that are simple to state and reason about, rather than rules that produce superficially intuitive results at the expense of special cases and conceptual complexity ? and I certainly hope saying that does not derail this conversation into other recent discussions with similar tradeoffs. ;-) If I were to propose this, which I?m not, I would discuss what the [a,b..c] notation is meant to represent. To me, personally and for no good reason, it looks like an iterator that yields numbers starting at a, adding (b-a) at each step and yielding the next number as long as it?s less than or equal to c, and continuing as long as c is neither reached nor exceeded. I make no claim on the universality of this interpretation or the naturality of its deduction as a result of some prior notational intuition, and I likewise make no claim about the adequacy of this intuition as the foundation for the rules in Haskell. In any case, I would personally never find it reasonable for a proposal to suggest changing the rules Haskell uses to assign meaning to this notation, unless there was very wide community consensus and interest in such a change, which I find doubtful as it?s such a minor detail. I would prefer to see this turn into, say, a very short note in the documentation pointing out this curiosity that may be inconsistent with the intuitive expectations of some of us. >> [6,6..6] would have the initial 6, and then it should have no other >> element beyond 6, so it should in fact equal [6] under this intuition. > > But [6,6,6,6,6,6,6,6,6,6,6....] ALSO has no other element beyond 6. > "Not going beyond 6" is one thing, "stopping exactly at 6" is another. I misspoke again, indeed! I should have said ?it should have no other element beyond the first 6?. Note I also purposely avoided cases with b < a and c < a, as those confuse me even further, and I have no opinion or solid intuition about them. From barak at pearlmutter.net Sat Mar 19 14:05:48 2016 From: barak at pearlmutter.net (Barak A. Pearlmutter) Date: Sat, 19 Mar 2016 14:05:48 +0000 Subject: [Haskell-cafe] Haskell-Cafe Digest, Vol 151, Issue 22 In-Reply-To: References: Message-ID: > If I were to propose this, which I'm not, I would discuss what the > [a,b..c] notation is meant to represent. To me, personally and for no > good reason, it looks like an iterator that yields numbers starting at > a, adding (b-a) at each step and yielding the next number as long as > it's less than or equal to c, and continuing as long as c is neither > reached nor exceeded. Yes, the current situation is somewhat odd. $ ghci GHCi, version 7.10.3: http://www.haskell.org/ghc/ :? for help Prelude> [0,5..9] [0,5] Prelude> [0,0.5..0.9] [0.0,0.5,1.0] Prelude> [0.0..0.49999999999999991] [0.0] Prelude> [0.0..0.49999999999999992] [0.0,1.0] Prelude> :m Data.Ratio Prelude Data.Ratio> [0..1%2] [0 % 1,1 % 1] This makes the construct into a serious bug generator for anything numeric. For instance, consider a naive numeric integration of the sort one might wish to exhibit while teaching Haskell this past pi day, Monday the fourteenth of March. Prelude> let h=1e-1 in sum $ map (\x -> 4*h*sqrt(1-x^2)) [0,h..1] 3.304518326248318 Prelude> let h=1e-2 in sum $ map (\x -> 4*h*sqrt(1-x^2)) [0,h..1] NaN Prelude> let h=1e-3 in sum $ map (\x -> 4*h*sqrt(1-x^2)) [0,h..1] NaN Prelude> let h=1e-4 in sum $ map (\x -> 4*h*sqrt(1-x^2)) [0,h..1] 3.141791477784753 Prelude> let h=1e-5 in sum $ map (\x -> 4*h*sqrt(1-x^2)) [0,h..1] 3.1416126164824103 Prelude> let h=1e-6 in sum $ map (\x -> 4*h*sqrt(1-x^2)) [0,h..1] NaN One invariant that people seem to find natural regarding [x,y..z] is that its elements are all between x and z (inclusive), regardless of the value of y. This is, in part, because the mathematical notation [x,z] often denotes the closed interval whose endpoints are x and z. I myself cannot think of any advantage of the behaviour exhibited above. To take a slightly deeper violated invariant, it seems like map f [x,y..z] and [f x,f y..f z] should be the same when f is a linear (in the numeric sense) function. The current behaviour violates this. From jkarni at gmail.com Sat Mar 19 15:58:27 2016 From: jkarni at gmail.com (Julian Arni) Date: Sat, 19 Mar 2016 16:58:27 +0100 Subject: [Haskell-cafe] [ANN] servant 0.5 Message-ID: Dear all, We have just released a new major version (0.5) of the official servant packages: - servant - servant-server - servant-client - servant-docs - servant-foreign - servant-js - servant-cassava - servant-blaze - servant-lucid - servant-mock (servant-js and servant-foreign are being released for the first time. servant-jquery will be deprecated in favour of servant-js) This new version brings quite a number of significant changes. Servant is now faster, more correct, more replete with features, and more consistent. We have a blog post going into more details about the changes: http://haskell-servant.github.io/posts/2016-03-19-servant-0.5-release.html Note also that we have revamped our tutorial, and moved it to readthedocs: http://haskell-servant.readthedocs.org/en/master/ Enjoy the weekend, Julian -------------- next part -------------- An HTML attachment was scrubbed... URL: From tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk Sat Mar 19 23:03:30 2016 From: tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk (Tom Ellis) Date: Sat, 19 Mar 2016 23:03:30 +0000 Subject: [Haskell-cafe] =?utf-8?q?Ambiguous_type_variable_=E2=80=98f0?= =?utf-8?b?4oCZIGFyaXNpbmcgZnJvbSBhIHVzZSBvZiDigJhm4oCZ?= Message-ID: <20160319230330.GX25143@weber> Can anyone explain what happened in GHC 8 such that it forced this change: -data PackMap a b s t = PackMap (Applicative f => (a -> f b) -> s -> f t) +data PackMap a b s t = PackMap (forall f. Applicative f => (a -> f b) -> s -> f t) ... instance PP.SumProfunctor (PackMap a b) where - f +++! g = (PackMap (\x -> eitherFunction (f' x) (g' x))) - where PackMap f' = f - PackMap g' = g + f +++! g = + PackMap (\x -> + case f of + PackMap f' -> + case g of + PackMap g' -> + eitherFunction (f' x) + (g' x)) https://github.com/tomjaguarpaw/haskell-opaleye/pull/140/files The errors are Ambiguous type variable ?f0? arising from a use of ?f? etc., as seen here https://github.com/tomjaguarpaw/haskell-opaleye/pull/140#issuecomment-198297953 Thanks, Tom From mick.francis at lightfootsolutions.com Sun Mar 20 10:50:01 2016 From: mick.francis at lightfootsolutions.com (Mick Francis) Date: Sun, 20 Mar 2016 03:50:01 -0700 (PDT) Subject: [Haskell-cafe] Gaussian Elimination over GF2 Message-ID: Does anyone know of any implementation in Haskell of Gaussian Elimination over GF2? I'm experimenting with congruence-based factoring algorithms, and need an implementation for the Linear Algebra stage. Mick. -------------- next part -------------- An HTML attachment was scrubbed... URL: From eir at cis.upenn.edu Sun Mar 20 18:47:18 2016 From: eir at cis.upenn.edu (Richard Eisenberg) Date: Sun, 20 Mar 2016 14:47:18 -0400 Subject: [Haskell-cafe] =?windows-1252?q?Ambiguous_type_variable_=91f0=92_?= =?windows-1252?q?arising_from_a_use_of_=91f=92?= In-Reply-To: <20160319230330.GX25143@weber> References: <20160319230330.GX25143@weber> Message-ID: <77076C91-5C25-4126-8E7D-33CF0D31EB3E@cis.upenn.edu> GHC 8 does implicit quantification a little differently than previous versions. Previously, writing `=>` in a type meant that GHC looked through the type for free variables and put an implicit `forall` for those variables out front. GHC 8 doesn't do this, explaining the first change. There seems to be no documentation about this (intentional) change; I've filed #11726 requesting documentation. As for the second change, GHC 7.10 should not have accepted the old program, as it was incorrect. The problem is that GHC must infer types for f' and g'. These types are constrained (they have `Applicative f =>`). They have no type signature, nor are they declared using function syntax. Thus, the monomorphism restriction applies, causing chaos. I bet enabling -XNoMonomorphismRestriction would allow you to undo the second change. Another common workaround to the monomorphism restriction is to add a type signature. But this doesn't work in the presence of pattern bindings, which is filed as #11339. I hope this helps! Richard On Mar 19, 2016, at 7:03 PM, Tom Ellis wrote: > Can anyone explain what happened in GHC 8 such that it forced this change: > > -data PackMap a b s t = PackMap (Applicative f => (a -> f b) -> s -> f t) > +data PackMap a b s t = PackMap (forall f. Applicative f => (a -> f b) -> s -> f t) > > ... > > instance PP.SumProfunctor (PackMap a b) where > - f +++! g = (PackMap (\x -> eitherFunction (f' x) (g' x))) > - where PackMap f' = f > - PackMap g' = g > + f +++! g = > + PackMap (\x -> > + case f of > + PackMap f' -> > + case g of > + PackMap g' -> > + eitherFunction (f' x) > + (g' x)) > > https://github.com/tomjaguarpaw/haskell-opaleye/pull/140/files > > The errors are > > Ambiguous type variable ?f0? arising from a use of ?f? > > etc., as seen here > > https://github.com/tomjaguarpaw/haskell-opaleye/pull/140#issuecomment-198297953 > > Thanks, > > Tom > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > From tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk Sun Mar 20 20:33:52 2016 From: tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk (Tom Ellis) Date: Sun, 20 Mar 2016 20:33:52 +0000 Subject: [Haskell-cafe] =?utf-8?q?Ambiguous_type_variable_=E2=80=98f0?= =?utf-8?b?4oCZIGFyaXNpbmcgZnJvbSBhIHVzZSBvZiDigJhm4oCZ?= In-Reply-To: <77076C91-5C25-4126-8E7D-33CF0D31EB3E@cis.upenn.edu> References: <20160319230330.GX25143@weber> <77076C91-5C25-4126-8E7D-33CF0D31EB3E@cis.upenn.edu> Message-ID: <20160320203352.GK4605@weber> Hi Richard, thank you very much for the explanations. On Sun, Mar 20, 2016 at 02:47:18PM -0400, Richard Eisenberg wrote: > GHC 8 does implicit quantification a little differently than previous > versions. Previously, writing `=>` in a type meant that GHC looked > through the type for free variables and put an implicit `forall` for those > variables out front. GHC 8 doesn't do this, explaining the first change. That makes sense, thanks. > As for the second change, GHC 7.10 should not have accepted the old > program, as it was incorrect. The problem is that GHC must infer types > for f' and g'. These types are constrained (they have `Applicative f > =>`). They have no type signature, nor are they declared using function > syntax. Thus, the monomorphism restriction applies, causing chaos. I bet > enabling -XNoMonomorphismRestriction would allow you to undo the second > change. According to Travis the old program compiled on 7.8 and 7.10. It certainly compiled on 7.6 on my local machine. When was the change that made it break introduced (and what was that change exactly)? Tom From eir at cis.upenn.edu Sun Mar 20 21:36:42 2016 From: eir at cis.upenn.edu (Richard Eisenberg) Date: Sun, 20 Mar 2016 17:36:42 -0400 Subject: [Haskell-cafe] =?windows-1252?q?Ambiguous_type_variable_=91f0=92_?= =?windows-1252?q?arising_from_a_use_of_=91f=92?= In-Reply-To: <20160320203352.GK4605@weber> References: <20160319230330.GX25143@weber> <77076C91-5C25-4126-8E7D-33CF0D31EB3E@cis.upenn.edu> <20160320203352.GK4605@weber> Message-ID: <5D4006DF-581F-45AF-8D46-899B86D0DA57@cis.upenn.edu> On Mar 20, 2016, at 4:33 PM, Tom Ellis wrote: > According to Travis the old program compiled on 7.8 and 7.10. It certainly > compiled on 7.6 on my local machine. When was the change that made it break > introduced (and what was that change exactly)? The change was for 8.0, as part of the redesign of part of the typechecker to support TypeApplications. The change in behavior that you're seeing here was not intentional, but was just a side effect of the redesign. It was originally reported as a regression, but I'm pretty sure that your original program should have been rejected, according to my understanding of how the monomorphism restriction works. Richard From tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk Sun Mar 20 21:38:04 2016 From: tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk (Tom Ellis) Date: Sun, 20 Mar 2016 21:38:04 +0000 Subject: [Haskell-cafe] =?utf-8?q?Ambiguous_type_variable_=E2=80=98f0?= =?utf-8?b?4oCZIGFyaXNpbmcgZnJvbSBhIHVzZSBvZiDigJhm4oCZ?= In-Reply-To: <5D4006DF-581F-45AF-8D46-899B86D0DA57@cis.upenn.edu> References: <20160319230330.GX25143@weber> <77076C91-5C25-4126-8E7D-33CF0D31EB3E@cis.upenn.edu> <20160320203352.GK4605@weber> <5D4006DF-581F-45AF-8D46-899B86D0DA57@cis.upenn.edu> Message-ID: <20160320213804.GA6696@weber> On Sun, Mar 20, 2016 at 05:36:42PM -0400, Richard Eisenberg wrote: > On Mar 20, 2016, at 4:33 PM, Tom Ellis wrote: > > According to Travis the old program compiled on 7.8 and 7.10. It certainly > > compiled on 7.6 on my local machine. When was the change that made it break > > introduced (and what was that change exactly)? > > The change was for 8.0, as part of the redesign of part of the typechecker > to support TypeApplications. The change in behavior that you're seeing > here was not intentional, but was just a side effect of the redesign. It > was originally reported as a regression, but I'm pretty sure that your > original program should have been rejected, according to my understanding > of how the monomorphism restriction works. Oh, so you're saying it used to work by accident? From eir at cis.upenn.edu Sun Mar 20 21:39:26 2016 From: eir at cis.upenn.edu (Richard Eisenberg) Date: Sun, 20 Mar 2016 17:39:26 -0400 Subject: [Haskell-cafe] =?windows-1252?q?Ambiguous_type_variable_=91f0=92_?= =?windows-1252?q?arising_from_a_use_of_=91f=92?= In-Reply-To: <20160320213804.GA6696@weber> References: <20160319230330.GX25143@weber> <77076C91-5C25-4126-8E7D-33CF0D31EB3E@cis.upenn.edu> <20160320203352.GK4605@weber> <5D4006DF-581F-45AF-8D46-899B86D0DA57@cis.upenn.edu> <20160320213804.GA6696@weber> Message-ID: On Mar 20, 2016, at 5:38 PM, Tom Ellis wrote: > Oh, so you're saying it used to work by accident? Yes, exactly. And it was fixed by accident, too. But the new behavior seems to me to be more consistent with the documentation than the old behavior. From ok at cs.otago.ac.nz Mon Mar 21 00:22:20 2016 From: ok at cs.otago.ac.nz (Richard A. O'Keefe) Date: Mon, 21 Mar 2016 13:22:20 +1300 Subject: [Haskell-cafe] Odd list comprehension behaviour In-Reply-To: References: <20160317032634.GA1494@casa.casa> <9e45922f-23ed-a3e6-e2bc-6d35aca913bb@cs.otago.ac.nz> Message-ID: <396f5381-64ec-0b48-3ddb-889c7b371c31@cs.otago.ac.nz> Arithmetic progressions make *sense* for anything that has "+", whether or not it also has "<". For my Smalltalk system, I ended up with a GenericInterval class with a creation method new: size from: start by: delta. With *that* interface, a delta of zero is perfectly harmless. GenericInterval new: 4 from: 6 by: 0 is (6 6 6 6) and of course GenericInterval new: 1 from: 6 by: 0 is (6) because the new: argument *says* there is to be 1 element. I understand why class Enum doesn't have this kind of interface. Basically, we want to compute [delta*n + start | n <- [0..size-1]] where in cases like duration*n+timestamp delta and start are not the same type. But let's face it, all that means is that if we want this kind of thing, all we have to do is roll our own arithmetic progression functions. Enum has other problems, like its coupling to Int. I find it odd that [1%1,9%8..2%1] works usefully even though fromEnum (1%1) == fromEnum (9%8) == 1. Sensible, just odd. From nadine.and.henry at pobox.com Mon Mar 21 02:40:02 2016 From: nadine.and.henry at pobox.com (Henry Laxen) Date: Mon, 21 Mar 2016 02:40:02 +0000 (UTC) Subject: [Haskell-cafe] Using rebox2 (emacs) with Haskell Message-ID: If any of you have tried using rebox2 with haskell, you've discovered that it does not have a built in Haskell comment mode. I was looking for something like this: ------------------------------------- -- You can put a nice comment here -- -- and surround with a pretty box -- ------------------------------------- Actually, it is easy to set this up with a few lines in your .emacs file. Here is what you need: (require 'rebox2) (add-to-list 'rebox-language-character-alist '(7 . "-")) (setq rebox-style-loop '(725)) (rebox-register-all-templates) (add-hook 'haskell-mode-hook 'rebox-mode) Then just type Meta-q if you want to refill the comment, and Meta-Q if you don't want to refill. I hope this is helpful. Best wishes, Henry Laxen From eir at cis.upenn.edu Mon Mar 21 21:42:27 2016 From: eir at cis.upenn.edu (Richard Eisenberg) Date: Mon, 21 Mar 2016 17:42:27 -0400 Subject: [Haskell-cafe] Stuck on a type family problem where kind inference fails In-Reply-To: References: <45E0231D-8895-42F5-A0C9-97EA2C8395A7@cis.upenn.edu> <7A1B5B01-C31D-4F2D-B161-1C8B72F55A6A@cis.upenn.edu> Message-ID: On Mar 18, 2016, at 11:37 AM, Oliver Charles wrote: > Fascinating! The mentions of bidirectional type checking remind me of this recent paper - Sound and Complete Bidirectional Typechecking for Higher-Rank Polymorphism and Indexed Types - is this similar to what would be required in GHC? The suffix of "for higher-rank polymorphism" makes me wonder if this doesn't require solving impredicativity, as that seems like a massive can of worms. The Dunfield/Krishnaswami papers have a key detail that makes them fall short of what we need in GHC: let-generalization. The type system in that paper is, if my understanding is correct, not an extension of Hindley-Milner. When I say bidirectional typechecking here, I mean something like the "Practical Type Inference for Higher-Rank Types" paper or my recent "Visible Type Application" paper. I hope this helps! Richard > > I'll read the conclusion of your paper again to see if I can learn more about that wrt GHC 8. I'd love to donate some engineering resources, but I have a feeling this might all be a little over my head. > > Anyway, thanks for the discussion - it's been very interesting, even if the outcome is perhaps slightly disappointing in the immediate. Of course, there are other approaches I can take if I add a few more limitations, such as only working for one specific ordering of "features" (e.g., columns of kind (Column (Null (Default k)))), and that's what I've switched over to for now. > > - Ollie > > On Fri, Mar 18, 2016 at 3:28 PM Richard Eisenberg wrote: > Well, the issue as reported is now fixed (validating soon; barring disaster, will push today). > > But it doesn't fully solve the problem because my fix allows you to declare a higher-kinded type family but not to write higher-kinded type family equations. To do this requires proper bidirectional type-checking in types. GHC 8 actually has some degree of bidirectional type-checking in types, but not quite enough to pull this off. No real barriers here, just engineering time that I don't currently have. However, even if we had all the bidirectional type-checking and the ability to define higher-kinded type family equations, it *still* wouldn't work for you because the defunctionalization trick would fail. Defunctionalizing a higher-kinded type family requires impredicativity. (Think of the instantiation of the kind variables on the Apply function.) I'm not going to touch type-level impredicativity until term-level impredicativity is all sorted, and that is far from happening. > > The silver lining here is that I have an approach to unsaturated type functions (summarized in the conclusion to my paper about promoting functions to type families that describes the defunctionalization trick) in mind that will obviate the need for defunctionalization. My guess is that unsaturated type functions will be available before impredicativity, but I can't be sure. > > So, unbeknownst to you, your example requires a fair bit of research to be done before it can be written, in Haskell at least. > > Richard > > On Mar 18, 2016, at 10:26 AM, Richard Eisenberg wrote: > >> Perhaps. On further consideration, this problem may not be as hard as I thought. I may get a chance to look into it today. >> >> On Mar 17, 2016, at 8:40 PM, Oliver Charles wrote: >> >>> I have just found https://ghc.haskell.org/trac/ghc/ticket/11635 - is that perhaps the same thing? >>> >>> On Thu, Mar 17, 2016 at 8:29 PM Oliver Charles wrote: >>> Rats. Shall I open something in Trac? >>> >>> >>> On Thu, 17 Mar 2016 8:26 pm Richard Eisenberg, wrote: >>> Bah. I've just tried to mock something up, but GHC 8 doesn't support higher-rank kinds in type families. They work fine in datatypes and classes, but not in type families. I know exactly why this is failing, and I'm pretty sure I know how to fix it, but it's certainly not going to make it for GHC 8 -- there's a significant engineering hurdle before we can allow type family arguments' kinds to be fancy. >>> >>> Sorry to disappoint here. Perhaps there's a way to work around the problem, maybe by burying the higher-rank kind under a newtype or some similar trick. >>> >>> Just to show what I tried: >>> >>>> import Data.Kind >>>> >>>> data TyFun :: * -> * -> * >>>> type a ~> b = TyFun a b -> * >>>> >>>> type family (f :: a ~> b) @@ (x :: a) :: b >>> >>>> >>>> data Null a = Nullable a | NotNullable a >>>> >>> >>>> type family ((f :: b ~> c) ? (g :: a ~> b)) (x :: a) :: c where >>>> (f ? g) x = f @@ (g @@ x) >>>> >>>> type family BaseType (k :: forall a. a ~> Type) (x :: b) :: Type where -- this fails :( >>>> -- BaseType k x = (@@) k x >>> >>> (By the way, Type and * are synonyms in GHC 8. There's no rhyme nor reason for why I used both in this example.) >>> >>> Richard >>> >>> On Mar 17, 2016, at 4:12 PM, Oliver Charles wrote: >>> >>>> Your term level stuff is exactly what I got to - a need for rank-2 type.. Err, kinds! I was trying to do that within a class but gave up on GHC 7. Great to hear GHC 8 will get me there, is there anything I can look at in the mean time? I don't need singletons entirely, so I'm happy to reimplement small parts. >>>> >>>> - Ollie >>>> >>>> >>>> On Thu, 17 Mar 2016 7:05 pm Richard Eisenberg, wrote: >>>> Interesting use case! >>>> >>>> You need a higher-rank kind. >>>> >>>> All the typey stuff is getting in the way of understanding. I've implemented what you want at the term level: >>>> >>>> >>>>> data Null a = Nullable a | NotNullable a >>>>> >>>> >>>>> notNullableType :: (forall a. a -> Type) -> Null a -> Type >>>> >>>>> notNullableType k (NotNullable a) = baseType k a >>>>> >>>> >>>>> nullableType :: (forall a. a -> Type) -> Null a -> Type >>>> >>>>> nullableType k (Nullable a) = baseType (k . Nullable) a >>>>> >>>> >>>>> baseType :: (forall a. a -> Type) -> forall b. b -> Type >>>> >>>>> baseType k a = k a >>>>> >>>> >>>>> exprTyFun :: Null b -> (forall a. a -> Type) -> Null b -> Type >>>>> exprTyFun (NotNullable _) = notNullableType >>>>> exprTyFun (Nullable _) = nullableType >>>> >>>> >>>> It's critical that notNullableType and nullableType have the same type, which is achievable only with higher-rank types. >>>> >>>> Happily, GHC 8.0 comes equipped with higher-rank kinds. `singletons` doesn't yet build on 8.0, but it will in the future, for a sufficiently expansive definition of future. Christiaan Baaij is working on this, but I've been all-consumed by getting GHC 8 out and haven't given Christiaan's contributions the attention they deserve. So: all in good time! >>>> >>>> I hope this answers your question. >>>> >>>> Richard >>>> >>>> On Mar 17, 2016, at 8:46 AM, Oliver Charles wrote: >>>> >>>>> Hi all, >>>>> >>>>> This is a little tricky to explain, so bear with me. I'm working on some code that roughly models a PostgreSQL schema. Users begin by defining their tables as Haskell records, parametrized over some f :: k -> *, and use a special Col type family that applies some normalisation: >>>>> >>>>> data Table f = Table { tableId :: Col f ('NotNullable 'DBInt) >>>>> , tableX :: Col f ('Nullable 'DBString) } >>>>> >>>>> is one such example. >>>>> >>>>> The idea behind Col is that sometimes we don't need information about the "full type" when we know more about f. >>>>> >>>>> One such choice of f is Expr, which corresponds to expressions inside a query. In this case, I would desire >>>>> >>>>> tableId :: Col Expr ('NotNullable 'DBInt) = tableId :: Expr 'DBInt >>>>> tableX :: Col Expr ('Nullable 'DBString) = tableX :: Expr ('Nullable 'DBString) >>>>> >>>>> Notice here that if you use 'NotNullable, then this information is erased - but it's important if the column is 'Nullable. >>>>> >>>>> However, I'm struggling to work out any way to actually pull this off in the general case. Here's what I've been attempting: >>>>> >>>>> {-# LANGUAGE FunctionalDependencies #-} >>>>> {-# LANGUAGE FlexibleInstances #-} >>>>> {-# LANGUAGE RankNTypes #-} >>>>> {-# LANGUAGE MultiParamTypeClasses #-} >>>>> {-# LANGUAGE DataKinds #-} >>>>> {-# LANGUAGE TypeOperators #-} >>>>> {-# LANGUAGE TypeFamilies #-} >>>>> {-# LANGUAGE KindSignatures #-} >>>>> {-# LANGUAGE PolyKinds #-} >>>>> {-# LANGUAGE TemplateHaskell #-} >>>>> {-# LANGUAGE GADTs #-} >>>>> {-# LANGUAGE UndecidableInstances #-} >>>>> {-# LANGUAGE ScopedTypeVariables #-} >>>>> >>>>> module ExprTest where >>>>> >>>>> import Data.Singletons >>>>> import Data.Singletons.Prelude hiding (Null) >>>>> import Data.Singletons.TH >>>>> >>>>> data Expr (a :: k) >>>>> >>>>> data MyExprSym :: TyFun k * -> * >>>>> type instance Apply MyExprSym (x :: k) = Expr x >>>>> >>>>> $(singletons [d| >>>>> data Null a = Nullable a | NotNullable a >>>>> |]) >>>>> >>>>> $(promote [d| >>>>> notNullableType k (NotNullable a) = baseType k a >>>>> nullableType k (Nullable a) = baseType (k . Nullable) a >>>>> baseType k a = k a >>>>> |]) >>>>> >>>>> So far, this seems to work well. If I ask GHCI: >>>>> >>>>> *ExprTest> :kind! Apply (Apply NullableTypeSym0 MyExprSym) ('Nullable 'DBString) >>>>> Apply (Apply NullableTypeSym0 MyExprSym) ('Nullable 'DBString) :: * >>>>> = Expr ('Nullable 'DBString) >>>>> >>>>> *ExprTest> :kind! Apply (Apply NotNullableTypeSym0 MyExprSym) ('NotNullable 'DBInt) >>>>> Apply (Apply NotNullableTypeSym0 MyExprSym) ('NotNullable 'DBInt) :: * >>>>> = Expr 'DBInt >>>>> >>>>> This is exactly what I want, but note that I had to choose the necessary symbols NullableTypeSym0 and NotNullableTypeSym0. I would like to calculate those symbols from the column type itself. Looking at the kinds of these symbols though, they are both different: >>>>> >>>>> *ExprTest> :kind! NotNullableTypeSym0 >>>>> NotNullableTypeSym0 :: TyFun >>>>> (TyFun k1 k -> *) (TyFun (Null k1) k -> *) >>>>> -> * >>>>> = NotNullableTypeSym0 >>>>> *ExprTest> :kind! NullableTypeSym0 >>>>> NullableTypeSym0 :: TyFun >>>>> (TyFun (Null k1) k -> *) (TyFun (Null k1) k -> *) >>>>> -> * >>>>> = NullableTypeSym0 >>>>> >>>>> So I can't see a way to write a single type family that returns them. >>>>> >>>>> >>>>> To summarise, I'd like a way to write this following instance for Col: >>>>> >>>>> type instance Col Expr x = Apply (Apply ?? MyExprSym) x >>>>> >>>>> such that >>>>> >>>>> Col Expr ('Nullable a) = Expr ('Nullable a') and >>>>> Col Expr ('NotNullable a) = Expr a >>>>> >>>>> but I cannot work out how to write the placeholder ?? above. >>>>> >>>>> One attempt is >>>>> >>>>> type family ExprTyfun (col :: colK) :: TyFun (TyFun k * -> *) (TyFun j * -> *) -> * >>>>> type instance ExprTyfun ('NotNullable a) = NotNullableTypeSym0 >>>>> type instance ExprTyfun ('Nullable a) = NullableTypeSym0 >>>>> >>>>> But neither of these instances actually normalise as I'd like, presumably because of k and j being forall'd in the return type: >>>>> >>>>> *ExprTest> :set -fprint-explicit-kinds >>>>> >>>>> >>>>> *ExprTest> :kind! ExprTyfun ('Nullable 'DBInt) >>>>> ExprTyfun ('Nullable 'DBInt) :: TyFun >>>>> (TyFun k * -> *) (TyFun k1 * -> *) >>>>> -> * >>>>> = ExprTyfun k k1 (Null DBType) ('Nullable DBType 'DBInt) >>>>> >>>>> >>>>> *ExprTest> :kind! ExprTyfun ('NotNullable 'DBInt) >>>>> ExprTyfun ('NotNullable 'DBInt) :: TyFun >>>>> (TyFun k * -> *) (TyFun k1 * -> *) >>>>> -> * >>>>> = ExprTyfun k k1 (Null DBType) ('NotNullable DBType 'DBInt) >>>>> >>>>> >>>>> *ExprTest> :i ExprTyfun >>>>> type family ExprTyfun (k :: BOX) >>>>> (j :: BOX) >>>>> (colK :: BOX) >>>>> (col :: colK) :: >>>>> TyFun (TyFun k * -> *) (TyFun j * -> *) -> * >>>>> -- Defined at src/Opaleye/TF/ExprTest.hs:39:1 >>>>> type instance ExprTyfun >>>>> (Null k) (Null k) (Null k1) ('Nullable k1 a) >>>>> = NullableTypeSym0 * k >>>>> -- Defined at src/Opaleye/TF/ExprTest.hs:41:1 >>>>> type instance ExprTyfun k (Null k) (Null k1) ('NotNullable k1 a) >>>>> = NotNullableTypeSym0 * k >>>>> -- Defined at src/Opaleye/TF/ExprTest.hs:40:1 >>>>> >>>>> >>>>> I'd also like to point out that in my full code the types to Col can be a lot bigger, and I'd like to not assume any ordering. For example, here's a possible type: >>>>> >>>>> userId :: Col f ('Column "id" ('NotNullable ('HasDefault 'DBInt))) >>>>> >>>>> In this case Col Expr ('Column "id" ('NotNullable ('HasDefault 'DBInt))) = Expr 'DBInt >>>>> >>>>> I hope this question is understandable! Please let me know if there's anything I can do to provide more clarity. >>>>> >>>>> - Ollie >>>> >>>>> _______________________________________________ >>>>> Haskell-Cafe mailing list >>>>> Haskell-Cafe at haskell.org >>>>> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe >>>> >>> >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From P.Achten at cs.ru.nl Tue Mar 22 13:25:18 2016 From: P.Achten at cs.ru.nl (Peter Achten) Date: Tue, 22 Mar 2016 14:25:18 +0100 Subject: [Haskell-cafe] [TFPIE 2016] 2nd call for papers Message-ID: <56F147BE.6050707@cs.ru.nl> Trends in Functional Programming in Education (TFPIE 2016) 2nd Call for papers https://wiki.science.ru.nl/tfpie/TFPIE2016 The 5th International Workshop on Trends in Functional Programming in Education, TFPIE 2016, will be held on June 7, 2016 at the University of Maryland College Park in the USA. It is co-located with the Symposium on Trends in Functional Programming (TFP 2016) which takes place from June 8 - 10. *** Goal *** The goal of TFPIE is to gather researchers, teachers and professionals that use, or are interested in the use of, functional programming in education. TFPIE aims to be a venue where novel ideas, classroom-tested ideas and work-in-progress on the use of functional programming in education are discussed. The one-day workshop will foster a spirit of open discussion by having a review process for publication after the workshop. The program chair of TFPIE 2016 will screen submissions to ensure that all presentations are within scope and are of interest to participants. Potential presenters are invited to submit an extended abstract (4-6 pages) or a draft paper (up to 16 pages) in EPTCS style. The authors of accepted presentations will have their preprints and their slides made available on the workshop's website/wiki. Visitors to the TFPIE 2016 website/wiki will be able to add comments. This includes presenters who may respond to comments and questions as well as provide pointers to improvements and follow-up work. After the workshop, presenters will be invited to submit (a revised version of) their article for review. The PC will select the best articles for publication in the journal Electronic Proceedings in Theoretical Computer Science (EPTCS). Articles rejected for presentation and extended abstracts will not be formally reviewed by the PC. TFPIE workshops have previously been held in St Andrews, Scotland (2012), Provo Utah, USA (2013), Soesterberg, The Netherlands (2014), and Sophia-Antipolis, France (2015). *** Program Committee *** Stephen Chang at Northeastern University in Massachusetts, USA Marc Feeley at Universit? de Montr?al in Qu?bec, Canada Patricia Johann at Appalachian State University in North Carolina, USA Jay McCarthy at University of Massachusetts Lowell in Massachusetts, USA (Chair) Prabhakar Ragde at University of Waterloo in Ontario, Canada Brent Yorgey at Hendrix College in Arkansas, USA *** Submission Guidelines *** TFPIE 2016 welcomes submissions describing techniques used in the classroom, tools used in and/or developed for the classroom and any creative use of functional programming (FP) to aid education in or outside Computer Science. Topics of interest include, but are not limited to: - FP and beginning CS students - FP and Computational Thinking - FP and Artificial Intelligence - FP in Robotics - FP and Music - Advanced FP for undergraduates - Tools supporting learning FP - FP in graduate education - Engaging students in research using FP - FP in Programming Languages - FP in the high school curriculum - FP as a stepping stone to other CS topics - FP and Philosophy *** Best Lectures *** In addition to papers, we request "best lecture" presentations. What is your best lecture topic in an FP related course? Do you have a fun way to present FP concepts to novices or perhaps an especially interesting presentation of a difficult topic? In either case, please consider sharing it. Best lecture topics will be selected for presentation based on a short abstract describing the lecture and its interest to TFPIE attendees. *** Submission *** Papers and abstracts can be submitted via EasyChair at the following link: https://easychair.org/conferences/?conf=tfpie2016 It is expected at at least one author for each submitted paper will attend the workshop. *** Registration & Local Information *** Please see the TFP site for registration and local information: http://tfp2016.org/ *** Important Dates *** April 27, 2016: Submission deadline for draft TFPIE papers and abstracts May 3, 2016: Notification of acceptance for presentation May 13, 2016: Registration for TFP/TFPIE closes June 7, 2016: Presentations in Maryland, USA July 7, 2016: Full papers for EPTCS proceedings due. September 1, 2016: Notification of acceptance for proceedings September 22, 2016: Camera ready copy due for EPTCS Submission of an abstract implies no obligation to submit a full version; abstracts with no corresponding full versions by the full paper deadline will be considered as withdrawn. From M.W.Wang at kent.ac.uk Tue Mar 22 22:11:10 2016 From: M.W.Wang at kent.ac.uk (Meng Wang) Date: Tue, 22 Mar 2016 22:11:10 +0000 Subject: [Haskell-cafe] Haskell-related PhD Studentship at Kent In-Reply-To: <75B07F0E-F6BB-4855-A8F1-65A22BF1B2B2@kent.ac.uk> References: <75B07F0E-F6BB-4855-A8F1-65A22BF1B2B2@kent.ac.uk> Message-ID: <62D48451-395F-47F4-8CD7-B41F07E291CA@kent.ac.uk> Dear Haskellers, I am seeking a PhD student on Haskell-related projects, particularly in the area of bidirectional programming (lenses), property-based testing (QuickCheck) and refactoring. This would be a good opportunity for someone who is interested in applying Haskell ideas to real problems. The student will be part of the Programming Languages and Systems (PLAS) group in the School of Computing at the University of Kent. A major focus within the group is functional programming (FP), where it has had an international reputation for more than twenty five years. The group currently has 12 FTE academic staff, 3 RAs and 15 doctoral students. The funding covers maintenance, EU student fees and research related expenses. But non-EU students are welcome to apply too. For Sep 2016 starting, the application deadline is 8 April 2016. If you are interested, please contact me at m.w.wang at kent.ac.uk. Best wishes, Meng ? Dr Meng Wang School of Computing University of Kent http://www.cs.kent.ac.uk/people/staff/mw516/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From dons00 at gmail.com Wed Mar 23 09:38:43 2016 From: dons00 at gmail.com (Don Stewart) Date: Wed, 23 Mar 2016 09:38:43 +0000 Subject: [Haskell-cafe] Three Haskell dev roles at Standard Chartered Message-ID: Hi all I'm hiring another 3 devs to join Strats at Standard Chartered in London or Singapore. This is a good chance to join a growing, experienced team using Haskell for a wide set of projects in finance. More details in https://donsbot.wordpress.com/2016/03/23/haskell-developer-roles-at-standard-chartered-london-singapore-3/ -- Don -------------- next part -------------- An HTML attachment was scrubbed... URL: From axel.mannhardt at freiheit.com Thu Mar 24 12:15:51 2016 From: axel.mannhardt at freiheit.com (Axel Mannhardt) Date: Thu, 24 Mar 2016 13:15:51 +0100 Subject: [Haskell-cafe] [ANN] task-distribution: simple distribution of new code in a cluster computing setup Message-ID: <1458821751.6062.242.camel@methylbromid> Hello cafe, I am happy to announce task-distribution, a framework written in order to distribute and execute tasks as fast as possible on a large data set. Its accentuation is that it supports distributing new logic to other nodes from within the program itself, thus avoiding both restarting slave node processes and a separated plugin-management infrastructure. An example use case is running continuously changing analytics logic on a given data set stored in HDFS. Avalailable on hackage and github: https://github.com/michaxm/task-distribution Cheers, Axel From rob at mars.org Thu Mar 24 23:38:44 2016 From: rob at mars.org (Rob Leslie) Date: Thu, 24 Mar 2016 16:38:44 -0700 Subject: [Haskell-cafe] Lightweight Unicode normalization library In-Reply-To: References: Message-ID: <1493FB7E-112B-434B-B3F0-5CB9E67E962C@mars.org> I don?t have a good answer, but I thought I?d mention this project which looks interesting and I?m considering using myself: https://github.com/llelf/prose -- Rob Leslie rob at mars.org > On Mar 17, 2016, at 12:59 AM, Harendra Kumar wrote: > > I looked around and found only one package, text-icu which provides unicode normalization operations and a lot more. But text-icu depends on the icu library being installed on the system. We would prefer to avoid dependency on the icu library. > > Is there a lightweight alternative which does not depend on icu? It could be a pure Haskell package or bindings to a lightweight C library where the library is small and shipped with the package itself. > > I wonder if there is a need for unicode normalization operations in GHC code itself? If so how does it handle that? > > I found a lightweight C library (https://github.com/JuliaLang/utf8proc ) for normalization and case folding used by the Julia lang project. If there is no other option I am considering creating bindings to this library. > > Any pointers, thoughts? > > Thanks, > Harendra > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe -------------- next part -------------- An HTML attachment was scrubbed... URL: From hjgtuyl at chello.nl Fri Mar 25 00:31:56 2016 From: hjgtuyl at chello.nl (Henk-Jan van Tuyl) Date: Fri, 25 Mar 2016 01:31:56 +0100 Subject: [Haskell-cafe] Docs pending for a long time, on Hackage Message-ID: L.S., There is no documentation for the most recent version of package wx[0], even though it is on Hackage since December last year. It's Hackage page says: Status Docs pending Build status unknown [no reports yet] Why is this and how can I get the build started? Regards, Henk-Jan van Tuyl [0] https://hackage.haskell.org/package/wx-0.92.2.0 -- Folding at home What if you could share your unused computer power to help find a cure? In just 5 minutes you can join the world's biggest networked computer and get us closer sooner. Watch the video. http://folding.stanford.edu/ http://Van.Tuyl.eu/ http://members.chello.nl/hjgtuyl/tourdemonad.html Haskell programming -- From harendra.kumar at gmail.com Fri Mar 25 10:27:13 2016 From: harendra.kumar at gmail.com (Harendra Kumar) Date: Fri, 25 Mar 2016 15:57:13 +0530 Subject: [Haskell-cafe] Lightweight Unicode normalization library In-Reply-To: <1493FB7E-112B-434B-B3F0-5CB9E67E962C@mars.org> References: <1493FB7E-112B-434B-B3F0-5CB9E67E962C@mars.org> Message-ID: Ah, I created a package for unicode normalization already since I got no responses to my mail: https://github.com/harendra-kumar/unicode-transforms I will take a look at prose as well since it is native Haskell. It does not seem to be on Hackage yet. -harendra On 25 March 2016 at 05:08, Rob Leslie wrote: > I don?t have a good answer, but I thought I?d mention this project which > looks interesting and I?m considering using myself: > > https://github.com/llelf/prose > > -- > Rob Leslie > rob at mars.org > > > On Mar 17, 2016, at 12:59 AM, Harendra Kumar > wrote: > > I looked around and found only one package, text-icu which provides > unicode normalization operations and a lot more. But text-icu depends on > the icu library being installed on the system. We would prefer to avoid > dependency on the icu library. > > Is there a lightweight alternative which does not depend on icu? It could > be a pure Haskell package or bindings to a lightweight C library where the > library is small and shipped with the package itself. > > I wonder if there is a need for unicode normalization operations in GHC > code itself? If so how does it handle that? > > I found a lightweight C library (https://github.com/JuliaLang/utf8proc) > for normalization and case folding used by the Julia lang project. If there > is no other option I am considering creating bindings to this library. > > Any pointers, thoughts? > > Thanks, > Harendra > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From harendra.kumar at gmail.com Fri Mar 25 13:31:15 2016 From: harendra.kumar at gmail.com (Harendra Kumar) Date: Fri, 25 Mar 2016 19:01:15 +0530 Subject: [Haskell-cafe] Lightweight Unicode normalization library In-Reply-To: References: <1493FB7E-112B-434B-B3F0-5CB9E67E962C@mars.org> Message-ID: I looked at prose and did some tests. It builds and works very well functionally (normalization tests passed) but turns out to be pretty poor on normalization performance (171 times slower than text-icu). I believe it can be improved with some changes to the data structures. Though the performance may or may not matter depending on your use case. Here are the results of a quick normalization benchmarking test that I did using text-icu, unicode-transforms (bindings to the utf8proc C library) and prose: text-icu = 1 sec (224 MB/s on the test machine) unicode-transforms = 6 sec (40 MB/s) prose = 171 sec (1.3 MB/s) It looks like icu is the gold standard in performance. Even GNU libunistring's performance seems to be very similar to utf8proc. -harendra On 25 March 2016 at 15:57, Harendra Kumar wrote: > Ah, I created a package for unicode normalization already since I got no > responses to my mail: > > https://github.com/harendra-kumar/unicode-transforms > > I will take a look at prose as well since it is native Haskell. It does > not seem to be on Hackage yet. > > -harendra > > > On 25 March 2016 at 05:08, Rob Leslie wrote: > >> I don?t have a good answer, but I thought I?d mention this project which >> looks interesting and I?m considering using myself: >> >> https://github.com/llelf/prose >> >> -- >> Rob Leslie >> rob at mars.org >> >> >> On Mar 17, 2016, at 12:59 AM, Harendra Kumar >> wrote: >> >> I looked around and found only one package, text-icu which provides >> unicode normalization operations and a lot more. But text-icu depends on >> the icu library being installed on the system. We would prefer to avoid >> dependency on the icu library. >> >> Is there a lightweight alternative which does not depend on icu? It could >> be a pure Haskell package or bindings to a lightweight C library where the >> library is small and shipped with the package itself. >> >> I wonder if there is a need for unicode normalization operations in GHC >> code itself? If so how does it handle that? >> >> I found a lightweight C library (https://github.com/JuliaLang/utf8proc) >> for normalization and case folding used by the Julia lang project. If there >> is no other option I am considering creating bindings to this library. >> >> Any pointers, thoughts? >> >> Thanks, >> Harendra >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe >> >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From anton.kholomiov at gmail.com Sat Mar 26 17:47:56 2016 From: anton.kholomiov at gmail.com (Anton Kholomiov) Date: Sat, 26 Mar 2016 20:47:56 +0300 Subject: [Haskell-cafe] [ANN] Csound-expression-5 is out (framework for computer music) Message-ID: I'd like to announce a new version of Csound-expression library. It's a framework for computer music production. It compiles Haskell code to Csound. What's new? **The 5.0 is out! New features:** csound-expression * **Microtonal tunings**. We can use custom temperaments with insturments, patches, soundfonts and MIDI-instruments. Check out the guide on tuning and microtonal music (see also module `Csound.Tuning`). There are many predefined tunings (including ancient ones). Now we can play the authentic Bach music with Haskell! See [Custom temperament. Microtonal music]( https://github.com/anton-k/csound-expression/blob/master/tutorial/chapters/Tuning.md ) for details. * **Functions for Csound API**. We can interface with generated code through many other languages. We can generate the code with Haskell and the use it in other environments. we can build UI with Python or Clojure, we can create an Android synthesizer. See the guide section on Csound API. See [Csound API. Using generated code with another languages]( https://github.com/anton-k/csound-expression/blob/master/tutorial/chapters/CsoundAPI.md ) for details. * **Padsynth algorithm** (need Csound 6.05). There are functions that makes it easy to use wonderful PADsynth algorithm, This algorithm is designed to make "alive" instruments, natural pads. There are not only function that explore the algorithm but also new PAtches in the package csound-catalog that are based on it! See the section in the guide on the PADsynth. Lot's of padsynth instruments are mode with morphing support. We can crossfade between 2 or even 4 timbres. See [Padsynth algorithm]( https://github.com/anton-k/csound-expression/blob/master/tutorial/chapters/Padsynth.md ) for details. * **Argument modifiers** make it very convinient to modulate the rguments (apply vibrato to frequency or add some randomness to the parameter). See [Arguments modulation]( https://github.com/anton-k/csound-expression/blob/master/tutorial/chapters/ModArg.md ) for details. * The **hard clipping** was substituted with **limiter**. There should be no distortion when amplitude goes higher than `0dbfs` value. * Adds **Ping-pong delay** implementation. See function `pingPong` at the module `Csound.Air.Fx`. * Adds Rory Walsh's brand **new analog filters** (need Csound 6.07). See functions `alp1`, `alp2` and `alp3` at the module `Csound.Air.Filter`. * Bugfixes for `mixAt` function. Now it doesn't duplicates the effectful-code. Now `mixAt` is not a function that is based on class `At`. It becomes a method in it's own class called `MixAt`. That fixes the code duplication problem. csound-catalog * **new instruments** that are based on **PADsynth algorithm**. Check out `Csound.Patch` at the section on PADsynth Sharc instruments. There are new deep spiritual vedic pads (vibhu, rishi, agni, prakriti, rajas, avatara, bhumi). See [Padsynth algorithm]( https://github.com/anton-k/csound-expression/blob/master/tutorial/chapters/Padsynth.md ) for details. Link to the library: http://hackage.haskell.org/package/csound-expression Github repo: https://github.com/spell-music/csound-expression You can listen to some PADsynth instruments at the link: https://www.dropbox.com/s/pqn4dkvoo01dome/ce-5.zip?dl=0 Cheers, Anton -------------- next part -------------- An HTML attachment was scrubbed... URL: From theedge456 at free.fr Sat Mar 26 18:15:07 2016 From: theedge456 at free.fr (Fabien R) Date: Sat, 26 Mar 2016 19:15:07 +0100 Subject: [Haskell-cafe] build error using hsqml Message-ID: <56F6D1AB.8050804@free.fr> Hello, I'm trying to build a program using HsQml. cabal 1.14.0 fails with this error: Building HsQmlTest-0.0.1... Preprocessing executable 'HsQmlTest' for HsQmlTest-0.0.1... [1 of 1] Compiling Main ( src/Main.hs, dist/build/HsQmlTest/HsQmlTest-tmp/Main.o ) Loading package ghc-prim ... linking ... done. Loading package integer-gmp ... linking ... done. Loading package base ... linking ... done. Loading package array-0.4.0.0 ... linking ... done. Loading package deepseq-1.3.0.0 ... linking ... done. Loading package containers-0.4.2.1 ... linking ... done. Loading package filepath-1.3.0.0 ... linking ... done. Loading package tagged-0.4.2.1 ... linking ... done. Loading package bytestring-0.9.2.1 ... linking ... done. Loading package text-0.11.2.0 ... linking ... done. Loading package transformers-0.3.0.0 ... linking ... done. : can't load .so/.DLL for: /home/fabien/.cabal/lib/hsqml-0.3.4.0/ghc-7.4.1/libcbits-hsqml-0.3.4.0.so (libQt5Widgets.so.5: cannot open shared object file: No such file or directory) Loading package hsqml-0.3.4.0 ... Using --extra-lib-dirs to set the path of the library does not improve the situation. Here is the cabal description: name: HsQmlTest version: 0.0.1 cabal-version: >=1.2 build-type: Simple license: AllRightsReserved license-file: "" description: data-dir: "" executable HsQmlTest build-depends: QuickCheck -any, base -any, hsqml -any, text -any main-is: Main.hs buildable: True cpp-options: -DMAIN_FUNCTION=exeMain extra-lib-dirs: /media/travail/debian-sources/qt5/qtbase/lib/ hs-source-dirs: src Any hint ? -- Fabien From max.voit+mlhc at with-eyes.net Sat Mar 26 18:35:10 2016 From: max.voit+mlhc at with-eyes.net (Max Voit) Date: Sat, 26 Mar 2016 19:35:10 +0100 Subject: [Haskell-cafe] build error using hsqml In-Reply-To: <56F6D1AB.8050804@free.fr> References: <56F6D1AB.8050804@free.fr> Message-ID: <20160326193510.7a3fa49f@veeloqu.lan> On Sat, 26 Mar 2016 19:15:07 +0100 Fabien R wrote: > Any hint ? You're missing the .so file: > : can't load .so/.DLL for: > /home/fabien/.cabal/lib/hsqml-0.3.4.0/ghc-7.4.1/libcbits-hsqml-0.3.4.0.so > (libQt5Widgets.so.5: cannot open shared object file: No such file or > directory) Loading package hsqml-0.3.4.0 ... On debian-based distributions you may use apt-file to find which package(s) contain files, e.g. (on jessie): % apt-file find libQt5Widgets.so libqt5widgets5: /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5 ... qtbase5-dev: /usr/lib/x86_64-linux-gnu/libQt5Widgets.so These paths ought to be searched by default, so I suggest you're just missing the package. Best, Max From althainz at gmail.com Sat Mar 26 19:56:31 2016 From: althainz at gmail.com (Peter Althainz) Date: Sat, 26 Mar 2016 20:56:31 +0100 Subject: [Haskell-cafe] HGamer3D has a new dependency installer Message-ID: Dear All, it took a long while, but now a new solution has been found for dependency setup for HGamer3D. What do you think? Check here: http://www.hgamer3d.org/Install.html . regards uotbw -------------- next part -------------- An HTML attachment was scrubbed... URL: From theedge456 at free.fr Sun Mar 27 08:49:57 2016 From: theedge456 at free.fr (Fabien R) Date: Sun, 27 Mar 2016 10:49:57 +0200 Subject: [Haskell-cafe] build error using hsqml In-Reply-To: <20160326193510.7a3fa49f@veeloqu.lan> References: <56F6D1AB.8050804@free.fr> <20160326193510.7a3fa49f@veeloqu.lan> Message-ID: <56F79EB5.7060009@free.fr> On 26/03/2016 19:35, Max Voit wrote: > On debian-based distributions you may use apt-file to find which > package(s) contain files, e.g. (on jessie): > > % apt-file find libQt5Widgets.so > libqt5widgets5: /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5 I compiled Qt5 from sources. This file is in /media/travail/debian-sources/qt5/qtbase/lib/ . Is the path correctly set in the cabal description file ? -- Fabien From komadori at gekkou.co.uk Sun Mar 27 13:23:18 2016 From: komadori at gekkou.co.uk (Robin KAY) Date: Sun, 27 Mar 2016 14:23:18 +0100 Subject: [Haskell-cafe] build error using hsqml In-Reply-To: <56F79EB5.7060009@free.fr> References: <56F6D1AB.8050804@free.fr> <20160326193510.7a3fa49f@veeloqu.lan> <56F79EB5.7060009@free.fr> Message-ID: <56F7DEC6.4040005@gekkou.co.uk> Dear Fabien, On Sun, Mar 27, 2016, at 09:49 AM, Fabien R wrote: > I compiled Qt5 from sources. This file is in > /media/travail/debian-sources/qt5/qtbase/lib/ . > Is the path correctly set in the cabal description file ? I think your problem is that pointing the compiler to your local Qt libraries at build time does not necessarily mean that the dynamic linker can find them at run time. Most expediently, try adding the your local lib directory to the LD_LIBRARY_PATH environment variable. You can bake the runtime search path into your executable by passing the -rpath flag to the linker. I suppose that, since your Qt install location isn't on the system global library search path, strictly speaking its pkg-config files should contain the correct -rpath flags so that everything links correctly at runtime. Perhaps Qt's build can be configured to do that. Regards, -- Robin KAY http://www.gekkou.co.uk/ From theedge456 at free.fr Sun Mar 27 19:08:58 2016 From: theedge456 at free.fr (Fabien R) Date: Sun, 27 Mar 2016 21:08:58 +0200 Subject: [Haskell-cafe] build error using hsqml In-Reply-To: <56F7DEC6.4040005@gekkou.co.uk> References: <56F6D1AB.8050804@free.fr> <20160326193510.7a3fa49f@veeloqu.lan> <56F79EB5.7060009@free.fr> <56F7DEC6.4040005@gekkou.co.uk> Message-ID: <56F82FCA.6040705@free.fr> On 27/03/16 15:23, Robin KAY wrote: > Dear Fabien, > > I think your problem is that pointing the compiler to your local Qt > libraries at build time does not necessarily mean that the dynamic > linker can find them at run time. Most expediently, try adding the your > local lib directory to the LD_LIBRARY_PATH environment variable. Thanks Robin, Updating LD_LIBRARY_PATH did the trick. -- Fabien From mainland at drexel.edu Mon Mar 28 17:44:17 2016 From: mainland at drexel.edu (Geoffrey Mainland) Date: Mon, 28 Mar 2016 13:44:17 -0400 Subject: [Haskell-cafe] [2nd CFP] Haskell Symposium 2016 Message-ID: <56F96D71.2020207@drexel.edu> ======================================================================== ACM SIGPLAN CALL FOR SUBMISSIONS Haskell Symposium 2016 Nara, Japan, 22-23 September 2015, directly after ICFP http://www.haskell.org/haskell-symposium/2016 ======================================================================== ** The Haskell Symposium has an early track this year ** ** See the Submission Timetable for details. ** The ACM SIGPLAN Haskell Symposium 2016 will be co-located with the International Conference on Functional Programming (ICFP 2016) in Vancouver, Canada. The Haskell Symposium aims to present original research on Haskell, discuss practical experience and future development of the language, and to promote other forms of denotative programming. Topics of interest include: * Language Design, with a focus on possible extensions and modifications of Haskell as well as critical discussions of the status quo; * Theory, such as formal semantics of the present language or future extensions, type systems, effects, metatheory, and foundations for program analysis and transformation; * Implementations, including program analysis and transformation, static and dynamic compilation for sequential, parallel, and distributed architectures, memory management, as well as foreign function and component interfaces; * Libraries, that demonstrate new ideas or techniques for functional programming in Haskell; * Tools, such as profilers, tracers, debuggers, preprocessors, and testing tools; * Applications, to scientific and symbolic computing, databases, multimedia, telecommunication, the web, and so forth; * Functional Pearls, being elegant and instructive programming examples; * Experience Reports, to document general practice and experience in education, industry, or other contexts. Papers in the latter three categories need not necessarily report original academic research results. For example, they may instead report reusable programming idioms, elegant ways to approach a problem, or practical experience that will be useful to other users, implementors, or researchers. The key criterion for such a paper is that it makes a contribution from which other Haskellers can benefit. It is not enough simply to describe a standard solution to a standard programming problem, or report on experience where you used Haskell in the standard way and achieved the result you were expecting. More advice is available via the Haskell wiki: (http://wiki.haskell.org/HaskellSymposium/ExperienceReports) Regular papers should explain their research contributions in both general and technical terms, identifying what has been accomplished, explaining why it is significant, and relating it to previous work, and to other languages where appropriate. In addition, we solicit proposals for: * System Demonstrations, based on running software rather than novel research results. These proposals should summarize the system capabilities that would be demonstrated. The proposals will be judged on whether the ensuing session is likely to be important and interesting to the Haskell community at large, whether on grounds academic or industrial, theoretical or practical, technical, social or artistic. Please contact the program chair with any questions about the relevance of a proposal. Travel Support: =============== Student attendees with accepted papers can apply for a SIGPLAN PAC grant to help cover travel expenses. PAC also offers other support, such as for child-care expenses during the meeting or for travel costs for companions of SIGPLAN members with physical disabilities, as well as for travel from locations outside of North America and Europe. For details on the PAC program, see its web page (http://pac.sigplan.org). Proceedings: ============ Accepted papers will be included in the ACM Digital Library. Authors must grant ACM publication rights upon acceptance (http://authors.acm.org/main.html). Authors are encouraged to publish auxiliary material with their paper (source code, test data, etc.); they retain copyright of auxiliary material. Accepted proposals for system demonstrations will be posted on the symposium website but not formally published in the proceedings. All accepted papers and proposals will be posted on the conference website one week before the meeting. Publication date: The official publication date of accepted papers is the date the proceedings are made available in the ACM Digital Library. This date may be up to two weeks prior to the first day of the conference. The official publication date affects the deadline for any patent filings related to published work. Submission Details: =================== Submitted papers should be in portable document format (PDF), formatted using the ACM SIGPLAN style guidelines (http://www.acm.org/sigs/sigplan/authorInformation.htm). The text should be in a 9-point font in two columns. The length is restricted to 12 pages, except for "Experience Report" papers, which are restricted to 6 pages. Papers need not fill the page limit---for example, a Functional Pearl may be much shorter than 12 pages. Each paper submission must adhere to SIGPLAN's republication policy, as explained on the web. Demo proposals are limited to 2-page abstracts, in the same ACM format as papers. "Functional Pearls", "Experience Reports", and "Demo Proposals" should be marked as such with those words in the title at time of submission. The paper submission deadline and length limitations are firm. There will be no extensions, and papers violating the length limitations will be summarily rejected. Papers may be submitted at: https://icfp-haskell2016.hotcrp.com/ Submission Timetable: ===================== Early Track Regular Track System Demos ---------------- ------------------- --------------- 1st April Paper Submission 20th May Notification 6th June Abstract Submission 10th June Paper Submission 17th June Resubmission Demo Submission 8th July Notification Notification Notification 31st July Camera ready due Camera ready due Deadlines stated are valid anywhere on earth. The Haskell Symposium uses a two-track submission process so that some papers can gain early feedback. Papers can be submitted to the early track on 1st April. On 20th May, strong papers are accepted outright, and the others will be given their reviews and invited to resubmit. On 17th June, early track papers may be resubmitted and are sent back to the same reviewers. The Haskell Symposium regular track operates as in previous years. Papers accepted via the early and regular tracks are considered of equal value and will not be distinguished in the proceedings. Although all papers may be submitted to the early track, authors of functional pearls and experience reports are particularly encouraged to use this mechanism. The success of these papers depends heavily on the way they are presented, and submitting early will give the program committee a chance to provide feedback and help draw out the key ideas. Program Committee: =================== James Cheney University of Edinburgh Iavor Diatchki Galois David Duke University of Leeds Richard Eisenberg University of Pennsylvania Ken Friis Larsen University of Copenhagen Andy Gill University of Kansas Zhenjiang Hu National Institute of Informatics Ranjit Jhala UC San Diego Yukiyoshi Kameyama University of Tsukuba Geoffrey Mainland (chair) Drexel University Mary Sheeran Chalmers University of Technology David Terei Stanford Niki Vazou UC San Diego Dimitrios Vytiniotis Microsoft Research ===================================================================== From haskell at bunix.org Mon Mar 28 17:53:32 2016 From: haskell at bunix.org (Martijn Rijkeboer) Date: Mon, 28 Mar 2016 19:53:32 +0200 Subject: [Haskell-cafe] Hspec + QuickCheck passing type Message-ID: Hi, I'm writing the following Hspec + QuickCheck test for some type: context "Type1" $ it "decode inverses encode" $ property $ \x -> (decode . encode) x == Right (x::Type1) However, I have a number of these types, and I could write the same test for every type, but that isn't very DRY. Therefore I would like to put the test in a function and call that function for every type. Something like the following: typeTest name = do context name $ it "decode inverses encode" $ property $ \x -> (decode . encode) x == Right x Unfortunately this doesn't work, since QuickCheck doesn't know which Arbitrary instance to use. How can I pass the type, e.g. x::Type1, to this function so QuickCheck knows what Arbitrary instance to use? Kind regards, Martijn Rijkeboer From will.yager at gmail.com Mon Mar 28 18:55:31 2016 From: will.yager at gmail.com (Will Yager) Date: Mon, 28 Mar 2016 13:55:31 -0500 Subject: [Haskell-cafe] Hspec + QuickCheck passing type In-Reply-To: References: Message-ID: <0331DCA1-C86E-42E3-B5F0-480C13EB41EC@gmail.com> I would recommend using http://hackage.haskell.org/package/base-4.8.2.0/docs/Prelude.html#v:asTypeOf And passing a dummy variable of the correct type. -Will > On Mar 28, 2016, at 12:53, Martijn Rijkeboer wrote: > > Hi, > > I'm writing the following Hspec + QuickCheck test for some type: > > context "Type1" $ > it "decode inverses encode" $ property $ > \x -> (decode . encode) x == Right (x::Type1) > > > However, I have a number of these types, and I could write the same test > for every type, but that isn't very DRY. Therefore I would like to put the > test in a function and call that function for every type. Something like > the following: > > typeTest name = do > context name $ > it "decode inverses encode" $ property $ > \x -> (decode . encode) x == Right x > > > Unfortunately this doesn't work, since QuickCheck doesn't know which > Arbitrary instance to use. How can I pass the type, e.g. x::Type1, to > this function so QuickCheck knows what Arbitrary instance to use? > > Kind regards, > > > Martijn Rijkeboer > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe From johnw at newartisans.com Mon Mar 28 19:46:55 2016 From: johnw at newartisans.com (John Wiegley) Date: Mon, 28 Mar 2016 12:46:55 -0700 Subject: [Haskell-cafe] Hspec + QuickCheck passing type In-Reply-To: (Martijn Rijkeboer's message of "Mon, 28 Mar 2016 19:53:32 +0200") References: Message-ID: >>>>> Martijn Rijkeboer writes: > Unfortunately this doesn't work, since QuickCheck doesn't know which > Arbitrary instance to use. How can I pass the type, e.g. x::Type1, to this > function so QuickCheck knows what Arbitrary instance to use? For example: {-# LANGUAGE ScopedTypeVariables #-} import Test.QuickCheck import Test.Hspec import Data.Serialize import Data.Proxy typeTest :: forall a. (Show a, Eq a, Arbitrary a, Serialize a) => String -> Proxy a -> SpecWith () typeTest name _ = context name $ it "decode inverses encode" $ property $ \(x :: a) -> (decode . encode) x == Right x main :: IO () main = hspec $ typeTest "foo" (Proxy :: Proxy Int) The use of Proxy conveys the needed type information, as Will had also suggested. -- John Wiegley GPG fingerprint = 4710 CF98 AF9B 327B B80F http://newartisans.com 60E1 46C4 BD1A 7AC1 4BA2 From chneukirchen at gmail.com Mon Mar 28 21:55:29 2016 From: chneukirchen at gmail.com (Christian Neukirchen) Date: Mon, 28 Mar 2016 23:55:29 +0200 Subject: [Haskell-cafe] Munich Haskell Meeting, 2015-03-30 @ 19:30 Message-ID: <87shzas1wu.fsf@gmail.com> Dear all, This week, our monthly Munich Haskell Meeting will take place again on Wednesday, March 30 at Cafe Puck at 19h30. For details see here: http://chneukirchen.github.io/haskell-munich.de/dates.html If you plan to join, please add yourself to this dudle so we can reserve enough seats! It is OK to add yourself to the dudle anonymously or pseudonymously. https://dudle.inf.tu-dresden.de/haskell-munich-mar-2016/ Everybody is welcome! -- Christian Neukirchen http://chneukirchen.org From oleg at okmij.org Tue Mar 29 13:17:29 2016 From: oleg at okmij.org (Oleg) Date: Tue, 29 Mar 2016 22:17:29 +0900 Subject: [Haskell-cafe] Type equality with "forall" Message-ID: <20160329131729.GA1911@Magus.sf-private> There are no problems in the code you have posted so far: it works exactly as it is supposed to. Overlapping instances worked as designed. It seems the problem is not in Haskell but in your expectations of existentials. Existentials are a means of abstraction, that is, deliberately forgetting details. In our case, forgetting all the details about the type. Consider the following code data W where Wrap :: a -> W test1 = case Wrap True of Wrap x -> not x It does not type-check. The variable x in test1 has the type which is different from any other existing type. Therefore, you cannot do anything sensible with it -- in particular, you cannot apply 'not', which works only for Booleans. Can't GHC just see that ``x is Bool'' -- just look at the line above!? No, by using the existential you specifically told GHC to forget all it knows about the type of the Wrapped value. If you want to remember some information about the existential type, you have to do it explicitly. For example, you can use Typeable and cast data W where Wrap :: Typeable a => a -> W test1 = case Wrap True of Wrap x' | Just x <- cast x' -> not x Wrap _ -> error "not a Bool" or build your own Universe (if you know in advance all the types you will be working with) data TypeRep a where TInt :: TypeRep Int TBool :: TypeRep Bool TArr :: TypeRep a -> TypeRep b -> TypeRep (a -> b) data W where Wrap :: TypeRep a -> a -> W test1 :: Bool test1 = case Wrap TBool True of Wrap TBool x -> not x Wrap _ _ -> error "not a Bool" In the latter case, the type signature is required. Basically, you have to write signature for every function that pattern-matches on the real GADTs (sometimes you can get away; but oftentimes you'll get a really cryptic error message instead). The latter pattern, using TypeRep, is the foundation of basically all generic programming out there. From haskell at bunix.org Tue Mar 29 16:58:42 2016 From: haskell at bunix.org (Martijn Rijkeboer) Date: Tue, 29 Mar 2016 18:58:42 +0200 Subject: [Haskell-cafe] Hspec + QuickCheck passing type In-Reply-To: <0331DCA1-C86E-42E3-B5F0-480C13EB41EC@gmail.com> References: <0331DCA1-C86E-42E3-B5F0-480C13EB41EC@gmail.com> Message-ID: <10db5d64d8ac328b417d2a3c00ee4f73.squirrel@mail.bunix.org> > I would recommend using > http://hackage.haskell.org/package/base-4.8.2.0/docs/Prelude.html#v:asTypeOf > > And passing a dummy variable of the correct type. Thanks, this is exactly what I was looking for. Kind regards, Martijn Rijkeboer From rustompmody at gmail.com Wed Mar 30 13:30:40 2016 From: rustompmody at gmail.com (Rustom Mody) Date: Wed, 30 Mar 2016 19:00:40 +0530 Subject: [Haskell-cafe] parsec reorganization Message-ID: Ive been trying parsec And I gather that the modules structures are heavily reorganized eg https://kunigami.wordpress.com/2014/01/21/an-introduction-to-the-parsec-library/ starts with import Data.Char (char) which immediately gives Module ?Data.Char? does not export ?char? Change that to import Text.Parsec.Char (char) and that error goes and more and more arcane ones start Likewise all the stuff here http://jakewheat.github.io/intro_to_parsing/ seems to be wrong paths Is there no tutorial for the current versions? ghc 7.8.4 parsec 3.1.9-2 -------------- next part -------------- An HTML attachment was scrubbed... URL: From spam at scientician.net Wed Mar 30 15:16:57 2016 From: spam at scientician.net (Bardur Arantsson) Date: Wed, 30 Mar 2016 17:16:57 +0200 Subject: [Haskell-cafe] parsec reorganization In-Reply-To: References: Message-ID: On 03/30/2016 03:30 PM, Rustom Mody wrote: > Ive been trying parsec > And I gather that the modules structures are heavily reorganized > Unless you're dead set on parsec specifically, I'd recommend looking into megaparsec instead. Regards, From nicola.gigante at gmail.com Wed Mar 30 15:43:20 2016 From: nicola.gigante at gmail.com (Nicola Gigante) Date: Wed, 30 Mar 2016 17:43:20 +0200 Subject: [Haskell-cafe] parsec reorganization In-Reply-To: References: Message-ID: <24B0A3AC-306E-4E2F-9B38-0FA99ED309BD@gmail.com> > Il giorno 30 mar 2016, alle ore 17:16, Bardur Arantsson ha scritto: > > On 03/30/2016 03:30 PM, Rustom Mody wrote: >> Ive been trying parsec >> And I gather that the modules structures are heavily reorganized >> > > Unless you're dead set on parsec specifically, I'd recommend looking > into megaparsec instead. > If one cares about error messages, ?trifecta? is also a very good choice. In combination with the interface from the ?parsers? package is also very pleasant to use. > Regards, Regards, Nicola From omari at smileystation.com Wed Mar 30 16:26:41 2016 From: omari at smileystation.com (Omari Norman) Date: Wed, 30 Mar 2016 12:26:41 -0400 Subject: [Haskell-cafe] parsec reorganization In-Reply-To: References: Message-ID: On Wednesday, March 30, 2016, Rustom Mody wrote: > Ive been trying parsec > And I gather that the modules structures are heavily reorganized > > eg > https://kunigami.wordpress.com/2014/01/21/an-introduction-to-the-parsec-library/ > starts with > > import Data.Char (char) > That's incorrect and has never been correct. The parser you want is in Text.Parsec.Char. Data.Char is a standard Haskell module and has nothing to do with Parsec. Unfortunately I can't recommend any particular tutorial. Mostly I thrashed about, reading this and that. The principles are best explained in the original papers, such as this one: http://research.microsoft.com/en-us/um/people/daan/download/papers/parsec-paper.pdf But unfortunately the original papers are somewhat out of date too. -------------- next part -------------- An HTML attachment was scrubbed... URL: From joehillen at gmail.com Wed Mar 30 16:36:14 2016 From: joehillen at gmail.com (Joe Hillenbrand) Date: Wed, 30 Mar 2016 09:36:14 -0700 Subject: [Haskell-cafe] parsec reorganization In-Reply-To: References: Message-ID: Parsec isn't as maintained as Megaparsec . I recommend checking out the tutorials here . On Wed, Mar 30, 2016 at 6:30 AM, Rustom Mody wrote: > Ive been trying parsec > And I gather that the modules structures are heavily reorganized > > eg > https://kunigami.wordpress.com/2014/01/21/an-introduction-to-the-parsec-library/ > starts with > > import Data.Char (char) > > which immediately gives > Module ?Data.Char? does not export ?char? > > Change that to > import Text.Parsec.Char (char) > > and that error goes and more and more arcane ones start > Likewise all the stuff here > http://jakewheat.github.io/intro_to_parsing/ > seems to be wrong paths > > > Is there no tutorial for the current versions? > ghc 7.8.4 > parsec 3.1.9-2 > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rustompmody at gmail.com Wed Mar 30 17:32:49 2016 From: rustompmody at gmail.com (Rustom Mody) Date: Wed, 30 Mar 2016 23:02:49 +0530 Subject: [Haskell-cafe] parsec reorganization In-Reply-To: References: Message-ID: Thanks all for the suggestions The first tut I tried seems to have an omission. I needed to add a import Control.Applicative to https://mrkkrp.github.io/megaparsec/tutorials/parsing-simple-imperative-language.html [Saw it in the others so guessed it has to be added] Can report if desirable but Im yet quite in noob stage... On Wed, Mar 30, 2016 at 10:06 PM, Joe Hillenbrand wrote: > Parsec isn't as maintained as Megaparsec > . > > I recommend checking out the tutorials here > . > > On Wed, Mar 30, 2016 at 6:30 AM, Rustom Mody > wrote: > >> Ive been trying parsec >> And I gather that the modules structures are heavily reorganized >> >> eg >> https://kunigami.wordpress.com/2014/01/21/an-introduction-to-the-parsec-library/ >> starts with >> >> import Data.Char (char) >> >> which immediately gives >> Module ?Data.Char? does not export ?char? >> >> Change that to >> import Text.Parsec.Char (char) >> >> and that error goes and more and more arcane ones start >> Likewise all the stuff here >> http://jakewheat.github.io/intro_to_parsing/ >> seems to be wrong paths >> >> >> Is there no tutorial for the current versions? >> ghc 7.8.4 >> parsec 3.1.9-2 >> >> >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe >> >> > -- http://www.the-magus.in http://blog.languager.org -------------- next part -------------- An HTML attachment was scrubbed... URL: From carter.schonwald at gmail.com Wed Mar 30 19:00:03 2016 From: carter.schonwald at gmail.com (Carter Schonwald) Date: Wed, 30 Mar 2016 15:00:03 -0400 Subject: [Haskell-cafe] [2nd CFP] Haskell Symposium 2016 In-Reply-To: <56F96D71.2020207@drexel.edu> References: <56F96D71.2020207@drexel.edu> Message-ID: I notice the notification date is 2 days after the popl submission deadline, is that by design or an oversight? thanks! -Carter On Mon, Mar 28, 2016 at 1:44 PM, Geoffrey Mainland wrote: > ======================================================================== > ACM SIGPLAN CALL FOR SUBMISSIONS > Haskell Symposium 2016 > > Nara, Japan, 22-23 September 2015, directly after ICFP > http://www.haskell.org/haskell-symposium/2016 > ======================================================================== > > ** The Haskell Symposium has an early track this year ** > ** See the Submission Timetable for details. ** > > The ACM SIGPLAN Haskell Symposium 2016 will be co-located with the > International Conference on Functional Programming (ICFP 2016) in > Vancouver, Canada. > > The Haskell Symposium aims to present original research on Haskell, > discuss practical experience and future development of the language, and > to promote other forms of denotative programming. > > Topics of interest include: > > * Language Design, with a focus on possible extensions and modifications > of Haskell as well as critical discussions of the status quo; > > * Theory, such as formal semantics of the present language or future > extensions, type systems, effects, metatheory, and foundations for > program analysis and transformation; > > * Implementations, including program analysis and transformation, static > and dynamic compilation for sequential, parallel, and distributed > architectures, memory management, as well as foreign function and > component interfaces; > > * Libraries, that demonstrate new ideas or techniques for functional > programming in Haskell; > > * Tools, such as profilers, tracers, debuggers, preprocessors, and > testing tools; > > * Applications, to scientific and symbolic computing, databases, > multimedia, telecommunication, the web, and so forth; > > * Functional Pearls, being elegant and instructive programming examples; > > * Experience Reports, to document general practice and experience in > education, industry, or other contexts. > > Papers in the latter three categories need not necessarily report > original academic research results. For example, they may instead report > reusable programming idioms, elegant ways to approach a problem, or > practical experience that will be useful to other users, implementors, > or researchers. The key criterion for such a paper is that it makes a > contribution from which other Haskellers can benefit. It is not enough > simply to describe a standard solution to a standard programming > problem, or report on experience where you used Haskell in the standard > way and achieved the result you were expecting. More advice is available > via the Haskell wiki: > (http://wiki.haskell.org/HaskellSymposium/ExperienceReports) > > Regular papers should explain their research contributions in both > general and technical terms, identifying what has been accomplished, > explaining why it is significant, and relating it to previous work, and > to other languages where appropriate. > > In addition, we solicit proposals for: > > * System Demonstrations, based on running software rather than novel > research results. > > These proposals should summarize the system capabilities that would be > demonstrated. The proposals will be judged on whether the ensuing > session is likely to be important and interesting to the Haskell > community at large, whether on grounds academic or industrial, > theoretical or practical, technical, social or artistic. Please contact > the program chair with any questions about the relevance of a proposal. > > Travel Support: > =============== > > Student attendees with accepted papers can apply for a SIGPLAN PAC grant > to help cover travel expenses. PAC also offers other support, such as > for child-care expenses during the meeting or for travel costs for > companions of SIGPLAN members with physical disabilities, as well as for > travel from locations outside of North America and Europe. For details > on the PAC program, see its web page (http://pac.sigplan.org). > > Proceedings: > ============ > > Accepted papers will be included in the ACM Digital Library. Authors > must grant ACM publication rights upon acceptance > (http://authors.acm.org/main.html). Authors are encouraged to publish > auxiliary material with their paper (source code, test data, etc.); they > retain copyright of auxiliary material. > > Accepted proposals for system demonstrations will be posted on the > symposium website but not formally published in the proceedings. > > All accepted papers and proposals will be posted on the conference > website one week before the meeting. > > Publication date: The official publication date of accepted papers is > the date the proceedings are made available in the ACM Digital > Library. This date may be up to two weeks prior to the first day of the > conference. The official publication date affects the deadline for any > patent filings related to published work. > > Submission Details: > =================== > > Submitted papers should be in portable document format (PDF), formatted > using the ACM SIGPLAN style guidelines > (http://www.acm.org/sigs/sigplan/authorInformation.htm). The text should > be in a 9-point font in two columns. The length is restricted to 12 > pages, except for "Experience Report" papers, which are restricted to 6 > pages. Papers need not fill the page limit---for example, a Functional > Pearl may be much shorter than 12 pages. Each paper submission must > adhere to SIGPLAN's republication policy, as explained on the web. > > Demo proposals are limited to 2-page abstracts, in the same ACM format > as papers. > > "Functional Pearls", "Experience Reports", and "Demo Proposals" should > be marked as such with those words in the title at time of submission. > > The paper submission deadline and length limitations are firm. There > will be no extensions, and papers violating the length limitations will > be summarily rejected. > > Papers may be submitted at: https://icfp-haskell2016.hotcrp.com/ > > Submission Timetable: > ===================== > > Early Track Regular Track System Demos > ---------------- ------------------- --------------- > 1st April Paper Submission > 20th May Notification > 6th June Abstract Submission > 10th June Paper Submission > 17th June Resubmission Demo Submission > 8th July Notification Notification Notification > 31st July Camera ready due Camera ready due > > Deadlines stated are valid anywhere on earth. > > The Haskell Symposium uses a two-track submission process so that some > papers can gain early feedback. Papers can be submitted to the early > track on 1st April. On 20th May, strong papers are accepted outright, > and the others will be given their reviews and invited to resubmit. On > 17th June, early track papers may be resubmitted and are sent back to > the same reviewers. The Haskell Symposium regular track operates as in > previous years. Papers accepted via the early and regular tracks are > considered of equal value and will not be distinguished in the > proceedings. > > Although all papers may be submitted to the early track, authors of > functional pearls and experience reports are particularly encouraged to > use this mechanism. The success of these papers depends heavily on the > way they are presented, and submitting early will give the program > committee a chance to provide feedback and help draw out the key ideas. > > Program Committee: > =================== > > James Cheney University of Edinburgh > Iavor Diatchki Galois > David Duke University of Leeds > Richard Eisenberg University of Pennsylvania > Ken Friis Larsen University of Copenhagen > Andy Gill University of Kansas > Zhenjiang Hu National Institute of Informatics > Ranjit Jhala UC San Diego > Yukiyoshi Kameyama University of Tsukuba > Geoffrey Mainland (chair) Drexel University > Mary Sheeran Chalmers University of Technology > David Terei Stanford > Niki Vazou UC San Diego > Dimitrios Vytiniotis Microsoft Research > > ===================================================================== > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From fa-ml at ariis.it Wed Mar 30 20:12:39 2016 From: fa-ml at ariis.it (Francesco Ariis) Date: Wed, 30 Mar 2016 22:12:39 +0200 Subject: [Haskell-cafe] parsec reorganization In-Reply-To: References: Message-ID: <20160330201239.GA1378@casa.casa> On Wed, Mar 30, 2016 at 07:00:40PM +0530, Rustom Mody wrote: > Ive been trying parsec > And I gather that the modules structures are heavily reorganized Indeed I recall having problems with modules being shifted around a bit when I first read the tutorial. Keeping an eye on the index [1] did it for me at the time. [1] http://hackage.haskell.org/package/parsec-3.1.9/docs/doc-index-All.html From maydwell at gmail.com Wed Mar 30 22:00:44 2016 From: maydwell at gmail.com (Lyndon Maydwell) Date: Thu, 31 Mar 2016 09:00:44 +1100 Subject: [Haskell-cafe] Melbourne Haskell Users Group Meetup, Tonight, 31-03-2016 @ 6:30pm Message-ID: Hi All, Tonight we're having our monthly Haskell meetup in the Melbourne CBD. Please come along if you're interested and free! http://www.meetup.com/Melbourne-Haskell-Users-Group/events/228915323/ Hope to see you there :) Regards, - Lyndon -------------- next part -------------- An HTML attachment was scrubbed... URL: From jm at memorici.de Wed Mar 30 23:41:08 2016 From: jm at memorici.de (Jonn Mostovoy) Date: Thu, 31 Mar 2016 01:41:08 +0200 Subject: [Haskell-cafe] Testing Msgpack system Message-ID: Dear friends, we have a distributed system written in Haskell, consisting of three types of nodes with dozen of instances of each of two types and a central node of the third type. Each node is started by executing a binary which sets up acid-state persistence layer and sockets over which msgpack messages are sent around. It is trivial to write low level functionality quickcheck test suites, which test properties of functions. We would like, however, to have a quickcheck-esque suite which sets up the network, then gets it to an arbitrary valid state (sending correct messages between nodes), then rigorously testing it for three high-level properties: 1. Chaos monkey test (disable random node, see if certain invariants hold); 2. Evil node test (make several nodes work against the system, see if certain properties hold); 3. Rigorous testing of network-wide invariants, if all the nodes operate correctly. The problem we're facing is the following ? if we want to inspect state of nodes in Haskell-land, we have to write a huge machinery which emulates every launch of node via thread. There will be bugs in this machinery, so we won't be able to get quality testing information before we fix those; if we want to run things as processes, then the best thing we can do is to inspect either acid-state dbs of each node (it poses resource locking problems and forces us to dump the state on every change, which is undesirable), or make an observer node, which dumps the consensus as Text and then parsing the data into Haskell terms, making decisions about the required properties based on that (so far, it feels like the best option). Am I missing something? How is something like this achieved in culture? How would you approach such a problem? Links to source files of test suites which do something similar are highly appreciated. From andrew.pennebaker at gmail.com Thu Mar 31 02:11:14 2016 From: andrew.pennebaker at gmail.com (Andrew Pennebaker) Date: Wed, 30 Mar 2016 21:11:14 -0500 Subject: [Haskell-cafe] cabal: --enable-tests by default Message-ID: In the future, could cabal --enable-tests by default when `cabal install`ing local project directories? Other languages' package managers automatically do this, a more intuitive default behavior. -- Cheers, Andrew -------------- next part -------------- An HTML attachment was scrubbed... URL: From ivan.miljenovic at gmail.com Thu Mar 31 02:23:48 2016 From: ivan.miljenovic at gmail.com (Ivan Lazar Miljenovic) Date: Thu, 31 Mar 2016 13:23:48 +1100 Subject: [Haskell-cafe] cabal: --enable-tests by default In-Reply-To: References: Message-ID: On 31 March 2016 at 13:11, Andrew Pennebaker wrote: > In the future, could cabal --enable-tests by default when `cabal install`ing > local project directories? Other languages' package managers automatically > do this, a more intuitive default behavior. Do you mean just when doing "cabal install" within a Cabal project to install it as opposed to doing "cabal install foo" to install a specific package? -- Ivan Lazar Miljenovic Ivan.Miljenovic at gmail.com http://IvanMiljenovic.wordpress.com From dct25-561bs at mythic-beasts.com Thu Mar 31 08:10:46 2016 From: dct25-561bs at mythic-beasts.com (David Turner) Date: Thu, 31 Mar 2016 09:10:46 +0100 Subject: [Haskell-cafe] Testing Msgpack system In-Reply-To: References: Message-ID: Hi Jonn, I work on a similar-sounding system. We have arranged things so that each node is a pure state machine, with outputs that are a pure function of its inputs, with separate (and simple, obviously correct) machinery for connecting these state machines over the network. This makes it rather simple to run a bunch of these state machines in a test harness that simulates all sorts of network nastiness (disconnections, dropped or reordered messages, delays, corruption etc.) on a single thread. One trick that proved useful was to feed in the current time as an explicit input message. This makes it possible to test things like timeouts without having to actually wait for the time to pass, which speeds things up immensely. We also make use of ContT somewhere in the tests to interleave processing and assertions, and to define a 'hypothetically' operator that lets a test run a sequence of actions and then backtrack. I think this idea was inspired by https://github.com/NicolasT/paxos/blob/master/bin/synod.hs, at least the network nastiness simulator thing. He uses threads for that demo but the nodes' behaviour itself is pure: https://github.com/NicolasT/paxos/blob/master/src/Network/Paxos/Synod/Proposer.hs for example. We also have proved certain key properties of the network are implied by certain local invariants, which reduces the testing problem down to one of checking properties on each node separately. This was time consuming, but highlighted certain important corner cases that it's unlikely we would have found by random testing. If you're interested in Byzantine behaviour (the 'evil node' test) then you may enjoy reading James Mickens' article on the subject: https://www.usenix.org/publications/login-logout/may-2013/saddest-moment Hope that helps, David PS a double apology: firstly for the double message (my first attempt was sent from the wrong address) and secondly for spelling your name wrong in that message! On 31 March 2016 at 00:41, Jonn Mostovoy wrote: > Dear friends, > > we have a distributed system written in Haskell, consisting of three > types of nodes with dozen of instances of each of two types and a > central node of the third type. > > Each node is started by executing a binary which sets up acid-state > persistence layer and sockets over which msgpack messages are sent > around. > > It is trivial to write low level functionality quickcheck test suites, > which test properties of functions. > > We would like, however, to have a quickcheck-esque suite which sets up > the network, then gets it to an arbitrary valid state (sending correct > messages between nodes), then rigorously testing it for three > high-level properties: > > 1. Chaos monkey test (disable random node, see if certain invariants hold); > 2. Evil node test (make several nodes work against the system, see if > certain properties hold); > 3. Rigorous testing of network-wide invariants, if all the nodes > operate correctly. > > The problem we're facing is the following ? if we want to inspect > state of nodes in Haskell-land, we have to write a huge machinery > which emulates every launch of node via thread. There will be bugs in > this machinery, so we won't be able to get quality testing information > before we fix those; if we want to run things as processes, then the > best thing we can do is to inspect either acid-state dbs of each node > (it poses resource locking problems and forces us to dump the state on > every change, which is undesirable), or make an observer node, which > dumps the consensus as Text and then parsing the data into Haskell > terms, making decisions about the required properties based on that > (so far, it feels like the best option). > > Am I missing something? How is something like this achieved in > culture? How would you approach such a problem? > > Links to source files of test suites which do something similar are > highly appreciated. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From anakreonmejdi at gmail.com Thu Mar 31 15:37:08 2016 From: anakreonmejdi at gmail.com (Anakreontas) Date: Thu, 31 Mar 2016 08:37:08 -0700 (PDT) Subject: [Haskell-cafe] ghc 7.10.3 crashes frequently on Windows Message-ID: <129fce9d-22c6-42da-87c9-436101af10ea@googlegroups.com> I have installed ghc from Haskell Platform version 7.10.3. When I run QuickCheck or HSpec tests interactively, every so often ghc crashes when I reload a file form withing Emacs and haskell mode. This problem manifested in earlier versions as well. Loading a file which does not contain tests never crashes ghc so far. How could I try to identify the cause of the crash? -------------- next part -------------- An HTML attachment was scrubbed... URL: From anakreonmejdi at gmail.com Thu Mar 31 15:43:31 2016 From: anakreonmejdi at gmail.com (Anakreontas) Date: Thu, 31 Mar 2016 08:43:31 -0700 (PDT) Subject: [Haskell-cafe] Deriving Eq and Show instances for testing Message-ID: <61344674-9551-4bac-ae4d-37321d3a2ab0@googlegroups.com> I have datatypes for which I need an Eq and Show instance only for testing. I could derive those instances in the datatype declaration but I prefer not to add unnecessary functionality. With StandaloneDeriving extension I can derive the instances in the test module but this produces many warning about orphan instances. Is there a better approach or a way to stop reports about orphan instance warnings? Regards -------------- next part -------------- An HTML attachment was scrubbed... URL: From ruben.astud at gmail.com Thu Mar 31 15:50:24 2016 From: ruben.astud at gmail.com (Ruben Astudillo) Date: Thu, 31 Mar 2016 12:50:24 -0300 Subject: [Haskell-cafe] Deriving Eq and Show instances for testing In-Reply-To: <61344674-9551-4bac-ae4d-37321d3a2ab0@googlegroups.com> References: <61344674-9551-4bac-ae4d-37321d3a2ab0@googlegroups.com> Message-ID: <56FD4740.2060603@gmail.com> On 31/03/16 12:43, Anakreontas wrote: > I have datatypes for which I need an Eq and Show instance only for testing. > I could derive those instances in the datatype declaration but I prefer not > to add unnecessary functionality. With StandaloneDeriving extension I can > derive the instances in the test module but this produces many warning > about orphan instances. Is there a better approach or a way to stop reports > about orphan instance warnings? > > Regards > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > You can put {-# OPTIONS_GHC -fno-warn-orphans #-} At the top of such files to stop warnings, see also [1] [1]: https://stackoverflow.com/questions/3079537/orphaned-instances-in-haskell -- -- Ruben Astudillo From omeragacan at gmail.com Thu Mar 31 16:18:49 2016 From: omeragacan at gmail.com (=?UTF-8?Q?=C3=96mer_Sinan_A=C4=9Facan?=) Date: Thu, 31 Mar 2016 12:18:49 -0400 Subject: [Haskell-cafe] hslua and language-lua need new maintainers Message-ID: Hi all, I need new maintainers for my packages hslua[1] and language-lua[2]. None of these packages is super popular so it's not going to be a lot of work. I just need someone to take care of new issues and pull requests. + points if the maintainer is a user of the library :-) I just don't have time and motivation to maintain those as I'm not a user anymore. Some background, lanugage-lua was the first Haskell program I've written (according to git logs, 3 years 6 months ago). I maintained it over the years and used in some projects. Currently Eric Mertens (glguy) is also a maintainer who occasionally sends some patches, but I need someone to take care of the new issues and pull requests. One thing you may want to do is to merge Eric's patch that ports the parser to Happy (currently it's Parsec) and improves the performance significantly. hslua was originally written by Gracjan Polak. I was using it and sending some patches and eventually I became the maintainer, created a Git repo, wrote some blogs posts about it, wrote tests and examples etc. I think the library is in good shape. One thing you may want to do if you take over the maintainership might be to port it to Lua 5.3 and drop the LuaJIT support. Every once in a while someone asks for it, there's even a pull request that is in bad shape that makes it working with 5.3. There's also another feature request for handling memory exhaustion in the interpreter. If you're interested in maintaining any of these please reply to this thread or send me a mail. Thanks. --- [1]: http://hackage.haskell.org/package/hslua [2]: http://hackage.haskell.org/package/language-lua From pakin at lanl.gov Thu Mar 31 20:05:57 2016 From: pakin at lanl.gov (Scott Pakin) Date: Thu, 31 Mar 2016 14:05:57 -0600 Subject: [Haskell-cafe] Postdoc ad: quantum-computing programming languages Message-ID: <56FD8325.7070603@lanl.gov> My institution just bought a D-Wave 2X adiabatic quantum computer. The problem is, no one really has a grasp on how to *program* an adiabatic quantum computer. It's a totally different beast from the gate-model quantum computers that most people imply when they talk about quantum computing. I'm looking to hire a postdoc to work with me on designing and implementing programming models suitable for execution on D-Wave-style quantum computers. The formal job ad can be found at http://tinyurl.com/jdlo556 or go to http://jobs.lanl.gov/ and look up job IRC49031. Disclaimer: This is not specifically a Haskell-hacking position, although you can use any language you want for the classical-side development. I'm posting here because a key skill I'm looking for is breadth of language knowledge. I see a candidate who knows nonstrict functional programming, declarative programming, and maybe a few "fringe" programming models as more valuable than one who knows only a dozen isomorphic imperative languages. -- Scott From f.occhipinti at gmail.com Thu Mar 31 20:12:19 2016 From: f.occhipinti at gmail.com (Francesco Occhipinti) Date: Thu, 31 Mar 2016 22:12:19 +0200 Subject: [Haskell-cafe] Postdoc ad: quantum-computing programming languages In-Reply-To: <56FD8325.7070603@lanl.gov> References: <56FD8325.7070603@lanl.gov> Message-ID: It is amazing to see this coming. Philip Wadler uses to say that ?-calculus is "Multiversal" ... I guess that with the paradigm shift brought by quantum computing we will have an opportunity to verify the statement! 2016-03-31 22:05 GMT+02:00 Scott Pakin : > My institution just bought a D-Wave 2X adiabatic quantum computer. > The problem is, no one really has a grasp on how to *program* an > adiabatic quantum computer. It's a totally different beast from the > gate-model quantum computers that most people imply when they talk > about quantum computing. > > I'm looking to hire a postdoc to work with me on designing and > implementing programming models suitable for execution on D-Wave-style > quantum computers. The formal job ad can be found at > http://tinyurl.com/jdlo556 or go to http://jobs.lanl.gov/ and look up > job IRC49031. > > Disclaimer: This is not specifically a Haskell-hacking position, > although you can use any language you want for the classical-side > development. I'm posting here because a key skill I'm looking for is > breadth of language knowledge. I see a candidate who knows nonstrict > functional programming, declarative programming, and maybe a few > "fringe" programming models as more valuable than one who knows only a > dozen isomorphic imperative languages. > > -- Scott > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dedgrant at gmail.com Thu Mar 31 20:52:08 2016 From: dedgrant at gmail.com (Darren Grant) Date: Thu, 31 Mar 2016 13:52:08 -0700 Subject: [Haskell-cafe] Postdoc ad: quantum-computing programming languages In-Reply-To: <56FD8325.7070603@lanl.gov> References: <56FD8325.7070603@lanl.gov> Message-ID: Congrats on the purchase! I am not qualified for the position, but it is exciting to see the hardware attracting comp sci researchers. I would love to keep up with the discoveries here. Cheers, Darren On Mar 31, 2016 13:06, "Scott Pakin" wrote: > My institution just bought a D-Wave 2X adiabatic quantum computer. > The problem is, no one really has a grasp on how to *program* an > adiabatic quantum computer. It's a totally different beast from the > gate-model quantum computers that most people imply when they talk > about quantum computing. > > I'm looking to hire a postdoc to work with me on designing and > implementing programming models suitable for execution on D-Wave-style > quantum computers. The formal job ad can be found at > http://tinyurl.com/jdlo556 or go to http://jobs.lanl.gov/ and look up > job IRC49031. > > Disclaimer: This is not specifically a Haskell-hacking position, > although you can use any language you want for the classical-side > development. I'm posting here because a key skill I'm looking for is > breadth of language knowledge. I see a candidate who knows nonstrict > functional programming, declarative programming, and maybe a few > "fringe" programming models as more valuable than one who knows only a > dozen isomorphic imperative languages. > > -- Scott > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: