Skip to content

Instantly share code, notes, and snippets.

View goldfirere's full-sized avatar

Richard Eisenberg goldfirere

View GitHub Profile
{-# LANGUAGE NoFieldSelectors, NamedFieldPuns, DuplicateRecordFields, DerivingStrategies #-}
{-# OPTIONS_GHC -Wall #-}
module UpdateSections where
import Data.List ( mapAccumL )
newtype SectionPos = MkSP Int
deriving newtype (Show, Enum)
@goldfirere
goldfirere / EvalPolyRec.hs
Created November 11, 2016 02:44
Inferring constraints with polymorphic recursion
module EvalPolyRec where
import Prelude hiding (seq)
class Eval a where
seq :: a -> b -> b
instance Eval (a,b) where
seq (_, _) = id
@goldfirere
goldfirere / Vec.hs
Last active December 5, 2016 13:50
{-# LANGUAGE TemplateHaskell, ScopedTypeVariables, TypeInType, TypeOperators,
TypeFamilies, GADTs, UndecidableInstances, InstanceSigs #-}
{-# OPTIONS_GHC -Wincomplete-patterns #-}
import Data.Kind
import Data.Singletons.TH
import Data.Singletons.Prelude
import Prelude hiding ( take )
$(singletons [d|
@goldfirere
goldfirere / Basics.hs
Created January 30, 2016 19:34
TypeRep tomfoolery
{-# LANGUAGE TypeOperators, TypeFamilies, TypeApplications,
ExplicitForAll, ScopedTypeVariables, GADTs, TypeFamilyDependencies,
TypeInType, ConstraintKinds, UndecidableInstances,
FlexibleInstances, MultiParamTypeClasses, FunctionalDependencies,
FlexibleContexts, StandaloneDeriving, InstanceSigs #-}
module Basics where
import Data.Type.Bool
import Data.Type.Equality
**********************************************
** THIS IS A WARNING MESSAGE ONLY **
** YOU DO NOT NEED TO RESEND YOUR MESSAGE **
**********************************************
The original message was received at Fri, 17 Oct 2014 12:34:35 -0400
from c-98-225-220-10.hsd1.pa.comcast.net [98.225.220.10]
----- Transcript of session follows -----
<austin@well-typed.com>... Deferred: 403 4.7.0 TLS handshake failed.
@goldfirere
goldfirere / Shape-7.6.hs
Last active December 25, 2015 02:29
Strongly-typed version of code from GHC Trac #8423.
{-# LANGUAGE DataKinds, PolyKinds, GADTs, TypeFamilies, TypeOperators,
ConstraintKinds, ScopedTypeVariables, RankNTypes #-}
module Shape where
import GHC.Exts
data a :=: b where
Refl :: a :=: a