This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Separate string with escaped '\\n' literals. | |
;; These '\\n' literals will be interpreted by `echo'. | |
;; | |
;; (broken "hello") | |
;; = "h\\ne\\nl\\nl\\no" | |
(defun broken (str) | |
(mapconcat | |
(lambda (x) (make-string 1 x)) | |
str | |
"\\n")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# Language DerivingVia #-} | |
{-# Language StandaloneKindSignatures #-} | |
-- Some imports and pragmas missing. | |
import GHC.Generics | |
import Control.Applicative | |
import GHC.TypeLits | |
import Data.Kind | |
import Data.Coerce | |
import Data.Monoid |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- this allows you to derive | |
-- | |
-- data OneTwo = OneTwo { x :: Int, y :: Int } | |
-- deriving stock Generic | |
-- deriving (Semigroup, Monoid) via Overriding '[ '[Sum Int, Sum Int] ] Onetwo | |
-- | Override | |
newtype Override (code :: [[Type]]) a = Override { getOverride :: a } | |
type Overriding code a = Generically (Override code a) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- This witnesses multiplying two polynomials | |
-- | |
-- Code (Maybe a) = [[], [a]] | |
-- Code (Maybe b) = [[], [b]] | |
-- | |
-- Then the product of (Maybe a, Maybe b) is isomorphic to the | |
-- multiplication of their codes | |
-- | |
-- Code (MegaMaybe a b) = [[], [a], [b], [a,b]] | |
-- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE DeriveGeneric #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE GeneralizedNewtypeDeriving #-} | |
{-# LANGUAGE InstanceSigs #-} | |
{-# LANGUAGE MultiParamTypeClasses #-} | |
{-# LANGUAGE PolyKinds #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
{-# LANGUAGE StandaloneDeriving #-} | |
{-# LANGUAGE TypeApplications #-} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type f ~> g = (forall x. f x -> g x) | |
infixr 0 ··> | |
type (··>) :: (Type -> Type) -> (Type -> Type) -> Type | |
type f ··> g = Proxy '(f, g) -> Type | |
type Idiom :: f ··> g -> Constraint | |
class Idiom (hom :: f ··> g) where | |
idiom :: f ~> g |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
infixr 80 _◦_ | |
_◦_ : forall {l1 l2 l3 : Level } | |
{A : -> Set l1} | |
{B : A -> Set l2} | |
{C : (a : A) -> B a -> Set l3} | |
(g : {a : A} -> (b : B a) -> C a b ) | |
(f : (a : A) -> B a) | |
-> (a : A) -> C a (f a) | |
g ◦ f = \a -> g (f a) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
norm :: Generic1 f => Summs (Rep1 f) => f ~> Summ (Rep1 f) Zero | |
norm as = summs (from1 as) (Proxy @Zero) | |
class Summs rep where | |
type Summ rep (end :: Type -> Type) :: Type -> Type | |
summs :: rep a -> Proxy end -> Summ rep end a | |
skips :: Proxy rep -> end a -> Summ rep end a | |
instance Summs Zero where |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# Language EmptyCase #-} | |
{-# Language GADTs #-} | |
{-# Language InstanceSigs #-} | |
{-# Language PatternSynonyms #-} | |
{-# Language PolyKinds #-} | |
{-# Language ScopedTypeVariables #-} | |
{-# Language StandaloneKindSignatures #-} | |
{-# Language TypeApplications #-} | |
{-# Language TypeFamilies #-} | |
{-# Language TypeOperators #-} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{- | |
Every functor is a function mapping categories. | |
I want to specify them all in one place, | |
instance Functor (->) where | |
type Arr (->) = (<–) :- (->) :- End (->) | |
without having to specified partial applications of it |
NewerOlder