After I updated GHC to the latest version, I have got very weird and annoying error that constantly has been appearing when I open a Haskell source file in Emacs:
HandsomeSoup-0.4.2-686424195026beeaefb436ceaeb25636 is unusable due to missing or recursive dependencies:
HTTP-4000.2.20-4ed6237e324cc4ce05d3713645af2c44 base-220.127.116.11-075aa0db10075facc5aaa59a7991ca2f containers-0.5.6.2-2b49cce16f8a2908df8454387e550b93 hxt-18.104.22.168-a32a252f9c713840de391f0697d844e0 hxt-http-22.214.171.124-2d2f40dc927b9b1b2fc42c5087997de9 mtl-2.2.1-5cf332b11edb88a6040af20fd6a58acb network-126.96.36.199-54f9bbbc4dc78b945fb82127414a5b82 network-uri-188.8.131.52-a5f987b3a4896895214d8fff79983154 parsec-3.1.9-bddea73c8bf2d5ff1335dae2cc92e789 transformers-0.4.2.0-21dcbf13c43f5d8cf6a1f54dee6c5bff
(use -v for more information)
I spent a couple of days on resolving this issue, and the clue is apparently very simple. I made this note just to keep in mind how this error can be resolved.
First of all, check which GHC version you have installed don your machine:
# ❯ stack ghc -- --version The Glorious Glasgow Haskell Compilation System, version 7.10.2
Next, check which GHC version ghc-mod is linked to:
# ❯ ~/.local/bin/ghc-mod --version ghc-mod version 184.108.40.206 compiled by GHC 7.10.3
Here we have a difference: system compiler is of version 7.10.2, and ghc-mod is linked to 7.10.3 — and this is the root cause of the problem.
Also, check the project.yaml: resolver should be set to lts-5.1 for GHC 7.10.3 (for 7.10.2 it would be of 3.4)
GHC is stored in the project locally: ./stack-work/install/
Globally GHC can be found under: ~/.stack/*/
Playing with Scala, have written a simple tool for basic controlling HornetQ: HornetQ web console
Even Fibonacci numbers
Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.
lastN :: Int -> [a] -> [a] lastN n l = foldl (const .drop 1) l (drop n l) fibo' :: (Num a, Ord a) => a -> [a] -> a -> a -> [a] fibo' n l x y = if x+y <= n then fibo' n (l++[x]) y (x+y) else l++[x,y] fibo :: (Num a, Ord a) => a -> [a] fibo n = fibo' n  2 3 fi :: (Num a, Ord a, Integral a) => a -> a fi n = sum [x | x <- fibo n, 0 == mod x 2]
Multiples of 3 and 5
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
Find the sum of all the multiples of 3 or 5 below 1000.
sum [x | x <- [1..1000], x < 1000, 0 == mod x 3 || 0 == mod x 5]
lists:sum([X || X <- lists:seq(1,1000), X < 1000, (0 == X rem 3) or (0 == X rem 5)]).
A new book on WebRTC is finally published: WebRTC Cookbook! It is definitely worth to take a look, if you're developing any WebRTC-related service.