Announcing the new Haskell Fundamentals trail

We’ve been learning and teaching each other Haskell for a while now, and we’ve
been using the same exercise system you do to create and participate in Haskell
exercises. Today, I’m happy to announce that these exercises are now available
to all of you in a brand new “Haskell Fundamentals” trail!

https://thoughtbot.com/upcase/haskell-fundamentals

This trail is designed to be a companion to the excellent book, Learn You a
Haskell for Great Good!
You can read it online
for free or buy it in print or ebook format.

Haskell is a richly-typed, purely-functional programming language. Learning
Haskell will introduce you to a totally different world of programming, giving
you another powerful tool in your programming belt, as well as providing new
perspectives on the Ruby concepts you already know.

We hope you’ll use some of your downtime during this Thanksgiving break to learn
Haskell with us. Let us know what you think!

2 Likes

Hey Joe!

Could you provide a use-case for Haskell that you guys have used on an actual project? I don’t doubt Haskell is good for me, but, just like exercising and eating right, it helps to have a motivation for “What I can accomplish with this.” I certainly can google my way to an answer, but I’m interested in the types of things the Robot crew does with Haskell to solve client problems.

Haskell is a general-purpose language - it can do anything - and in the end, a dominant factor is going to be preference. I’ve started to prefer Haskell to Ruby in general because:

  • I really enjoy functional programming. I find functions to be easier to compose than classes.
  • I really enjoy statically-typed languages. Users of these languages tend to think more about the types, rather than using arrays, hashes, and nullable references everywhere. I find it comforting to catch errors during compilation. I find it frustrating to catch errors during development. I find it scary to catch errors in production.
  • I really enjoy Haskell’s rich type system. You can encode more of the domain in Haskell’s types, which serves as executable documentation and eliminates an entire class of unit tests you need for Ruby.
  • The Haskell community is dedicated to experimentation and constant improvement.

When trying to gauge whether to use Ruby or Haskell, here are some important questions to ask:

  • Is the Ruby ecosystem particularly good or bad at the problem you’re trying to solve? Rails is great at building form-based, database-backed applications with a little JavaScript layered in. I’ve found Ruby to be lacking when it comes to things like parsing, concurrent processing, and complex logic.
  • Is the Haskell ecosystem particularly good or bad at the problem you’re trying to solve? Haskell has wonderful libraries for complex problems, but it’s frequently behind Ruby when it comes to things like libraries for interacting with GitHub or newer databases.
  • Will you introduce an unreasonable amount of risk by introducing a language you’re less familiar with? Newer languages always introduce risk, but following your passions and preferences can help to overcome that risk. However, it’s good to be honest with yourself and your team about how risky your new favorite language might be.

Our best production showcase app is currently Carnival, which powers the comments on our company blog.

I signed up for Upcase to learn Haskell, so I’m super excited about this, but the fundamentals track seems to be lacking in instructions.

I figured out that I need to run ‘cabal sandbox init’ (the instructions didn’t say I would) in order to run ‘cabal test’ but then ‘cabal test’ returns:

$ cabal test   
Preprocessing library head-tail-init-last-0.0.0...   
[1 of 1] Compiling HeadTailInitLast ( src/HeadTailInitLast.hs, dist/build/HeadTailInitLast.o )
In-place registering head-tail-init-last-0.0.0...
Preprocessing test suite 'spec' for head-tail-init-last-0.0.0...
test/HeadTailInitLastSpec.hs:3:8:
    Could not find module ‘Test.Hspec’
    There are files missing in the ‘hspec-2.1.2’ package,
    try running 'ghc-pkg check'.
    Use -v to see a list of the files searched for.
test/Spec.hs:4:8:
    Could not find module ‘Test.Hspec.Discover’
    There are files missing in the ‘hspec-2.1.2’ package,
    try running 'ghc-pkg check'.
    Use -v to see a list of the files searched for.

How can I fix this?

Have you run bin/setup yet? Each repository comes with a bin/setup script which attempts to prepare the dependencies. That will take care of initializing the sandbox and installing test dependencies.

I had run bin/setup, but “cabal test” returned an error that suggested I hadn’t initiated the sandbox. once i ran “cabal init” it said it would use the existing sandbox, and the error went away.

After that, running “cabal test” as instructed on the page you linked gives me the error in my previous message.

Can you run the following from a shell and paste the output?

git clean -fxd
bin/setup

That will let me see the original error so I can tell what’s going wrong with the bin/setup script.

I am getting this error when I run bin/setup:

$ bin/setup
cabal: unrecognised command: sandbox
$ ghci --version
The Glorious Glasgow Haskell Compilation System, version 7.6.3
$ cabal --version
cabal-install version 1.16.0.2
using version 1.16.0 of the Cabal library

Do I need a newer version of cabal?

The sandbox feature was added to Cabal 1.18, so you’ll need to update.

Generally, you can do this by running cabal install cabal-install.

“The last reply to this topic is now over 205 days old.” Sorry about that, but I can reach the haskell trail by following this link, however it’s not visible from the upcases/practices page. I’m really excited about Haskell and eager to dive in further, just curious what’s going on with that, why it’s not listed among the trails by default.

Edit: I see this is covered in the “Retiring trails” thread.