[Haskell-cafe] What is your favourite Haskell "aha" moment?

Vilem-Benjamin Liepelt vl81 at kent.ac.uk
Fri Jul 13 19:14:31 UTC 2018


Dear Simon,

I was always impressed by Haskell, but my "aha" moment was when I realised how great it is as a scripting language. How cool is the fact that you can glue together a bunch of small programs and make a bigger program out of it without toil? Haskell helps you get mundane tasks done while being a pleasure to write (in relative terms)!

There are much better examples online—I love Gabriel Gonzalez' turtle library—but I find the following compelling enough, and anybody can understand more or less what is going on with some explanation:



#!/usr/bin/env stack
-- stack script --resolver lts-10.1 --install-ghc

{-# LANGUAGE TypeApplications #-}

import Data.Maybe (mapMaybe)
import Text.Read (readMaybe)

main :: IO ()
main =
  interact
  ( show @Double
  . sum
  . mapMaybe readMaybe
  . words
  )

-- Adapted from a script by Taylor Fausak: https://gist.github.com/tfausak/fcd11dfcec616622033dfb64eb2378e1



Good luck with the presentation!

Best,

Vilem
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20180713/0f661714/attachment.html>


More information about the Haskell-Cafe mailing list