📖 Haskell を Ubuntu にインストールできねーの(^〜^)?
🗒 view_shogiban.hs
:
📖 ubuntu20.04.1 vscodeで日本語入力ができない
「 snap でインストールした VSCode は、日本語入力ができないらしいわよ」
「 アンインストールは つらい、なにかアップデートする方法はないか?」
Japanese Language Pack for Visual Studio Code
[Ctrl] + [Shift] + [P]
で Configure Display Language
で日本語へ。
「 ダメだ、何も変わらん。
フロント・エンド・プロセッサーが反応してない」
📖 【新入生夏記事】Ubuntu の VSCode で 日本語入力 ができない問題
「 ↑ Ubuntu Software
や snap
は、土台がダメみたいよ」
sudo snap remove code
「 ↑ Visual Studio Code をアンインストールするぜ」
「 ↑ Ubuntu なんで、 .deb
を選ぶぜ。デビアンという意味かな」
code_1.85.1-1702462158_amd64.deb
「 ↑ フォルダーなのか、圧縮ファイルなのか、なにかダウンロードしたが」
sudo apt install code_1.85.1-1702462158_amd64.deb
muzudho@muzudho-MS-7B09:~/Downloads$ sudo apt install code_1.85.1-1702462158_amd64.deb
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package code_1.85.1-1702462158_amd64.deb
📖 Unable to install files with apt-get: "unable to locate package" [duplicate]
sudo apt-get update
sudo apt install code_1.85.1-1702462158_amd64.deb
sudo apt install ./code_1.85.1-1702462158_amd64.deb
「 ↑ カレント・ディレクトリの指定を忘れていた。これでインストールが始まった」
code
「 うわっ、日本語版の GUI が出てきた、かっこ悪いから 英語版に戻そう」
[Ctrl] + [Shift] + [P]
で Configure Display Language
で英語へ。
「 よし、 Visual Studio Code は英語表示で、日本語入力できるようになったぜ」
🗒 view_shogiban.hs
:
{-
ビュー / 将棋盤
-}
main = putStrLn "+--+--+--+--+--+--+--+--+--+"
「 ↑ さまざまなことがわからないので、将棋盤の上辺を表示したいぜ」
# コンパイル
ghc -o view_shogiban view_shogiban.hs
# 実行
./view_shogiban
Output:
+--+--+--+--+--+--+--+--+--+
「 Haskell で複数行文字列って どうやってコーディングすんの?」
📖 How can I write multiline strings in Haskell?
{-
ビュー / 将棋盤
-}
main = putStrLn " 9 8 7 6 5 4 3 2 1\n\
\ +--+--+--+--+--+--+--+--+--+\n\
\ 1 | | | | | | | | | |\n\
\ +--+--+--+--+--+--+--+--+--+\n\
\ 2 | | | | | | | | | |\n\
\ +--+--+--+--+--+--+--+--+--+\n\
\ 3 | | | | | | | | | |\n\
\ +--+--+--+--+--+--+--+--+--+\n\
\ 4 | | | | | | | | | |\n\
\ +--+--+--+--+--+--+--+--+--+\n\
\ 5 | | | | | | | | | |\n\
\ +--+--+--+--+--+--+--+--+--+\n\
\ 6 | | | | | | | | | |\n\
\ +--+--+--+--+--+--+--+--+--+\n\
\ 7 | | | | | | | | | |\n\
\ +--+--+--+--+--+--+--+--+--+\n\
\ 8 | | | | | | | | | |\n\
\ +--+--+--+--+--+--+--+--+--+\n\
\ 9 | | | | | | | | | |\n\
\ +--+--+--+--+--+--+--+--+--+\n"
Output:
muzudho@muzudho-MS-7B09:~/Documents/git_hub/haskell-practice-on-ubuntu$ ./view_shogiban
9 8 7 6 5 4 3 2 1
+--+--+--+--+--+--+--+--+--+
1 | | | | | | | | | |
+--+--+--+--+--+--+--+--+--+
2 | | | | | | | | | |
+--+--+--+--+--+--+--+--+--+
3 | | | | | | | | | |
+--+--+--+--+--+--+--+--+--+
4 | | | | | | | | | |
+--+--+--+--+--+--+--+--+--+
5 | | | | | | | | | |
+--+--+--+--+--+--+--+--+--+
6 | | | | | | | | | |
+--+--+--+--+--+--+--+--+--+
7 | | | | | | | | | |
+--+--+--+--+--+--+--+--+--+
8 | | | | | | | | | |
+--+--+--+--+--+--+--+--+--+
9 | | | | | | | | | |
+--+--+--+--+--+--+--+--+--+
「 日本語と 半角文字の横幅の 桁が揃わない。
VSCodeのフォントを 等幅フォントの mplus code にしたい。できるの?」
「 じゃあ MPlus のフォントを Ubuntu へインストールできるかどうかか」
📖 M+Fonts
📖 M+Fonts / otf
「 Git Hub 上の Mplus1Code-Regular.otf
リンクを コンコン クリックして進んでいったら インストールまで行けた 便利だな」
「 VSCode のメインメニューから [File] - [Preferences] - [Settings]
。
Font Family の先頭に 'M Plus 1 Code',
を追加したけど、どうか?」
「 Visual Studio Code を全部閉じて再起動。
よしいけた」
muzudho@muzudho-MS-7B09:~/Documents/git_hub/haskell-practice-on-ubuntu$ ./view_shogiban
飛 角 金 銀 桂 香 歩 [nnn move(s) / sente / 0 repeat(s)]
+-----+-----+-----+-----+-----+-----+-----+
| 2 | 2 | 4 | 4 | 4 | 4 | 18 |
+-----+-----+-----+-----+-----+-----+-----+
一 二 三 四 五 六 七 八 九
+-----+-----+-----+-----+-----+-----+-----+-----+-----+
1 |[香> | |[歩> |[歩> |[歩> |[歩> | <歩]| | <香]|
+-----+-----+-----+-----+-----+-----+-----+-----+-----+
2 |[桂> |[角> |[歩> | | | | <歩]| <飛]| <桂]|
+-----+-----+-----+-----+-----+-----+-----+-----+-----+
3 |[銀> | |[歩> | | | | <歩]| | <銀]|
+-----+-----+-----+-----+-----+-----+-----+-----+-----+
4 |[金> | |[歩> | | | | <歩]| | <金]|
+-----+-----+-----+-----+-----+-----+-----+-----+-----+
5 |[玉> | |[歩> | | | | <歩]| | <玉]|
+-----+-----+-----+-----+-----+-----+-----+-----+-----+
6 |[金> | |[歩> | | | | <歩]| | <金]|
+-----+-----+-----+-----+-----+-----+-----+-----+-----+
7 |[銀> | |[歩> | | | | <歩]| | <銀]|
+-----+-----+-----+-----+-----+-----+-----+-----+-----+
8 |[桂> |[飛> |[歩> | | | | <歩]| <角]| <桂]|
+-----+-----+-----+-----+-----+-----+-----+-----+-----+
9 |[香> | |[歩> | | | | <歩]| | <香]|
+-----+-----+-----+-----+-----+-----+-----+-----+----+
歩 香 桂 銀 金 角 飛
+-----+-----+-----+-----+-----+-----+-----+
| 18 | 4 | 4 | 4 | 4 | 4 | 4 |
+-----+-----+-----+-----+-----+-----+-----+
uzudho@muzudho-MS-7B09:~/Documents/git_hub/haskell-practice-on-ubuntu$ ./view_shogiban
飛 角 金 銀 桂 香 歩 [nnn move(s) / sente / 0 repeat(s)]
+-----+-----+-----+-----+-----+-----+-----+
| 2 | 2 | 4 | 4 | 4 | 4 | 18 |
+-----+-----+-----+-----+-----+-----+-----+
一 二 三 四 五 六 七 八 九
+-----+-----+-----+-----+-----+-----+-----+-----+-----+
1 | 香> | | 歩> | | | | <歩 | | <香 |
+-----+-----+-----+-----+-----+-----+-----+-----+-----+
2 | 桂> | 角> | 歩> | | | | <歩 | <飛 | <桂 |
+-----+-----+-----+-----+-----+-----+-----+-----+-----+
3 | 銀> | | 歩> | | | | <歩 | | <銀 |
+-----+-----+-----+-----+-----+-----+-----+-----+-----+
4 | 金> | | 歩> | | | | <歩 | | <金 |
+-----+-----+-----+-----+-----+-----+-----+-----+-----+
5 | 玉> | | 歩> | | | | <歩 | | <玉 |
+-----+-----+-----+-----+-----+-----+-----+-----+-----+
6 | 金> | | 歩> | | | | <歩 | | <金 |
+-----+-----+-----+-----+-----+-----+-----+-----+-----+
7 | 銀> | | 歩> | | | | <歩 | | <銀 |
+-----+-----+-----+-----+-----+-----+-----+-----+-----+
8 | 桂> | 飛> | 歩> | | | | <歩 | <角 | <桂 |
+-----+-----+-----+-----+-----+-----+-----+-----+-----+
9 | 香> | | 歩> | | | | <歩 | | <香 |
+-----+-----+-----+-----+-----+-----+-----+-----+----+
歩 香 桂 銀 金 角 飛
+-----+-----+-----+-----+-----+-----+-----+
| 18 | 4 | 4 | 4 | 4 | 4 | 4 |
+-----+-----+-----+-----+-----+-----+-----+
muzudho@muzudho-MS-7B09:~/Documents/git_hub/haskell-practice-on-ubuntu$ ./view_shogiban
飛 角 金 銀 桂 香 歩 [nnn move(s) / sente / 0 repeat(s)]
+-----+-----+-----+-----+-----+-----+-----+
| 2 | 2 | 4 | 4 | 4 | 4 | 18 |
+-----+-----+-----+-----+-----+-----+-----+
一 二 三 四 五 六 七 八 九
+-----+-----+-----+-----+-----+-----+-----+-----+-----+
1 |香> | |歩> | | | | <歩| | <香|
+-----+-----+-----+-----+-----+-----+-----+-----+-----+
2 |桂> |角> |歩> | | | | <歩| <飛| <桂|
+-----+-----+-----+-----+-----+-----+-----+-----+-----+
3 |銀> | |歩> | | | | <歩| | <銀|
+-----+-----+-----+-----+-----+-----+-----+-----+-----+
4 |金> | |歩> | | | | <歩| | <金|
+-----+-----+-----+-----+-----+-----+-----+-----+-----+
5 |玉> | |歩> | | | | <歩| | <玉|
+-----+-----+-----+-----+-----+-----+-----+-----+-----+
6 |金> | |歩> | | | | <歩| | <金|
+-----+-----+-----+-----+-----+-----+-----+-----+-----+
7 |銀> | |歩> | | | | <歩| | <銀|
+-----+-----+-----+-----+-----+-----+-----+-----+-----+
8 |桂> |飛> |歩> | | | | <歩| <角| <桂|
+-----+-----+-----+-----+-----+-----+-----+-----+-----+
9 |香> | |歩> | | | | <歩| | <香|
+-----+-----+-----+-----+-----+-----+-----+-----+----+
歩 香 桂 銀 金 角 飛
+-----+-----+-----+-----+-----+-----+-----+
| 18 | 4 | 4 | 4 | 4 | 4 | 4 |
+-----+-----+-----+-----+-----+-----+-----+
「 入り組んだときに 見やすいかどうかが 重要じゃないの?」
uzudho@muzudho-MS-7B09:~/Documents/git_hub/haskell-practice-on-ubuntu$ ./view_shogiban
WCSC33 決勝6回戦 ▲ dlshogi with H vs ▽ やねうら王
飛 角 金 銀 桂 香 歩 [199 move(s) / ▲2一金 / n repeat(s)]
+-----+-----+-----+-----+-----+-----+-----+
| | | | 1 | | | |
+-----+-----+-----+-----+-----+-----+-----+
一 二 三 四 五 六 七 八 九
+-----+-----+-----+-----+-----+-----+-----+-----+-----+
1 |玉> |角> | <香| |角> | |と> | | |
+-----+-----+-----+-----+-----+-----+-----+-----+-----+
2 | <金| |歩> |桂> | | <金| | <飛| |
+-----+-----+-----+-----+-----+-----+-----+-----+-----+
3 | <全| | |歩> | | | | | |
+-----+-----+-----+-----+-----+-----+-----+-----+-----+
4 | | | | | | <歩| <金| | |
+-----+-----+-----+-----+-----+-----+-----+-----+-----+
5 | | | <銀| <桂|歩> | | <歩| | <玉|
+-----+-----+-----+-----+-----+-----+-----+-----+-----+
6 | | | |歩> | |竜> | | <桂| |
+-----+-----+-----+-----+-----+-----+-----+-----+-----+
7 | | | | | | | <香| <歩|金> |
+-----+-----+-----+-----+-----+-----+-----+-----+-----+
8 | | <全| | | | |歩> | <銀| |
+-----+-----+-----+-----+-----+-----+-----+-----+-----+
9 | | | |歩> | | <歩| | | <香|
+-----+-----+-----+-----+-----+-----+-----+-----+----+
歩 香 桂 銀 金 角 飛
+-----+-----+-----+-----+-----+-----+-----+
| 7 | 1 | | | | | |
+-----+-----+-----+-----+-----+-----+-----+
muzudho@muzudho-MS-7B09:~/Documents/git_hub/haskell-practice-on-ubuntu$ ./view_shogiban
WCSC33 決勝6回戦 ▲ dlshogi with H vs ▽ やねうら王
飛 角 金 銀 桂 香 歩 [199 move(s) / ▲2一金 / n repeat(s)]
+-----+-----+-----+-----+-----+-----+-----+
| | | | 1 | | | |
+-----+-----+-----+-----+-----+-----+-----+
一 二 三 四 五 六 七 八 九
+-----+-----+-----+-----+-----+-----+-----+-----+-----+
1 | 玉> : 角> : <香 : : 角> : : と> : : |
+ - - + - - + - - + - - + - - + - - + - - + - - + - - +
2 | <金 : : 歩> : 桂> : : <金 : : <飛 : |
+ - - + - - + - - + - - + - - + - - + - - + - - + - - +
3 | <全 : : : 歩> : : : : : |
+ - - + - - + - - + - - + - - + - - + - - + - - + - - +
4 | : : : : : <歩 : <金 : : |
+ - - + - - + - - + - - + - - + - - + - - + - - + - - +
5 | : : <銀 : <桂 : 歩> : : <歩 : : <玉 |
+ - - + - - + - - + - - + - - + - - + - - + - - + - - +
6 | : : : 歩> : : 竜> : : <桂 : |
+ - - + - - + - - + - - + - - + - - + - - + - - + - - +
7 | : : : : : : <香 : <歩 : 金> |
+ - - + - - + - - + - - + - - + - - + - - + - - + - - +
8 | : <全 : : : : : 歩> : <銀 : |
+ - - + - - + - - + - - + - - + - - + - - + - - + - - +
9 | : : : 歩> : : <歩 : : : <香 |
+-----+-----+-----+-----+-----+-----+-----+-----+-----+
歩 香 桂 銀 金 角 飛
+-----+-----+-----+-----+-----+-----+-----+
| 7 | 1 | | | | | |
+-----+-----+-----+-----+-----+-----+-----+
```
![ramen-tabero-futsu2.png](https://crieit.now.sh/upload_images/d27ea8dcfad541918d9094b9aed83e7d61daf8532bbbe.png)
「 ↑ 盤の方を点線にしてみたり」
```plaintext
muzudho@muzudho-MS-7B09:~/Documents/git_hub/haskell-practice-on-ubuntu$ ./view_shogiban
WCSC33 決勝6回戦 ▲ dlshogi with H vs ▽ やねうら王
飛 角 金 銀 桂 香 歩 [199 move(s) / ▲2一金 / n repeat(s)]
+-----+-----+-----+-----+-----+-----+-----+
| | | | 1 | | | |
+-----+-----+-----+-----+-----+-----+-----+
一 二 三 四 五 六 七 八 九
+-----+-----+-----+-----+-----+-----+-----+-----+-----+
1 | 玉> ・ 角> ・ ・ ・ と> ・ ・ |
+ ・ + ・ + ・ + ・ + ・ + ・ + ・ + ・ + ・ +
2 | ・ 桂> ・ ・
+ ・ + ・ + ・ + ・ + ・ + ・ + ・ + ・ + ・ +
3 | ・ ・ ・ ・ ・ |
+ ・ + ・ + ・ + ・ + ・ + ・ + ・ + ・ + ・ +
4 | ・ ・ ・ ・ ・
+ ・ + ・ + ・ + ・ + ・ + ・ + ・ + ・ + ・ +
5 | ・ ・
+ ・ + ・ + ・ + ・ + ・ + ・ + ・ + ・ + ・ +
6 | ・ ・ ・ 歩> ・ ・ 竜> ・ ・
+ ・ + ・ + ・ + ・ + ・ + ・ + ・ + ・ + ・ +
7 | ・ ・ ・ ・ ・ ・
+ ・ + ・ + ・ + ・ + ・ + ・ + ・ + ・ + ・ +
8 | ・ ・
+ ・ + ・ + ・ + ・ + ・ + ・ + ・ + ・ + ・ +
9 | ・ ・ ・ 歩> ・ ・
+-----+-----+-----+-----+-----+-----+-----+-----+-----+
歩 香 桂 銀 金 角 飛
+-----+-----+-----+-----+-----+-----+-----+
| 7 | 1 | | | | | |
+-----+-----+-----+-----+-----+-----+-----+
```
![ramen-tabero-futsu2.png](https://crieit.now.sh/upload_images/d27ea8dcfad541918d9094b9aed83e7d61daf8532bbbe.png)
「 ↑ 半角の中点もあるが」
![kifuwarabe-futsu.png](https://crieit.now.sh/upload_images/beaf94b260ae2602ca8cf7f5bbc769c261daf8686dbda.png)
「 将棋は罫線が多すぎでは? 囲碁みたいに 交点にしたらどうだぜ?」
```plaintext
muzudho@muzudho-MS-7B09:~/Documents/git_hub/haskell-practice-on-ubuntu$ ./view_shogiban
WCSC33 決勝6回戦 ▲ dlshogi with H vs ▽ やねうら王
飛 角 金 銀 桂 香 歩 [199 move(s) / ▲2一金 / n repeat(s)]
+----+----+----+----+----+----+----+
| | | | 1 | | | |
+----+----+----+----+----+----+----+
一 二 三 四 五 六 七 八 九
+----+----+----+----+----+----+----+----+----+
1 | 玉> 角> <香 ・ 角> ・ と> ・ ・ |
+ +
2 |<金 ・ 歩> 桂> ・ <金 ・ <飛 ・ |
+ +
3 |<全 ・ ・ 歩> ・ ・ ・ ・ ・ |
+ +
4 | ・ ・ ・ ・ ・ <歩 <金 ・ ・ |
+ +
5 | ・ ・ <銀 <桂 歩> ・ <歩 ・ <玉 |
+ +
6 | ・ ・ ・ 歩> ・ 竜> ・ <桂 ・ |
+ +
7 | ・ ・ ・ ・ ・ ・ <香 <歩 金>|
+ +
8 | ・ <全 ・ ・ ・ ・ 歩> <銀 ・ |
+ +
9 | ・ ・ ・ 歩> ・ <歩 ・ ・ <香 |
+----+----+----+----+----+----+----+----+----+
歩 香 桂 銀 金 角 飛
+----+----+----+----+----+----+----+
| 7 | 1 | | | | | |
+----+----+----+----+----+----+----+
muzudho@muzudho-MS-7B09:~/Documents/git_hub/haskell-practice-on-ubuntu$ ./view_shogiban
WCSC33 決勝6回戦 ▲ dlshogi with H vs ▽ やねうら王
飛 角 金 銀 桂 香 歩 [199 move(s) / ▲2一金 / n repeat(s)]
+------+------+------+------+------+------+------+
| | | | 1 | | | |
+------+------+------+------+------+------+------+
一 二 三 四 五 六 七 八 九
+------+------+------+------+------+------+------+------+------+
1 | 玉 | 角 |<<香<<| | 角 | | と | | |
+------+------+------+------+------+------+------+------+------+
2 |<<金<<| | 歩 | 桂 | |<<金<<| |<<飛<<| |
+------+------+------+------+------+------+------+------+------+
3 |<<全<<| | | 歩 | | | | | |
+------+------+------+------+------+------+------+------+------+
4 | | | | | |<<歩<<|<<金<<| | |
+------+------+------+------+------+------+------+------+------+
5 | | |<<銀<<|<<桂<<| 歩 | |<<歩<<| |<<玉<<|
+------+------+------+------+------+------+------+------+------+
6 | | | | 歩 | | 竜 | |<<桂<<| |
+------+------+------+------+------+------+------+------+------+
7 | | | | | |<<香<<|<<歩<<| 金 | |
+------+------+------+------+------+------+------+------+------+
8 | |<<全<<| | | | 歩 |<<銀<<| | |
+------+------+------+------+------+------+------+------+------+
9 | | | | 歩 | |<<歩<<| | |<<香<<|
+------+------+------+------+------+------+------+------+------+
歩 香 桂 銀 金 角 飛
+------+------+------+------+------+------+------+
| 7 | 1 | | | | | |
+------+------+------+------+------+------+------+
```
![ramen-tabero-futsu2.png](https://crieit.now.sh/upload_images/d27ea8dcfad541918d9094b9aed83e7d61daf8532bbbe.png)
「 ↑ 先手の駒の表示を うるさく してみたらどうだぜ?」
![ohkina-hiyoko-futsu2.png](https://crieit.now.sh/upload_images/96fb09724c3ce40ee0861a0fd1da563d61daf8a09d9bc.png)
「 もっと濃い網掛けはないの?」
```plaintext
muzudho@muzudho-MS-7B09:~/Documents/git_hub/haskell-practice-on-ubuntu$ ./view_shogiban
WCSC33 決勝6回戦 ▲ dlshogi with H vs ▽ やねうら王
飛 角 金 銀 桂 香 歩 [199 move(s) / ▲2一金 / n repeat(s)]
+------+------+------+------+------+------+------+
| | | | 1 | | | |
+------+------+------+------+------+------+------+
一 二 三 四 五 六 七 八 九
+------+------+------+------+------+------+------+------+------+
1 | 玉 >| 角 >| 香 | | 角 >| | と >| | |
+------+------+------+------+------+------+------+------+------+
2 | 金 | | 歩 >| 桂 >| | 金 | | 飛 | |
+------+------+------+------+------+------+------+------+------+
3 | 全 | | | 歩 >| | | | | |
+------+------+------+------+------+------+------+------+------+
4 | | | | | | 歩 | 金 | | |
+------+------+------+------+------+------+------+------+------+
5 | | | 銀 | 桂 | 歩 >| | 歩 | | 玉 |
+------+------+------+------+------+------+------+------+------+
6 | | | | 歩 >| | 竜 >| | 桂 | |
+------+------+------+------+------+------+------+------+------+
7 | | | | | | | 香 | 歩 | 金 >|
+------+------+------+------+------+------+------+------+------+
8 | | 全 | | | | 歩 >| 銀 | | |
+------+------+------+------+------+------+------+------+------+
9 | | | | 歩 >| | 歩 | | | 香 |
+------+------+------+------+------+------+------+------+------+
歩 香 桂 銀 金 角 飛
+------+------+------+------+------+------+------+
| 7 | 1 | | | | | |
+------+------+------+------+------+------+------+
muzudho@muzudho-MS-7B09:~/Documents/git_hub/haskell-practice-on-ubuntu$ ./view_shogiban
WCSC33 決勝6回戦 ▲ dlshogi with H vs ▽ やねうら王
9 8 7 6 5 4 3 2 1 [199 move(s) / ▲2一金 / n repeat(s)]
+----+ +------+------+------+------+------+------+------+------+------+
歩 | 7 | | | | | | | | 圭 | 金 | v玉 | 一 ▲玉 59 ▲香 99 77 13 ___
+----+ +------+------+------+------+------+------+------+------+------+ ▽玉 11 ▽香 *__ ___ ___ ___
香 | 1 | | | 全 | | | | | | | v角 | 二
+----+ +------+------+------+------+------+------+------+------+------+ +----+ ▲飛 28 ___ ▲歩 ___ ___ ___
桂 | | | | | | | 銀 | | | v歩 | 香 | 三 | | 飛 ▽飛 +66 ___ _46 _57 ___
+----+ +------+------+------+------+------+------+------+------+------+ +----+ _78 _87 _96
銀 | | | v歩 | | | v歩 | 桂 | | v歩 | v桂 | | 四 | | 角 ▲角 ___ ___ ___ ___ ___ ___ ___ ___
+----+ +------+------+------+------+------+------+------+------+------+ +----+ ▽角 12 15 ___ ___ ___ ___ ___ ___
金 | | | | | | | v歩 | | | | v角 | 五 | | 金 ___ ___ ___ ___ ___ ___
+----+ +------+------+------+------+------+------+------+------+------+ +----+ ▲金 21 26 47 79
角 | | | 歩 | | | v竜 | | 歩 | | 金 | | 六 | 1 | 銀 ▽金 ___ ___ ___ ___ ▽歩 +17 _23 _34
+----+ +------+------+------+------+------+------+------+------+------+ +----+ ___ _55 _64
飛 | | | | 歩 | 香 | | 歩 | 金 | | | vと | 七 | | 桂 ▲銀 +82 53 88 *__ ___ ___ _94
+----+ +------+------+------+------+------+------+------+------+------+ +----+ ▽銀 ___ ___ ___ ___ *__ *__ *__ *__ *__ *__
| | 銀 | 歩 | 桂 | | | | 飛 | | 八 | | 香 *__ ___ ___ ___ ___ ___
+------+------+------+------+------+------+------+------+------+ +----+ ▲桂 +31 54 68 ___ ___ ___ ___ ___ ___ ___
| 香 | | 金 | | 玉 | | | | | 九 | | 歩 ▽桂 +24 ___ ___ ___
+------+------+------+------+------+------+------+------+------+ +----+
「 レイアウトはいったん これで確定して、モデルを作りましょう」
mkdir shogi-project
cd shogi-project
cabal init --interactive
📁 shogi-project
├── 📁 app
│ └── 🗒 Main.hs
├── 📁 src
│ └── 🗒 MyLib.hs
├── 🗒 CHANGELOG.md
└── 🗒 shogi-project.cabal
🗒 app/Main.hs
:
module Main where
import qualified MyLib (someFunc)
main :: IO ()
main = do
putStrLn "Hello, Haskell!"
MyLib.someFunc
「 ↑ おー、 do-notation
だ。
最後の MyLib.someFunc
が分からんが」
🗒 src/MyLib.hs
:
module MyLib (someFunc) where
someFunc :: IO ()
someFunc = putStrLn "someFunc"
cabal build
cabal run
Output:
Up to date
Hello, Haskell!
someFunc
module Main where
import qualified MyLib (someFunc)
main :: IO ()
main = do
putStrLn "Hello, Haskell!"
let x = 1 + 2
print x
{- putStrLn x -}
MyLib.someFunc
「 ↑ putStrLen
と print
の違いも分からん つら」
📖 Haskellで競技プログラミング IO編
📖 Haskellで競技プログラミング
📖 State of string interpolation in Haskell?
📖 Haskell: 文字列の連結、繰り返し、置き換え
📖 How to concat two (IO) Strings in Haskell?
「 ↑ 競技プログラマも よくわかってないようだ もっと調べよう」
module Main where
import qualified MyLib (someFunc)
main :: IO ()
main = do
y
putStrLn $ "入力は" ++ y -- 文字列連結するときは頭に $ を付ける
return ()
module Main where
import qualified MyLib (someFunc)
main :: IO ()
main = do
line
-- print はダブルクォーテーションがついてしまう。そもそもデバッグ用らしい
{-
if line == "usi"
then putStrLn "usiok"
else putStrLn "panic"
-}
case line of
"usi" -> putStrLn "usiok"
"isready" -> putStrLn "readyok"
"usinewgame" -> putStrLn ""
_ -> putStrLn "resign"
「 ↑ ケース文も こんな感じだが、ループは どうやって作る?」
module Main where
import qualified MyLib (someFunc)
main :: IO ()
main = do
line
case line of
"usi" -> putStrLn "usiok"
"isready" -> putStrLn "readyok"
"usinewgame" -> putStrLn ""
'p' : 'o' : 's' : 'i' : 't' : 'i' : 'o' : 'n' : ' ' : _ -> putStrLn ""
'g' : 'o' : ' ' : _ -> putStrLn "resign"
_ -> putStrLn ""
usi :: IO ()
usi = do
return ()
module Main where
import qualified MyLib (someFunc)
main :: IO ()
main = do
line
usi line
usi :: String -> IO ()
usi line = do
case line of
"usi" -> putStrLn "usiok"
"isready" -> putStrLn "readyok"
"usinewgame" -> putStrLn ""
'p' : 'o' : 's' : 'i' : 't' : 'i' : 'o' : 'n' : ' ' : _ -> putStrLn ""
'g' : 'o' : ' ' : _ -> putStrLn "resign"
_ -> putStrLn ""
-- loop
line
usi line
「 ↑ これでループする。
アプリケーションの終了って どうやるんだ?」
module Main where
import qualified MyLib (someFunc)
main :: IO ()
main = do
line
usi line
usi :: String -> IO ()
usi line = do
case line of
'g' : 'o' : ' ' : _ -> do
putStrLn "resign"
"isready" -> do
putStrLn "readyok"
'p' : 'o' : 's' : 'i' : 't' : 'i' : 'o' : 'n' : ' ' : _ -> do
putStrLn ""
"quit" -> do
putStrLn "" -- 何もしないという処理は書けるか?
"usi" -> do
putStrLn "usiok"
"usinewgame" -> do
putStrLn ""
_ -> do
putStrLn ""
if line == "quit"
then return ()
else do
-- loop
line
usi line
「 ↑ フォールスルーでアプリケーションを終了できるが、
何もしないという処理は どうやって書くんだぜ? Python の pass みたいなやつ」
module Main where
import qualified MyLib (someFunc)
main :: IO ()
main = do
line
usi line
usi :: String -> IO ()
usi line = do
if line == "quit"
then return () -- 関数を終了し、アプリケーションを終了する
else do
case line of
'g' : 'o' : ' ' : _ -> do
putStrLn "resign"
"isready" -> do
putStrLn "readyok"
'p' : 'o' : 's' : 'i' : 't' : 'i' : 'o' : 'n' : ' ' : _ -> do
putStrLn ""
"usi" -> do
putStrLn "usiok"
-- "usinewgame" -> putStr ""
_ -> putStr "" -- 何もしないという処理が書けないので、何か出力する
-- loop
line
usi line
「 GHC では 実行ファイル作れたが、
プロジェクトの場合は どうやる?」
muzudho@muzudho-MS-7B09:~/Documents/git_hub/haskell-practice-on-ubuntu/shogi-project/dist-newstyle/build/x86_64-linux/ghc-9.4.7/shogi-project-0.1.0.0/x/shogi-project/build/shogi-project$ ./shogi-project
「 ↑ すごい長いファイルパスの下に 実行ファイルがあった」
muzudho@muzudho-MS-7B09:~/Documents/Shogidokoro/Engine$ ./Lesserkai.exe
Cannot open assembly './Lesserkai.exe': File does not contain a valid CIL image.
「 ↑ れさかい は C# で書いてんのか? .NET Core
をインストールしてみるか」
📖 "mono app.exe" gives error "File does not contain a valid CIL image."
sudo apt install mono-complete
Output:
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
mono-complete : Depends: mono-runtime (= 6.12.0.200-0xamarin2+ubuntu1604b1) but 6.12.0.200-0xamarin2+ubuntu2004b1 is to be installed
Depends: mono-runtime-sgen (= 6.12.0.200-0xamarin2+ubuntu1604b1) but 6.12.0.200-0xamarin2+ubuntu2004b1 is to be installed
Depends: mono-llvm-support (= 6.12.0.200-0xamarin2+ubuntu1604b1) but 6.12.0.200-0xamarin2+ubuntu2004b1 is to be installed
Depends: libmono-2.0-1 (= 6.12.0.200-0xamarin2+ubuntu1604b1) but it is not going to be installed
Depends: mono-utils (= 6.12.0.200-0xamarin2+ubuntu1604b1) but it is not going to be installed
Depends: mono-devel (= 6.12.0.200-0xamarin2+ubuntu1604b1) but 6.12.0.200-0xamarin2+ubuntu2004b1 is to be installed
Depends: mono-mcs (= 6.12.0.200-0xamarin2+ubuntu1604b1) but 6.12.0.200-0xamarin2+ubuntu2004b1 is to be installed
Depends: mono-roslyn (= 6.12.0.200-0xamarin2+ubuntu1604b1) but 6.12.0.200-0xamarin2+ubuntu2004b1 is to be installed
Depends: mono-csharp-shell (= 6.12.0.200-0xamarin2+ubuntu1604b1) but 6.12.0.200-0xamarin2+ubuntu2004b1 is to be installed
Depends: mono-4.0-gac (= 6.12.0.200-0xamarin2+ubuntu1604b1) but 6.12.0.200-0xamarin2+ubuntu2004b1 is to be installed
Depends: libmono-cil-dev (= 6.12.0.200-0xamarin2+ubuntu1604b1) but 6.12.0.200-0xamarin2+ubuntu2004b1 is to be installed
Depends: ca-certificates-mono (= 6.12.0.200-0xamarin2+ubuntu1604b1) but 6.12.0.200-0xamarin2+ubuntu2004b1 is to be installed
E: Unable to correct problems, you have held broken packages.
sudo apt remove mono-complete
Output:
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package 'mono-complete' is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 4 not upgraded.
muzudho@muzudho-MS-7B09:~$ sudo apt remove mono
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package mono
📖 How to Completely remove mono?
sudo apt remove --purge --auto-remove mono-runtime
sudo apt remove mono-complete
Output:
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package 'mono-complete' is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 4 not upgraded.
muzudho@muzudho-MS-7B09:~/Documents/Shogidokoro$ mono Shogidokoro.exe
Command 'mono' not found, but can be installed with:
sudo apt install mono-runtime
muzudho@muzudho-MS-7B09:~$ sudo apt install mono-complete
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
libgdiplus : Depends: libpng12-0 (>= 1.2.13-4) but it is not installable
E: Unable to correct problems, you have held broken packages.
libgdiplus : Depends: libpng12-0 (>= 1.2.13-4) but it is not installable
sudo apt install ca-certificates gnupg
sudo gpg --homedir /tmp --no-default-keyring --keyring /usr/share/keyrings/mono-official-archive-keyring.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo "deb [signed-by=/usr/share/keyrings/mono-official-archive-keyring.gpg] https://download.mono-project.com/repo/ubuntu stable-focal main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list
sudo apt update
sudo apt install mono-devel
sudo apt install mono-complete
muzudho@muzudho-MS-7B09:~/Documents/Shogidokoro$ mono Shogidokoro.exe
Gtk-Message: 19:50:18.028: Failed to load module "canberra-gtk-module"
sudo apt install 'fonts-takao-*'
export TERM=xterm
「 ↑ 将棋エンジンを読み込む前に この設定をしておくといいらしいが、効果なし」
export TERM=xterm
mono Shogidokoro.exe
Output:
Gtk-Message: 19:57:43.757: Failed to load module "canberra-gtk-module"
📖 Failed to load module “canberra-gtk-module” .... but already installed
sudo apt install libcanberra-gtk-module libcanberra-gtk3-module
export TERM=xterm
mono Shogidokoro.exe
muzudho@muzudho-MS-7B09:~/Documents/git_hub/haskell-practice-on-ubuntu/shogi-project$ cabal run
Up to date
usi
id name Kifuwarakell
id author Muzudho
usiok
quit
「 ↑ ハスケルが "Up to date" とエコーするのを止めさせられないか?」
「 run
するから Up to date
と鳴くんじゃないか?」
muzudho@muzudho-MS-7B09:~/Documents/git_hub/haskell-practice-on-ubuntu/shogi-project/dist-newstyle/build/x86_64-linux/ghc-9.4.7/shogi-project-0.1.0.0/x/shogi-project/build/shogi-project$ ./shogi-project
usi
id name Kifuwarakell
id author Muzudho
usiok
quit
「 将棋所が頭に ./
を付けてコマンドを打鍵しますかね?」
📖 Cabal Doesn't Build Executable
「 ↑ カバルは実行ファイルを作ってくれないようなので、スタックを調べるか」
📖 How to compile an executable from Haskell Stack build?
# コンパイル
ghc -o kifuwarakell.exe kifuwarakell.hs
# 実行
./kifuwarakell.exe
「 ↑ 頭に ./
が付いたら、将棋所は読み込めないのでは?」
「 Ubuntu で、すでにパスが通っているディレクトリーはどこだぜ?」
echo $PATH
Output:
/home/muzudho/.cabal/bin:/home/muzudho/.ghcup/bin:/usr/local/cuda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin
cd ~
bkdir bin
muzudho@muzudho-MS-7B09:~/bin$ pwd
/home/muzudho/bin
export PATH="$PATH:/home/muzudho/bin"
echo $PATH
Output:
/home/muzudho/.cabal/bin:/home/muzudho/.ghcup/bin:/usr/local/cuda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin:/home/muzudho/bin
muzudho@muzudho-MS-7B09:~/bin$ kifuwarakell.exe
usi
id name Kifuwarakell
id author Muzudho
usiok
quit
「 ↑ Up to date
も出ないし、 ./
も要らないな」
「 それでも 将棋どころは きふわらべ をエンジン登録しない」
export PATH="$PATH:/home/muzudho/bin"
export TERM=xterm
mono Shogidokoro.exe
「 ↑ どうやっても ダメらしい。 将棋所は諦めて サーバー・プログラムを書こう」
「 何も分からない。 間に合わなかったら 去年のきふわらべで 出ればいいだろ」
「 ハスケルに時間 取られてるの もったいない…… C# でいいんじゃないのか?」
.
Crieitは誰でも投稿できるサービスです。 是非記事の投稿をお願いします。どんな軽い内容でも投稿できます。
また、「こんな記事が読みたいけど見つからない!」という方は是非記事投稿リクエストボードへ!
こじんまりと作業ログやメモ、進捗を書き残しておきたい方はボード機能をご利用ください。
ボードとは?
コメント