Skip to content

Instantly share code, notes, and snippets.

import Control.Applicative
data A
data B
data C
data D
data X
f :: A -> B -> C
module Main where
import Data.Maybe
import Data.Monoid
import Control.Applicative
import Control.Monad.State
import Control.Lens
import Text.Trifecta
main :: IO ()
main = do
@tokiwoousaka
tokiwoousaka / Main.hs
Last active May 16, 2023 15:26
関数型LT大会発表資料
module Main where
import Game.NovelMonad
import Game.NovelMonad.SimpleInterpreter
import Story
main :: IO ()
main = simpleInterpret defaultConfig novelMain
novelMain :: Novel ()
novelMain = do
@tokiwoousaka
tokiwoousaka / gist:11398245
Last active August 29, 2015 14:00
ブドウの房問題
module Main where
import Control.Monad
import Data.List
step :: Int
step = 5
clusterCount :: Int -> Int
clusterCount n = n * (n + 1) `div` 2
@tokiwoousaka
tokiwoousaka / gist:9786835
Last active August 29, 2015 13:57
1時間もかかってしまった。。。Hskell力が足りない・・・
module Main where
import Control.Monad
import Control.Monad.Trans
-- Try
data Try a b = Success a | Failed b deriving Show
instance Monad (Try a) where
return x = Failed x
m >>= k = case m of
Success x -> Success x
@tokiwoousaka
tokiwoousaka / gist:9783721
Last active August 29, 2015 13:57
"@zakky_dev: Aの処理に失敗したらBをやり、それにも失敗したらCをやり、そこで失敗したら例外をスローする。どの処理でも成功したらDの処理を実行する。こういったことやりたいのかなりあるんだけど、どうしよっかなー。" https://twitter.com/zakky_dev/status/448654622970753024
public class Main {
private static void procces(boolean success, String procName){
if(success){
System.out.println("処理 " + procName + " 成功");
throw new RuntimeException();
}
System.out.println("処理 " + procName + " 失敗。。。");
}
             / )
            ./ /
           / /
           / /
         ./ /      , -つ
         / /・_・`)   /__ノ
        /    \ / /
        .|    へ/ /
        |    レ'  /、二つ
        |     /
 *      +     巛 ヽ
            〒 !   +    。     +    。     *     。
       +     。  |  |
    *      +   / /   イヤッッホォォォオオォオウ!
       / /
      (´・_・`/ / +    。     +    。   *     。
      ,-     f
      / ュヘ    | *     +    。     +   。 +
     〈_} )   |
        /    ! +    。     +    +     *
           (´・_・`)
          /,  /
         (ぃ9  |
          /    /、
         /   ∧_二つ
         /   /
        /    \
       /  /~\ \
       /  /   >  )
     / ノ    / /
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ExistentialQuantification #-}
module Main where
----------
-- Eff
newtype Eff r a = Eff { runEff :: forall w. (a -> VE w r) -> VE w r}
instance Monad (Eff r) where
--return :: a -> Eff a