Almost anyone productively using Haskell has already stumbled upon Michael Snoyman’s Conduit library.
In this post I will show how to leverage the power of Conduit interleaved IO in order to parse author’s names from the Open Library data dumps.
Using traditional languages like Java or C, it would be significantly more difficult and error-prone to interleave the processing pipeline actions of
- Downloading the file
ol_dump_authors_latest.txt.gz using HTTP
- Decompressing using a
- Splitting into lines and discarding everything but the JSON from said lines
- Appropriately decoding the JSON and extracing the
name field, or ignoring the line if parsing is not possible
- Writing all said names into a files (
authors.txt in this example), one per line.
Using haskell, you want to get the current hour / minute / second (for the current timezone) as integral values.
Lately I’ve been experimenting with using Atom to generate intrinsically reliable embedded software.
In contrast to alternatives like Copilot in Atom you include the surrounding C code as Haskell strings whereas other concepts just generate a set of C files to include in your main code.
When running your Haskell program, you get the following error:
commitAndReleaseBuffer: invalid argument (invalid character)7
Using haskell, you want to get the current year, month and day (for the UTC time zone) as integral values.
In this post, we will show a method and provide a Haskell module capable of parsing both the IEEE OUI list and the IEEE IAB list.
While our code only parses the databases into an object form and doesn’t insert them into a tree capable of fast MAC address -> vendor lookup, it is based on Attoparsec, providing good performance and high flexibility for changes.
Problem: In Haskell, you intend to filter with an inverted filter operator.
For example, your code is (GHCi):
Prelude> import Data.List
Prelude Data.List> filter ( isPrefixOf "a" ) ["a","ab","cd","abcd","xyz"]
The list you need is
["cd","yz"]. In some cases, the easiest solution would be to use for example
<= instead of
>, but there isn’t a literal complement for all functions, like for example isPrefixOf, which is being used in the example.
In Haskell, you want to gzip-compress a string and write it to a file.