Skip to content

Commit

Permalink
Prepare article for publication
Browse files Browse the repository at this point in the history
  • Loading branch information
ploeh committed Feb 19, 2024
1 parent e9453cb commit 660fda5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ <h3 id="331b2ed3198f4a59872eb0e9d2f4ebd9">
As outlined above, I originally wrote a Haskell script to answer the questions, and only months later returned to the problem to give it a go in Python. When reading my detailed walkthroughs, keep in mind that I have 8-9 years of Haskell experience, and that I tend to 'think in Haskell', while I have only about a year of experience with Python. I don't consider myself proficient with Python, so the competition is rigged from the outset.
</p>
<ul>
<li>Extracting data from a small CSV file with Haskell</li>
<li><a href="/2024/02/19/extracting-data-from-a-small-csv-file-with-haskell">Extracting data from a small CSV file with Haskell</a></li>
<li>Extracting data from a small CSV file with Python</li>
</ul>
<p>
Expand All @@ -107,6 +107,6 @@ <h3 id="dcf63d011f02487eb051e3a75cbe59f7">
One point I'd like to make, however, is that there's nothing inherently better about a dynamically typed language when it comes to ad-hoc scripting. Languages with strong type inference work well, too.
</p>
<p>
<strong>Next:</strong> Extracting data from a small CSV file with Haskell.
<strong>Next:</strong> <a href="/2024/02/19/extracting-data-from-a-small-csv-file-with-haskell">Extracting data from a small CSV file with Haskell</a>.
</p>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
layout: post
title: "Extracting data from a small CSV file with Haskell"
description: "Statically typed languages are also good for ad-hoc scripting."
date: 2024-02-02 12:49 UTC
date: 2024-02-19 12:57 UTC
tags: [Haskell]
image: "/content/binary/difference-pmf-plot.png"
image_alt: "Bar chart of the differences PMF."
Expand All @@ -14,7 +14,7 @@
<em>{{ page.description }}</em>
</p>
<p>
This article is part of a <a href="">short series of articles</a> that compares ad-hoc scripting in <a href="https://www.haskell.org/">Haskell</a> with solving the same problem in <a href="https://www.python.org/">Python</a>. The <a href="">introductory article</a> describes the problem to be solved, so here I'll jump straight into the Haskell code. In the next article I'll give a similar walkthrough of my Python script.
This article is part of a <a href="/2024/02/05/statically-and-dynamically-typed-scripts">short series of articles</a> that compares ad-hoc scripting in <a href="https://www.haskell.org/">Haskell</a> with solving the same problem in <a href="https://www.python.org/">Python</a>. The <a href="/2024/02/05/statically-and-dynamically-typed-scripts">introductory article</a> describes the problem to be solved, so here I'll jump straight into the Haskell code. In the next article I'll give a similar walkthrough of my Python script.
</p>
<h3 id="0a705367eb2f4080ac168eb1bbe9b2ec">
Getting started <a href="#0a705367eb2f4080ac168eb1bbe9b2ec">#</a>
Expand Down Expand Up @@ -52,7 +52,7 @@ <h3 id="0a705367eb2f4080ac168eb1bbe9b2ec">
38</pre>
</p>
<p>
Looks good, but reading a text file is hardly the difficult part. The first obstacle, surprisingly, is to split comma-separated values into individual parts. For some reason that I've never understood, the Haskell base library doesn't even include something as basic as <a href="https://learn.microsoft.com/dotnet/api/system.string.split">String.Split</a> from .NET. I could probably hack together a function that does that, but on the other hand, it's available in the <a href="https://hackage.haskell.org/package/split/docs/Data-List-Split.html">split</a> package; that explains the <code>Data.List.Split</code> import. It's just such a bit of a bother that one has to pull in another package just to do that.
Looks good, but reading a text file is hardly the difficult part. The first obstacle, surprisingly, is to split comma-separated values into individual parts. For some reason that I've never understood, the Haskell base library doesn't even include something as basic as <a href="https://learn.microsoft.com/dotnet/api/system.string.split">String.Split</a> from .NET. I could probably hack together a function that does that, but on the other hand, it's available in the <a href="https://hackage.haskell.org/package/split/docs/Data-List-Split.html">split</a> package; that explains the <code>Data.List.Split</code> import. It's just a bit of a bother that one has to pull in another package only to do that.
</p>
<h3 id="a70030690c1645a2b0923ad354fa665b">
Grades <a href="#a70030690c1645a2b0923ad354fa665b">#</a>
Expand All @@ -78,7 +78,7 @@ <h3 id="a70030690c1645a2b0923ad354fa665b">
This lists all 38 expected grades found in the data file.
</p>
<p>
In the <a href="">introduction article</a> I spent some time explaining how languages with strong type inference don't need type declarations. This makes iterative development easier, because you can fiddle with an expression until it does what you'd like it to do. When you change an expression, often the inferred type changes as well, but there's no programmer overhead involved with that. The compiler figures that out for you.
In the <a href="/2024/02/05/statically-and-dynamically-typed-scripts">introduction article</a> I spent some time explaining how languages with strong type inference don't need type declarations. This makes iterative development easier, because you can fiddle with an expression until it does what you'd like it to do. When you change an expression, often the inferred type changes as well, but there's no programmer overhead involved with that. The compiler figures that out for you.
</p>
<p>
Even so, the above <code>grade</code> function does have a type annotation. How does that gel with what I just wrote?
Expand Down

0 comments on commit 660fda5

Please sign in to comment.