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
| (define $f | |
| (match-lambda something | |
| {[$x (lambda [$y] (+ x y))] | |
| })) | |
| (test ((f 1) 2)) | |
| #| | |
| > 3 | |
| |# |
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
| Prelude> let f0 = \x -> (x,x) | |
| Prelude> :t f0 | |
| f0 :: t -> (t, t) | |
| Prelude> let f1 x = f0(f0 x) | |
| Prelude> :t f1 | |
| f1 :: t -> ((t, t), (t, t)) | |
| Prelude> let f2 x = f1(f1 x) | |
| Prelude> :t f2 | |
| f2 | |
| :: t |
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
| (define $expl-hash | |
| {| ["key1" "data1"] ["key2" "data2"] ["key3" "data3"] |}) | |
| (test expl-hash_"key1") | |
| > "data1" |
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
| import Control.Monad.Writer | |
| import Control.Monad.Reader | |
| type FizzBuzz = ReaderT Int (Writer String) () | |
| tellFizz :: FizzBuzz | |
| tellFizz = do | |
| n <- ask | |
| when (n `rem` 3 == 0) $ tell "Fizz" |
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
| import Control.Monad.Writer | |
| import Control.Monad.Reader | |
| type FizzBuzz = ReaderT Int (Writer String) () | |
| tellFizz :: FizzBuzz | |
| tellFizz = do | |
| n <- ask | |
| when (n `rem` 3 == 0) $ tell "Fizz" |
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
| src\Control\Comonad\Representable\Store.hs:112:12: | |
| Couldn't match expected type `w x0 -> v x0' | |
| with actual type `StoreT g0 w0 a0' | |
| In the pattern: StoreT w s | |
| In an equation for `cohoist': | |
| cohoist (StoreT w s) = StoreT (Identity (extract w)) s | |
| In the instance declaration for `ComonadHoist (StoreT g)' | |
| src\Control\Comonad\Representable\Store.hs:112:26: | |
| Couldn't match expected type `StoreT g w a -> StoreT g v 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
| {-# Language TypeFamilies, DataKinds, KindSignatures, TypeOperators, UndecidableInstances, ScopedTypeVariables #-} | |
| module Main where | |
| import Data.Type.Natural | |
| import Data.Proxy | |
| data FB = Number Nat | Fizz | Buzz | FizzBuzz | |
| type family Add15 (fb :: FB) :: FB | |
| type instance Add15 (Number n) = Number (n :+ N15) |
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 TypeFamilies, DataKinds, KindSignatures, TypeOperators, UndecidableInstances, ScopedTypeVariables #-} | |
| module Main where | |
| import Data.Type.Natural | |
| import Data.Proxy | |
| data FB = Number Nat | Fizz | Buzz | FizzBuzz | |
| type family Mod (m :: Nat) (n :: Nat) :: Nat | |
| type instance Mod (S m) n = MN (S m) n (n :<<= m) |
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 TypeFamilies, KindSignatures, UndecidableInstances, DataKinds #-} | |
| module TypeLevelIf where | |
| import Data.Singletons.Types | |
| type family Loop n :: * | |
| type instance Loop a = Loop a | |
| main :: IO () | |
| main = do | |
| let a = undefined :: If 'True Int (Loop Int) |
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
| ;; map function | |
| (define $map : [$A $B] ([(A -> B) {A}] -> {B}) | |
| (lambda [$fn $xs] | |
| (match xs (list something) | |
| {[<nil> {}] | |
| [<cons $x $rs> {(fn x) @(map fn rs)}]}))) | |
| ;; Ord type class | |
| (type $Ordering {<Less> <Equal> <Greater>}) |