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 RankNTypes #-} | |
module Main where | |
---- | |
-- Coyoneda | |
data CoYoneda f x = forall b. CoYoneda (b -> x) (f b) | |
instance Functor (CoYoneda f) where |
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 Main where | |
import Control.Monad | |
type Season = String | |
type Fruit = String | |
type SeasonalFruits = [(Season, Fruit)] | |
dt :: SeasonalFruits | |
dt = | |
[ ("春", "いちご") |
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.State | |
main :: IO () | |
main = print $ runState f 1000 --状態の初期値を1000にしてfを実行 | |
f :: State Int () | |
f = do | |
x <- sub1 | |
sub2 x |
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
f :: Maybe Int | |
f = do | |
x <- return 5 | |
y <- return 3 | |
return $ x + y | |
f' :: Maybe Int | |
f' = do | |
x <- return 5 |
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 TemplateHaskell #-} | |
module Main where | |
import Control.Monad.State | |
import Control.Lens | |
type StateIO s a = StateT s IO a | |
data Hoge a = Hoge | |
{ _foo :: a | |
, _bar :: String |
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 TemplateHaskell #-} | |
module Main where | |
import Control.Lens | |
import Control.Monad.State | |
data Hoge = Hoge | |
{ _Foo :: Int | |
, _Bar :: String | |
} deriving (Show, Read, Eq, Ord) |
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 FlexibleContexts, ScopedTypeVariables #-} | |
{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses, UndecidableInstances #-} | |
{-# LANGUAGE DeriveDataTypeable #-} | |
{-# LANGUAGE TemplateHaskell #-} | |
module Main where | |
import Data.Typeable | |
import Control.Eff | |
import Control.Eff.State.Lazy as EST | |
import Control.Eff.Choose |
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 FlexibleContexts, ScopedTypeVariables #-} | |
{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses, UndecidableInstances #-} | |
{-# LANGUAGE DeriveDataTypeable #-} | |
{-# LANGUAGE TemplateHaskell #-} | |
module Main where | |
import Data.Typeable | |
import Control.Eff | |
import Control.Eff.State.Lazy as EST | |
import Control.Monad.State.Class (MonadState(..)) |
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 DeriveFunctor #-} | |
module Main where | |
import Test.QuickCheck | |
import Prelude (($), (.), id) | |
import Prelude (Integer, Bool) | |
import Prelude (IO(..), putStrLn) | |
import Prelude (Show(..), Read(..), Eq(..)) | |
import Prelude (Functor(..), Monad(..)) | |
import Control.Monad | |
import Control.Applicative |
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 DeriveFunctor #-} | |
module Main where | |
import Control.Applicative | |
import Test.QuickCheck | |
import Data.Maybe (fromJust) | |
class Functor w => Comonad w where | |
extract :: w a -> a | |
duplicate :: w a -> w (w a) | |
extend :: (w a -> b) -> w a -> w b |