Posts tagged 'month-of-haskell'
-
A Month of Haskell, Day 10 - String Types - May 19, 2017
Strings are one of the most basic types we deal with when programming, and yet languages typically do a very poor job with them. Haskell doesn’t exactly excell with string handling but it does a pretty good job. Unfortunately, it also has at least three different string types for you to choose among.
-
A Month of Haskell, Day 9 - Monoid and Bifunctor - May 17, 2017
I’ve got two more exciting type classes to discuss today. As usual, the internet is full of overly complicated descriptions for what are really very simple concepts. Don’t go look at wikipedia if you want to understand what’s going on. We’re going to talk about Monoid, in the Data.Monoid module, and Bifunctor in the Data.Bifunctor module.
-
A Month of Haskell, Day 8 - Heterogeneous Lists - May 15, 2017
I previously talked about type classes and class constraints. Today I’d like to talk about something occassionally useful you can do with these two concepts - make lists that can hold more than one type.
-
A Month of Haskell, Day 7 - Type Classes - May 11, 2017
I’ve mentioned type classes on day 2, day 5, day 6, and day 7. I didn’t intend to aim this series at people just starting with Haskell, but type classes are such a fundamental concept and so central to the language that I need to write about them before I go too much farther.
-
A Month of Haskell, Day 6 - Text.Printf - May 10, 2017
Here’s a quick one for the sixth entry in this series. The Text.Printf module won’t completely change how you program, but it’s an extremely useful module that needs to be more well known. Because it’s part of the base system, you don’t need to install anything to make use of it.
-
A Month of Haskell, Day 5 - Applicative, Alternative, and Functor - May 9, 2017
And now I’m two days behind. If I can think of something sufficiently quick, I’ll have a bonus day where I do two posts. For now, you’re just going to have to enjoy this one single post about three complementary type classes: Applicative, Alternative, and Functor. The first two are in the Control.Applicative module, while the last is in the Data.Functor module. I’m going to ignore the jargon-heavy definitions of these type classes and skip right to showing how they can be used.
-
A Month of Haskell, Day 4 - hlint - May 5, 2017
I got too busy last night and forgot to write about Haskell, so now day four occurs on the fifth of May. These things happen. Today I wanted to talk about something much quicker than the last installment. As you may remember from day 3 one of the many programs we installed was hlint. We made it work with the editor, but it’s easy to run it on its own.
-
A Month of Haskell, Day 3 - vim configuration - May 3, 2017
My favorite text editor is vim. While there are certainly better IDEs out there, vim is great at editing text and can be turned into a reasonable IDE with enough plugins and helper programs. It also has the advantage of being a text-based program that can easily be run over an ssh session.
This post is about how you can configure vim to be a better IDE for Haskell. There are a ton of other documents out there explaining this very thing, including an excellent one from Stephen Diehl. I’ve borrowed from him a bit, but made a lot of my own changes. There are also some projects up on github that look like you just clone them, install, and they make all the necessary changes. While that sounds fast, I’m not as much of a fan of that because it seems to take over your home directory.
-
A Month of Haskell, Day 2 - Enforcing things with types - May 2, 2017
One of my large Haskell projects is an amateur radio logging program. Part of this program takes data from various sources (a user interface, doing network queries, etc.) and stores them in a database. This data includes callsigns, state, mode (FM, SSB, CW, and so forth), and exchanges during contests. At various points, I want to compare new data to what’s already in the database.
For a long time, I’d been just making sure that before I did any comparison, I uppercased the data. However that is prone to error - if I missed a spot, my comparison would fail. Instead, I could use the type system to enforce the fact that certain pieces of data need to be uppercased before any comparison could take place. That would eliminate any possibility of busted comparisons at compile time. This is exactly the sort of thing Haskell’s type system is great at doing.
-
A Month of Haskell, Day 1 - Control.Conditional - May 1, 2017
In the spirit of 24 Days of GHC Extensions and 24 Days of Hackage I thought i would start my own series of posts on useful things about the Haskell programming language. While I am a big fan of the language, I have some complaints about the documentation. It tends to either be non-existent, written for someone who is alredy an expert with the language, or assumes familiarity with advanced mathematics.
The internet is littered with dense web pages about bifunctors and covariants and arrows and lifting. I am hoping to explain things that have been useful to me in much more plain language, aimed at someone who is more interested in the programming than the theory. While I am going to assume some familiarity with Haskell, I’m not going to assume you are an expert.