Skip to content

Instantly share code, notes, and snippets.

View SimonAlling's full-sized avatar

Simon Alling SimonAlling

View GitHub Profile
@SimonAlling
SimonAlling / Dates.hs
Created February 2, 2020 20:23
Palindrome dates with only two different digits
{-# LANGUAGE LambdaCase #-}
import Data.List
data Day = Day Int
instance Show Day where
show (Day d) = pad d
data Month = Jan | Feb | Mar | Apr | May | Jun | Jul | Aug | Sep | Oct | Nov | Dec
@SimonAlling
SimonAlling / RebindableSyntax.hs
Last active May 23, 2020 16:25
Haskell RebindableSyntax example
{-# LANGUAGE RebindableSyntax #-}
import Prelude hiding ((>>))
data Config = Config { depth :: Int, width :: Int }
printInfo :: Config -> IO ()
printInfo config = mapM_ putStrLn $ do
"************** INFORMATION **************"
"Welcome to the Hydraulic Press Channel."
@SimonAlling
SimonAlling / algebraic.ts
Last active October 24, 2023 21:00
Algebraic Data Types in TypeScript
// Types:
type Just<T> = { Just: T }
type Nothing = {}
type Maybe<T> = Just<T> | Nothing
type Left<L> = { Left: L }
type Right<R> = { Right: R }
type Either<L, R> = Left<L> | Right<R>
// For convenience:
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.