Skip to content

Instantly share code, notes, and snippets.

@avieth
avieth / Tuples.hs
Created May 26, 2023 14:25
Number-indexed tuples
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE FunctionalDependencies #-}
@avieth
avieth / Presentation.hs
Created February 26, 2021 21:47
Session types in Haskell
{-# LANGUAGE GADTs #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE EmptyCase #-}
{-# OPTIONS_GHC "-fwarn-incomplete-patterns" #-}
@avieth
avieth / 060618.hs
Created June 6, 2018 15:02
Inter-node comm
{-# LANGUAGE GADTSyntax #-}
-- # Inter-node messages
-- | A single 'Message' type for all inter-node communication.
data Message where
MessageControl :: Control -> Message
MessageDatum :: Datum -> Message
MessageAnnounce :: Announce -> Message
MessageRequest :: Request -> Message
@avieth
avieth / UI_Sketch.hs
Created May 22, 2016 00:37
Superficial sketch of type-directed storyboard user interfaces
{-# LANGUAGE GADTs #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeInType #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE RankNTypes #-}
import Data.Proxy
@avieth
avieth / gist:334201aa341d9a00c7fc
Last active July 22, 2022 13:42
Interpreting Free Monads of Functor Sums
Interpreting Free Monads of Functor Sums
========================================
This text deals with a way to compose certain kinds of monads, thereby mixing
their capabilities. It is a literate Haskell file, so let's begin with a
bunch of noise.
> {-# LANGUAGE MultiParamTypeClasses #-}
> {-# LANGUAGE FlexibleInstances #-}
> {-# LANGUAGE FlexibleContexts #-}
@avieth
avieth / Mechanics.hs
Created October 3, 2014 23:22
RE: adding energy and torque
-- This is in response to Robert Smallshire's talk titled
-- 'The Unreasonable Effectiveness of Dynamic Typing for Practical Programs'.
-- http://www.infoq.com/presentations/dynamic-static-typing/
-- Around the 30 minute mark he gives an example of what he calls a failure
-- of the F# type system, because it allows him to add energy to torque.
-- I demonstrate here that Haskell's type system is capable of ruling
-- out this nonsense. I have no experience with F#; maybe its type system
-- can do the same, if appropriately handled.
-- We'll need some multiparameter typeclasses.