Skip to content

Instantly share code, notes, and snippets.

@i-am-tom
i-am-tom / GenericLens.hs
Created October 5, 2018 17:31
Build yourself a generic lens!
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
@i-am-tom
i-am-tom / Talk.idr
Created September 2, 2018 11:07
LambdAle code talk. A love letter to Idris and its perhaps-too-bendy syntax.
module Talk
-- Tom Harding
--
-- Blog: tomharding.me
-- GitHub: github.com/i-am-tom
-- Twitter: twitter.com/am_i_tom
-- Work: habito.com
-- github.com/i-am-tom/LICK
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeInType #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
module Tree where
import Data.Kind
import GHC.TypeLits
data Tree a
@i-am-tom
i-am-tom / Main.purs
Created August 3, 2018 10:46
LIVE CODING from BusConf
module Main where
import Control.Apply (lift2)
import Data.Foldable (elem)
import Data.Tuple (Tuple(..))
import FRP.Behavior (Behavior, animate, fixB)
import FRP.Behavior.Keyboard (keys)
import FRP.Event.Keyboard (Keyboard, getKeyboard)
import Color.Scheme.MaterialDesign (deepPurple, lime)
import Data.Maybe (Maybe(..))
const Day = ({ get, left, right }) => {
const map = f => Day ({
get: f (extract()),
left, right
})
const extend = f =>
Day ({
get: (left, right) => f (Day ({ get, left, right })),
@i-am-tom
i-am-tom / Form.hs
Created July 15, 2018 15:26
Messing around with Typeable.
{-# LANGUAGE
DataKinds
, DeriveAnyClass
, DeriveGeneric
, DerivingStrategies
, FlexibleContexts
, FlexibleInstances
, FunctionalDependencies
, GeneralizedNewtypeDeriving
, PolyKinds
@i-am-tom
i-am-tom / Controller-SignUp.purs
Last active July 5, 2018 13:30
A little (hand-split-and-then-not-re-typechecked) demo of Panda's current state.
module Controller.SignUp where
import View.SignUp
( Input (..)
, Output (..)
, Message (..)
, State (..)
, Error (..)
, view
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
module YassQueen where
data Nil
data Cons x xs
type family First xs where
First (Cons x xs) = x
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
module Main where
data Nil
data Cons x xs
@i-am-tom
i-am-tom / STLC.hs
Last active May 21, 2018 20:10
Simply-Typed Lambda Calculus written in "glorious" "dependent" Haskell.
{-# LANGUAGE GADTs #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeInType #-}
{-# LANGUAGE TypeOperators #-}
module Main (test01, test02, main) where
import Data.Kind