Skip to content

Instantly share code, notes, and snippets.

@i-am-tom
i-am-tom / Transformers.hs
Created Jun 1, 2019
A little talk for Friday afternoon.
View Transformers.hs
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE GeneralisedNewtypeDeriving #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE LambdaCase #-}
@i-am-tom
i-am-tom / Trolling.hs
Created May 11, 2019
Ramda-style composition where the first function must receive all arguments.
View Trolling.hs
{-# LAnguage FlexibleInstances #-}
{-# LANGuage FunctionalDependencies #-}
{-# LANGUAge GADTs #-}
{-# LANGUAGE UndecidableInstances #-}
module Trolling where
---------------------------------------------------------------------
-- VARIADIC COMPOSITION IN HASKELL (A LA RAMDA.JS).
--
-- In Haskell, we typeically think of the composition operator (or
@i-am-tom
i-am-tom / Service.hs
Created May 8, 2019
Sketching out composite validation
View Service.hs
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DefaultSignatures #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralisedNewtypeDeriving #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
@i-am-tom
i-am-tom / DAG.hs
Last active Apr 18, 2019
Cached evaluation
View DAG.hs
{-# OPTIONS_GHC -Wno-name-shadowing #-}
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
@i-am-tom
i-am-tom / Commit.hs
Created Mar 22, 2019
Apply your function parameters in any order, for no reason other than that you can.
View Commit.hs
{-# lAnGuAgE DataKinds #-}
{-# LaNgUaGe FlexibleInstances #-}
{-# lAnGuAgE FunctionalDependencies #-}
{-# LaNgUaGe KindSignatures #-}
{-# lAnGuAgE TypeFamilies #-}
{-# LaNgUaGe TypeOperators #-}
{-# lAnGuAgE UndecidableInstances #-}
module Commit where
import Data.Kind (Constraint, Type)
@i-am-tom
i-am-tom / Halp.hs
Created Mar 15, 2019
Microservices with too many types
View Halp.hs
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
module Halp where
@i-am-tom
i-am-tom / HFolds.hs
Created Mar 4, 2019
Folding... heterogeneously.
View HFolds.hs
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE QuantifiedConstraints #-}
{-# LANGUAGE RankNTypes #-}
@i-am-tom
i-am-tom / Whole.hs
Created Mar 2, 2019
Visible quantification???
View Whole.hs
{-# LANGUAGE GADTs #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeInType #-}
module Data.Whole where
import Data.Kind (Type)
data Sign = Positive | Negative
@i-am-tom
i-am-tom / Listify.hs
Created Feb 5, 2019
JavaScript.method(... xs)
View Listify.hs
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
module Main where
import Data.Kind
@i-am-tom
i-am-tom / Tree.purs
Last active Feb 1, 2019
A labelled, uninterestingly-heterogeneous rose tree implementation in PureScript, with a little dash of Coyoneda.
View Tree.purs
module Data.Labelled.Tree where
-- Traditionally, we express a rose tree with a structure along the lines of
--
-- ```
-- data RoseTree a
-- = RoseTree a (Array (RoseTree a))
-- ```
--
-- As with many of our favourite "Haskell containers", this comes with an