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
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 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 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 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 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 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 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
{- http://d.hatena.ne.jp/majiang/20130602/1370188046 -} | |
-- return, >>= は所与ってことにする | |
s :: a -- 0 | |
ms :: m a -- 1 | |
f :: a -> b -- 4 | |
mf :: m (a -> b) -- 6 | |
f s :: b | |
return (f s) :: m 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
import Prelude hiding (head, tail) | |
import Control.Comonad | |
data Stream a = St {head :: a, tail :: Stream a} | |
instance Functor Stream where | |
fmap f s = St (f (head s)) (fmap f (tail s)) | |
instance Comonad Stream where | |
extract = 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
import Prelude hiding (head, tail) | |
import Control.Comonad | |
data Stream a = St {head :: a, tail :: Stream a} | |
instance Functor Stream where | |
fmap f s = St (f (head s)) (fmap f (tail s)) | |
instance Comonad Stream where | |
extract = 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
> (define $onetwo {1 @onetwo 2}) | |
> (test (match onetwo (list integer) {[<join _ _> <Ok>] [_ <Ko>]})) | |
> <Ok> |