-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Content Decisions for the new Cabal User Guide #1
Comments
Here are my initial thoughts:
I would love to have an involved role in this, and will spend some time over the weekend putting together my thoughts and suggestions. |
I'm very happy to see this initiative! Do you think setting up CI for a cabal project is something that should be covered in this guide as well? Another thing I'd be really happy to see is information on how to compile a Haskell project that can be deployed/run on other computers, maybe using static compilation and musl, ghc-musl, AppImage, or something else. Here are a couple more articles that could be use as inspiration (they use
|
@JonathanLorimer To your first point, absolutely. I think the more we can make a distinction between what documentation is useful for the better. The fact that the purpose of the docs on readthedocs is ambiguous is a big part of the problem. When we pipe new users to it, it's functionally useless for autodidactism! Re: Kowainik and School of FP, great finds. I'm happy to lean on them for inspiration. @soupi Absolutely. CI is fundamental to building a project and effectively testing it as it scales. Regarding static builds, I leave that to folks who have more experience with it. |
Let me elaborate why I think static builds is an important addition: a common problem that I have is that I run ubuntu 20.04 and I want my Haskell program to run on a remote linux box that has an older version of ubuntu. This linux box is often too weak to be able to successfully compile my programs, so I need to compile it on my computer and run the executable on the remote computer. This often fails because of glibc version mismatch. This issue will also pop-up when trying to provide an executable project for download of course. Over the years I've learned tricks to deal with it using static compilation. First with static-haskell-nix, and later with ghc-musl and even later with AppImage and hsinstall. But there may be other options I'm not aware of. I don't know if this is something that many people run into, but I ran into it fairly early and I have a feeling there are more people that have run into it. So I would be really happy if this tutorial could address this issue, whether using static builds or not. |
@soupi I'm happy for you to write a blurb about it, but consider scope: if we have to introduce several new tools to work it in, it may be out of scope for this being a Cabal user guide, whereas it may be more appropriate for future Haskell Book endeavors that will come down the line. I leave it up to you and other people more familiar with it to hash it out. I will not block the contributions if people write it, and it's justified! 😄 |
I think a small note on stack vs cabal would be good somewhere in the guide. As this is a very common question from beginners. Ie. something like:
|
Disagree. This is a cabal user guide. If someone is reading it, that would be because they've already made a choice. That material is suitable elsewhere, but this guide is explicitly for a particular tool and it is important to keep its focus narrow and laser-like to be effective. |
I know the |
I would argue that understanding alternatives to cabal is good for cabal users. It's fine if the comparison is a bit biased towards cabal. As an example I found More generally I think it is good for Haskell users. Perhaps this guide isn't the place? But I think it should be documented somewhere as it is key information that users currently need to get explained (in a biased way) in various Haskell forums. The standard answer to the question for beginners is 'just use stack'. A more nuanced comparison to link to would probably help cabal get users IMO. |
@AlistairB this could be an interesting addendum, and I'm imagining a table of comparisons between things like Stack, Bazel, Hadrian, and so on. However, I do think this user guide should focus on the tool in and of itself before considering its pros and cons with other tools. It does impose a burden, wherein we have to hope that at least a few contributors are familiar with both tools in order to maintain the documentation if Stack ever changes our comparison table, and I would hope that we could come up with something Cabal-centric first, before imposing that burden. |
Great ideas. I think it's fine to have an optional fluff introduction that discusses the context of cabal, such as GHC, ghcup and other ways to get cabal, Hackage, haddock, stack/LTS, CI, portability/static compilation, etc. and links to separate articles or appendixes or outside references about them. Just make sure it's in italics and otherwise obviously skippable for a person that googles for how-to-do-x and that the most common workflow howtos are at the start, perhaps in TL;DR version, again linking to a section describing the same in detail. Ideally the context fluff and the TL;DR versions would be immutable as tools change (e.g., the CI landscape changes often), while the in-detail articles would play the catch-up game. One more note to put in the fluff: the text tries to be up to date wrt newest published cabal version (if you agree that's the right policy; let's link to download for that version) and doesn't branch out into how it was done previously (with a possible exception of "since 3.4" or "deprecated" or similar annotations, but I think even those fit more a command reference, not a user guide). Lastly, I'm personally a fan of copy-paste programming and especially copy-paste learning, so I would not avoid front-loading the reader with a large .cabal file (to be copy-pasted from the guide, or even better, generated easily from |
I took a first run at coming up with a content structure.This was informed by @emilypi 's original post as well as the existing cabal user guide, kowainik's blog post, and school of fp's blog post. I created a summary of the topics covered by all three here. With regards to emily's original post, I figure the I think that a single example project can live in this repo, and we can use different directories to demonstrate the progression of the project as the cabal setup is expanded and improved. I was thinking that these different stages could correspond to different sections of the guide (i.e. a directory called ContentPreamble
New To Cabal
Leveling Up
Getting Fancy
Assumptions
Ideas For Appendices
|
For me this starts in the wrong place. The outlines look like a cabal package developer guide, rather than a cabal user guide. Before I want to initialise and develop a new package, I want to install an existing one. For me programming and using a library are not separate activities. I spend a lot of time working in ghci, as an 'end-user programmer'. To do this I want to install some libraries and use them together, to explore some idea. That said, some of those libraries I might be developing, and will want to re-install many times in the process of doing that. I can do My big worry is that while the v1- commands work well for me, the v2- commands in general are not designed for my approach to using haskell. I'd be very happy if I could finally work out how to use the v2- commands to do what I want, though. addendum I click on 'quickstart' and get instructions for how to install and use pip to install some libraries. Once I do that I can jump into ipython and start exploring them. Great! I'd find it a bit distressing if step one was "create a python project from scratch". Even if I click on "Python packaging user guide", the first tutorial is how to install packages, not how to make them. |
@yaxu I wish we could write a good users guide for the workflow you describe. But as you well know, until some additional work is done on cabal proper, that v2 workflow will not be nearly as seamless as you want! I think we should try to provide two quickstarts though, one with the package/application oriented workflow, and one with an exploratory/hacking workflow. The latter can explain making use of |
Hello I'm in the same position as @yaxu, i.e. my work is almost all done in the interpreter (ghci). And I have the exact same problem, I can't work out how to get v2- to install a set of loosely inter-connected libraries and have them appear in ghci (and ghc --make). So far I've just kept using v1- but I know at some point that won't work anymore. It'd be super helpful to have a transition guide for this kind of work. For instance, at the moment the way I update an existing library is to run "cabal v1-build && cabal v1-copy && cabal v1-register" v2- doesn't seem to have either copy or register? It's not clear what to do instead. Best, Ps. I recently tried to setup a system using v1- with ghc-8.10.5 and cabal-3.4.0 and it failed, with the error mentioned at: I'm a bit worried v1- will stop working before I can work out how to use v2- and I'll be stuck. |
@rd-- it seems like a Cabal User Guide that focuses on the v2 commands (just regular commands in cabal-3.4.0) would be beneficial for you? Correct me if I am wrong. I think a migration guide from v1 to v2 is more of a reference thing, but might make a nice appendix entry, I will add it to the list. @yaxu I am very interested in your pedagogical philosophy. I am definitely biased here, I learn much better when I can start from first principles and understand something end to end. However, I definitely respect the exploratory approach; get up to speed quickly and start playing around. I have a big ask of you yaxu, could you take the content template I have laid out above and re-arrange it / add and subtract things so that it fits your ideal curriculum? I think that would be the most productive way forward. I think that there might be something clever we can do with mdbook to take the same chapters and produce 2 books laid out in different orders. I know you say it is distressing to be confronted immediately with "starting a project from scratch", but you must admit that some people are looking for this kind of instruction. Also, in my opinion, installing a dependency is usually done relative to a project that is in need of a library, so I think that my original content template is at the very least defensible. The key takeaway I am getting from this ( |
Hello Jonathon Thanks, perhaps, although the transition guide I was thinking of was quite specifically how to do what I think @gbaz calls above "exploratory coding in a defined environment", where the environment in the one that you get when you run Does this make sense? It seem that perhaps at the moment this is not possible though? I'm not sure if Best, |
@JonathanLorimer: I'm afraid you are suddenly burdened with
These are the most difficult kind of questions for cabal maintainers, because they involve prioritizing some users at the expense of others, so there are no good answers, only bad and worse, according to one of many possible metrics. Also, no matter how brilliant the prioritizing, lots of raw effort, timely user feedback, luck with upstream fixes, patience and good will on all sides, most of all the side that is losing due to the decisions, is needed to move forward. FYI, the status quo we have inherited and we work with seems to be
@emilypi, @fgaz, other esteemed contributors, please correct me if I'm off the mark. Dear users of the "exploratory programming in a defined environment" workflow, thank you for making your voice heard and we also need your contributions in the respective tickets (mostly #6481, I guess). |
Yes definitely. I think probably all package management software apart from cabal present things in this way. The reason for this is that almost all users will want to install a library before they make their own package. If you disagree, please show me a Haskell textbook that puts 'how to create a haskell package' ahead of 'how to write haskell code'. For example real world haskell first tells you how to install ghc and run ghci: There is something about cabal in an appendix, but only how to install something. I feel like I'm being treated as an outsider when this is a totally standard way of learning and working, which is seemingly not supported by cabal any more. I find this baffling, but in case my tone is misread - I'm not angered by this, I'm fascinated. I'd really like to get to the bottom of this mismatch.
From what others write in this thread it seems that such a migration guide is not possible as the v2- commands are missing key features. At the same time v1- commands are unsupported and are undergoing bitrot.
Me too! But I don't think learning the intricacies of packaging is part of the first principles of programming.
I think the above outlines are fine as an introduction to making cabal packages. I just think there needs to be a separate document presented for new users that is about using them.
Yes, eventually, if they want to package up some code they've made. But I think they will want to install an existing library firs.t
Yes if you are already working on a project such content would be useful. |
I do by the way find this issue really serious. Newcomers to Haskell will pick up a copy of books like 'real world haskell' and find that the approach to programming that is introduced is not supported any more. I think haskell will be losing a lot of users over this, maybe over half? The profound difficulty in installing and using the tidal library is certainly losing end users in that kind of number. |
Some more examples.. Basics quickly cover how to install and use ruby gems. Step two is how to create your own package: However with stack, after a couple of minutes I still didn't find any information about how to install a library from stackage: Like with cabal, the 'quick start' documentation goes straight into how to create a new 'project'. So despite the cabal and stack folks behaving like different religions, it seems there is something about the recent Haskell mindset that runs against wanting to install a library outside of a particular project or package? I wonder where this comes from, and why it wasn't there when the v1- commands were designed. People keep mentioning this 'nix-like' thing, I'm not sure what that is, but maybe it's the source of this mindset? |
What you say, @yaxu, suggests the following questions to me: To what extent Cabal User Guide should become or contain or link to Haskell User Guide or Haskell Interactive Environment User Guide? What are the places readers are likely to be redirected to Cabal User Guide from and how should we cater to each class? E.g., one class I didn't think of is the people that googled cabal after trying to use cabal as instructed in old Haskell books and failing. There are, of course, many more obvious classes, very different from the dog-fooding class (cabal developers themselves, looking up a friendly workflow they never used before). |
Hi @Mikolaj, I guess the point of your question is to passively imply that people who want to use cabal to install something aren't using it in some sense, but I'm not sure. Could you explain yourself a bit more please? Jumping back in time a bit: https://cabal.readthedocs.io/en/2.4/ It starts with quite a friendly explanation of what cabal is, what it compares with (eggs, gems, cpan), and how to install packages with it including from hackage. What was wrong with this? As far as I can see, starting with anything more advanced than that would alienate all new users, and introductory guides normally begin by considering with new users, rather than denying that they exist. Again, I maintain a cabal package myself, so am also part of the dog-fooding class I suppose. |
Also one thing that hadn't occurred to me are the different definitions of "using" software here. When I think of using a package, I think of using a library and calling it from my code (my code is generally a repl, a project, or a cabal package itself). I did not think of the case where people are using cabal like I also think that the questions highlighted by @Mikolaj are good ones. Perhaps these action items are satisfactory?
|
Aha yes that makes sense! Of course Haskell is both interpreted and compiled. So could it be that between v2 and v3 of cabal people using it as an interpreted language somehow got totally forgotten? Despite that generally being how new users learn to program, and how many use it daily as part of an interactive workflow. |
Cabal hell was wrong with this. Daily reports from desperate users that wipe out their ~/.cabal [edit: and ~/.ghc] repeatedly and still can't compile, with different error each time, due to subtly transitively conflicting dependencies. Nix, stack, some OSes, most distributions of commercial software deal with it by either curating a fixed set of libraries or bundling all dependency libraries with the executable in hand and trying hard to avoid seeing any library installed outside a sandbox or project lest it introduces conflicts. We naively thought that Nix style is the way to go, including repl use, because the topelevel global namespace is just one more project, right? Years later we'll have it implemented RSN (#6481 and GHC fixes). |
I think the discrepancy here is that one must use cabal to use other developers' libraries, so I think there is an aspect of cabal that is commensurate with "how to write haskell code", but is still short of "how to create a haskell package". In this case, users still need to know how to make cabal aware of their code (as a library or executable) so that cabal can provide the external code and the user can compile everything. Even though compilation is generally seen as a "packaging" step, it is also a development aid in haskell. I hope that explanation demonstrates that we really aren't trying to throw beginners off the deep end. From my perspective, and the beginners that I have helped teach haskell, starting off with a project is a totally standard way to get up and running. I also think this is pretty standard in the world of javascript, ruby and python. Many javascript guides begin with
I am sorry to hear that you feel this way. FWIW different opinions are really important for these kind of guides and your input has made me aware of a workflow I hadn't even thought of (I am a relatively new cabal user btw). I also hope you don't feel like we are ganging up on you. I think we are just a) eager to discuss this topic and b) keen to find some kind of consensus so development on this user guide can begin! |
@JonathanLorimer Well something that a lot of beginners/learners (and we are all learners) share with a lot of professional end-user programmers is that the outcome they want isn't a program as such. A programming language can be a user interface to interacting with the world rather than a system for building an application for later use. Tidal is used to make live music as per the videos here https://tidalcycles.org/ . Scientists often use REPLs in a similar way to explore a dataset using statistics and visualisation. |
I think @rd-- 's use case is fully solved by
This seems like a flaw in the documentation. The library dependencies will be compiled code. Only the current project (which is null in the standalone case) is loaded interpreted. So simply moving The problem is that @yaxu 's workflow is more complicated, since that involves experimenting with a combination of local and hackage packages, i.e. sort of weaving together a combination environment, and also experimenting with updating local portions of that environment incrementally. This is precisely the sort of thing the That said, @yaxu, I'm still not sure why the |
Thanks @gbaz, looking at |
This is my revised content outline, given the discussion above ContentPreamble
New To Cabal
Leveling Up
Getting Fancy
Assumptions
Ideas For Appendices
|
Outline looks good. A few notes: "Explanation of different pieces of cabal (cabal-install, Cabal, and .cabal files)" -- mention cabal.project too even though you'll only get to them in "Getting Fancy". Under "Foreign Libraries" probably worth mentioning explicitly cpp and hsc2hs and c2hs and how they work with cabal (though not teaching how to use them as such). Also perhaps worth mentioning doctests in the fancy section. Also worth teaching: "If I have a project and now want to do a profiling buiild, how do I do that". |
great feedback, edited to reflect those suggestions. |
Great outline, definitely the right steps! It is already quite detailed, which I think is awesome! I am a bit afraid of assuming version 3.4, e.g. ubuntu has at most version 3.0 (https://packages.ubuntu.com/search?suite=default§ion=all&arch=any&keywords=cabal&searchon=names). Additionally, I think it might be nice to have a guide (maybe appendix?) on how to start your own local hoogle instance for querying your project, hope that isn't out of scope, but I think it is an important part of a cabal project. In the current Outline, I don't see where CI would be mentioned, just want to remind that this would be cool, too. Maybe even a docker section for gitlab? In that sense, deployment could be a section in the guide (expanding on static builds topic). |
@fendor I think CI is a rather large topic. I am not against it as an appendix, but it seems like there are lots of variables (cabal with nix, cabal with docker, github actions, travis ci, appveyor etc.). I will add it to the content outline as a stretch goal. I think its a great topic and would serve a lot of people well, but I am a bit uncertain how to structure that section. |
For me, it would be useful to even learn from the guide that various tasks can be integrated/automated/helped by cabal, with links or even without. I can google the details but the inspiration is invaluable on its own. E.g., various CIs offer ages old GHC setups and I might naively try to use these instead of searching for up to date scripts maintained by users. |
@Mikolaj thats very interesting. Perhaps an example that uses almost exclusively cabal for running tasks in ci would be useful. Then users with more complicated setups (thinking of nix here) can take the bits that apply! |
A good example is the old and trusty https://github.com/haskell-CI/haskell-ci for Travis with its interactive tool that generates a Travis script that uses cabal for the heavy lifting. I'm not up to date with others (AppVeyor, github, etc.) or perhaps there is (going to be) a universal one somewhere? |
Hello again, Looking further into this I'm still not sure One reason is that it's very slow, which is a problem if you have small haskell programs that you need to run in an interactive context.
One-fifth of a second is acceptable latency for "Select Menu Item -> Get Output" and on, whereas three seconds isn't really. So I think a section on "How to install libraries so they can be loaded by ghci (and located by ghc --make)" would still be very useful! Also (and I very, very much appreciate all the excellent things cabal does, it's wonderful!) I do think that for certain people in certain situations it's still nice to be able to think about Cabal as a program that's used to install Haskell libraries. So it'd be nice to have a section in the manual that tells people how to use it that way. Best, |
Is there a cabal issue about that? I'd like to understand why |
I don't know if there's an issue. I did look now and couldn't see one, but there's 1414 open issues (eek!) so I might've missed it... I don't actually use And mostly I do work in Emacs, with a long running connection to ghci. But not always, so it's nice to have scripts that do useful things and run fast. It does seems like (hopefully) some form of But maybe this does mean, in relation to the outline @JonathanLorimer sent above, that it might be nice to have a distinct section in "New To Cabal" for this, instead of just having "Cabal Repl". (Or perhaps making that section cover both cases and calling it something else? It's a little complicated because it's not only about the "interpreter", it's also related to whether you can use Best, |
@rd-- Yes the startup delay is enough of a reason to stick with the v1- commands for me. Perhaps there should be a transition section of the user guide that covers aspects not currently supported by v2-, that are covered by v1-, and explains how utilities like ghc-pkg relate to the different versions? |
@Mikolaj Some meta issue is here: haskell/cabal#6977 |
@fendor: thank you. The issue suggests the slowness comes from filesystem usage and lays out a path to working exclusively in-memory in such situations. I bumped priority of the issue, given that we'd love to get rid of v1-. Contributions are very welcome. Edit: however, /tmp on Linux boxes is usually a virtual file system, that is, in-memory. So I'm not 100% sure of the diagnosis. May be the fs-like bookkeeping and lots of memory allocations for the files is enough of a drag (and OS syscalls and inter-process communications at various stages). Edit2: @fgaz explains more in the issue, in particular, caching is needed. |
@JonathanLorimer and dear users, from our brainstorming on IRC and haskell/cabal#6977, it seems, if |
I am going to add a chapter for I think that the cabal user guide is not necessarily the correct place for deep treatment of cabal-alternatives as they pertain to specific workflow needs (startup speeds etc.), but rather it should focus on the kinds of workflows that cabal can offer or how cabal could fit into ones workflow. Additionally I am wary to direct users to |
@Mikolaj : I've left feedback (very positive!) for @JonathanLorimer : A chapter on I do think it's important that the manual not make it seem as if using cabal to install libraries for ghc/ghci is a particularly eccentric thing to want to do though, or that it's "for beginners" who will eventually move on to more serious things. I think it's just a different way of working, c.f. https://discourse.haskell.org/t/state-of-the-cabal-q1-q2-2021/2548/36 (and https://mail.haskell.org/pipermail/haskell-cafe/2021-March/133676.html which that quotes). |
100% agree on this. |
@rd--: I'm happy we are finding common ground. To reiterate: the v1- workflow leads to cabal hell (a kind of DLL hell; users getting used to it and then as their project grows suddenly getting impossible to resolve conflicts regularly). This is why we strive to convert as many users as possible to v2- and (with |
BTW, it seems this will be (quite late) addressed by the new guide: haskell/cabal#6104 (Documentation: v1 to v2 migration guide). I guess we should close that ticket once the guide has a preliminary release. Edit: I've also found a whole |
I am closing this issue because of #3 , If anyone wants new content to be included, or existing content to be altered, please submit a separate issue! Thank you to everyone who provided feedback! |
This repository intends to create a new Quickstart and User guide for the Cabal build tool. The Cabal team acknowledges that the current state of documents, located at cabal.readthedocs.io, serves more as a reference, and less as a guide for getting started or gathering intuition about how to effectively use the tool on projects. We would like to change this.
Tools
Rust has had a very successful, community-driven book built on mdbook, which allows users to contribute markdown to a codebase which may be compiled into a nice, legible and locally hostable book format. I propose we adopt this style, and contribute the missing content for this book in that format.
Content
There are two major areas of content that I'd like to cover:
stack
, or otherwise..cabal
and its components/vocabulary/syntax at a high levelcabal.project
and localcabal.project
configuration commands, syntax, and multiproject management. Here, we could add some content regarding remote source repositories like git..cabal
ecosystemGoals
The goals of this project, in my opinion, should achieve the following:
I'm interested to hear from @JonathanLorimer, @Mikolaj, @fgaz, @gbaz, and anyone else who has time to hash out an outline for this book. I'd love to have a public record here of our discussions for posterity.
The text was updated successfully, but these errors were encountered: