Skip to content

Instantly share code, notes, and snippets.

View rteabeault's full-sized avatar

Russell Teabeault rteabeault

  • Boulder, Colorado
View GitHub Profile

I started reading this book called Thinking with Types. https://leanpub.com/thinking-with-types Right off he gave an example that I thought was a pretty cool about using the algebra of types to analyze and improve some code. Granted this is a simple example but I got a bit of a chub from it. What follows is most of the lead up to the example and the example itself. Mostly converted from Haskell to Scala.

Cardinality of Types

As their name suggests, there is in fact an algebra behind algebraic data types. Being comfortable understanding and manipulating this algebra is a mighty superpower — it allows us to analyze types, find more convenient forms for them, and determine which operations

{-# LANGUAGE OverloadedStrings #-}
module Dave where
import qualified Data.ByteString as B
import Data.ByteString ( ByteString )
import qualified Data.ByteString.Builder as BB
import Data.ByteString.Builder ( Builder )
import Data.List ( foldl' )
import qualified Data.Map.Strict as Map
{-# LANGUAGE OverloadedStrings #-}
module Chris where
import qualified Data.ByteString as B
import Data.ByteString.Builder ( Builder )
import qualified Data.ByteString.Char8 as B8
import qualified Data.ByteString.Builder as BB
import Data.Word ( Word8 )
import Data.Word8 ( _comma
{-# LANGUAGE OverloadedStrings #-}
module Thomas.Original where
import Data.Monoid ( (<>) )
import System.IO
import Data.Text as T
import Data.Text.Encoding as TE
import Data.ByteString as B
import Data.ByteString.Builder as BB
@rteabeault
rteabeault / spacemacs-keybindings
Created March 31, 2018 16:58 — forked from adham90/spacemacs-keybindings
spacemacs keybindings that i need to learn
SPC s c remove highlight
**** Files manipulations key bindings
Files manipulation commands (start with ~f~):
| Key Binding | Description |
|-------------+----------------------------------------------------------------|
| ~SPC f c~ | copy current file to a different location |
| ~SPC f C d~ | convert file from unix to dos encoding |
| ~SPC f C u~ | convert file from dos to unix encoding |
@rteabeault
rteabeault / spacemacs-cheshe.md
Created March 29, 2018 21:02 — forked from robphoenix/spacemacs-cheshe.md
Spacemacs Cheat Sheet

Useful Spacemacs commands

  • SPC q q - quit
  • SPC w / - split window vertically
  • SPC w - - split window horizontally
  • SPC 1 - switch to window 1
  • SPC 2 - switch to window 2
  • SPC w c - delete current window
  • SPC TAB - switch to previous buffer
  • SPC b b - switch buffers