Just releasing it was, ahem, fun, as somebody noticed that it didn't build in a clean sandbox, and then that the haddock comments were broken (it's a bit annoying that a one space error in Haddock markup causes the whole install to fail). So hopefully now it's ready for people to try and improve!
Pull requests welcome!!
In order to improve my personal coding style I'd like to take the time to study exemplary Haskell. Can you recommend certain libraries or examples that are written especially clearly and idiomatically?submitted by begriffs
[link] [27 comments]
For example, if I have f n = n2, is there a way that I can do read "f 5" that will return 25? Is it possible to execute functions though the read function?
EDIT: Or any other function for that matter. I'm just wondering if it's possible.submitted by k3DW
[link] [14 comments]
You'll find an old discussion here: http://www.reddit.com/r/haskell/comments/1xnmiv/monad_layers_an_alternative_to_transformers/
It seems quite promising, but the hackage package is not up-to-date with the GitHub source. Is anyone actively using this?
Some context: "Monad layers, an alternative to transformers: The author claims [layers package's] superiority over transformers, but given that in my whole Haskell experience I have never heard anything about that package I am interested why, also whether the author's claims are true and in general opinions from the community."submitted by eacameron
[link] [4 comments]
While recovering from a knee surgery, I entertained myself by solving a geometry problem from the last International Mathematical Olympiad. My solution, shown below, is an example of using plane transformations (spiral similarity, in this case) to prove geometric statements.Problem
Points \(P\) and \(Q\) lie on side \(BC\) of acute-angled triangle \(ABC\) such that \(\angle PAB=\angle BCA\) and \(\angle CAQ = \angle ABC\). Points \(M\) and \(N\) lie on lines \(AP\) and \(AQ\), respectively, such that \(P\) is the midpoint of \(AM\) and \(Q\) is the midpoint of \(AN\). Prove that the lines \(BM\) and \(CN\) intersect on the circumcircle of triangle \(ABC\).Solution
Let \(\angle BAC = \alpha\).
\[\angle APB = \pi - \angle PAB - \angle PBA = \pi - \angle ACB - \angle CBA = \alpha\]
Let \(B_1\) and \(C_1\) be such points that \(B\) and \(C\) are midpoints of \(AB_1\) and \(AC_1\), respectively.
Consider a spiral similarity \(h\) such that \(h(B_1)=A\) and \(h(B)=C\) (it necessarily exists).
Now we shall prove that \(h(M)=N\), i.e. that \(h\) transforms the green \(\triangle B_1BM\) into the magenta \(\triangle ACN\) .
Being a spiral similarity, \(h\) rotates all lines by the same angle. It maps \(B_1B\) to \(AC\), therefore that angle equals \(\angle(B_1B, AC)=\pi-\alpha\). (We need to be careful to measure all rotations in the same direction; on my drawing it is clockwise.)
\(h(A)=C_1\), since \(h\) preserves length ratios. So \(h(AM)\) (where \(AM\) denotes the line, not the segment) is a line that passes through \(h(A)=C_1\). It also needs to be parallel to \(BC\), because \(\angle (AM,BC)=\pi-\alpha\) is the rotation angle of \(h\). \(C_1B_1\) is the unique such line (\(C_1B_1 \parallel BC\) by the midline theorem).
Since \(h(AM)=C_1B_1\) and \(h(MB_1)=NA\), \[h(M)=h(AM\cap MB_1)=h(AM)\cap h(MB_1)=C_1B_1\cap NA=N.\]
Now that we know that \(h(BM)=CN\), we can deduce that \(\angle BZC=\angle(BM,CN)=\pi-\alpha\) (the rotation angle). And because \(\angle BAC+\angle BZC=\pi\), \(Z\) lies on the circumcircle of \(ABC\).
What are the current best practices for installing and maintaining Haskell development environment, with multiple versions of GHC, installed global packages, etc.
I know this question is probably here quite often, but after not having worked in Haskell for around 8 months, I've found that a lot of things have changed, and my old way of working doesn't work anymore.
I'm splitting this into multiple questions, so that it is easier to answer them.
- It seems that Stackage LTS is the way to go if one wants to avoid cabal hell while installing global packages (like ghc-mod, yesod-bin, hlint, etc.)?
- What version of cabal-install is the go-to one? Since cabal itself constantly prompts for new updates, I ended up installing 1.22.x, which turns out to be incompatible with ghc-mod on GHC 7.8 (https://github.com/kazu-yamamoto/ghc-mod/issues/429), and now I'm feeling stuck, now knowing if I should upgrade GHC, downgrade cabal-install, or choose a completely different approach?
- Is there a point in using sandboxes when one uses Stackage? I used to use sandboxed for everything, but if Stackage LTS would avoid the versioning issues, are they still needed?
- What is the correct way of installing global packages, such as (ghc-mod, hlint, ..., or even lens)? Should I rm -rf ~/.ghc ~/.cabal, install a specific version of cabal, download stackage config and then proceed with installing everything else? Or is there a better way?
- What is the best way of installing GHC on OS X? There's Haskell Platform, Homebrew GHC/Cabal formulas, and Haskell for OS X. I've been told that Homebrew formulas were broken a few months ago, and that Haskell Platform is not good if you plan on doing anything but the most basic things. And now that I'm looking at versions of Cabal, it seems that Haskell for OS X uses cabal-install 18.104.22.168, while Stackage LTS locks at 22.214.171.124 ... wouldn't this cause problems? One can also download the binary build of GHC and install it manually, which seemed to work quite well in the past, but it wasn't so easy to uninstall.
- Similar to the previous question, what is a good way of maintaining multiple GHC versions? There are versions of packages that only work under GHC 7.10, and others that don't, so it seems quite important to be able to switch with ease, without having to reinstall everything.
I'm sorry if this looks like a rant, but I just can't seem to find this kind of information written up in one place. There are snippets and guides and tutorials, and everyone is recommending something else (since there are multiple solutions), but also every time I ask on IRC or somewhere about an issue like this, it ends up being a problem in my setup and I have to reinstall a bunch of packages to get everything working again.
TL;DR: What is the best and most versatile way to install GHC, global packages and avoid reinstalling every single thing every time in a sandbox. It's not that I don't like sandboxes, but my fastest quad core machine still takes over a half an hour to build some packages, which just kills the "let's quickly start up a new project and play around" kind of work.
edit: It'd be great if we had a list of the install options, with pros&cons and recommendations when to use which one, such as "don't use Haskell Platform if you want to use bleeding edge packages, because of X", etc.submitted by progfu
[link] [26 comments]