Skip to content

Instantly share code, notes, and snippets.

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'
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"
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"
(define $expl-hash
{| ["key1" "data1"] ["key2" "data2"] ["key3" "data3"] |})
(test expl-hash_"key1")
> "data1"
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
@xenophobia
xenophobia / nested match-lambda
Created November 20, 2013 04:19
match-lambdaをネストした場合のegison3.0.11の挙動
(define $f
(match-lambda something
{[$x (lambda [$y] (+ x y))]
}))
(test ((f 1) 2))
#|
> 3
|#
{- 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
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
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
> (define $onetwo {1 @onetwo 2})
> (test (match onetwo (list integer) {[<join _ _> <Ok>] [_ <Ko>]}))
> <Ok>