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
func main () { | |
let typedHeterogeneousList = true =+= "Hello" =+= 1 =+= HNil() | |
let first: Bool = typedHeterogeneousList.head() | |
let second: String = typedHeterogeneousList.tail().head() | |
let third: Int = typedHeterogeneousList.tail().tail().head() | |
} | |
protocol HList { | |
typealias Head |
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 | |
GADTs | |
, KindSignatures | |
, RankNTypes | |
, TupleSections | |
, TypeOperators | |
#-} | |
module Generics.Morphism where | |
import Control.Arrow |
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
-- Inspired by http://www2.tcs.ifi.lmu.de/~abel/popl13.pdf | |
[codata| | |
codata Stream a where | |
head :: Stream a -> a | |
tail :: Stream a -> Stream a | |
|] | |
fib :: Stream Nat | |
[copattern| |
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 GADTs, TypeOperators, TupleSections #-} | |
module Generics.Algebra where | |
import Control.Category | |
import Control.Arrow | |
import Control.Applicative | |
import Prelude hiding ((.), id) | |
import Generics.Combinator |
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
func unwrap<T1, T2>(optional1: T1?, optional2: T2?) -> (T1, T2)? { | |
switch (optional1, optional2) { | |
case let (.Some(value1), .Some(value2)): | |
return (value1, value2) | |
default: | |
return nil | |
} | |
} | |
func unwrap<T1, T2, T3>(optional1: T1?, optional2: T2?, optional3: T3?) -> (T1, T2, T3)? { |
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 TypeFamilies, FlexibleContexts, TypeOperators, UndecidableInstances, GeneralizedNewtypeDeriving #-} | |
module Numeric.Vector.Space where | |
import Data.Functor.Representable.Trie hiding (Entry) | |
import Data.Key (Adjustable(..), Key) | |
import qualified Data.Key as Key | |
import qualified Data.Heap as Heap | |
import Data.Heap (Heap, Entry(..)) | |
import qualified Data.List.NonEmpty as NonEmpty | |
import Data.List.NonEmpty (NonEmpty(..)) |
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 RankNTypes, TypeFamilies, DataKinds, TypeOperators, | |
ScopedTypeVariables, PolyKinds, ConstraintKinds, GADTs, | |
MultiParamTypeClasses, FlexibleInstances, UndecidableInstances, | |
FlexibleContexts #-} | |
module InductiveConstraints where | |
import GHC.Prim (Constraint) | |
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 AllowAmbiguousTypes #-} | |
{-# LANGUAGE MultiParamTypeClasses #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
{-# LANGUAGE TypeApplications #-} | |
module NamedTypeclass where | |
import Prelude hiding (Monoid, mempty, (<>)) |
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 RankNTypes #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE QuantifiedConstraints #-} | |
import Prelude hiding (id, (.)) | |
import Control.Category | |
import Control.Monad.State hiding (lift) | |
class Category k => Terminal k where | |
term :: k 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
{-# LANGUAGE BlockArguments #-} | |
{-# LANGUAGE LambdaCase #-} | |
{-# LANGUAGE LinearTypes #-} | |
{-# LANGUAGE OverloadedRecordDot #-} | |
{-# LANGUAGE NoImplicitPrelude #-} | |
-- Quick demonstration that linear-base is enough to implement linear logic | |
import Data.Array.Destination | |
import Data.Array.Polarized.Pull |
OlderNewer