Skip to content

Instantly share code, notes, and snippets.

View therewillbecode's full-sized avatar

Tom therewillbecode

  • Edinburgh, UK
View GitHub Profile
therewillbecode /
Last active August 29, 2023 20:44
Blog Post on IO Monad.
12th April 2020

If Haskell is a pure functional language then how does anything get done?

Useful programs need to perform input/output or I/O if there are to interact with the outside world. How else would a program read files, print to the screen and interact with the external world. I/O is the process of responding to input signals from the external world and responding with output signals.

Haskell is a purely functional language. Let's define purity.

Purity is the property of functions which when given the same input always return the same output.

module Main where
import Lib
import Data.Char
import Data.Machine
-- newtype CurrPlayerToAct = CurrPlayerToAct String deriving (Eq, Show, Ord)
therewillbecode / todo.hs
Last active November 11, 2021 14:14
To do List
data User = User { email :: Text }
newtype TodoList = TodoList ([UTCTime, Map TodoId Todo])
newtype UserLists = UserLists (Map Email [TodoList])
newtype TodoId = TodoId Int
data Todo = Todo
{ description :: Description,
therewillbecode /
Last active December 27, 2020 11:21

Number theory

Primes are the atoms of the integers.

Fundamental theorem of arithmetic

Absolute values and inequalities

Remember to flip inequalities when taking the reciprocal of both sides or multiplying/diving both sides by a negative.

therewillbecode /
Last active August 30, 2020 08:32
Papers I like
therewillbecode /
Last active April 25, 2020 13:29
Exceptions in Haskell Notes


All code that runs in IO can experience exceptions of any type.

Remember you can only catch an exception in IO. But it is possible to throw exceptions from pure code. An example of this is error.

Throw doesn't throw until forced

Due to laziness the order of evaluation of expressions can be modified by the compiler. This means that throw can return an

“Worry about data quality: Everything rests on the data.” ― David Spiegelhalter, The Art of Statistics: How to Learn from Data

“What am I not being told? This is perhaps the most important question of all.” ― David Spiegelhalter, The Art of Statistics: How to Learn from Data

“The numbers have no way of speaking for themselves. We speak for them. We imbue them with meaning. — Nate Silver, The Signal and the Noise1” ― David Spiegelhalter, The Art of Statistics: Learning from Data

Code by Petzold
Ben Eater 6502 breadboard project
Computerphile how memory works
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
module Socket.Table where
import Control.Concurrent hiding ( yield )
import Control.Concurrent.Async
import Control.Concurrent.STM
import qualified Data.Map.Lazy as M
import Database.Persist.Postgresql
import qualified Network.WebSockets as WS