This file contains hidden or 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
| module MultiFilters where | |
| import Control.Applicative ((<$>)) | |
| (.:) :: (c -> d) -> (a -> b -> c) -> a -> b -> d | |
| a .: b = (a .) . b | |
| juxt :: [a -> b] -> a -> [b] | |
| juxt = sequence |
This file contains hidden or 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 GADTs #-} | |
| {-# LANGUAGE DataKinds #-} | |
| {-# LANGUAGE KindSignatures #-} | |
| module Truffula where | |
| data Path = LeftOf Path | RightOf Path | Root | |
| data Tree (p :: Path) a where | |
| Tree :: { value :: a |
This file contains hidden or 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
| -- a Wrapper is a pair of *something*, and if that something is an Int, an additional boolean | |
| data Wrapper a = | |
| Wrapper { get :: a | |
| , test :: (a ~ Int) => Bool } | |
| -- We can construct a Wrapper from something of any type | |
| makeWrapper :: a -> Wrapper a | |
| makeWrapper x = Wrapper x (x == 0) -- Whoa! We're comparing it to zero even if it might not be an Int! | |
| -- We can construct a Wrapper, as noted above, at various type indices… |
This file contains hidden or 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 RankNTypes #-} | |
| {-# LANGUAGE GADTs #-} | |
| {-# LANGUAGE PolyKinds #-} | |
| -- How to use fix to implement polymorphic recursion! | |
| module PolymorphicFixedpoints where | |
| import Data.Function ( fix ) |
This file contains hidden or 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 RankNTypes #-} | |
| {-# LANGUAGE TypeOperators #-} | |
| {-# LANGUAGE UnicodeSyntax #-} | |
| module DeMorganCPS where | |
| -- Products and sums with prettier type notation | |
| data a ∧ b = Pair a b | |
| data a ∨ b = InL a | InR b |
This file contains hidden or 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 GADTs #-} | |
| {-# LANGUAGE PolyKinds #-} | |
| {-# LANGUAGE DataKinds #-} | |
| {-# LANGUAGE ConstraintKinds #-} | |
| {-# LANGUAGE TypeFamilies #-} | |
| {-# LANGUAGE TypeOperators #-} | |
| import Data.Constraint | |
| import Data.Proxy |
This file contains hidden or 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 GADTs #-} | |
| {-# LANGUAGE PolyKinds #-} | |
| {-# LANGUAGE DataKinds #-} | |
| {-# LANGUAGE ConstraintKinds #-} | |
| {-# LANGUAGE TypeFamilies #-} | |
| {-# LANGUAGE TypeOperators #-} | |
| {-# LANGUAGE ScopedTypeVariables #-} | |
| import Data.Constraint | |
| import Data.Proxy |
This file contains hidden or 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 GADTs #-} | |
| {-# LANGUAGE PolyKinds #-} | |
| {-# LANGUAGE DataKinds #-} | |
| {-# LANGUAGE ConstraintKinds #-} | |
| {-# LANGUAGE TypeFamilies #-} | |
| {-# LANGUAGE UndecidableInstances #-} | |
| {-# LANGUAGE RankNTypes #-} | |
| {-# LANGUAGE TypeOperators #-} | |
| {-# LANGUAGE ScopedTypeVariables #-} | |
| {-# LANGUAGE FlexibleContexts #-} |
This file contains hidden or 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
| module Spiral where | |
| -- Based on <pigworker.wordpress.com/2015/01/02/coinduction> | |
| data Tree x = Leaf x | |
| | Branch x (Tree x) (Tree x) | |
| deriving ( Show ) | |
| data Stream x = x :> Stream x | |
| deriving ( Show ) |
This file contains hidden or 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 GADTs #-} | |
| module Cooperational where | |
| import Control.Monad | |
| import Control.Applicative | |
| import Control.Comonad | |
| data Oper f a = | |
| Return a |
OlderNewer