Using Phantom Types in Haskell for Extra Safety - Part 2

I’ve received a lot of reactions to the previous blog post about Phantom Types over the past two days, which is why I’ve decided to summarize what I’ve learned in another blog post. First, here’s a summarized problem from the previous post. We have a Message which can be either PlainText or Encrypted. We’ve used Phantom Types to enforce this in the type system: data Message a = Message String data PlainText data Encrypted send :: Message Encrypted -> IO () encrypt :: Message PlainText -> Message Encrypted decrypt :: Message Encrypted -> Message PlainText Can newtype do the same?

Read More →

Using Phantom Types for Extra Safety

If you’ve been programming in a dynamic language, you’ve probably heard that type systems can catch more errors before your application even gets run. The more powerful the type system is, the more you can express in it. And because we’re talking about Haskell, we have a great number of tools at our disposal when trying to express things in terms of the types. Why is this important? Sometimes a function has an expectation about the value that it’s receiving.

Read More →

Evil Mode: How I Switched From VIM to Emacs

I’ve been a long time VIM user. I use it every day for all of my work and side projects, writing blog posts, writing other content, sometimes even for writing emails if the text is long enough. VIM is like my home and I’m deeply in love with it. The problem is that VIM is a horrible IDE. It’s an amazing and super productive editor, but it really sucks at doing IDE-like things.

Read More →

Yesod is Fun

I’ve been trying many Haskell web frameworks over the past few weeks. I wrote one small app with Simple, almost wrote another one with Scotty. Then decided it’s time to take a look at the big guys, Happstack, Snap and Yesod. First I tried Happstack, which felt kind of OK and very understandable, mostly because it doesn’t seem to be trying to do much magic. This is really great for learning, but then I stumbled when I found that it’s not actually being developed on GitHub.

Read More →

Duplication in Tests Is Sometimes Good

Having powerful tools like RSpec gives us so much power, that what was once a nice suite of readable specs becomes a huge bunch of unreadable mess, just because someone tried to DRY it up. When writing your production code, there’s a good reason to keep the code DRY. Most of the times having duplication in your code can be a smell. But just because something sometimes smells, it doesn’t mean you should try to fix it all the time.

Read More →

Light Table Plugin Tutorial

I’ve been playing around with Light Table since the day its source code was released (even made a tiny Ruby plugin). First of all, Light Table is based on the BOT architecture. Which means there are three core concepts: behaviors, objects and tags. If you have any experience with Node.js or event driven programming, you’ll have an easy time understanding the concepts. Imagine you have a button which listens on a click event and displays a notice to the user when it’s clicked

Read More →