[
  {
    "path": "README.md",
    "content": "# すごいHaskell　つくばで学ぼう！\n\n2016年 筑波大学 Haskell集中講義の資料です。\n\n- 最新の講義資料はこちらを参照してください： https://github.com/nushio3/learn-haskell/blob/master/Tsukuba-2016.pdf\n- 授業中随時、質問が出たポイントをまとめていきます： https://github.com/nushio3/learn-haskell/blob/master/tips.md\n\n\n"
  },
  {
    "path": "choose-name/LICENSE",
    "content": "Copyright Takayuki Muranushi (c) 2015\n\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n\n    * Redistributions in binary form must reproduce the above\n      copyright notice, this list of conditions and the following\n      disclaimer in the documentation and/or other materials provided\n      with the distribution.\n\n    * Neither the name of Takayuki Muranushi nor the names of other\n      contributors may be used to endorse or promote products derived\n      from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n\"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\nLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\nA PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\nOWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\nSPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\nLIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\nDATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\nTHEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\nOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
  },
  {
    "path": "choose-name/Setup.hs",
    "content": "import Distribution.Simple\nmain = defaultMain\n"
  },
  {
    "path": "choose-name/choose-name.cabal",
    "content": "name:                choose-name\nversion:             0.1.0.0\nsynopsis:            Simple project template from stack\ndescription:         Please see README.md\nhomepage:            http://github.com/nushio3/choose-name#readme\nlicense:             BSD3\nlicense-file:        LICENSE\nauthor:              Takayuki Muranushi\nmaintainer:          muranushi@gmail.com\ncopyright:           2010 Author Here\ncategory:            Web\nbuild-type:          Simple\ncabal-version:       >=1.10\n\nexecutable choose-name\n  hs-source-dirs:      src\n  main-is:             Main.hs\n  default-language:    Haskell2010\n  build-depends:       base >= 4.7 && < 5\n                     , process\n                     , random\n                     , unix\n"
  },
  {
    "path": "choose-name/src/Main.hs",
    "content": "module Main where\nimport Control.Monad\nimport Data.List\nimport System.Environment (getArgs)\nimport System.IO\nimport System.Posix.Unistd\nimport System.Process (system)\nimport System.Random\n\n\ndraw :: [String] -> IO ()\ndraw names0 = do\n  let names = names0 ++ names0\n  let getSortedNames = do\n        rs <- replicateM (length names) randomIO\n        return $ map snd $ sort $ zip (rs::[Int]) names\n  sn0 <- getSortedNames\n  forM sn0 $ \\n0 -> do\n    system \"clear\"\n    spinNames <- take 50 <$> concat <$> replicateM 10 getSortedNames\n    forM spinNames $ \\n1 -> do\n      putStr $ n1 ++ \"\\r\"\n      hFlush stdout\n      usleep 10000\n    system \"clear\"\n    putStrLn $ n0 ++ \" 様\"\n\n    getLine\n  return ()\n\nmain :: IO ()\nmain = do\n  argv <- getArgs\n  contents <- mapM readFile argv\n  let names = lines $ concat contents\n  forever $ draw names\n"
  },
  {
    "path": "choose-name/stack.yaml",
    "content": "# For more information, see: https://github.com/commercialhaskell/stack/blob/release/doc/yaml_configuration.md\n\n# Specifies the GHC version and set of packages available (e.g., lts-3.5, nightly-2015-09-21, ghc-7.10.2)\nresolver: lts-5.0\n\n# Local packages, usually specified by relative directory name\npackages:\n- '.'\n\n# Packages to be pulled from upstream that are not in the resolver (e.g., acme-missiles-0.3)\nextra-deps: []\n\n# Override default flag values for local packages and extra-deps\nflags: {}\n\n# Extra package databases containing global packages\nextra-package-dbs: []\n\n# Control whether we use the GHC we find on the path\n# system-ghc: true\n\n# Require a specific version of stack, using version ranges\n# require-stack-version: -any # Default\n# require-stack-version: >= 0.1.4.0\n\n# Override the architecture used by stack, especially useful on Windows\n# arch: i386\n# arch: x86_64\n\n# Extra directories used by stack for building\n# extra-include-dirs: [/path/to/dir]\n# extra-lib-dirs: [/path/to/dir]\n"
  },
  {
    "path": "concepts.md",
    "content": "変数\n\nリテラル\n\n関数適用\n\nLet式\n\nλ式\n\nCase式\n\n型\n\n型注釈\n\n型クラス\n\nリスト\n\nリスト内包表記\n\nタプル\n\n\n無限リスト\n\nquicksort\n\n素数リスト\n\n\n\n\n文字規則\n\nパターンマッチ\n\nガード\n\n演算子の優先順位と定義\n\n関数の部分適用\n\n演算子と関数の相互変換\n\n再帰と高階関数の使い方\n\nモジュール\n\nデータ型の自作\n\n型クラスの自作\n\n\nIO\n\n\nFunctor\n\nApplicative\n\nMonad\n\nMaybeモナド\n\nListモナド\n\nStateモナド\n\nトランスフォーマー\n\n\nhttps://wiki.haskell.org/Typeclassopedia#Functor\n"
  },
  {
    "path": "desugar-monad.hs",
    "content": "main :: IO ()\nmain = getLine >>= (\\x -> getLine >>= (\\y -> let z = x++y in putStrLn z))\n\n"
  },
  {
    "path": "exercise-1-hello-cat/TASK.md",
    "content": "# exercise 1. Hello, cat!\n\n## task 1\n\n`hello-world` という名前のプロジェクトを作り、 実行すると\"hello world\"と表示するプログラムを作ってください。\n\nただし、次の２つの関数を使ってください。\n\n`interact :: (String -> String) -> IO ()`\n`const :: a -> b -> a`\n\n## task 2\n\n`cat` という名前のプロジェクトで、 実行すると標準入力から入力された内容を１行づつ標準出力に出力するプログラムを作ってください。\n\nただし、次の２つの関数を使ってください。\n\n`interact :: (String -> String) -> IO ()`\n`id :: a -> a`\n"
  },
  {
    "path": "exercise-10-free/TASK.md",
    "content": "# exercise 10. This is a free-style task!\n\n自分の気になるHaskellのライブラリを調べて使って、独自のHaskellプログラムを作ってみてください。\n"
  },
  {
    "path": "exercise-3-string-Num/LICENSE",
    "content": "Copyright Takayuki Muranushi (c) 2015\n\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n\n    * Redistributions in binary form must reproduce the above\n      copyright notice, this list of conditions and the following\n      disclaimer in the documentation and/or other materials provided\n      with the distribution.\n\n    * Neither the name of Takayuki Muranushi nor the names of other\n      contributors may be used to endorse or promote products derived\n      from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n\"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\nLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\nA PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\nOWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\nSPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\nLIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\nDATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\nTHEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\nOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
  },
  {
    "path": "exercise-3-string-Num/Setup.hs",
    "content": "import Distribution.Simple\nmain = defaultMain\n"
  },
  {
    "path": "exercise-3-string-Num/String-Num.cabal",
    "content": "name:                String-Num\nversion:             0.1.0.0\nsynopsis:            Simple project template from stack\ndescription:         Please see README.md\nhomepage:            http://github.com/nushio3/String-Num#readme\nlicense:             BSD3\nlicense-file:        LICENSE\nauthor:              Takayuki Muranushi\nmaintainer:          muranushi@gmail.com\ncopyright:           2010 Author Here\ncategory:            Web\nbuild-type:          Simple\ncabal-version:       >=1.10\n\nexecutable String-Num\n  hs-source-dirs:      src\n  main-is:             Main.hs\n  default-language:    Haskell2010\n  build-depends:       base >= 4.7 && < 5\n"
  },
  {
    "path": "exercise-3-string-Num/TASK.md",
    "content": "# exercise 3. instance Num String\n\nHaskellではリストの結合は演算子 ++ で行います。\n\n他のプログラミング言語では、 + 演算子で文字列を結合したり、`整数n * 文字列`という構文で文字列をｎ回繰り返した文字列を生成できるものもあります。時にはこちらが便利に感じることもありますね！\n\nこのフォルダにあるプロジェクトは、String同士を + で演算しているため、このままではコンパイルできません。\n\nString 同士の + 演算を定義して、このプログラムが動くようにしてください。\n\n## 発展課題\n\n`整数n * 文字列` という構文も使えるようにできないでしょうか？\n"
  },
  {
    "path": "exercise-3-string-Num/src/Main.hs",
    "content": "module Main where\n\n-- {- Hint -}\n--\ninstance Num String where\n  a + b = a ++ b\n--   ...\n\nmain :: IO ()\nmain = do\n  putStrLn \"May I have your name?\"\n  name <- getLine\n  putStrLn $ \"Congratulations, \" + name + \" has now mastered class Num!\"\n\n--  {- Can you also make these work? -}\n--  putStrLn 5963\n--  putStrLn $ 3 * (\"All hail \" + name + \"! \")\n"
  },
  {
    "path": "exercise-3-string-Num/stack.yaml",
    "content": "# For more information, see: https://github.com/commercialhaskell/stack/blob/release/doc/yaml_configuration.md\n\n# Specifies the GHC version and set of packages available (e.g., lts-3.5, nightly-2015-09-21, ghc-7.10.2)\nresolver: lts-5.0\n\n# Local packages, usually specified by relative directory name\npackages:\n- '.'\n\n# Packages to be pulled from upstream that are not in the resolver (e.g., acme-missiles-0.3)\nextra-deps: []\n\n# Override default flag values for local packages and extra-deps\nflags: {}\n\n# Extra package databases containing global packages\nextra-package-dbs: []\n\n# Control whether we use the GHC we find on the path\n# system-ghc: true\n\n# Require a specific version of stack, using version ranges\n# require-stack-version: -any # Default\n# require-stack-version: >= 0.1.4.0\n\n# Override the architecture used by stack, especially useful on Windows\n# arch: i386\n# arch: x86_64\n\n# Extra directories used by stack for building\n# extra-include-dirs: [/path/to/dir]\n# extra-lib-dirs: [/path/to/dir]\n"
  },
  {
    "path": "exercise-4-brain-twister/TASK.md",
    "content": "# exercise 4. reverse the string\n\nある学説によれば、ヒトは英語を読むとき、英単語の「最初の文字」「最後の文字」「途中の文字の集合」を認識するようになっているため、英文を書くとき、英単語の最初と最後以外の文字の順序を入れ替えておいても、ほとんどの人は間違いに気づかずに読めてしまうそうです。\n\n本当でしょうか？\n\nこれを検証するために、スペース区切りの文字列を入力に受け取って、各単語の最初と最後の文字以外を逆順にしてしまうプログラムを作ってください。\n\nこのフォルダにある input-n.txt を標準入力から読ませると、対応する output-n.txt を出力するようなプログラムになればokです。\n"
  },
  {
    "path": "exercise-4-brain-twister/input-1.txt",
    "content": "a ab abc abcd\nabcde abcdef abc123\n!\"#$%&\n"
  },
  {
    "path": "exercise-4-brain-twister/input-2.txt",
    "content": "\nThe purpose of this project is to design a high-level language for implementing explicit partial-differential equations solvers on supercomputers as well as today’s advanced personal computers. A language to describe the knowledge on algebraic concepts, physical equations, integration algorithms, optimization techniques, and hardware designs --- all the necessaries of the simulations in abstract, modular, re-usable and combinable forms.\n"
  },
  {
    "path": "exercise-4-brain-twister/input-3.txt",
    "content": "Why dsdit tohu psimore scuh a buoetuaes dya,\nAnd mkae me tevarl ftroh wuohtit my ckaol,\nTo let bsae cduols okatre'e me in my wya,\nHnidig thy brevary in tiehr retton sekom?\n'iTs not eguonh taht tguorhh the cuold tohu bkaer,\nTo dry the rian on my setaeb-mrotn feca,\nFor no man wlel of scuh a svlae can saepk\nTaht hlaes the wnuod and cerus not the decargsi:\nNor can thy smahe gvie pisyhc to my gfeir;\nTguohh tohu rtnepe, yet I hvae slitl the lsso:\nThe o'redneffs sorrow ldnes but waek reilef\nTo him taht braes the snortg o'ecneffs cssor.\nAh! but tsohe traes are prael wcihh thy lvoe ssdeh,\nAnd tehy are rcih and rosnam all ill dsdee.\n"
  },
  {
    "path": "exercise-4-brain-twister/output-1.txt",
    "content": "a ab abc acbd\nadcbe aedcbf a21cb3\n!%$#\"&\n"
  },
  {
    "path": "exercise-4-brain-twister/output-2.txt",
    "content": "\nThe psoprue of tihs pcejort is to dgisen a hevel-hgil lgaugnae for initnemelpmg eicilpxt paitnereffid-laitral enoitauqs srevlos on sretupmocrepus as wlel as t’yados aecnavdd panosrel csretupmo. A lgaugnae to dbircsee the kgdelwone on aiarbeglc cstpecno, pacisyhl esnoitauq, ioitargetnn asmhtirogl, ooitazimitpn tseuqinhce, and hrawdrae dngises --- all the neirasseces of the snoitalumis in atcartsb, mraludo, rlbasu-ee and clbanibmoe fsmro.\n"
  },
  {
    "path": "exercise-4-brain-twister/output-3.txt",
    "content": "Why didst thou promise such a beauteous day,\nAnd make me travel forth without my cloak,\nTo let base clouds o'ertake me in my way,\nHiding thy bravery in their rotten smoke?\n'Tis not enough that through the cloud thou break,\nTo dry the rain on my storm-beaten face,\nFor no man well of such a salve can speak\nThat heals the wound and cures not the disgrace:\nNor can thy shame give physic to my grief;\nThough thou repent, yet I have still the loss:\nThe offender's sorrow lends but weak relief\nTo him that bears the strong offence's cross.\nAh! but those tears are pearl which thy love sheds,\nAnd they are rich and ransom all ill deeds.\n"
  },
  {
    "path": "exercise-5-1-fast-reverse/TASK.md",
    "content": "# exercise 5-1. faster reverse\n\nexercise 4. reverse the string で作ったプログラムは、文字列をCharのリストとして扱っているため、実行速度が遅くなっています。文字列処理用のライブラリtext　https://hackage.haskell.org/package/text を利用して、このプログラムをより高速にしてみましょう。\n\nString を利用する版と、Textを利用する版のプログラムを作り、両方のプログラムの実行結果が一致することを確認してください。\nまた、両方のプログラムについて、ファイルを処理する時間をファイルサイズ等の関数として測定してみてください。\n(計測結果、またはそのファイルの所在を、SOLUTION ファイルに記入すること。)\n\n大きな英文テキストファイルは例えば、以下のURLからダウンロードできます。\n\n* http://www.geocities.jp/f9305710/PAI1000000.html (1.2MB)\n* http://norvig.com/big.txt (6.2MB)\n"
  },
  {
    "path": "exercise-5-1-fast-reverse/with-string.hs",
    "content": "import System.IO\n\nwordreverse :: [Char] -> [Char]\nwordreverse xs\n\t| length xs < 2 = xs\n\t| otherwise = do\n\t    take 1 xs ++ (reverse $ drop 1 (take ((length xs) - 1) xs )) ++ drop (length xs -1) xs\n\nmain :: IO ()\nmain = do\n    strings <- getLine\n    putStrLn $unwords $map wordreverse $words strings\n    f<- isEOF\n    if f then return() else main\n"
  },
  {
    "path": "exercise-5-2-confuse-prelude/LICENSE",
    "content": "Copyright Takayuki Muranushi (c) 2015\n\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n\n    * Redistributions in binary form must reproduce the above\n      copyright notice, this list of conditions and the following\n      disclaimer in the documentation and/or other materials provided\n      with the distribution.\n\n    * Neither the name of Takayuki Muranushi nor the names of other\n      contributors may be used to endorse or promote products derived\n      from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n\"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\nLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\nA PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\nOWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\nSPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\nLIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\nDATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\nTHEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\nOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
  },
  {
    "path": "exercise-5-2-confuse-prelude/Setup.hs",
    "content": "import Distribution.Simple\nmain = defaultMain\n"
  },
  {
    "path": "exercise-5-2-confuse-prelude/TASK.md",
    "content": "# exercise 5-2. Confuse the Prelude!\n\nこのプロジェクトの実行ファイルは`app/Main.hs`です。\n\nこのプログラムを普通に実行すると、 5 + 100 * 7 + 10 を計算して715 と表示されます。\n演算子 + と * の意味と優先順位を入れ替えて、このプログラムが 570 と表示するようにしてください。\n\nつまり、　5 + 100 * 7 + 10　という式が、 + が乗算、 * が加算であるうえに、\n優先順位が(5 + 100) * (7 + 10)なので、\n\n  (5 + 100) * (7 + 10) = (500) * (70) = 570\n\nと解釈されるようにしてください。\n\nなお、他のモジュールファイルはいくらでも作ってかまいませんが、app/Main.hsは\nimport文以外の部分を編集してはいけません。\nimport文はいくら追加・削除しても大丈夫です。\n\n\n1. Main.hsにおいて、Preludeが提供する + ,  * 識別子を隠し、自作のライブラリLibが提供する +, * を利用するようにします。\n2. src/Lib.hs において、 演算子 + と * を、所定の意味と優先順位を持つように定義します。\n3. 演算子の優先順位と結合性は、予約語 infix / infixl / infixr で指定します。 + や * の元々の優先順位については :info で調べられます！\n"
  },
  {
    "path": "exercise-5-2-confuse-prelude/app/Main.hs",
    "content": "module Main where\n\n{-\n　このプログラムを普通に実行すると、　　715 と表示されます。\n　演算子 + と * の意味と優先順位を入れ替えて、このプログラムが 570 と表示するようにしてください。\n\n  なお、他のモジュールファイルはいくらでも作ってかまいませんが、このファイルは\n  import文以外の部分を編集してはいけません。\n　import文はいくら追加・削除しても大丈夫です。\n-}\n\nimport Lib\n\nmain :: IO ()\nmain = do\n  print $ 5 + 100 * 7 + 10\n"
  },
  {
    "path": "exercise-5-2-confuse-prelude/confuse-prelude.cabal",
    "content": "name:                confuse-prelude\nversion:             0.1.0.0\nsynopsis:            Initial project template from stack\ndescription:         Please see README.md\nhomepage:            http://github.com/nushio3/confuse-prelude#readme\nlicense:             BSD3\nlicense-file:        LICENSE\nauthor:              Takayuki Muranushi\nmaintainer:          muranushi@gmail.com\ncopyright:           2010 Author Here\ncategory:            Web\nbuild-type:          Simple\n-- extra-source-files:\ncabal-version:       >=1.10\n\nlibrary\n  hs-source-dirs:      src\n  exposed-modules:     Lib\n  build-depends:       base >= 4.7 && < 5\n  default-language:    Haskell2010\n\nexecutable i-am-confused\n  hs-source-dirs:      app\n  main-is:             Main.hs\n  ghc-options:         -threaded -rtsopts -with-rtsopts=-N\n  build-depends:       base\n                     , confuse-prelude\n  default-language:    Haskell2010\n"
  },
  {
    "path": "exercise-5-2-confuse-prelude/src/Lib.hs",
    "content": "module Lib\n    ( someFunc\n    ) where\n\nsomeFunc :: IO ()\nsomeFunc = putStrLn \"someFunc\"\n"
  },
  {
    "path": "exercise-5-2-confuse-prelude/stack.yaml",
    "content": "# For more information, see: https://github.com/commercialhaskell/stack/blob/release/doc/yaml_configuration.md\n\n# Specifies the GHC version and set of packages available (e.g., lts-3.5, nightly-2015-09-21, ghc-7.10.2)\nresolver: lts-5.0\n\n# Local packages, usually specified by relative directory name\npackages:\n- '.'\n\n# Packages to be pulled from upstream that are not in the resolver (e.g., acme-missiles-0.3)\nextra-deps: []\n\n# Override default flag values for local packages and extra-deps\nflags: {}\n\n# Extra package databases containing global packages\nextra-package-dbs: []\n\n# Control whether we use the GHC we find on the path\n# system-ghc: true\n\n# Require a specific version of stack, using version ranges\n# require-stack-version: -any # Default\n# require-stack-version: >= 0.1.4.0\n\n# Override the architecture used by stack, especially useful on Windows\n# arch: i386\n# arch: x86_64\n\n# Extra directories used by stack for building\n# extra-include-dirs: [/path/to/dir]\n# extra-lib-dirs: [/path/to/dir]\n"
  },
  {
    "path": "exercise-6-1-data-Vec/LICENSE",
    "content": "Copyright Takayuki Muranushi (c) 2015\n\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n\n    * Redistributions in binary form must reproduce the above\n      copyright notice, this list of conditions and the following\n      disclaimer in the documentation and/or other materials provided\n      with the distribution.\n\n    * Neither the name of Takayuki Muranushi nor the names of other\n      contributors may be used to endorse or promote products derived\n      from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n\"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\nLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\nA PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\nOWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\nSPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\nLIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\nDATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\nTHEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\nOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
  },
  {
    "path": "exercise-6-1-data-Vec/Setup.hs",
    "content": "import Distribution.Simple\nmain = defaultMain\n"
  },
  {
    "path": "exercise-6-1-data-Vec/TASK.md",
    "content": "# exercise 6-1. 3次元ベクトルを表す型を作ろう\n\napp/Main.hs では3次元ベクトルを表す型 Vec が使える前提でプログラムを書いています。\nこの型は Data/Vec.hs にて\n\n```\ndata Vec a = Vec a a a\n```\n\nとして定義されかかっていますが、実装はまだ途中です。\n\n1. src/Data/Vec.hs を編集して、 app/Main.hs が動くようにしてください！\n2. test/Spec.hs にはこのライブラリをテストするプログラムが入っています。\n   `stack test` を実行して、あたなが実装したモジュール Data.Vec がテストを通ることを確認してください。\n"
  },
  {
    "path": "exercise-6-1-data-Vec/app/Main.hs",
    "content": "module Main where\n\nimport Data.Vec\n\nmain :: IO ()\nmain = do\n  let u, v :: Vec Integer\n      v = Vec 1 2 3\n      u = Vec 10 10 10\n  print $ u + v\n  -- Vec 11 12 13 と表示されてほしい！\n\n  print $ u ・ v\n  -- 60 と表示されてほしい！\n\n  print $ u × v\n  -- Vec (-10) 20 (-10) と表示されてほしい！\n"
  },
  {
    "path": "exercise-6-1-data-Vec/src/Data/Vec.hs",
    "content": "module Data.Vec where\n\ndata Vec a = Vec a a a\n\n(・) :: Vec a -> Vec a -> a\n(Vec ax ay az) ・ (Vec bx by bz) = undefined\n\n(×) :: Vec a -> Vec a -> Vec a\n(Vec ax ay az) × (Vec bx by bz) = undefined\n"
  },
  {
    "path": "exercise-6-1-data-Vec/stack.yaml",
    "content": "# For more information, see: https://github.com/commercialhaskell/stack/blob/release/doc/yaml_configuration.md\n\n# Specifies the GHC version and set of packages available (e.g., lts-3.5, nightly-2015-09-21, ghc-7.10.2)\nresolver: lts-5.0\n\n# Local packages, usually specified by relative directory name\npackages:\n- '.'\n\n# Packages to be pulled from upstream that are not in the resolver (e.g., acme-missiles-0.3)\nextra-deps: []\n\n# Override default flag values for local packages and extra-deps\nflags: {}\n\n# Extra package databases containing global packages\nextra-package-dbs: []\n\n# Control whether we use the GHC we find on the path\n# system-ghc: true\n\n# Require a specific version of stack, using version ranges\n# require-stack-version: -any # Default\n# require-stack-version: >= 0.1.4.0\n\n# Override the architecture used by stack, especially useful on Windows\n# arch: i386\n# arch: x86_64\n\n# Extra directories used by stack for building\n# extra-include-dirs: [/path/to/dir]\n# extra-lib-dirs: [/path/to/dir]\n"
  },
  {
    "path": "exercise-6-1-data-Vec/test/Spec.hs",
    "content": "import Control.Applicative\nimport Test.Framework (defaultMain, testGroup)\nimport Test.Framework.Providers.API (Test)\nimport Test.Framework.Providers.QuickCheck2 (testProperty)\nimport Test.QuickCheck.Arbitrary\n\nimport Data.Vec\n\ninstance Arbitrary a => Arbitrary (Vec a) where\n  arbitrary = Vec <$> arbitrary <*> arbitrary <*> arbitrary\n\ntests :: [Test]\ntests = [\n  testProperty \"addition of Vec is associative.\" $\n  \\u v w ->  u+(v+w) == (u+v)+ (w :: Vec Integer) ,\n  testProperty \"addition of Vec is commutative.\" $\n  \\u v ->  u+v == v + (u :: Vec Integer),\n  testProperty \"zero.\" $\n  \\v ->  v +0  == (v :: Vec Integer),\n  testProperty \"one.\" $\n  \\v ->  1*v  == (v :: Vec Integer),\n  testProperty \"negate.\" $\n  \\v ->  v - v == (0 :: Vec Integer),\n  testProperty \"distributive vector.\" $\n  \\a u v ->  fromInteger a*(u+v)  ==fromInteger  a*u +fromInteger  a * (v :: Vec Integer),\n  testProperty \"distributive scalar.\" $\n  \\a b v ->  fromInteger (a+b)*v  == fromInteger a*v+fromInteger b* (v :: Vec Integer),\n  testProperty \"commutative scalar product.\" $\n  \\a b v ->  fromInteger (a*b)*v  == fromInteger a* (fromInteger b* (v :: Vec Integer)),\n  testProperty \"inner product is zero for perpendicular vector.\" $\n  \\x y -> Vec x 0 0 ・ Vec 0 y 0 == (0::Integer),\n  testProperty \"outer product is zero for parallel vector.\" $\n  \\x1 x2 -> Vec x1 0 0 × Vec x2 0 0 == (0::Vec Integer)\n        ]\n\nmain :: IO ()\nmain = defaultMain tests\n"
  },
  {
    "path": "exercise-6-1-data-Vec/vec.cabal",
    "content": "name:                vec\nversion:             0.1.0.0\nsynopsis:            Initial project template from stack\ndescription:         Please see README.md\nhomepage:            http://github.com/nushio3/vec#readme\nlicense:             BSD3\nlicense-file:        LICENSE\nauthor:              Takayuki Muranushi\nmaintainer:          muranushi@gmail.com\ncopyright:           2010 Author Here\ncategory:            Web\nbuild-type:          Simple\n-- extra-source-files:\ncabal-version:       >=1.10\n\nlibrary\n  hs-source-dirs:      src\n  exposed-modules:     Data.Vec\n  build-depends:       base >= 4.7 && < 5\n  default-language:    Haskell2010\n\nexecutable use-vector\n  hs-source-dirs:      app\n  main-is:             Main.hs\n  ghc-options:         -threaded -rtsopts -with-rtsopts=-N\n  build-depends:       base\n                     , vec\n  default-language:    Haskell2010\n\ntest-suite vec-test\n  type:                exitcode-stdio-1.0\n  hs-source-dirs:      test\n  main-is:             Spec.hs\n  build-depends:       base\n                     , vec\n                     , test-framework\n                     , test-framework-quickcheck2\n                     , QuickCheck\n\n  ghc-options:         -threaded -rtsopts -with-rtsopts=-N\n  default-language:    Haskell2010\n\nsource-repository head\n  type:     git\n  location: https://github.com/nushio3/vec\n"
  },
  {
    "path": "exercise-7-nabe/LICENSE",
    "content": "Copyright Takayuki Muranushi (c) 2015\n\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n\n    * Redistributions in binary form must reproduce the above\n      copyright notice, this list of conditions and the following\n      disclaimer in the documentation and/or other materials provided\n      with the distribution.\n\n    * Neither the name of Takayuki Muranushi nor the names of other\n      contributors may be used to endorse or promote products derived\n      from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n\"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\nLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\nA PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\nOWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\nSPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\nLIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\nDATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\nTHEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\nOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
  },
  {
    "path": "exercise-7-nabe/Setup.hs",
    "content": "import Distribution.Simple\nmain = defaultMain\n"
  },
  {
    "path": "exercise-7-nabe/TASK.md",
    "content": "# exercise 7. 鍋サーバー\n\n次のような手順で、鍋サーバープログラムを完成させて下さい。Data.Mapを操作するのに必要な関数は、すべて以下のマニュアルのどこかにあるはずです。\n\nhttps://hackage.haskell.org/package/containers-0.5.7.1/docs/Data-Map-Lazy.html\n\n1. \"recipe.txt\" から具材の名前と数を読み取り、 [(String, Int)] 型の値を作ります。\n2. guzaiがnabeに入っていたらその具材の個数を１減らす、guzaiの個数がゼロになったらその項目をMapから消す、\n   ように、関数eatを追記してください。\n3. 鍋が空になったかどうかを判定する式を書いてください。\n"
  },
  {
    "path": "exercise-7-nabe/nabe.cabal",
    "content": "name:                nabe\nversion:             0.1.0.0\nsynopsis:            Simple project template from stack\ndescription:         Please see README.md\nhomepage:            http://github.com/nushio3/nabe#readme\nlicense:             BSD3\nlicense-file:        LICENSE\nauthor:              Takayuki Muranushi\nmaintainer:          muranushi@gmail.com\ncopyright:           2010 Author Here\ncategory:            Web\nbuild-type:          Simple\ncabal-version:       >=1.10\n\nexecutable nabe\n  hs-source-dirs:      src\n  main-is:             Main.hs\n  default-language:    Haskell2010\n  build-depends:       base >= 4.7 && < 5\n                     , containers\n"
  },
  {
    "path": "exercise-7-nabe/recipe.txt",
    "content": "tebamoto 3\nhakusai 4\nninjin 2\nshiitake 2\ntofu 2\n"
  },
  {
    "path": "exercise-7-nabe/src/Main.hs",
    "content": "module Main where\n\nimport qualified Data.Map as M\n\n-- guzaiがnabeに入っていたらその具材の個数を１減らす、\n-- guzaiの個数がゼロになったらその項目をMapから消す、\n-- ように、関数eatを追記してください。\neat :: String ->  M.Map String Int -> M.Map String Int\neat guzai nabe = nabe\n\nparty ::   M.Map String Int -> IO ()\nparty nabe = do\n  putStrLn $ \"Nabe: \" ++ show nabe\n  order <- getLine\n  let newNabe = eat order nabe\n  if False -- ここで、鍋が空(null)かどうかを判定してください。\n    then putStrLn \"The party is over!\"\n    else party newNabe\n\nreadRecipe :: IO (M.Map String Int)\nreadRecipe = do\n  content <- readFile \"recipe.txt\"\n  -- content の内容を解釈して、おいしそうな鍋の中身を作ってください！\n  return $ M.fromList [(\"Kuuki\",1)]\n\nmain :: IO ()\nmain = do\n  initialNabe <- readRecipe\n  party initialNabe\n"
  },
  {
    "path": "exercise-7-nabe/stack.yaml",
    "content": "# For more information, see: https://github.com/commercialhaskell/stack/blob/release/doc/yaml_configuration.md\n\n# Specifies the GHC version and set of packages available (e.g., lts-3.5, nightly-2015-09-21, ghc-7.10.2)\nresolver: lts-5.0\n\n# Local packages, usually specified by relative directory name\npackages:\n- '.'\n\n# Packages to be pulled from upstream that are not in the resolver (e.g., acme-missiles-0.3)\nextra-deps: []\n\n# Override default flag values for local packages and extra-deps\nflags: {}\n\n# Extra package databases containing global packages\nextra-package-dbs: []\n\n# Control whether we use the GHC we find on the path\n# system-ghc: true\n\n# Require a specific version of stack, using version ranges\n# require-stack-version: -any # Default\n# require-stack-version: >= 0.1.4.0\n\n# Override the architecture used by stack, especially useful on Windows\n# arch: i386\n# arch: x86_64\n\n# Extra directories used by stack for building\n# extra-include-dirs: [/path/to/dir]\n# extra-lib-dirs: [/path/to/dir]\n"
  },
  {
    "path": "exercise-8-1-safe-pred/LICENSE",
    "content": "Copyright Takayuki Muranushi (c) 2015\n\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n\n    * Redistributions in binary form must reproduce the above\n      copyright notice, this list of conditions and the following\n      disclaimer in the documentation and/or other materials provided\n      with the distribution.\n\n    * Neither the name of Takayuki Muranushi nor the names of other\n      contributors may be used to endorse or promote products derived\n      from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n\"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\nLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\nA PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\nOWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\nSPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\nLIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\nDATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\nTHEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\nOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
  },
  {
    "path": "exercise-8-1-safe-pred/Setup.hs",
    "content": "import Distribution.Simple\nmain = defaultMain\n"
  },
  {
    "path": "exercise-8-1-safe-pred/TASK.md",
    "content": "# Exercise 8-1. safe pred\n\npred :: Enum a => a -> aは危険な部分関数です。\n```\n> pred True\nFalse\n> pred False\n*** Exception: Prelude.Enum.Bool.pred: bad argument\n>\n```\n\n安全なpred関数 `predMay :: Enum a => a -> Maybe a`\nを用意しましたので、これを使って、ある値の「３つ前の値」、「ｎ個前の値」を求める関数を作ってください。\n`pred3 :: Enum a => a -> Maybe a`\n`predN :: Enum a => Int -> a -> Maybe a`\n"
  },
  {
    "path": "exercise-8-1-safe-pred/safe-pred.cabal",
    "content": "name:                safe-pred\nversion:             0.1.0.0\nsynopsis:            Simple project template from stack\ndescription:         Please see README.md\nhomepage:            http://github.com/nushio3/safe-pred#readme\nlicense:             BSD3\nlicense-file:        LICENSE\nauthor:              Takayuki Muranushi\nmaintainer:          muranushi@gmail.com\ncopyright:           2010 Author Here\ncategory:            Web\nbuild-type:          Simple\ncabal-version:       >=1.10\n\nexecutable safe-pred\n  hs-source-dirs:      src\n  main-is:             Main.hs\n  default-language:    Haskell2010\n  build-depends:       base >= 4.7 && < 5\n                     , deepseq\n                     , spoon\n"
  },
  {
    "path": "exercise-8-1-safe-pred/src/Main.hs",
    "content": "module Main where\n\nimport Control.Spoon (spoon)\nimport Control.DeepSeq (NFData)\n\npredMay :: (Enum a, NFData a) => a -> Maybe a\npredMay = spoon . pred\n\npred3 ::  (Enum a, NFData a) => a -> Maybe a\npred3 = undefined\n\npredN ::  (Enum a, NFData a) => Int -> a -> Maybe a\npredN 0 x = Just x\n\nmain :: IO ()\nmain = do\n  putStrLn \"hello world\"\n  print $ pred3 True\n  print $ predN 256 'a'\n  print $ predN 32 'z'\n"
  },
  {
    "path": "exercise-8-1-safe-pred/stack.yaml",
    "content": "# For more information, see: https://github.com/commercialhaskell/stack/blob/release/doc/yaml_configuration.md\n\n# Specifies the GHC version and set of packages available (e.g., lts-3.5, nightly-2015-09-21, ghc-7.10.2)\nresolver: lts-5.0\n\n# Local packages, usually specified by relative directory name\npackages:\n- '.'\n\n# Packages to be pulled from upstream that are not in the resolver (e.g., acme-missiles-0.3)\nextra-deps: []\n\n# Override default flag values for local packages and extra-deps\nflags: {}\n\n# Extra package databases containing global packages\nextra-package-dbs: []\n\n# Control whether we use the GHC we find on the path\n# system-ghc: true\n\n# Require a specific version of stack, using version ranges\n# require-stack-version: -any # Default\n# require-stack-version: >= 0.1.4.0\n\n# Override the architecture used by stack, especially useful on Windows\n# arch: i386\n# arch: x86_64\n\n# Extra directories used by stack for building\n# extra-include-dirs: [/path/to/dir]\n# extra-lib-dirs: [/path/to/dir]\n"
  },
  {
    "path": "exercise-8-2-learn-parser/LICENSE",
    "content": "Copyright Takayuki Muranushi (c) 2015\n\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n\n    * Redistributions in binary form must reproduce the above\n      copyright notice, this list of conditions and the following\n      disclaimer in the documentation and/or other materials provided\n      with the distribution.\n\n    * Neither the name of Takayuki Muranushi nor the names of other\n      contributors may be used to endorse or promote products derived\n      from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n\"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\nLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\nA PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\nOWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\nSPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\nLIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\nDATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\nTHEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\nOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
  },
  {
    "path": "exercise-8-2-learn-parser/Setup.hs",
    "content": "import Distribution.Simple\nmain = defaultMain\n"
  },
  {
    "path": "exercise-8-2-learn-parser/TASK.md",
    "content": "# exercise 8. 四則演算パーザー\n\ntrifectaはパーザーコンビネータライブラリ(パーザーを作るための道具を提供するライブラリ)です。\nsrc/ フォルダに、trifectaを使ういくつかのサンプルが入っています。\n\n* src/parse-integer.hs\n\n標準入力を1行毎に読み取り、整数を + 記号で区切った式であった場合にはその和を表示し、\nそれ以外の式の場合にはエラーメッセージを表示するプログラムです。\n\n* src/parse-question.hs\n\n標準入力から文字列を受け取り、一行ごとに、疑問文であると判定した場合は \"質問ではない。\"\n疑問文であった場合は \"質問ありがとう。\"と表示するプログラムです。\n\n* src/parse-S-expression.hs\n\nファイル名をコマンドライン引数から受け取り、各ファイルをS式(lispのプログラムに使われている形式)としてパーズし、\n構文木を表示するプログラムです。\n\n\n## 四則演算プログラム\n\n以上を参考にしながら、parse-arithmetic.hs を完成させて下さい。\n\n1. 四則演算を含む構文木Expr のパーザ、 arithmeticExprを完成させてください。\n\nbuildExpressionParser https://hackage.haskell.org/package/parsers/docs/Text-Parser-Expression.html#v:buildExpressionParser を解読して使うのもよし。自分で文法を考えてみるのもよいでしょう。\n\n2. 構文木Exprを評価して数値に変える関数evalを完成させてください。\n\n3. 以上の数式パーザー＆評価機によって　input-arith-(n).txt　が正しく計算できるか確認してください。\n"
  },
  {
    "path": "exercise-8-2-learn-parser/input-arith-1.txt",
    "content": "1\n4235\n-9801\n"
  },
  {
    "path": "exercise-8-2-learn-parser/input-arith-2.txt",
    "content": "1+2\n345+656\n456+2764+33344+63436\n"
  },
  {
    "path": "exercise-8-2-learn-parser/input-arith-3.txt",
    "content": "60+7\n60-7\n60*7\n60/7\n"
  },
  {
    "path": "exercise-8-2-learn-parser/input-arith-4.txt",
    "content": "1+2*3+4\n30/3+60/4\n100/7/3\n640*480\n1000-1-2-3-4\n1*23+4+56/7*8+9\n"
  },
  {
    "path": "exercise-8-2-learn-parser/input-arith-5.txt",
    "content": "1+2*(3+4)\n3000/(3+60)/4\n100/(7/3)\n640*480\n1000-(1-2-3)-4\n123-(45+67)+89\n"
  },
  {
    "path": "exercise-8-2-learn-parser/learn-parser.cabal",
    "content": "name:                learn-parser\nversion:             0.1.0.0\nsynopsis:            Simple project template from stack\ndescription:         Please see README.md\nhomepage:            http://github.com/nushio3/learn-parser#readme\nlicense:             BSD3\nlicense-file:        LICENSE\nauthor:              Takayuki Muranushi\nmaintainer:          muranushi@gmail.com\ncopyright:           2010 Author Here\ncategory:            Web\nbuild-type:          Simple\ncabal-version:       >=1.10\n\nexecutable parse-integer\n  hs-source-dirs:      src\n  main-is:             parse-integer.hs\n  default-language:    Haskell2010\n  build-depends:       base >= 4.7 && < 5\n                     , trifecta\n                     , ansi-wl-pprint\n\nexecutable parse-question\n  hs-source-dirs:      src\n  main-is:             parse-question.hs\n  default-language:    Haskell2010\n  build-depends:       base >= 4.7 && < 5\n                     , trifecta\n                     , ansi-wl-pprint\n\n\nexecutable parse-S-expression\n  hs-source-dirs:      src\n  main-is:             parse-S-expression.hs\n  default-language:    Haskell2010\n  build-depends:       base >= 4.7 && < 5\n                     , trifecta\n\nexecutable parse-arithmetic\n  hs-source-dirs:      src\n  main-is:             parse-arithmetic.hs\n  default-language:    Haskell2010\n  build-depends:       base >= 4.7 && < 5\n                     , trifecta\n                     , ansi-wl-pprint\n"
  },
  {
    "path": "exercise-8-2-learn-parser/output-arith-1.txt",
    "content": "1\n4235\n-9801\n"
  },
  {
    "path": "exercise-8-2-learn-parser/output-arith-2.txt",
    "content": "3\n1001\n100000\n"
  },
  {
    "path": "exercise-8-2-learn-parser/output-arith-3.txt",
    "content": "67\n53\n420\n8\n"
  },
  {
    "path": "exercise-8-2-learn-parser/output-arith-4.txt",
    "content": "11\n25\n4\n307200\n990\n100\n"
  },
  {
    "path": "exercise-8-2-learn-parser/output-arith-5.txt",
    "content": "15\n11\n50\n307200\n1000\n100\n"
  },
  {
    "path": "exercise-8-2-learn-parser/src/parse-S-expression.hs",
    "content": "import Control.Applicative((<|>))\nimport Data.Char (isSpace)\nimport Text.Trifecta\nimport System.Environment (getArgs)\n\ndata SExpr = Atom String | List [SExpr] deriving Show\n\nprogram :: Parser [SExpr]\nprogram = sexpr `sepEndBy` spaces\n\nsexpr :: Parser SExpr\nsexpr =  list <|> atom\n\natom :: Parser SExpr\natom = Atom <$> some identifierChar <* spaces\n\nidentifierChar :: Parser Char\nidentifierChar = satisfy $ \\c -> not (isSpace c) && c /= '(' && c /= ')'\n\nlist :: Parser SExpr\nlist = do\n  symbol \"(\"\n  ret <- many sexpr\n  symbol \")\"\n  return $ List ret\n\nprocessFile :: FilePath -> IO ()\nprocessFile filename = do\n  result <- parseFromFile program filename\n  case result of\n    Nothing -> putStrLn \"parse error.\"\n    Just x -> mapM_ print x\n\nmain :: IO ()\nmain = do\n  filenames <- getArgs\n  mapM_ processFile filenames\n"
  },
  {
    "path": "exercise-8-2-learn-parser/src/parse-arithmetic.hs",
    "content": "module Main where\nimport Control.Monad (forM_)\nimport Text.Trifecta\nimport Text.Trifecta.Delta(Delta(..))\nimport Text.PrettyPrint.ANSI.Leijen(putDoc)\n\ndata Expr = Literal Integer\n          | Add Expr Expr\n          | Sub Expr Expr\n          | Mul Expr Expr\n          | Div Expr Expr\n\narithmeticExpr :: Parser Expr\narithmeticExpr = do\n  n  <- integer\n  x2 <- optional $ do\n    symbol \"+\"\n    arithmeticExpr\n  case x2 of\n    Nothing -> return $ Literal n\n    Just x -> return $ Add (Literal n) x\n\neval :: Expr -> Integer\neval (Literal n) = n\neval (Add x y) = eval x + eval y\n\n\nmain = do\n  con <- getContents\n  forM_ (lines con) $ \\str -> do\n    case parseString arithmeticExpr (Columns 0 0) str of\n      Failure doc -> do\n        putDoc doc\n        putStrLn \"Parse error.\"\n      Success expr  -> print $ eval expr\n"
  },
  {
    "path": "exercise-8-2-learn-parser/src/parse-integer.hs",
    "content": "module Main where\n\nimport Text.Trifecta\nimport Text.Trifecta.Delta(Delta(..))\nimport Text.PrettyPrint.ANSI.Leijen(putDoc)\n\n\nadditions :: Parser [Integer]\nadditions = do\n  xs <- integer `sepBy` symbol \"+\"\n  eof\n  return xs\n\n\nmain = do\n  str <- getLine\n  case parseString additions (Columns 0 0) str of\n    Failure doc -> do\n      putDoc doc\n      putStrLn \"I can't understand this expression!\"\n    Success xs -> print $ sum xs\n  main\n"
  },
  {
    "path": "exercise-8-2-learn-parser/src/parse-question.hs",
    "content": "module Main where\n\nimport Text.Trifecta\nimport Text.Trifecta.Delta(Delta(..))\nimport Text.PrettyPrint.ANSI.Leijen(putDoc)\n\n\nquestion :: Parser ()\nquestion = do\n  many $ satisfy $ (/= '?')\n  string \"?\"\n  eof\n\n\nmain = do\n  str <- getLine\n  case parseString question (Columns 0 0) str of\n    Failure doc -> do\n      putDoc doc\n      putStrLn \"質問ではない。\"\n    Success _  -> putStrLn \"質問ありがとう。\"\n  main\n"
  },
  {
    "path": "exercise-8-2-learn-parser/stack.yaml",
    "content": "# For more information, see: https://github.com/commercialhaskell/stack/blob/release/doc/yaml_configuration.md\n\n# Specifies the GHC version and set of packages available (e.g., lts-3.5, nightly-2015-09-21, ghc-7.10.2)\nresolver: lts-5.0\n\n# Local packages, usually specified by relative directory name\npackages:\n- '.'\n\n# Packages to be pulled from upstream that are not in the resolver (e.g., acme-missiles-0.3)\nextra-deps: []\n\n# Override default flag values for local packages and extra-deps\nflags: {}\n\n# Extra package databases containing global packages\nextra-package-dbs: []\n\n# Control whether we use the GHC we find on the path\n# system-ghc: true\n\n# Require a specific version of stack, using version ranges\n# require-stack-version: -any # Default\n# require-stack-version: >= 0.1.4.0\n\n# Override the architecture used by stack, especially useful on Windows\n# arch: i386\n# arch: x86_64\n\n# Extra directories used by stack for building\n# extra-include-dirs: [/path/to/dir]\n# extra-lib-dirs: [/path/to/dir]\n"
  },
  {
    "path": "exercise-9-traversable-Vec/LICENSE",
    "content": "Copyright Takayuki Muranushi (c) 2015\n\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n\n    * Redistributions in binary form must reproduce the above\n      copyright notice, this list of conditions and the following\n      disclaimer in the documentation and/or other materials provided\n      with the distribution.\n\n    * Neither the name of Takayuki Muranushi nor the names of other\n      contributors may be used to endorse or promote products derived\n      from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n\"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\nLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\nA PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\nOWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\nSPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\nLIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\nDATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\nTHEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\nOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
  },
  {
    "path": "exercise-9-traversable-Vec/Setup.hs",
    "content": "import Distribution.Simple\nmain = defaultMain\n"
  },
  {
    "path": "exercise-9-traversable-Vec/TASK.md",
    "content": "# exercise 9-1. 3次元ベクトルをTraversableにしよう。\n\nData/Vec.hs の定義のうち、exercise 6-1から流用できる部分は流用してください。\nさらに、Vec型のFoldable, Traversableインスタンスを書いてみましょう。\n\n\nとして定義されかかっていますが、実装はまだ途中です。\n\n1. src/Data/Vec.hs を編集して、 app/Main.hs が動くようにしてください！\n2. test/Spec.hs にはこのライブラリをテストするプログラムが入っています。\n   `stack test` を実行して、あたなが実装したモジュール Data.Vec がテストを通ることを確認してください。\n"
  },
  {
    "path": "exercise-9-traversable-Vec/app/Main.hs",
    "content": "module Main where\n\nimport Data.Vec\n\nmain :: IO ()\nmain = do\n  let u, v :: Vec Integer\n      v = Vec 1 2 3\n      u = Vec 10 10 10\n  print $ u + v\n  -- Vec 11 12 13 と表示されてほしい！\n\n  print $ u ・ v\n  -- 60 と表示されてほしい！\n\n  print $ u × v\n  -- Vec (-10) 20 (-10) と表示されてほしい！\n\n  -- VecはFoldableのインスタンスなので、ベクトル３成分の最大値・最小値が求められる。\n  print $ maximum v\n  print $ minimum v\n"
  },
  {
    "path": "exercise-9-traversable-Vec/app/geometry.hs",
    "content": "import Data.Foldable\nimport Data.Traversable\nimport Data.SBV\nimport Data.Vec\n\ninstance EqSymbolic a => EqSymbolic (Vec a) where\n  u .== v = toList u .== toList v\n\nproblem :: Symbolic SBool\nproblem = do\n  a <- exists \"a\"\n  let o :: Vec SReal\n      o = Vec (-1) 0 0\n      v :: Vec SReal\n      v = Vec 2 1 1\n      z = o + pure a * v\n  return $ z ・ z .== 1\n\nproblem2 :: Symbolic SBool\nproblem2 = do\n  oy <- exists \"oy\"\n  let o :: Vec SReal\n      o = Vec 0 oy 0\n  v <- traverse exists (Vec \"x\" \"y\" \"z\")\n  constrain $ v ・ v .== 1\n  a <- exists \"a\"\n  b <- exists \"b\"\n\n  return $ (o + pure a * v .== Vec (-1) 0 0 &&& o + pure b * v .== Vec 1 2 0)\n\n\nmain :: IO ()\nmain = do\n  putStrLn \"Problem 1:\"\n  ret <- allSat $ problem\n  print ret\n  putStrLn \"Problem 2:\"\n  ret <- allSat $ problem2\n  print ret\n"
  },
  {
    "path": "exercise-9-traversable-Vec/src/Data/Vec.hs",
    "content": "module Data.Vec where\n\nimport Data.Monoid\nimport Data.Foldable\nimport Data.Traversable\n\ndata Vec a = Vec a a a deriving (Show)\n\ninstance Num a => Num (Vec a) where\n  -- . . . . . .\n\n(・) :: Vec a -> Vec a -> a\n(Vec ax ay az) ・ (Vec bx by bz) = undefined\n\n(×) :: Vec a -> Vec a -> Vec a\n(Vec ax ay az) × (Vec bx by bz) = undefined\n\ninstance Functor Vec where\n  fmap f (Vec x y z) = undefined\n\ninstance Applicative Vec where\n  pure a = undefined\n  (Vec ax ay az) <*> (Vec bx by bz) = undefined\n\ninstance Foldable Vec where\n  foldMap toMonoid (Vec x y z) = undefined\n\ninstance Traversable Vec where\n  sequenceA (Vec fx fy fz) = undefined\n"
  },
  {
    "path": "exercise-9-traversable-Vec/stack.yaml",
    "content": "# For more information, see: https://github.com/commercialhaskell/stack/blob/release/doc/yaml_configuration.md\n\n# Specifies the GHC version and set of packages available (e.g., lts-3.5, nightly-2015-09-21, ghc-7.10.2)\nresolver: lts-5.0\n\n# Local packages, usually specified by relative directory name\npackages:\n- '.'\n\n# Packages to be pulled from upstream that are not in the resolver (e.g., acme-missiles-0.3)\nextra-deps: []\n\n# Override default flag values for local packages and extra-deps\nflags: {}\n\n# Extra package databases containing global packages\nextra-package-dbs: []\n\n# Control whether we use the GHC we find on the path\n# system-ghc: true\n\n# Require a specific version of stack, using version ranges\n# require-stack-version: -any # Default\n# require-stack-version: >= 0.1.4.0\n\n# Override the architecture used by stack, especially useful on Windows\n# arch: i386\n# arch: x86_64\n\n# Extra directories used by stack for building\n# extra-include-dirs: [/path/to/dir]\n# extra-lib-dirs: [/path/to/dir]\n"
  },
  {
    "path": "exercise-9-traversable-Vec/test/Spec.hs",
    "content": "import Control.Applicative\nimport Test.Framework (defaultMain, testGroup)\nimport Test.Framework.Providers.API (Test)\nimport Test.Framework.Providers.QuickCheck2 (testProperty)\nimport Test.QuickCheck.Arbitrary\n\nimport Data.Vec\n\ninstance Arbitrary a => Arbitrary (Vec a) where\n  arbitrary = Vec <$> arbitrary <*> arbitrary <*> arbitrary\n\ntests :: [Test]\ntests = [\n  testProperty \"addition of Vec is associative.\" $\n  \\u v w ->  u+(v+w) == (u+v)+ (w :: Vec Integer) ,\n  testProperty \"addition of Vec is commutative.\" $\n  \\u v ->  u+v == v + (u :: Vec Integer),\n  testProperty \"zero.\" $\n  \\v ->  v +0  == (v :: Vec Integer),\n  testProperty \"one.\" $\n  \\v ->  1*v  == (v :: Vec Integer),\n  testProperty \"negate.\" $\n  \\v ->  v - v == (0 :: Vec Integer),\n  testProperty \"distributive vector.\" $\n  \\a u v ->  fromInteger a*(u+v)  ==fromInteger  a*u +fromInteger  a * (v :: Vec Integer),\n  testProperty \"distributive scalar.\" $\n  \\a b v ->  fromInteger (a+b)*v  == fromInteger a*v+fromInteger b* (v :: Vec Integer),\n  testProperty \"commutative scalar product.\" $\n  \\a b v ->  fromInteger (a*b)*v  == fromInteger a* (fromInteger b* (v :: Vec Integer)),\n  testProperty \"inner product is zero for perpendicular vector.\" $\n  \\x y -> Vec x 0 0 ・ Vec 0 y 0 == (0::Integer),\n  testProperty \"outer product is zero for parallel vector.\" $\n  \\x1 x2 -> Vec x1 0 0 × Vec x2 0 0 == (0::Vec Integer)\n        ]\n\nmain :: IO ()\nmain = defaultMain tests\n"
  },
  {
    "path": "exercise-9-traversable-Vec/vec.cabal",
    "content": "name:                vec\nversion:             0.1.0.0\nsynopsis:            Initial project template from stack\ndescription:         Please see README.md\nhomepage:            http://github.com/nushio3/vec#readme\nlicense:             BSD3\nlicense-file:        LICENSE\nauthor:              Takayuki Muranushi\nmaintainer:          muranushi@gmail.com\ncopyright:           2010 Author Here\ncategory:            Web\nbuild-type:          Simple\n-- extra-source-files:\ncabal-version:       >=1.10\n\nlibrary\n  hs-source-dirs:      src\n  exposed-modules:     Data.Vec\n  build-depends:       base >= 4.7 && < 5\n  default-language:    Haskell2010\n\nexecutable use-vector\n  hs-source-dirs:      app\n  main-is:             Main.hs\n  ghc-options:         -threaded -rtsopts -with-rtsopts=-N\n  build-depends:       base\n                     , vec\n  default-language:    Haskell2010\n\nexecutable geometry\n  hs-source-dirs:      app\n  main-is:             geometry.hs\n  ghc-options:         -threaded -rtsopts -with-rtsopts=-N\n  build-depends:       base\n                     , vec\n                     , sbv\n  default-language:    Haskell2010\n\n\n\ntest-suite vec-test\n  type:                exitcode-stdio-1.0\n  hs-source-dirs:      test\n  main-is:             Spec.hs\n  build-depends:       base\n                     , vec\n                     , test-framework\n                     , test-framework-quickcheck2\n                     , QuickCheck\n\n  ghc-options:         -threaded -rtsopts -with-rtsopts=-N\n  default-language:    Haskell2010\n\nsource-repository head\n  type:     git\n  location: https://github.com/nushio3/vec\n"
  },
  {
    "path": "greet-using-overloaded-string.hs",
    "content": "{-# LANGUAGE OverloadedStrings #-}\nimport Data.Monoid  ((<>))\nimport qualified Data.Text    as T\nimport qualified Data.Text.IO as T\n\nmain :: IO ()\nmain = do\n  name <- T.getLine\n  T.putStrLn $ \"Hello, \" <> name\n  putStrLn \"This is String\"\n\n\n"
  },
  {
    "path": "greet-using-string.hs",
    "content": "main :: IO ()\nmain = do\n  name <- getLine\n  putStrLn $ \"Hello, \" ++ name\n\n\n"
  },
  {
    "path": "greet-using-text.hs",
    "content": "import Data.Text    (pack)\nimport Data.Monoid  ((<>))\nimport Data.Text.IO (getLine, putStrLn)\nimport Prelude hiding (getLine, putStrLn)\n\nmain :: IO ()\nmain = do\n  name <- getLine\n  putStrLn $ pack \"Hello, \" <> name\n\n\n"
  },
  {
    "path": "greet-winter.txt",
    "content": "様、\n\n立春とは名ばかりの寒い日が続きますが、いかがお過ごしでしょうか。\nそちらは季節はずれの大雪となった聞きました。何かとご不自由なこともあるだとは存じますが、xx様方にはお身体だけはくれぐれもご自愛ください。\n日々暖かさを増してはまいりましたが、寒い日もありますのでxx様方には、くれぐれもご自愛いただきますようお祈り申し上げます。\n\n敬具 \n"
  },
  {
    "path": "hello-world.hs",
    "content": "main :: IO ()\nmain = interact $ const \"Hello World!\\n\"\n"
  },
  {
    "path": "how-to-submit.txt",
    "content": "この授業の(最終)レポート提出方法は以下の通りです．\n\n1. manabaシステムにログインする．\n   https://manaba.tsukuba.ac.jp/\n\n2. 「ソフトウェアサイエンス特別講義E (GB27301)」という授業に\n   自分を登録する．この際，登録キーとして，2163426 を使ってください．\n\n3. 「村主先生出題のレポート」というところから，ファイルを投入して\n   ください．ファイルを1つだけ，提出できます．ファイルの形式等は\n   村主先生から指示があるはずです．\n\n4. 締切は 2016/2/15 (月) 午前9:00 (日本時間) です．締切後に\n   manaba から提出することはできません．\n\n\n締切より前であれば何回でも再提出できますが，最後に提出したもののみが\n生き残ります．\n"
  },
  {
    "path": "kazu.hs",
    "content": "data Count = One | Two | Three | Huh\n           deriving (Eq, Ord, Show, Read, Enum)\n\ninstance Num Count where\n  One + One = Two\n  One + Two = Three\n  Two + One = Three\n  _   + _   = Huh\n\n  Three - One = Two\n  Three - Two = One\n  Two   - One = One\n  _     - _   = Huh\n\n  One * x   = x\n  x   * One = x\n  _   * _   = Huh\n\n  negate _ = Huh\n\n  abs x = x\n\n  signum Huh = Huh\n  signum _   = One\n\n  fromInteger 1 = One\n  fromInteger 2 = Two\n  fromInteger 3 = Three\n  fromInteger _ = Huh\n\nmain :: IO ()\nmain = do\n  print $ One + One\n  print $ One + Two\n  print $ One + Three\n  print $ One + 4\n  print $ [One ..]\n"
  },
  {
    "path": "monad-compose.hs",
    "content": "{-# LANGUAGE DeriveTraversable, DeriveFoldable, DeriveFunctor #-}\n\nimport Control.Monad\nimport Data.Traversable\nimport Test.QuickCheck\n\ndata Pair a = P a a\n              deriving (Eq, Show, Functor, Foldable, Traversable)\n\ninstance Applicative Pair where\n  pure = return\n  (P f g) <*> (P x y) = P (f x) (g y)\ninstance Monad Pair where\n  return x = P x x\n  (P x y) >>= k = do\n    (P x2 _) <- k x\n    (P _ y2) <- k y\n    return $ P x2 y2\n\n\nnewtype Bad a = B {unB :: (Maybe (Pair a))}\n\n-- http://stackoverflow.com/questions/13034229/concrete-example-showing-that-monads-are-not-closed-under-composition-with-proo?lq=1\njoin2 :: (Monad m, Monad n, Traversable n) => m (n (m (n a))) -> m (n a)\njoin2 = fmap join  . join .  fmap sequence\n\ninstance Monad Bad where\n  return x = B $ Just (P x x)\n  (B x) >>= k = B $ join2 $ (fmap $ fmap $ unB . k) x\n\n-- monad laws\n-- (1) join (return x) = x\n-- (2) join (fmap return x) = x\n-- (3) join (join x) = join (fmap join x)\n\nmain :: IO ()\nmain = print $ P 4 2\n"
  },
  {
    "path": "monad-family-tree.hs",
    "content": "type Hito = String\n\nparents :: Hito -> [Hito]\nparents x = [x++\"の父\", x++\"の母\"]\n\nsenzo :: Int -> Hito -> [Hito]\nsenzo 0 x = return x\nsenzo n x = do\n  y <- senzo (n-1) x\n  parents y\n\nsenzo' n x = \n  senzo (n-1) x >>=\n  parents \n\n\nmain = mapM_ putStrLn $ \n  senzo 3 \"村主\"\n"
  },
  {
    "path": "parser-sample.hs",
    "content": "module Main where\n\nimport Control.Monad (replicateM)\nimport Text.Trifecta\nimport Text.Trifecta.Delta(Delta(..))\nimport Text.PrettyPrint.ANSI.Leijen(putDoc)\n\n\nint :: Parser Int\nint = fromInteger <$> integer\n\nn_words :: Int -> Parser [String]\nn_words n = replicateM n \n  (token $ some alphaNum)\n\ngrammar :: Parser ()\ngrammar = int >>= n_words >> eof\n\n\nmain = do\n  putStr \"INPUT> \"\n  str <- getLine\n  case parseString grammar (Columns 0 0) str of\n    Failure doc -> do\n      putDoc doc\n      putStrLn \"Wrong!\"\n    Success xs -> putStrLn \"Correct!\"\n  main\n"
  },
  {
    "path": "quicktest.hs",
    "content": "import Test.QuickCheck\n\nbothBig :: Integer -> Integer -> Bool\nbothBig x y = x>=2 && y>=2\n\nmain :: IO ()\nmain = do\n  quickCheck (\\x y -> bothBig x y ==> x*y /= 7)\n  quickCheck (\\x y -> bothBig x y ==> x*y /= 8)\n"
  },
  {
    "path": "setup-tsukuba-2016.sh",
    "content": "echo 'export PATH=$PATH:$HOME/.local/stack/:$HOME/.local/bin/' >> $HOME/.bashrc\necho 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/.local/lib/' >> $HOME/.bashrc\nsource $HOME/.bashrc\nmkdir -p $HOME/.local/bin/\nmkdir -p Downloads\ncd Downloads\nwget https://www.stackage.org/stack/linux-x86_64-gmp4\ntar xf linux-x86_64-gmp4\ncp stack-1.0.2-linux-x86_64-gmp4/stack  ~/.local/bin/\nstack setup\nwget https://github.com/Z3Prover/z3/archive/z3-4.4.1.tar.gz\ntar xf z3-4.4.1.tar.gz\ncd z3-z3-4.4.1/\n./configure --prefix=$HOME/.local/\ncd build/\nmake\nmkdir -p $HOME/.local/lib/python2.6/dist-packages\nmake install\ncd $HOME\n"
  },
  {
    "path": "tips.md",
    "content": "# Stackの使い方\n\n## インタプリタ編\n\n`stack ghci`で、プロジェクトの`stack.yaml`に従った環境、または\nstackのグローバル設定ファイル`~/.stack/global-project/stack.yaml`に従った環境でインタプリタが起動する。\n\n### インタプリタのプロンプトを簡潔にする\n\nデフォルトの設定では、インタプリタのプロンプトにはロードされているモジュールの一覧が表示される。モジュールが多すぎると見にくくなることも。\nこの設定は、`:set prompt`で変更できる。\n\n```\n~$ stack ghci\nRun from outside a project, using implicit global project config\nUsing resolver: lts-5.0 from implicit global project's config file: /home/nushio/.stack/global-project/stack.yaml\nError parsing targets: The specified targets matched no packages.\nPerhaps you need to run 'stack init'?\nWarning: build failed, but optimistically launching GHCi anyway\nConfiguring GHCi with the following packages:\nGHCi, version 7.10.3: http://www.haskell.org/ghc/  :? for help\nOk, modules loaded: none.\nPrelude>\nPrelude> import Data.Map\nPrelude Data.Map> import Data.List\nPrelude Data.Map Data.List> import Data.Array.Storable.Internals\nPrelude Data.Map Data.List Data.Array.Storable.Internals> print $ 1+1\n2\nPrelude Data.Map Data.List Data.Array.Storable.Internals> :set prompt \"> \"\n> print $ 1+1\n2\n>\n```\n\nホームフォルダの`.ghci`ファイルにghciへの入力を書いておくと、ghciを起動するたびにこれを実行してくれる。\n```\n$ cat ~/.ghci\n:set -W -fno-warn-unused-imports\n:seti -XDataKinds -XPolyKinds -XTypeFamilies -XScopedTypeVariables -XGADTs -XTypeOperators -XTemplateHaskell\n:def x (\\t -> return (\":kind! \" ++ t))\n:set prompt \"> \"\nlet myName = \"Takayuki Muranushi\"\nputStrLn \"今日もHappy Hacking!\"\n```\n\n## ビルド編\n\n### `hello-project`という名前の新しいプロジェクトを作る\n````\n$ stack new hello-project simple\n````\n\n### プロジェクトのビルド\nプロジェクトのフォルダに移動して`stack build`\n````\n$ cd hello-project\n$ stack build\nhello-project-0.1.0.0: configure\nConfiguring hello-project-0.1.0.0...\nhello-project-0.1.0.0: build\nPreprocessing executable 'hello-project' for hello-project-0.1.0.0...\n[1 of 1] Compiling Main             ( src/Main.hs, .stack-work/dist/x86_64-linux/Cabal-1.22.5.0/build/hello-project/hello-project-tmp/Main.o )\nLinking .stack-work/dist/x86_64-linux/Cabal-1.22.5.0/build/hello-project/hello-project ...\nhello-project-0.1.0.0: copy/register\nInstalling executable(s) in\n/home/nushio/nushiolab/practice/learn-haskell/exercise-1-hello-cat/hello-project/.stack-work/install/x86_64-linux/lts-5.0/7.10.3/bin\n````\n実行ファイルは、stackが生成するバージョン固有のフォルダ(`.stack-work/install/x86_64-linux/lts-5.0/7.10.3/bin`など)に生成されます。どこに生成したかはstackが言ってくれます (`Installing executable(s) in...`)\n\n### ビルドされたファイルの実行\n\n`stack exec`で、stackが所在を把握している実行ファイルを実行してくれます。\n\n````\n$ stack exec hello-project\nhello world\n````\n\n### お手軽開発支援\n\n次のようにすると、ファイルの変更を監視して繰り返しビルドしてくれる。\n````\n$ stack build --file-watch\n````\n別コンソールで`stack build --file-watch`を立ち上げておくとデバッグがはかどります。\n\n\n\n### stackが生成するファイルの構造\n\n````\n$ tree hello-project/\nhello-project/\n├── LICENSE\n├── Setup.hs\n├── hello-project.cabal\n├── src\n│   └── Main.hs\n└── stack.yaml\n\n1 directory, 5 files\n````\n###　プロジェクトで利用するライブラリの追加\n\n```\n$ cat hello-project.cabal\nname:                hello-project\nversion:             0.1.0.0\nsynopsis:            Simple project template from stack\ndescription:         Please see README.md\nhomepage:            http://github.com/nushio3/hello-project#readme\nlicense:             BSD3\nlicense-file:        LICENSE\nauthor:              Takayuki Muranushi\nmaintainer:          muranushi@gmail.com\ncopyright:           2010 Author Here\ncategory:            Web\nbuild-type:          Simple\ncabal-version:       >=1.10\n\nexecutable hello-project　　　　　　-- 生成される実行ファイルの名前\n  hs-source-dirs:      src          -- 実行ファイルの所在\n  main-is:             Main.hs      -- ソースコードの名前\n  default-language:    Haskell2010\n  build-depends:       base >= 4.7 && < 5\n                     , quickcheck   -- 使いたいライブラリはここに追記します\n                     , text         -- textを使いたい場合\n                     , vector\n```\n\n\n### テンプレートの一覧を表示する\n````\n$ stack templates\nchrisdone\nfranklinchen\nghcjs\nghcjs-old-base\nhakyll-template\nhspec\nnew-template               # 最小限のライブラリ・実行ファイル・テストが揃っているテンプレート\nquickcheck-test-framework\nrubik\nscotty-hello-world\nscotty-hspec-wai\nservant\nsimple                     # 最もシンプルな、ソースが１つのテンプレート\nyesod-hello-world\nyesod-minimal\nyesod-mongo\nyesod-mysql\nyesod-postgres\nyesod-postgres-fay\nyesod-simple\nyesod-sqlite\n````\n\n### ネットに繋がらない！けどプロジェクトを作りたい。\n\nローカルに既にダウンロードされているテンプレートのファイル名を指定することができます。\n\n```\nstack new offline-project ~/.stack/templates/simple.hsfiles\n```\n"
  },
  {
    "path": "typeclass.hs",
    "content": "data Person = Male String Int\n            | Female String Int\n            | Cat String Int Person\n\nclass Greetable a where\n  greet :: a -> IO ()\n\ninstance Greetable Person where\n  greet (Male name _) = putStrLn $ \"Hello, Mr. \" ++ name\n  greet (Female name _) = putStrLn $ \"Hello, Ms. \" ++ name\n  greet (Cat name _ _) = putStrLn $ \"Meow, \" ++ name\n\nmain :: IO ()\nmain = do\n  greet $ Male \"nushio\" 32\n"
  },
  {
    "path": "unsafe-io.hs",
    "content": "{-# LANGUAGE TypeSynonymInstances #-}\n\nimport System.IO.Unsafe\n\ntype Prog a =\n  Int -> (Int, a)\n\nrunProg :: Prog a -> (Int, a)\nrunProg p = p 0\n\npureProgram x = \n  (\\n -> (n, x))\n\nexec :: Prog a -> (a -> Prog b) -> Prog b\nexec p1 p2 = \n  (\\n -> let (n1,a1) = p1    n\n             (n2,b1) = p2 a1 n1 in \n         (n2,b1))\n\nget :: Prog String\nget = \n  \\n -> (n+1, unsafePerformIO getLine)\n\nput :: String -> Prog ()\nput str = \n  \\n -> (n+1, unsafePerformIO $ putStrLn str)\n\n\nmain = print $ runProg $ \n  put \"May I have your name?\" `exec`\n  (\\() -> get `exec` \n  (\\name -> put $ name ++ \" Nice to meet you!\"))\n"
  },
  {
    "path": "world-state.hs",
    "content": "import Control.Monad(ap,liftM)\n\n--            Input , Output\ntype World = (String, String)\n\nnewtype P a = P (World->(World,a))\n\nrunProgram :: P a -> IO ()\nrunProgram (P f) = \n  interact (\\input -> \n    let ((_, output),_) = f (input,\"\")\n    in output)\n\ninChar :: P Char\ninChar = P $\n  \\(i, o) -> ((tail i, o), head i)\n\ninLine :: P String\ninLine = P $\n  \\(i, o) ->\n    let i2 = drop 1 $ \n             dropWhile (/='\\n') i \n        line = takeWhile (/='\\n') i \n    in ((i2, o), line)\n\noutChar :: Char -> P ()\noutChar c = P $\n  \\(i, o) -> ((i, o ++ [c]), ())\n\noutLine :: String -> P ()\noutLine str = P $\n  \\(i, o) -> ((i, o ++ str ++ \"\\n\"), ())\n\n\ninstance Functor P where\n  fmap = liftM\ninstance Applicative P where\n  pure = return\n  (<*>) = ap\n\ninstance Monad P where\n  return x = P $ \\(i,o) -> ((i,o), x)\n  a >>= b = P $ \\(i,o) -> let\n    P f1 = a\n    ((i1,o1),v1) = f1 (i,o)\n    P f2 = b v1\n    ((i2,o2),v2) = f2 (i1,o1)\n    in ((i2,o2),v2)\n\n\ngreet :: P ()\ngreet = do\n  outLine \"May I have your name?\"\n  name <- inLine\n  outLine $ name ++ \", Nice to meet you!\"\n\nmain = runProgram greet\n\n\n"
  }
]