title | subtitle | author |
---|---|---|
The Fools Who Dream |
(Computer Science Edition) |
Justin Hurwitz (Lyrics Justin Le) |
[Charles Babbage]
His difference engine / did multiplication
And sometimes addition by three
{-# LANGUAGE OverloadedStrings #-} | |
{-# LANGUAGE DefaultSignatures #-} | |
{-# LANGUAGE DeriveDataTypeable #-} | |
import ClassyPrelude | |
import Control.Lens | |
import Data.Typeable | |
import Data.Data | |
newtype Name = Name Text deriving (Monoid, Semigroup, IsString, Show, Typeable) |
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE TypeFamilies #-} | |
{-# LANGUAGE TypeFamilyDependencies #-} | |
{-# LANGUAGE TypeInType #-} | |
data These a b = Neither | |
| This a | |
| That b | |
| These a b | |
#!/usr/bin/env stack | |
-- stack --install-ghc runghc --package type-combinators --package ad --package lens --package vector --package reflection -- -Wall | |
{-# LANGUAGE BangPatterns #-} | |
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE DeriveGeneric #-} | |
{-# LANGUAGE ExistentialQuantification #-} | |
{-# LANGUAGE FlexibleContexts #-} | |
{-# LANGUAGE GADTs #-} | |
{-# LANGUAGE KindSignatures #-} |
title | subtitle | author |
---|---|---|
The Fools Who Dream |
(Computer Science Edition) |
Justin Hurwitz (Lyrics Justin Le) |
[Charles Babbage]
His difference engine / did multiplication
And sometimes addition by three
{-# language DeriveFunctor #-} | |
{-# language UndecidableInstances #-} | |
{-# language TypeInType #-} | |
{-# language TypeOperators #-} | |
{-# language TemplateHaskell #-} | |
{-# language KindSignatures #-} | |
{-# language DataKinds #-} | |
{-# language ViewPatterns #-} | |
{-# language GADTs #-} | |
{-# language TypeFamilies #-} |
{-# LANGUAGE FlexibleContexts #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
{-# LANGUAGE TypeApplications #-} | |
{-# LANGUAGE UndecidableInstances #-} | |
import Data.Proxy | |
import Data.Reflection | |
data EqDict a = EQD { withEqDict :: a -> a -> Bool } |
data Auto1 a b = A1 { runAuto :: a -> (b, Auto1 a b) } | |
data Auto2 a b = forall s. A2 s ((a, s) -> (b, s)) | |
sumFrom1 :: Int -> Auto1 Int Int | |
sumFrom1 n = A1 $ \x -> (x + n, sumFrom1 (x + n)) | |
sumFrom2 :: Int -> Auto2 Int Int | |
sumFrom2 n0 = A2 n0 $ \(x, n) -> (x + n, x + n) |
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE DeriveFoldable #-} | |
{-# LANGUAGE DeriveFunctor #-} | |
{-# LANGUAGE FlexibleContexts #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE GADTs #-} | |
{-# LANGUAGE GeneralizedNewtypeDeriving #-} | |
{-# LANGUAGE LambdaCase #-} | |
{-# LANGUAGE MultiParamTypeClasses #-} | |
{-# LANGUAGE NoImplicitPrelude #-} |
data ProdMap :: (a -> b -> Type) -> [a] -> [b] -> Type where | |
PMZ :: ProdMap f '[] '[] | |
PMS :: f a b -> ProdMap f as bs -> ProdMap f (a ': as) (b ': bs) | |
data Slice :: Nat -> Nat -> Type where | |
Slice :: Sing l -> Sing c -> Sing r -> Slice (l + c + r) c | |
slice | |
:: (SingI ns, SingI ms) | |
=> ProdMap Slice ns ms |