Skip to content

Instantly share code, notes, and snippets.

@Icelandjack
Icelandjack / 14823.md
Last active April 5, 2018 20:08
#14832: QuantifiedConstraints: Adding to the context causes failure

Solving Trac ticket #14832:

{-# Language QuantifiedConstraints, ScopedTypeVariables, TypeOperators, GADTs, FlexibleInstances, UndecidableInstances, ConstraintKinds, MultiParamTypeClasses, InstanceSigs, TypeApplications #-}

import Prelude hiding (id, (.))
import Control.Category
import Data.Coerce

data Dict c where
@Icelandjack
Icelandjack / TypeApp.markdown
Last active September 6, 2018 13:01
Examples of Type Application for Infix Operators

Nested

Showing where types change:

infixr 5 :::
data Nest a = N | a ::: Nest (a, a)

In

@Icelandjack
Icelandjack / Braindump.hs
Last active October 15, 2018 20:46
For Chris Allen, braindump
-- type Sig k = [k] -> Type
--
-- data AST :: Sig k -> Sig k where
-- Sym :: dom a -> AST dom a
-- (:$) :: AST dom (a:as) -> AST dom '[a] -> AST dom as
singletons [d| data N = O | S N |]
infixr 5 :·
data Vec :: N -> Type -> Type where
@Icelandjack
Icelandjack / Inj.markdown
Created October 20, 2018 17:37
GHC Trac #10832
data Kl_kind :: (Type -> Type) -> Type where
  Kl :: Type -> Kl_kind(m)
  
type family
  UnKl (kl :: Kl_kind m) = (res :: Type) | res m -> kl where
  UnKl (Kl a) = a
@Icelandjack
Icelandjack / Buggy_Program.hs
Created November 19, 2018 18:52
Buggy Program
{-# Language RankNTypes #-}
{-# Language LambdaCase #-}
{-# Language TypeOperators #-}
{-# Language TypeApplications #-}
{-# Language PolyKinds #-}
{-# Language TypeFamilies #-}
{-# Language FlexibleInstances #-}
{-# Language GADTs #-}
{-# Language ConstraintKinds #-}
{-# Language MultiParamTypeClasses #-}
@Icelandjack
Icelandjack / SystemF.hs
Last active November 27, 2018 02:00
System F
-- SYSTEM F
-- http://homepages.inf.ed.ac.uk/slindley/papers/embedding-f.pdf
--
-- Type-level lambdas
-- https://gist.github.com/AndrasKovacs/ac71371d0ca6e0995541e42cd3a3b0cf
{-# language TemplateHaskell, ScopedTypeVariables, RankNTypes,
TypeFamilies, UndecidableInstances, DeriveFunctor, GADTs,
TypeOperators, TypeApplications, AllowAmbiguousTypes,
@Icelandjack
Icelandjack / ZipWith.markdown
Last active December 29, 2018 09:37
Variable-arity zipWith in terms of Applicative ZipList

I was implementing "variable-arity zipWith" from Richard Eisenberg's thesis (recommended) when I noticed it used

apply :: [a -> b] -> [a] -> [b]
apply (f:fs) (a:as) = f a : apply fs as
apply _      _      = []

and

repeat :: a -> [a]
@Icelandjack
Icelandjack / Kleisli_Category.hs
Last active January 6, 2019 11:20
Kind-indexed Category instance for Kleisli
-- https://www.reddit.com/r/haskell/comments/abxem5/experimenting_with_kleisli_instance_of/
{-# Language TypeApplications #-}
{-# Language RankNTypes #-}
{-# Language DataKinds #-}
{-# Language KindSignatures #-}
{-# Language PolyKinds #-}
{-# Language TypeOperators #-}
{-# Language GADTs #-}
{-# Language TypeFamilies #-}