ãã¼ã«ã«k8sã®ä¸ã«è²ããªãµã¼ãã¹ãç«ã¦ã¦å£ã
ã¢ãã³ãªãµã¼ãã¹éçºã¯ã¨ã«ããå ¥ç¨ã®ããã«ã¦ã§ã¢ãå¤ããã¡ãã£ã¨ãããã®ãä½ãã ã㧠RDB 㨠NoSQL ã¨ã¤ã³ã¡ã¢ãªãã£ãã·ã¥ã¨ç£è¦ããã·ã¥ãã¼ããå¿ è¦ã«ãªã£ã¦ãã¾ããé ãè¨æ¶ã« RDB ã¨ãã¼ããªã¥ã¼ã¹ãã¢ã¨ãã£ãã·ã¥ã¨æ¤ç´¢ã¨ã¸ã§ããã¥ã¼ããã¹ã¦ MySQL ã«ãããã¦ããç§æçãªæ代ããã£ããããªæ°ãããããããããªæ代ã§ã¯ãªãã®ã ã£ãã
å®éã«ãµã¼ãã¹ããããã¤ãã段ã§ã¯ãªããã¼ã«ã«ã§éçºããã¨ãã«ããããã£ãããã«ã¦ã§ã¢ããªãã¨éçºèªä½ãé²ã¾ãªãããã¨è¨ã£ã¦ç´ ã® OS ã®ä¸ã«ããã«ã¦ã§ã¢ãå ¥ãã¾ããã¨è¨å®ãã¡ã¤ã«ãã£ã¬ã¯ããªã¨ããã¼ã¿ãã£ã¬ã¯ããªãæ£é¸ãã¦ã¢ã³ã¤ã³ã¹ãã¼ã«ããã©ãã«ã·ã¥ã¼ãã®å¦¨ãã«ãªã£ã¦ãã¾ãã
ãããããããã£ãè¤æ°ã®ãµã¼ãã¹ããã¼ã«ã«ã«ç«ã¡ä¸ããã¨ãã«ãã使ãããã®ã¯ Docker Compose ã ã¨æããã¾ããããæ£çã ã¨æããæ§ã ãªããã«ã¦ã§ã¢ã Docker Compose ã®ãµã³ãã«ã³ã¼ããæä¾ãã¦ããã
ãã㪠Docker Compose ã«ãã¡ãã£ã¨ããä¸æºããã£ã¦ãéçºã®ææç©ã¨ã㦠Docker image ãä½ã£ããªãã°å®éã«ãµã¼ãã¹ããããã¤ããå ã¯å¤§æµ Kubernetes ã¯ã©ã¹ã¿ã¼ã«å¤ããªãã¨ãããªãã
(ãããããã Docker Compose ããããã¯ã·ã§ã³ç°å¢ã§ä½¿ãã±ã¼ã¹ããããããããªããèªåã®å¨ãã«ããããé°å²æ°ã¯ãªãã£ã)
ãã¼ã«ã«éçºã§ãã使ããªãæè¡ãè¦ããã®ãè °ãéããããªãæåãããã¼ã«ã«ã« Kubernetes ã¯ã©ã¹ã¿ã¼ãç¨æãã¦ãã®ä¸ã§ããããããã°ããã®ã§ã¯ãã¨ãããã¨ã§ä½ã£ããã®ãããã
ããã¯ãã¼ã«ã«ç°å¢ã§ Kubernetes ãå®è¡ããæ¹æ³ã®ä¸ã¤ã§ãã kind ãå©ç¨ãã¦æ§ã ãªãµã¼ãã¹ãç«ã¡ä¸ãããå£ãããã§ãããã®ã ã
ç¾å¨ã®ã¨ãã以ä¸ã®ãµã¼ãã¹ãæ§ç¯&ç ´å£ã§ããã
- Kubernetes Dashboard
- Grafana
- PostgreSQL
- Redis (single)
- Scylla (single)
主è¦ãªæä½ã¯ Makefile ã«æ¼ãè¾¼ãã§ãããã¾ããã¯ã©ã¹ã¿ã¼èªä½ã®ä½æã¨ç ´æ£ã¯æ¬¡ã®ããã«ãããä½ããCPUãé£ãã¤ã¶ãã¦ãããªãã¨ããã¨ãã¯ã¯ã©ã¹ã¿ã¼å ¨ä½ãéã«åæ¢ã§ããã
gist1a1da78dc3271f98fda41b05fe858954
ãã®ã¯ã©ã¹ã¿ã¼ã®ä¸ã«åããã«ã¦ã§ã¢ãç«ã¦ã¦ããï¼Redisã®ä¾ï¼ã
gist59f7240b34ebea34766d95e9c9d8686a
å¿ è¦ã§ããã° Kubernetes Dashboard ãè¦ããã¨ãã§ããï¼è¨äºä¸é¨ã®ç»åï¼ã
gist05df9585c8076ac1accd6c27c0b06f69
ãã®ä»ã®ä»æ§ï¼
- ããã«ã¦ã§ã¢åºæã®è¨å®ãã¡ã¤ã«ã¯ kustomize ã® configMapGenerator ã使ã£ã¦æå ¥ããï¼Scylla ããã®ä¾ï¼ã
- ã¯ã©ã¹ã¿ã¼ãããã¹ãå´ã«å ¬éãããã¼ãã®è¨å®ã¯ cluster.yaml ã«ããã
- ããã«ã¦ã§ã¢ã®ãã¼ã¿ããã¹ãå´ã§æ°¸ç¶åãããã£ã¬ã¯ããªã®è¨å®ã cluster.yaml ã«ããã
Â
ãã¦ããã§ãããç®çã¯éæã§ããã
- Docker Compose ããã¯ãããã¯ã·ã§ã³ã«è¿ãç°å¢ã§ã
- æ§ç¯ãé¢åãªããã«ã¦ã§ã¢ãèªç±ã«ä½æãç ´æ£ã§ããã
ã¨è¨ãããã¨ããã ãåé¡ç¹ãããã
- kind ã®ã¯ã©ã¹ã¿ã¼è¨å®ãã©ãããåçã«å¤æ´ã§ããªããã¤ã¾ãå ¬éãã¼ããæ°¸ç¶åãã£ã¬ã¯ããªã追å ãããå¤æ´ããããããã³ã«ã¯ã©ã¹ã¿ã¼å ¨ä½ãåä½æããªãã¨ãããªãã
ãã¯ã Docker Compose ã®æ¹ãããã£ããããããªãã
ããããã½éãä½ã
ããããã½éãä½ãã¾ãã
å ·æ
- ããããã½
- ããã¨ãã®æ¯å å°é¶ã¹ã¼ã
- é¶è
- ãã®
- ã´ãã¦
- ãã¤ã¿ã±
- 糸ã³ã³ãã£ã¯
- ã»ãª
æé
- é¶èãæé ãªå¤§ããã«åãã
- éã«æ°´1200mlãå¼µã£ã¦ç«ã«ãããé¶èãæ°´ããç ®å§ããã
- ã´ãã¦ãããããã«ãã¦ãã¦ã«ã®æ°´ã«ã¤ããã
- ã´ãã¦ããã¦ã«ããåºãã¦éã«å ¥ããã
- æ¯å å°é¶ã¹ã¼ããå ¥ããã
- 沸騰ããã糸ã³ã³ãã£ã¯ã¨ãã¤ã¿ã±ãå ¥ããã
- 20åã»ã©ç ®ãããã®ãå ¥ããã
- ãã®ã«ç«ãéã£ããããã§ããããã½ãå ¥ããã
- ããããã½ãç ®ãæéã¯å¥½ã¿ã§èª¿ç¯ãã(1ï½5åããã?)ã
- æå¾ã«ã»ãªãæå ¥ããã湯æ°ãéãç¨åº¦ã§ããã
- å®æã
è£è¶³
æ¯å å°é¶ã¹ã¼ãã¯ããã¨ãã®ã§ãªãã¦ããããç¨ã«ãããããªãã¹ã¼ããããã
æ¯å å°é¶ã¹ã¼ãã«å«ã¾ãã¦ããããå¿ è¦ã§ã¯ãªããé¶ã¬ã©ã§ãã·ãåã£ã¦ãããã
ã»ãªã¯ä¸é¢ç£ãæã¾ãããä¸é¢ç£ã®å ´åã¯ã»ãªã®æ ¹ãç ®ã¦ããã
ããããã½ã¯ç ®ãæéãé·ãã¨å´©ããã®ã§ãã¾ãé·ãã¯ç ®ãªããããããã½ã ãå¥ã®éã§ç ®ããã¯ããã¯ãããã
ããããã½ä»¥å¤ã«ããã ã¾ãããå ¥ãã¦ãããã
ãç§ç°çæ°ã¯å®¶ã§ã¯ããããã½éãé£ã¹ãªããã¨è¨ããã¦ããã¡ã§ã¯ä½ããã©ãªâ¦â¦ã¨ãªã£ãã®ã§ãã®è¨äºãæ¸ããã
Nixã«ããHaskelléçºç°å¢ã®æ§ç¯
Nix package manager ã«ãã£ã¦ Haskell ã®ã¹ã¯ãªããã£ã³ã°ããã³ããã±ã¼ã¸éçºã®ç°å¢æ§ç¯ããã¦ããã
- ããã¤ãã¤ãç°å¢æ§ç¯ãã¦ããª
- ããã§è§¦ããããªããã¨
- Nix
- ã¹ã¯ãªããã£ã³ã°
- ã¡ããã¨ããéçº
- ãã©ãã«ã·ã¥ã¼ãã£ã³ã°
ããã¤ãã¤ãç°å¢æ§ç¯ãã¦ããª
ç°å¢æ§ç¯ä»¥å¤ã¯ããã°ã«æ¸ããããªä¸è¬æ§ã®ãããã¨ããã£ã¦ããªãã¨ãããã¨ã§â¦â¦ã
ããã§è§¦ããããªããã¨
- cabal.project ã«ãããã«ãããã¸ã§ã¯ããæ±ãæ¹æ³
- å¤é¨ã® nix store ã使ããã¨
- nix ã®æ°ããã³ãã³ã群 (nix ã³ãã³ãã®ãµãã³ãã³ã群)
- ãããã¤ãå ¬å¼ Docker ã¤ã¡ã¼ã¸ã«ã¤ãã¦
- Stack integration
- IOHKã®ãªã½ã¼ã¹
- NixOS
- ãã®ä» Nix ã®æ·±ã話
Nix
Nix ããªã«ãããåãããªããæ§ã ãªç°å¢ã§ä½¿ããããã±ã¼ã¸ã»ããã¨ãã¦å©ç¨ãã¦ããã
ããã ãèã㨠stackage ã¿ããã ãå ¨ç¶ Haskell ã«éãããã®ã§ã¯ãªãã¦æ®éã® OS ã®ããã±ã¼ã¸ããã¼ã¸ã£ã®ãããªã«ãã¼ç¯å²ãæã£ã¦ããã ããã§ã㦠Haskell ã®ã©ã¤ãã©ãªä¾åé¢ä¿ãç¸å½ãªãªã½ã¼ã¹ãæå ¥ãã¦å®å®ã«ä¿ããã¦ããã¨ãããã¨ã®ããã ã
èªå㯠Mac 㨠Ubuntu on WSL ã§åãè¨å®ãã¡ã¤ã«ã§ Haskell ã®ç°å¢ãæ§ç¯ã§ãã¦ããã
ã㦠Nix ã§æ¤ç´¢ãã㨠NixOS ã¨ããã®ãåºã¦ããã OS ãèããã«ããã±ã¼ã¸ããã¼ã¸ã£ã ãå©ç¨ãããã¨ãã§ããã
å©ç¨å½¢æ :
- Nix package manager ã®ã¿
- NixOS 㨠Nix package manager
Nix ã§ã¯ããã±ã¼ã¸ã»ããã channel ã¨å¼ã³ãããã«ã¯ä½ç¨®é¡ãããã
https://nixos.wiki/wiki/Nix_channels
Nix channel:
- nixpkgs-unstable (= nixpkgs)
- NixOS-xx.yy (NixOS-21.11 ãªã©)
NixOS channel ã¯ååã®éã NixOS ç¨ã§ãã Nix package manager ã ãã®ã¨ãã«ä½¿ããã¨ã¯æ¨å¥¨ãããªãã ã¤ã¾ã Nix package manager ã®ã¿ã®å©ç¨ã®ã¨ãã«ã¯ nixpkgs ã使ããã¨ã«ãªãã ãªã nixpkgs-stable ã¨ãã channel ã¯ãªãããã ã
ããã¸ã§ã¯ãã®ç°å¢ãåºå®ãããã¨ãã¯ãã® channel ã®ãã¼ã¸ã§ã³ãåºå®ããã°ããã
https://nixos.wiki/wiki/FAQ/Pinning_Nixpkgs
ã¹ã¯ãªããã£ã³ã°
ã¾ããNix ã使ããªãã¦ã Haskell ã¹ã¯ãªããã£ã³ã°ã¯ã§ããã
cabal ããã³ stack ã®ã¹ã¯ãªããã¯ã ãã½æ°ã«ããè¨äºãã¨ã¦ãåèã«ãªãã¨æãã
https://zenn.dev/mod_poppo/scraps/e2891dbebb235d
Nix ã«ããæ¹æ³ã¯ãã¾ã Nix package manager ãã使ãã®ç°å¢ã«ã¤ã³ã¹ãã¼ã«ããã
https://nixos.org/download.html
ããã¨ã·ã³ãã«ãªã¹ã¯ãªããã¯ä»¥ä¸ã®ããã«æ¸ãã (æ¨æºå ¥åãã1è¡èªãã§é©å½ãªè²ãã¤ãã¦åºåããã¹ã¯ãªãã)ã
> echo "ã¤ããã¼" | ./yamabiko-nix.hs ã¤ããã¼
nix-shell
㯠Nix ã®ç°å¢ã®ä¸ã«å
¥ãããã®ã³ãã³ãã ãã
shebang ã«æ¸ããã¨ã§ç¹æ®ãªåä½ããã¦ãã®ã¹ã¯ãªããã
Nix ç°å¢ã®ä¸ã§å®è¡ããããã«åãã
ã³ãã³ãã©ã¤ã³å¼æ°ã¯è¤æ°è¡ã«åãã¦è¨è¿°ã§ããã
-p
/--packages
: ä¾åããã±ã¼ã¸ãæå®ãããã©ã«ãã® channel 㯠nixpkgs ãé¸ã°ããã-i
/--interpreter
: ãã®ã¹ã¯ãªãããå¦çããã³ãã³ããæå®ã
ããã±ã¼ã¸æå®ã Nix Haskell ã®ç¹å¾´çãªè¨è¿°ã«ãªã£ã¦ããã ããã¯æ¬¡ã®ããã«æ§æããã¦ããã
pkgs
: nixpkgs ã®ã«ã¼ãhaskell.packages.ghc921
: GHC 9.2.1 ç¨ã® Haskell ä¾åé¢ä¿ã®åå空éghcWithPackages
: ä¾åã©ã¤ãã©ãªã¨GHCãåæã«æå®ããããã® Nix å¼ (é¢æ°)p: [p.ansi-terminal]
: ä¾åã©ã¤ãã©ãªã®ãªã¹ããè¿ãç¡åé¢æ° ãªã¹ãã¯ã¹ãã¼ã¹åºåã
GHCãã¼ã¸ã§ã³ã«ãã ããããªãå ´å haskell.packages.ghc921
ã
haskellPackages
ã§ç½®ãæãã¦ãããã
é¸æå¯è½ãªGHCãã¼ã¸ã§ã³ã¯æ¬¡ã®ã³ãã³ãã§ãããã
> nix-env -f '<nixpkgs>' -qaP -A "pkgs.haskell.compiler" pkgs.haskell.compiler.ghc8107 ghc-8.10.7 pkgs.haskell.compiler.ghc884 ghc-8.8.4 pkgs.haskell.compiler.ghc902 ghc-9.0.2 pkgs.haskell.compiler.ghc921 ghc-9.2.1 ...
ã¾ã channel ã§ç®¡çããã¦ããä¾åã©ã¤ãã©ãªã®ãã¼ã¸ã§ã³ã¯æ¬¡ã®ã³ãã³ãã§ãããã
> nix-env -f '<nixpkgs>' -qaP -A "pkgs.haskell.packages.ghc921.ansi-terminal" pkgs.haskell.packages.ghc921.ansi-terminal ansi-terminal-0.11.1
ghcWithPackages
ã®å®è£
㯠ãã ã«ããã
GHCã¨ã©ã¤ãã©ãªãå¥ã
ã«æå®ãã¦ãã¾ãã¨GHCãã©ã¤ãã©ãªãè¦ã¤ããããªããããã
ã¡ããã¨ããéçº
haskell-language-server ã®å°å ¥
haskell-language-server ã¯ã¨ãã£ã¿ãè¦ããã®ã ãã è¤æ°ã®GHCãã¼ã¸ã§ã³ã«å¯¾å¿ãããã®ã§ãããã®ã§ã ä»ã«ä½¿ããããªãã®ã¨ä¸ç·ã«ã°ãã¼ãã«ã«ã¤ã³ã¹ãã¼ã«ãã¦ãã¾ãã
次ã®ãã¡ã¤ã«ã $HOME/nix/haskell/default.nix
ã«ã§ãç¨æãã¦
nix-env -i
ããããã¨ã°ãã¼ãã«ã«ã¤ã³ã¹ãã¼ã«ãããã
(ãã® default.nix 㯠ãã¡ã ãåèã«ããã¦ããã£ã¦ãã)ã
> nix-env -i --file $HOME/nix/haskell/ ... building '/nix/store/knnnspc3dxxbk9nwv9rqznrrf01rrl8d-user-environment.drv'...
overlay
ã«ãã£ã¦ haskell-language-server ã«ãªãã·ã§ã³ãä¸ãã¦ããã
supportedGhcVersions
ã¯èªãã§ã®éãã
dynamic=true
ã«ã¤ãã¦ã¯ä½ã®ããã¥ã¡ã³ããè¦ã¤ããããªãã Template Haskell ã®ã³ã¼ããæ±ããªãå¿
è¦ãªããã ã
ãã ããã®ãªãã·ã§ã³ãæå¹ã«ãã㨠haskell-language-server ã®ã¤ã³ã¹ãã¼ã«ã«ä½è¨ã«æéãããããããããªãã
ãªãã·ã§ã³ã®å®è£
㯠ãã
ã«ããã
haskell-language-server å´ã®ããã¥ã¡ã³ãã§ã¯ ãã
ã«ç¸å½ããå¦çããã¦ããã¨æãããã
ããã±ã¼ã¸ã®è¨å®
Nix ã§ã® Haskell éçºã«ã¤ãã¦èª¿ã¹ã¦ãã㨠cabal2nix ã¨ããååãããåºã¦ãããããããç´æ¥ä½¿ãæ©ä¼ã¯ãã¾ããªãããã ã ä»ã¯ nixpkgs ã® Haskell module ã cabal2nix ãã©ãããã便å©é¢æ°ãããããæä¾ãã¦ãã¦ã ãããã使ãã®ã主æµã®ããã ã ãã®è¨äºã§ã cabal2nix ãç´æ¥ã¯ä½¿ããªãæ¹æ³ã説æããã
ã¾ãã¯ãã¤ãã®ããã« cabal init
ã§ããã±ã¼ã¸ãåæåããã
(--enable-nix
ãªãã·ã§ã³ã¯ä¸è¦ãããããªã)ã
> mkdir test-package > cd test-package > nix-shell -p "pkgs.cabal-install" -p "pkgs.haskell.compiler.ghc921" --run "cabal --enable-nix init --exe"
åæåãã§ããã次ã®ãã㪠default.nix
ãç¨æããã
ããã§æ¬¡ã®ããã«ããã°ããã±ã¼ã¸ã® executable ãå®è¡ã§ããã
(nix-build
ã¯ååã ãã§ããã¯ã)ã
> nix-build > nix-shell --run "cabal run" "Hello, Haskell!"
ãã¨ã¯æ®éã« .cabal ãã¡ã¤ã«ãç·¨éãã¦éçºãã¦ããã°ããã
ãã¦ããã® default.nix
㯠nixpkgs ã® Haskell module ãæä¾ãã
developPackage
ãå¼ã㧠Haskell ããã±ã¼ã¸ã®éçºã®ããã®è¨å®ãæ§ç¯ãã¦ããã
source-overrides
ã§ä¾åé¢ä¿ã®ãªã¼ãã¼ã©ã¤ããã§ããã
Hackage ã®ãã¼ã¸ã§ã³ãæå®ããæ¹æ³ã¨ tarball ã®URLãæå®ããæ¹æ³ãããã
modifier
ã§ã¯ cabal ã®ããã¤ãã®ãªãã·ã§ã³ãè¨å®ã§ããã
è¨å®é
ç®ã®å
訳㯠ãã ã«ããã
ãªããghcBuild
å¼æ°ã«å¤ãä¸ãã¦å¥ã®GHCãã¼ã¸ã§ã³ãæå®ãããã¨ãã§ããã
(GHC㨠base ã®ãã¼ã¸ã§ã³ãåããªãã¨ã㯠version-history ãåç
§ãã¦èª¿æ´ãã)ã
> nix-shell --argstr "ghcBuild" "ghc902" --run "cabal run"
é«åº¦ãªä¾åé¢ä¿ãªã¼ãã¼ã©ã¤ã
ãã®é ç®ãæ¸ãã¨ãã«åå°½ããã ä¾åé¢ä¿ãªã¼ãã¼ã©ã¤ãã¯ããã»ã©å°é£ãªéã ã£ãã ã©ããã¦ããªã¼ãã¼ã©ã¤ãããããªã次ã®è¨äºãåèã«ãªãã
Nix recipes for Haskellers â Sridhar Ratnakumar
How to override dependency versions when building a Haskell project with Nix
ãã©ãã«ã·ã¥ã¼ãã£ã³ã°
nix-shell ã®ç«ã¡ä¸ãããé ã
direnv Nix integration ãå°å ¥ããã¨ãããããããªãã direnv èªä½ã¯ Nix ã¨é¢ä¿ãªã使ããã²ã¨ã¤ã®ãã¼ã«ã ãã Nix ãããã¨é£æºããã®ã«ã¯ããã¤ãã®ãªãã·ã§ã³ãããã
https://github.com/direnv/direnv/wiki/Nix
èªåã¯ã·ã³ãã«ãã㪠nix-direnv ã使ã£ã¦ããã
VSCode ã« direnv æ¡å¼µãå°å ¥ãã㨠VSCode ããã direnv ã®ç°å¢ãè¦ããããã«ãªãã ãã é渡æã«ããããã§ä½ãé¸ã¶ã注æãå¿ è¦ããã ã
VSCode direnv æ¡å¼µã¯ä¸ãã3çªç®ã®ãå ¬å¼ãã¤ææ°ãããããªããªãã®ç½ ã pic.twitter.com/IOkIJBIaQk
— ãããã¼ (@syocy) 2022å¹´3æ18æ¥
cabal run 㧠cabal èªä½ã®åºåãç¡è¦ããã
ãã㯠Nix ã¨ãããã cabal ã® Tips ã ã次ã®ããã«ããã¨ãããããããªãã
> nix-shell --run "cabal build && \$(cabal list-bin test-package) | clip.exe"
Mac 㧠nix-env -i ã失æãã
ãã§ã«ä¿®æ£ãããããã ã Mac ç°å¢ã§ nix-env -i
ã失æãããã¨ãããã
ãã®ã¨ãã¯ä»¥ä¸ã® issue ã«ããæ¹æ³ã§åé¿ã§ãããã¨ãããã
https://github.com/NixOS/nixpkgs/issues/163374
Mac 㧠channel ãæ¶æ» ãã
çç±ã¯åãããªãã Mac 㧠channel è¨å®ãæ¶æ»
ãããã¨ããã
(nix-channel --list
ãä½ãè¿ããªã)ã
nixpkgs ãèªåã§åè¨å®ããå¿
è¦ããããããããªãã
> nix-channel --add https://channels.nixos.org/nixpkgs-unstable nixpkgs > nix-channel --update nixpkgs
家ããåºãªãçæ´»ï¼é±é
åºç¤¾éæ¨å¥¨ã«ãªã£ãã®ãæ©ã«å®¶ããåºãªãçæ´»ãå§ãã¦ï¼é±éãçµã£ããä»ã¾ã§ãã£ããã¨ãã¾ã¨ãã¦ããã
é£æå
ãã£ããã ããçæ´»ã§ç¸ããã¬ã¤ããã¦ã¿ããã¨æã£ã¦ Amazon 㨠Yodobashi ãç¦æ¢ã«ãã¦ããããã®ï¼ç¤¾ã¯æè¿è©å¤ãè¯ããªããã¨ããããã
æ¥åã¹ã¼ãã¼ã®é販
ãããããããã¹ã¼ãã¼ã¯ãµã¤ããæ¿éã«ãªã£ã¦ãããé éå¯è½æ¥ããã¹ã¦âã«ãªã£ã¦ãããã§æ©è½ä¸å ¨ãèµ·ããã¦ããããã ã£ããããã§é£²é£åºãã¡ã¤ã³ã¿ã¼ã²ããã§ãããæ¥åã¹ã¼ãã¼ãªãä»ç©ºãã¦ããã ããã¨ããèªã¿ãããã§ã¯ãã¶ææãå·åéèãå²ã箸ãªã©ãå ¥æãã¦ããã
ã¨ã«ããæ¥åã¹ã¼ãã¼ã®é販ãæ大éå©ç¨ããã«ã¯å·å室ã®å®¹ç©ãå¿ è¦ã§ã製氷ç¿ã¨ãºãããã«ã«ã¯æ¸æ£å¾ æ©ããé¡ããããã¨ã¨ãªã£ãã
æ¥æ¸ ãªã¼ã«ã¤ã³ãã¹ã¿
æ é¤ãåã£ã¦èæ°ã¨ãå£è¡ç ã«ãªãã®ãæãã®ã§ããé«ããããã°ããæ é¤è£å©ã®ç®çã§é£ã¹ã¦ããã
森永製èã®é販
ãã¨ãã¨å¥åº·é£åç¨ã®ãµã¤ãã ã£ãã®ãç¢é±ã¨ã³ã©ã¼ã²ã³ãæ¨ãã¦ããããæ®éã®ãèåãããããè²·ãããinã¼ãªã¼ããããã¤ã³ãã¼ãã©ã ããªã©ã
ã³ã¼ãã¼
ãã¯ããã«ãã®ã³ã¼ãã¼ãå ¥æã§ããªããªã£ã¦å®¶ã®ã³ã¼ãã¼è±æ¶è²»ãå¢ãããããããå®å®¶ãç§ç°ã®ãè«ãã¨ãã¢ã©ã¸ã³ãã®è±ãéã£ã¦ãããããããããã
é販ã ã¨ã ãããããã«ã½ã³ã³ã¼ãã¼ãã¼ã¹ã¿ã¼ããããã¾ãã®ã³ã¼ãã¼ããå©ç¨ãã¦ããã
ãã«ã½ã³ã³ã¼ãã¼ãã¼ã¹ã¿ã¼
ä»å°æå¨ã®ãã¼ã¹ã¿ã¼ãåå¸ã®ããã«ã½ã³ã³ã¼ãã¼ãã¨ã¯å¥ããããã¾ãããããããµãããååã®ããã¯ãåºãã¦ããã500g1300åã®ããã¯ãå®ãã
ãã¾ãã®ã³ã¼ãã¼
ãå¤æ©ã¯ã¼ã«ãã³ã¼ãã¼ãã®é販ããã£ã©ã¯ã¿ã¼ããããããvtuber ã«ããªã£ã¦ããã
ãªã¢ã¼ãã¯ã¼ã¯ãããã¯WFM
æ¤ å
ãã£ã¨å®¶ã«ããã¨è °ããã°ãããªã®ã§æ¤ åã¯è²·ããã¨ã«ãããã¨ãããé¨å±ã®çä»ããããªããã¡ã«å±ãã¦ãã¾ã£ãããå庫çªã²ã¼ã ãçºçãçµå±è °ã¯çããã
ã座é¢ã¨èé¢ãç´°ããã¡ãã·ã¥ãã¨ããæ¡ä»¶ã ãã§10ä¸åè¶ ãããã ããâ¦â¦ãä¼ç¤¾ã®è£å©å¶åº¦ã£ã½ããã®ãå©ç¨ã§ããã¨ã¯ãã試座ãã¦ãã決ãããã£ãã
ãã¬ãä¼è°
ã«ã¡ã©ã¯ã©ãããããåãä»ãã®ãã®ã§ããã¨ãã¦ããã¤ã¯ãéé³æºã¨è¿ããã¦æãããããããã¤ã¯ã¯è²·ããã¨ã«ããããããã§ã«ä½ä¾¡æ ¼å¸¯ã®ãã¤ã¯ã®å¨åº«ã¯ãªããªã£ã¦ããã®ã ã£ãã
BGM
ããã¦ãã©ã®é¨ãããããªãã¨ä½æ¥ã«éä¸ã§ããªã人㯠vtuber ã®ææ ã§ãæµãã¦ããã°ããããããªãããªãéã«æè¿ã®ãã¾ã¨ããåçãªã¹ããç½®ãã¦ããã https://www.youtube.com/playlist?list=PL1bkZdoXAsdpO3zlsyU5zDUdqh8fS2jmG
éå
åèã«ãªãåã«ãªã³ã°ãã£ããã¢ããã³ãã£ã¼è²·ããå¢ã
ä½æ
FF14 㨠STEAM 㨠vtuber ãããã®ã§æã¯ãªãã
æªè§£æ±ºåé¡ã¨ææ
æ£é«ªã«è¡ããªãã®ãè¾ãããããããªããããã½ããã¯ã®é·ãã«åããããªã«ã³ã¿ãããªã®(ãã)ãæã£ã¦ããã®ã§èªåã§åããªããã¨ããªãã
çªããé ããè¦ããç«å°ã§ãªãã®ã§è¿ç¼ãããã«é²ã¿ãããHMDããã¶ãã¨è¦åãè¯ããªã説ãæ¤è¨¼ãã¦ã¿ãã¹ãããä»HMDæã«å ¥ãã®ãç¥ããªããâ¦â¦ã
ãã¨ã¯ï¼é±éãå¨å® å¤åã§ãããªãä»ã¾ã§ãæ¯æ¥åºç¤¾ããå¿ è¦ã¯ãªãã£ãã®ã§ã¯ã¨æãããã¨ãåºç¤¾éæ¨å¥¨ã解ãããã¨ãã¦ãåã®ããã«æ¯æ¥å ¨å¡ãåºç¤¾ããåæã«ã¯æ»ããªãããããªãã ããããå人çã«ãæºå¡é»è»ãããããä¸å¿«ææ°ã«å æ ããã®ã¯å¿è¦ããã
ã¨ã¯è¨ã
ã¨ã¯è¨ãããããå¤ã«åºããããªã£ã¦ãããè¨æ¶ã確ããªãæ©ãã¦ãããè·é¢ã«åµã®èªè²©æ©ããã£ãã¯ãã ãããããã£ã¦ãããç®æ¨å°ç¹ã«ãã¦äººã®ããªãæé帯ã«åºæ©ãã¦ã¿ããã¨ã«ãããã
Haskellãã£ã¦ããGHC8.8.1令åå å¹´ç½é²ã®å
GHC 8.8.1 ãåºãã®ã§éã«ç°å¢ãæ´ãã¦ããã¾ãã
OS: Ubuntu 18.04 LTS on VirtualBox on Windows
GHC, Cabal
æè¿ã¯ ghcup ã§å ¥ãã¦ããã
$ ghcup upgrade $ ghcup list --tool all $ ghcup install 8.8 $ ghcup install-cabal latest
~/.ghcup/bin 㨠~/.cabal/bin ã«PATHãéã£ã¦ããªãå ´åã¯éãã¦ããã
stack ã¯æã«ãªãã¾ãªãæãããã¦æè¿ä½¿ã£ã¦ããªãã stack ã®ããã¨ããã¨ãã¦ã¹ã¯ãªãããæ¸ããã¨ããã®ããã£ãããæè¿ã¯ cabal ã§ãããæãã« shebang ãæ¸ãã°ã¹ã¯ãªããã£ã³ã°ã§ããããã«ãªã£ãã¨ããã®ãããã
Haskellãã¼ã«
使ããããªHaskellãã¼ã«ãã¤ã³ã¹ãã¼ã«ããã
$ cabal new-update $ cabal new-install doctest hlint ghcid fast-tags --installdir=$HOME/.cabal/bin
ã¾ã GHC 8.8.1 ãä¸ã«åºã¦æ¥ãæµ ãã®ã§ã¤ã³ã¹ãã¼ã«ã§ããªãããã±ã¼ã¸ãå¤ãã èªåã試ããæç¹ã§ã¯ä»¥ä¸ã®ãã®ã¯ã¤ã³ã¹ãã¼ã«ã§ããªãã£ãã
- apply-refact
- hasktags
- stylish-haskell
- hhp (HEADã§ã¯å¯¾å¿æ¸ã¿ã ãhackageã«ä¸ãã£ã¦ããªã?)
- haskell-ide-engine (rcçã¯åºã¦ãã?)
ãã¼ã«ã«ãã£ã¦ã¯ããããGHC8.8.1ã§ã¤ã³ã¹ãã¼ã«ããå¿
è¦ããªããã®ãããã
ãããããã®ã¯ ghcup set
ã§GHCãåãæ¿ãã¦ã¤ã³ã¹ãã¼ã«ããã¨ãããããããªã(試ãã¦ã¯ããªã)ã
ã¨ãã£ã¿
ã¢ã¼ãã«ã§ã«ã¹ã¿ãã¤ã¶ãã«ãªã¨ãã£ã¿ãããã®ã§ Spacemacs ã使ãã ãããã Emacs 26 ãå¿ è¦ã«ãªããç´ ã® apt ã ã¨å ¥ããªããããããªãã ãã®ã¨ã㯠apt repository ã追å ãããªã©ããã ã㨠Spacemacs 㯠master ãã ãã¶å¤ãã¦ç develop ã使ã£ã¦ãããããªã®ã§èªåããããã¦ããã
èªåã®.spacemacs: https://gist.github.com/syocy/5ea4d65f3f819a2a2e82e3f8ff2f3d82
ã·ã§ã«ã¯ fish ã·ã§ã«ã使ã£ã¦ãããããã®ããã Spacemacs ããã¾ãPATHãç¶æ¿ããªããã¨ããã£ãã
ãã®ã¨ã㯠SPC f e e
ã§ç°å¢è¨å®ãã¡ã¤ã«ãéãã¦ç´æ¥ç·¨éããã°ããããã ã
Haskell layer
ã®è£å®ããã¯ã¨ã³ã㯠company-ghci ã使ã£ã¦ããã
dante ã¯èªåã®ç°å¢ã§ã¯åããªãã£ã(æ¦ãã®çªçã.spacemacsã«æ®ã£ã¦ãã)ã
company-ghci 㯠SPC m s b
㧠ghci ããã¼ããã¦ãããªãã¨åä½ããªãã®ã§æ³¨æã
ã¤ã³ã¿ã©ã¯ãã£ããªã¨ã©ã¼ãã§ãã¯ã¯ Haskell layer ã«å«ã¾ãã flycheck-haskell ã使ã£ã¦ããã ghci ã®ã»ããhlint ãããã¨ãããèµ°ããã¦ãããã ã¿ã¤ã«åã¦ã£ã³ãã¦ããã¼ã¸ã£(i3wm)ã使ã£ã¦ããé 㯠ghcid ã使ã£ã¦ããã flycheck-haskell ã使ã£ã¦ãããã¡ã«ä¸é½åãããã°æ»ããããããªãã
ãã®ã»ãç´°ããè¨å®ã¯ .spacemacs ãè¦ã¦ã»ããã
ãµã³ãã«ããã¸ã§ã¯ã
cabal init ãæè¿å¼·åãããããããããã¸ã§ã¯ããä½ãã®ããã楽ã«ãªã£ãããã ã
cabal init --help
ãè¦ãã¨ãªãã·ã§ã³ãå¢ãã¦ããã
ãã¨ãã°ãã¹ãã®ããã©ã¤ãã©ãªã¨ãã¦ããã¸ã§ã¯ããä½ãã«ã¯ä»¥ä¸ã®ããã«ããã
$ cabal init --lib --source-dir=src --tests --test-dir=test -p sample-project
ã¡ãªã¿ã«åé ã®ç»åãåç¾ããã«ã¯ã
SPC e L
㧠flycheck ã®ã¨ã©ã¼ã¦ã£ã³ãã¦ãéãSPC f t
(SPC p t
) 㧠treemacs ã¦ã£ã³ãã¦ãéãSPC w
ã§ã¦ã£ã³ãã¦ãã好ã¿ã§é ç½®ãã
ãªã©ããã°ã§ããã
ãªãã¦ã£ã³ãã¦ã¬ã¤ã¢ã¦ãã®ä¿å㯠SPC l
ã§ã§ãã(æã® eyebrowse layer?)ã
以ä¸ãGHC 8.8.1 ã§ã Haskell ãã£ã¦ãããã
追è¨: Cabal 3.0 ããä¸é¨ãªãã·ã§ã³ã®ããã©ã«ãå¤ãå¤ãã£ãé¢ä¿ã§ flycheck-haskell ã doctest ã®ãããªãã¼ã«ãåä½ããªãã¨ãããã¨ããã£ããããããã¨ã㯠cabal ã®ãªãã·ã§ã³ã« --write-ghc-environment-files=ghc8.4.4+
ãæå®ããã¨ããã stackoverflow ã«ããã®æ¨ãæ¸ããã
GHCã®ç·å½¢åãããã¿ã¤ãã試ãã ã
GHCã«ç·å½¢åãå°å ¥ããã¨ä»¥ä¸ã®ãããªè¯ãäºããããããã
- ãªã½ã¼ã¹å®å ¨æ§: ãã¡ã¤ã«ãã³ãã«ãã½ã±ãããDBã³ãã¯ã·ã§ã³ã®ãããªãªã½ã¼ã¹ã«ã¤ãã¦ãããããæä¾ããAPIã®è¨è¨è ãå®å ¨ãªä½¿ç¨ãå¼·å¶ã§ããããªã½ã¼ã¹è§£æ¾å¾ã®ã¢ã¯ã»ã¹ãäºé解æ¾ã解æ¾å¿ããé²æ¢ãããã¨ãã§ããã
- ã¬ã¤ãã³ã·: ãªã½ã¼ã¹APIã®å®è£ ããã¾ãããã¨off-heap(GCã®å¯¾è±¡å¤)ã§ãªã½ã¼ã¹ã確ä¿ã»è§£æ¾ã§ãããGC対象ãå°ãªããªããã¨ã«ããGCã«ãã£ã¦ããã°ã©ã ãåæ¢ããæéãæ¸ãããã
- 並åæ§: éå°ãªç´ååãå¼·è¦ããªãããªã½ã¼ã¹å®å ¨æ§ãä¿ã¡ã¤ã¤ãã§ããéã並ååã§ããã
詳ããã¯proposalã
ãã®è¨äºã§ã¯ç·å½¢åGHCã®ãããã¿ã¤ãå®è£ ããã³ç·å½¢åãã¡ã¤ã«æä½ã©ã¤ãã©ãªã®ãããã¿ã¤ãå®è£ ã試ãã¦ã¿ãã ããã§ç´¹ä»ãããã®ãæ£å¼ãªãªã¼ã¹ã§å¤æ´ããã¦ããå¯è½æ§ã¯å¤§ãã«ããã
ãªãcabalã®new APIã使ãã®ããã¤ãã¼ã ãªã®ã§ä»åã¯stackã使ããªãæ¹æ³ã§ãã£ã¦ããã
GHCã®ãã«ãæºå
ã¾ãGHCã®ãã«ãã«å¿ è¦ãªãã®ãã¤ã³ã¹ãã¼ã«ããã
- autoconf
- automake
- ncurses
- happy
- alex
- cabal-install
- ghc
ãã®ãã¡ãautoconf, automake, ncursesã¯aptçã§ã¤ã³ã¹ãã¼ã«ã§ããã¯ãã
ghcã¯Unixç³»ç°å¢ã§ããã°ghcupã§å°å ¥ããã®ããããããã¨æãã ç°ãªããã¼ã¸ã§ã³ã®ghcãåãæ¿ãããã¨ãã§ããã (ä»åã®ããã«ç¬èªãã«ãããghcã管ç対象ã«è¿½å ã§ããã®ãã¯æªç¢ºèª)
ghcup install 8.6.3 ghcup set 8.6.3 ghcup install-cabal ghcup new-install cabal-install
happy, alexã¯cabalã§å
¥ããã°ãã: cabal new-install happy alex
linear-typesãã©ã³ãããã«ã
GHCã®ã½ã¼ã¹ã¯GitHubã®ãã©ã¼ããåå¾ããã®ãéãã
git clone https://github.com/ghc/ghc
linear-typesãã©ã³ãã¯å¥ã®ã¨ããã§éçºããã¦ããã®ã§ãªã¢ã¼ãã½ã¼ã¹ã«è¿½å ãã¦ãã§ãã¯ã¢ã¦ãããã (ãã®è¨äºã§ã®commit id: 782869e3d1a25b4a84c405be346ef5b9c1fbfc8b)
cd ghc git remote add tweag https://github.com/tweag/ghc.git git fetch tweag linear-types git checkout tweag/linear-types
GHCã®gitéç¨ãGitHubã¨ãã¹ããããèµ·ããã¦ããã¨ãããããã®ã§å°ãæãå ããã
git config --global url."git://github.com/ghc/packages-".insteadOf git://github.com/ghc/packages/ git config --global url."http://github.com/ghc/packages-".insteadOf http://github.com/ghc/packages/ git config --global url."https://github.com/ghc/packages-".insteadOf https://github.com/ghc/packages/ git config --global url."ssh://git\@github.com/ghc/packages-".insteadOf ssh://git\@github.com/ghc/packages/ git config --global url."git\@github.com:/ghc/packages-".insteadOf git\@github.com:/ghc/packages/
ãã«ããããmakeã®Nã¯ç©çCPUã³ã¢+1ã«ããã®ãè¯ããããã
./boot ./configure make -j N
ãã«ãã§ãããã ./inplace/bin/ghc-stage2
ãããç¥ãghcã³ãã³ãã«ãªã£ã¦ããã
å®éã«è©¦ã
ãã£ã¨ç·å½¢åGHCãå®è¡ããæºåãã§ããã
ã³ã¼ããæ§ã
ã«å¤ãã¦è©¦ãã«ã¯ ghci ã® :reload
ã ghcid ã®å¤æ´æ¤ç¥ã®ãããªã¤ã³ã¿ã©ã¯ãã£ããªç°å¢ãç¨æããã¨ãããããã
ghci 㯠./inplace/bin/ghc-stage2 --interactive
ã§èµ·åããã
ghcid ãªã ghcid --command='/path-to-ghc/ghc/inplace/bin/ghc-stage2 --interactive' Main.hs
ã®ããã«ããã¨ããã ããã
å®é¨ç¨ããã¸ã§ã¯ãã cabal init
ã§ä½ãå ´å㯠cabal new-configure
ã§ããã¸ã§ã¯ãã®ãã«ãã§ä½¿ãghcãå¤æ´ã§ããã
ãã®ãµãã³ãã³ãã«ããå¤æ´ã¯ cabal.project.local ã¨ãããã¼ã«ã«ç°å¢ç¨ãã¡ã¤ã«ã«ä¿åãããã
ããã¸ã§ã¯ãã GitHub ãªã©ã«ä¸ãããªã .gitignore ã«è¿½å ãã¦ããã¨ãªãã¸ããªããç°å¢ä¾åã®ãã¡ã¤ã«ããªãããã
cabal new-configure --with-compiler=/path-to-ghc/ghc/inplace/bin/ghc-stage2
ããã§ã¯ã³ã¼ããã³ã³ãã¤ã©ã«ããã¦ã¿ããã
{-# LANGUAGE LinearTypes #-} module Main where flugal :: a ->. (a, a) flugal a = (a, a) -- Error! wasteful :: a ->. b ->. a wasteful a b = a -- Error! main = putStrLn "Hello, LinearTypes"
flugal
㨠wasteful
ã¯ã³ã³ãã¤ã«ã¨ã©ã¼ã«ãªãã
->.
ã LinearTypes
ã§æå¹ã«ãªãåã¬ãã«æ¼ç®åã§ã ->
ã¨ã»ã¼åãã ãå·¦ã®å¤ãå¿
ãä¸åº¦ã ã使ããªããã°ãªããªãã¨ããå¶éãã¤ãã
flugal
㯠a ã2å使ã£ã¦ããã®ã§ã¨ã©ã¼ã wasteful
㯠b ã1åã使ã£ã¦ããªãã®ã§ã¨ã©ã¼ã¨ãªãã
ããå®ç¨çãªä¾ãè¦ã¦ã¿ããã
linear-base ããã±ã¼ã¸ã¯ç·å½¢åã«ãããã¡ã¤ã«æä½API(ã¨ããã«å¿
è¦ãªè«¸ã
)ãæä¾ããã
ããã¯ç¾æç¹ã§ Hackage ã«ã¢ãããã¼ãããã¦ããªãã®ã§ GitHub ããå
¥æããå¿
è¦ãããã
å®é¨ç¨ããã¸ã§ã¯ããcabalããã¸ã§ã¯ãã§ä½ã£ã¦ããå ´åã¯ã以ä¸ã®å
容㧠cabal.project ã¨ãããã¡ã¤ã«ãä½ã㨠cabal new-build
㧠GitHub ããããã±ã¼ã¸ãæã£ã¦æ¥ã¦ãããã
source-repository-package type: git location: https://github.com/tweag/linear-base tag: 0d6165fbd8ad84dd1574a36071f00a6137351637 packages: ./
ãã¡ã¤ã«ã2ã¤ãªã¼ãã³ããçæ¹ãã1è¡èªãã§ããçæ¹ã«æ¸ãè¾¼ãããã°ã©ã ã¯ä»¥ä¸ã®ããã«ãªãã
cabalããã¸ã§ã¯ãã®å ´å㯠cabal new-run
ã§å®è¡ã§ããã
ããã¯ã¡ãã£ã¨è¾¼ã¿å
¥ã£ã¦ããã
{-# LANGUAGE LinearTypes #-} {-# LANGUAGE RebindableSyntax #-} {-# LANGUAGE RecordWildCards #-} module Main where -- linear-base import qualified Control.Monad.Linear.Builder as Linear import qualified System.IO.Resource as RIO import Prelude.Linear (Unrestricted(Unrestricted)) -- base import System.IO (IOMode(ReadMode, WriteMode)) import qualified System.IO as System mainRIO :: RIO.RIO (Unrestricted ()) mainRIO = do inHandle <- RIO.openFile "Main.hs" ReadMode outHandle <- RIO.openFile "dup.txt" WriteMode (inHandle', outHandle') <- dupOneLine inHandle outHandle RIO.hClose inHandle' RIO.hClose outHandle' return (Unrestricted ()) where Linear.Builder{..} = Linear.monadBuilder -- for do-notation dupOneLine :: RIO.Handle ->. RIO.Handle ->. RIO.RIO (RIO.Handle, RIO.Handle) dupOneLine inHandle outHandle = do (Unrestricted l, inHandle') <- RIO.hGetLine inHandle outHandle' <- RIO.hPutStrLn outHandle l return (inHandle', outHandle') main :: System.IO () main = RIO.run mainRIO
ããã¤ãã®è¦ç´ ãç»å ´ãã¦ããã è¦ç´ ãã¨ã«è¦ã¦ãããã
RebindableSyntax
㨠RecordWildCards
㯠do è¨æ³ã®å®è£
ãé常㮠Control.Monad
ããå¥ã®ãã®ã«å¤æ´ããããã«ã¤ãã¦ããã
ãªãã§ãããªãã¨ãããã®ãã¨ãã㨠Control.Monad
ã¯ç·å½¢ååãã«ä½ããããã®ã§ã¯ãªãããè©ä¾¡ã«ç·å½¢åã®å¶éãå
¥ã£ã¦ããªãã
ç·å½¢åã®å¶éãå
¥ã£ããã¼ã¸ã§ã³ã® Monad ã¨ã㦠linear-base 㯠Control.Monad.Linear
ãæä¾ãã¦ããã
ç·å½¢å do ã使ãããé¢æ°ã® where ç¯ã§ Linear.Builder{..} = Linear.monadBuilder
ã®ããã«ããã¨ã
RebindableSyntax
㨠RecordWildCards
ã®åãã«ãã do ã®å®è£
ãç·å½¢åç Monad ã«å¤æ´ãããã¨ãã§ããã
RIO
㯠Resource-aware IO ã®æå³ã§ãç·å½¢å Monad çã® IO ã¨ãªã£ã¦ãã
(rioã¨ã¯é¢ä¿ãªã)ã
IOã¨ããååã ãç¾ç¶æä¾ããã¦ããã®ã¯ããã¤ãã®ãã¡ã¤ã«æä½ã ãã§ããã
åºæ¬çãªAPIã¨åã·ã°ããã£ã¯é常ã®IOã®ãã®ã¨ä¼¼ã¦ãããã hClose
以å¤ã®é¢æ°ã¯ãã¹ã¦ãã³ãã«ãè¿ãããã«ãªã£ã¦ããã®ããã¤ã³ãã
RIO
㯠RIO.run
é¢æ°ã«ãã£ã¦é常ã®IOã®ä¸ã§èµ·åãããã¨ãã§ããã
ã¨ããã©ããã«åºã¦ãã Unrestricted
ã¨ããã®ã¯ç·å½¢åã®å¶éã®ä¸ããå¶éã®ãªãå¤ãåãåºãã¨ãã«ä½¿ããã¼ã¿åã§ããã
ãã¦ããã®ããã°ã©ã ã§ç·å½¢åã®å¶éãã¡ããã¨åãã¦ããã確ãããã«ã¯ hClose
ãåã£ãã2åå¼ãã§ã¿ãã¨ãã
dupOneLine
㧠hGetLine
ã hPutStrLn
ãè¿ãããã³ãã«ã§ã¯ãªãå¼æ°ã®ãã³ãã«ããã®ã¾ã¾è¿ããªã©ãã¦ã¿ãã¨ããã
ã³ã³ãã¤ã«ã¨ã©ã¼ã®ã¡ãã»ã¼ã¸ãã©ã®ãããªãã®ã«ãªãããã²ç¢ºèªãã¦ã¿ã¦ã»ããã
ææ
ç·å½¢åã®å°å ¥ã«ãã£ã¦ä¸è¬ã®Haskellããã°ã©ãã¼ã¯å½±é¿ãåããã ãããï¼
ç§ã¯å½±é¿ã¯éå®çã ã¨æãã
ç·å½¢å㯠LinearTypes
ãONã«ãã¦åã·ã°ããã£ã« ->.
ã使ã£ã¦ã¯ããã¦æå¹ã«ãªãã
ç·å½¢åã®å°å
¥ã«ããå®è¡æã·ã¹ãã ã¸ã®å¤æ´ããªãã
ä»å¾ãªã½ã¼ã¹ç³»ã©ã¤ãã©ãªã§ç·å½¢åAPIãæä¾ãããã®ãç¾ãã¦ã
ããã使ãã®ã§ããã°ç·å½¢åHaskellã®æ¸ãæ¹ãå¦ç¿ããå¿
è¦ã¯ããã ããã
å¥ã«ä»ã¾ã§ã®Haskellã®ãªã½ã¼ã¹ç®¡çãå±éºã ã£ãã¨ãããã¨ããªãã 以ä¸ã®è¨äºã«ç´¹ä»ããã¦ããããã«Haskellã«ã¯ãã§ã«æ§ã ãªãªã½ã¼ã¹ç®¡çã®ãã¼ã«ãããã
ããã¦ç·å½¢åãå¿ è¦ã¨ããã®ã¯ã ä¸è¨ã®ããã«ä½ã¬ã¤ã¤ã¼ã®APIãæä¾ãããªã½ã¼ã¹ç³»ã©ã¤ãã©ãªãã ã¬ã¤ãã³ã·ãç¹ã«æ°ã«ãªããµã¼ããã²ã¼ã ã®éçºãããã ãããã
ã²ã¨ã¤æ°ã«ãªããã¨ãããã¨ããã°ãç·å½¢åGHCã主å°ãã¦ããã®ã Tweag I/O ã ã¨ãããã¨ã ã Tweag ã¯GHCãæ¡å¼µã㦠asterius ã¨ãã Haskell to WebAssembly ã³ã³ãã¤ã©ãéçºãã¦ããã GHCã¸ã®ç·å½¢åã®å°å ¥ããå°æ¥ã® Haskell ã«ããWebããã°ã©ãã³ã°ãè¦æ®ãã¦ã®ãã®ã ã¨ããå¯è½æ§ã¯ããã¨æãã ã¯ã©ã¤ã¢ã³ããµã¤ãWebéçºã¯ã¾ãã«ã¬ã¤ãã³ã·ãéè¦ãªé åã ããã ã
Dhallã«ãããªãããªè¨å®ãã¡ã¤ã«ä½é¨
(ãã®è¨äºã®ã¬ã®ã¥ã¬ã¼ã·ã§ã³: lts-11.9)
Dhall ã¨ããè¨å®è¨è¿°ç¨è¨èªãããã使ã£ã¦ã¿ãã¨ããè¯ãæãã ã£ãã®ã§ç´¹ä»ãã¾ãã
ãªãããã®è¨äºã¯å æ¥ææã§çºè¡¨ãããã®ã®æ¡å¤§çã«ãªãã¾ãã
Dhallã¨ã¯ä½ã
Dhallã«ã¤ãã¦çãã表ç¾ãããªãå ¬å¼ãµã¤ãã®ä»¥ä¸ã®èª¬æãåãããããã§ãã
You can think of Dhall as: JSON + functions + types + imports
ãã¼ã¿è¡¨ç¾ã«ããã°ã©ããã«ãã¨éçãªæ¤æ»ã¨ãã¡ã¤ã«ã®ã¤ã³ãã¼ããå ãããã®ã¨ããããã§ãã
ã¾ã éçºä¸ã®ããããã¾ãã¢ãã¼ã«ããã¦ãã¾ããããã¼ã«ãã§ã¤ã³ãå å®ãã¦ããã ã¡ãã£ã¨ããå¦çã確ãããããã®REPLãã ä»ã©ãã®è¨èªãããå ¬å¼ãã©ã¼ããã¿ãããã¾ãã
ãã¨å¤§äºãªã®ã¯ãã¥ã¼ãªã³ã°å®å ¨ã§ã¯ãªãã¨ãããã¨ã§ãã å ·ä½çã«ã¯ã«ã¼ããªã©ã¯æ¸ãã¾ããã
è¨å®ãã¡ã¤ã«ã®å½¹å²ã¨ãããã®ã¯ã½ããã¦ã§ã¢ã®æé·ã«å¾ã£ã¦è¥å¤§åãã¦ãã宿å½ã«ããã æåã¯åç´ãªJSONãYAMLã§æ¸ãã§ãããã®ã®ä¸ã«ç¬èªå½¢å¼ã®ãã¯ãã追å ããã åç´ãªæååç½®ãæãã§æ¸ãã§ãããã¡ã¯ãããã®ã®è¦æ±ã®åä¸ã«å¾ã£ã¦ãã¯ãã®å½¹å²ã¯å¢ãã¦ããã å±ä¸å±ãéããæ«ã«ã¯ã·ã³ã¿ãã¯ã¹ãã¤ã©ã¤ããå¹ããªãã»å®è¡æã«ãªããªãã¨ã©ãããè¨å®ã«ãªããåãããªãã»ä¸æããã°ç¡éã«ã¼ããã¦åæ¢ããªãè¨å®ãã¡ã¤ã«ãã§ãããã£ã¦ãã¾ãã¾ãã
Dhallã¯æå³çã«ãã¯ã¼ãæãã¦è¨å®ãã¡ã¤ã«ã®é åãå®ããªããããç°¡åãªé¢æ°ãããã¯ä½¿ããããããã¨ããè¦æã«å¿ãã¦ãããã ã¨ã¦ãè¯ããã©ã³ã¹ãéæãã¦ããã¨æãã¾ãã
Dhallã¯ãã§ã«ããã¤ãã® å°å ¥äºä¾ ãã¾ã¨ã¾ã£ã¦ããããããã¯ã·ã§ã³ã§ååã«å©ç¨å¯è½ã¨è¨ããã§ãããã (åè¶ãªããå æ¥ç§ãä¼ç¤¾ã§ä½¿ããã¦ããé·å¤§ãªYAMLãDhallããçæããä»çµã¿ãä½ãã¾ããã ã¨ã¦ã便å©)ã
å°å ¥æ¹æ³
Dhallã«ã¯ dhall
ã³ãã³ããªã©ã®ã³ãã³ãã©ã¤ã³ãã¼ã«ç¾¤ã¨ã
dhall-json ã dhall-to-cabal ã¨ãã£ãã¢ããªã±ã¼ã·ã§ã³ã
ããã¦åããã°ã©ãã³ã°è¨èªãã Dhall ãã¡ã¤ã«ãèªã¿è¾¼ãããã®ããã¤ãã®ãã¤ã³ãã£ã³ã°ãããã¾ãã
ãµãã¼ãããã¦ããè¨èªã«ã¯ä»ã®ã¨ãã Haskell 㨠Nix ããããä»ã«ã Scala 㨠Rust ãéçºä¸ã®ããã§ãã
Dhallã³ãã³ãã©ã¤ã³ãã¼ã«
Stackããªãå ´åã¯ã¤ã³ã¹ãã¼ã«ãã¾ãã ä¾ã¨ã㦠Un*x ã®å ´å:
$ curl -sSL https://get.haskellstack.org/ | sh $ stack setup --resolver=lts-11.9
å¿
è¦ã«å¿ã㦠~/.local/bin
ã«PATHãéãã¦ãã ããã
Dhallãã¼ã«ç¾¤ã¯ä»¥ä¸ã®ããã«ãã¦ã¤ã³ã¹ãã¼ã«ãã¾ãã
$ stack install dhall --resolver=lts-11.9 $ ls ~/.local/bin/dhall* dhall dhall-format dhall-hash dhall-repl
(注æ: æè¿ã³ãã³ãã©ã¤ã³ãã¼ã«ã®æ§æã«å¤æ´ããã dhall-format
㨠dhall-hash
ã dhall
ã®ãµãã³ãã³ãã«ãªãã¾ãã
(issue)ã
ãã®å¤æ´ã¯ä»åæ¡ç¨ãã¦ãã lts-11.9 ã«ã¯ã¾ã å
¥ã£ã¦ããªãã®ã§ããã®è¨äºã§ã¯ãããã¯ã¾ã ç¬ç«ããã³ãã³ãã¨ãã¦æ±ãã¾ãã)
dhall
ã³ãã³ã㯠Dhall ãã¡ã¤ã«ã®è©ä¾¡ããããã®ã§ãé¢æ°ã®å±éãåãã§ãã¯ããã¾ã
(ã¤ã¾ããã¢ããªã±ã¼ã·ã§ã³ã«æå
¥ããåã«ã©ã®ãããªè¨å®ã«ãªãã&å½¢å¼ãééã£ã¦ããªãããåãã!)ã
dhall-format
ã³ãã³ã㯠Dhall ãã¡ã¤ã«ã®ãã©ã¼ããã¿ã§ãã
Dhall ãã¡ã¤ã«ã®ä¿åæã«ãããèµ°ãããã«ã¨ãã£ã¿ãè¨å®ãã¦ããã®ãããããã§ãã
Emacsã§ããã° dhall-mode ãå
¥ãã¦ããã°åæã«ãã®ãããªè¨å®ã«ãã¦ããã¾ãã
Dhallã¢ããªã±ã¼ã·ã§ã³
ç¾å¨ã®ã¨ãã Dhall ãå©ç¨ããã¢ããªã±ã¼ã·ã§ã³ã¨ãã¦ã¯ä»¥ä¸ã®ãã®ãããããã§ãã
dhall-json
Dhall ãã¡ã¤ã«ã JSON ã YAML ã«å¤æãã¾ãã
æ¢ã« JSON ã YAML ã®è¨å®ãã¡ã¤ã«ã使ç¨ãã¦ããã®ã§ããã°ã
ããã使ãã°éçæ¤æ»ãé¢æ°ã®ãã Dhall ãæ¬çªããã¼ã«å°å
¥ããããããããã¾ããã
stack install dhall-json --resolver=lts-11.9
ã¨ããã¨
dhall-to-json
㨠dhall-to-yaml
ã®2ã¤ã®ã³ãã³ããã¤ã³ã¹ãã¼ã«ããã¾ãã
dhall-to-cabal
Dhall ãã¡ã¤ã«ã cabal ãã¡ã¤ã«ã«å¤æãã¾ãã
ã¾ãããã ãã§ãªããcabal ãã¡ã¤ã«ã®ããã®(ãããã cabal ãå®å
¨ã«ã«ãã¼ãã**å¤ãã®åå®ç¾©ã
ããã¦è¨è¿°ã楽ã«ããããã®å¤ãã®é¢æ°ãæä¾ãã¾ãã
Dhall ãæ¬æ ¼å©ç¨ããä¸ã§ã®ãã¦ãã¦ã®å®åº«ã§ãã®ã§ cabal ãã¡ã¤ã«ã«èå³ããªã人ã§ãåèæç®ã¨ãã¦è¦ãã¦ããã¨ããã§ãããã
stack install dhall-to-cabal --resolver=lts-11.9
ã§ã¤ã³ã¹ãã¼ã«ã§ãã¾ãã
dhall-kubernetes
Dhall ãã¡ã¤ã«ã§ Kubernetes ã®è¨å®ãè¨è¿°ã§ããããã«ãããã¼ã«ã§ãã
Kubernetes ã¯é·å¤§ãª YAML è¨å®ãã¡ã¤ã«ã§ç¥ãããã®ã§ã¾ãã« Dhall ãçããé åã¨è¨ããã§ãããã
dhall-kubernetes èªä½ã¯ Dhall ãã¡ã¤ã«ã®ã¿ã§æ§æãããYAMLã¸ã®å¤æã«ã¯ dhall-json ãç¨ãã¾ãã
ãã ãè¦æ±ãã Dhall ã®ãã¼ã¸ã§ã³ãããæ°ãããã®ã®ãã LTS-11.9 ç°å¢ã§ã¯ã¤ã³ã¹ãã¼ã«ã§ãã¾ããã
stack instal dhall-json --resolver=nightly
ã§ææ°ã® dhall-json ãã¤ã³ã¹ãã¼ã«ããå¿
è¦ãããã¾ãã
ãã¤ã³ãã£ã³ã°
Dhall ãããã°ã©ãã³ã°è¨èªããå©ç¨ããå ´åã¯ãã®è¨èªã§ã® Dhall ã®ãã¤ã³ãã£ã³ã°ãå¿ è¦ã§ãã
ãã¨ãã° Dhall ãã¡ã¤ã«ã Haskell ã¢ããªã±ã¼ã·ã§ã³ããèªãå ´å㯠Haskell ã® dependencies ã« dhall ããã±ã¼ã¸ãå ãã¾ãã
Dhallåºç¤ç·¨
ããã§ã¯Dhallã®åè¦ç´ ãè¦ã¦ããã¾ãããã
ãã¼ã¿è¡¨ç¾
ãã¼ã¿ã®è¡¨ç¾ã¯ä¸è¬çãªè¨å®ãã¡ã¤ã«ã表ç¾ããã®ã«ååãªãã®ãæãã¦ãã¾ãã
ããªããã£ãã¨ã㦠Bool
, Integer
, Double
, Text
(ãã¨ããã»ã©ä½¿ããªãæ°ããããã©æ£ã®æ´æ°ã表ã Natural
) ãããã¾ãã
$ echo 'True || False' | dhall Bool True $ echo '1' | dhall Integer 1 $ echo '2.0' | dhall Double 2.0 $ echo '"Hello, World"' | dhall Text "Hello, World"
è¤å表ç¾ã¨ã㦠List
, Optional
, Record
, Union
ãããã¾ãã
$ echo '[1, 2]' | dhall List Integer [ 1, 2 ] $ echo '[] : Optional Integer' | dhall Optional Integer [] : Optional Integer $ echo '{ x = 1, y = 2 }' | dhall { x : Integer, y : Integer } { x = 1, y = 2 } $ echo '<Number = 1 | Name : Text>' | dhall < Name : Text | Number : Integer > < Number = 1 | Name : Text >
Union
ã®å¤ã®æ¸ãæ¹ãç
©é(使ããªãæ¹ã®èå¥åãæ¸ããªããã°ãªããªã)ã§ããããã«ã¯è§£æ±ºçãç¨æããã¦ãã¾ãã
å¾ã§è¿°ã¹ã¾ãã
åå®ç¾©
è¤å表ç¾ã«ååãã¤ãã¦ç¬èªã®åãå®ç¾©ãããã¨ãã§ãã¾ãã
$ echo 'let Point2d = {x:Integer, y:Integer}: Type in {x=1, y=2}: Point2d' | dhall { x : Integer, y : Integer } { x = 1, y = 2 }
ãã¡ããåãåã£ã¦ããªããã°æãã¦ããã¾ã(åºåã«ããããã« dhall
ã®ä»£ããã« dhall --explain
ã使ãã°ãã詳細ãªã¡ãã»ã¼ã¸ãåºãã¦ããã¾ã)ã
$ echo 'let Point2d = {x:Integer, y:Integer}: Type in {x=1, y="2"}: Point2d' | dhall Use "dhall --explain" for detailed errors Error: Expression doesn't match annotation {x=1, y="2"}: Point2d (stdin):1:47
å¤é¨ãã¡ã¤ã«ã®ã¤ã³ãã¼ã
Dhallã§ã¯å¤é¨ã®ãã¡ã¤ã«ãã¤ã³ãã¼ããã¦ä½¿ããã¨ãã§ãã¾ãã
ãã¨ãã°ä»¥ä¸ã®ãã㪠Point2d
åãå®ç¾©ãã Point2d.dhall ãç¨æãã¾ãã
$ cat Point2d.dhall { x : Integer, y : Integer } : Type $ cat Point2d.dhall | dhall Type { x : Integer, y : Integer }
ããã以ä¸ã®ããã«ã¤ã³ãã¼ãããã°å¥ã®ãã¡ã¤ã«ã§ Point2d
åã使ã£ã¦åãã§ãã¯ãããã¨ãã§ãã¾ãã
$ dhall { x = 1, y = 2 } : ./Point2d.dhall [Enter] [Ctrl-d] { x : Integer, y : Integer } { x = 1, y = 2 } $ dhall { x = "1", y = 2 } : ./Point2d.dhall [Enter] [Ctrl-d] Use "dhall --explain" for detailed errors Error: Expression doesn't match annotation { x = "1", y = 2 } : ./Point2d.dhall (stdin):1:1
ãªãããã§ã¯ãã¼ã«ã«ã®ãã¹ããã¤ã³ãã¼ããã¾ãããURLããã¤ã³ãã¼ããããã¨ãã§ããããã§ãã
é¢æ°
é¢æ°ã¯ç¡åé¢æ°ã¨ãã¦ä½ããã¨ãã§ãã¾ãã
以ä¸ã¯ Integer
ã®å¼æ°ã1ã¤åãåã£ã¦ãã®ã¾ã¾è¿ãé¢æ°ã§ãã
$ echo 'let id = \(x:Integer) -> x in id 10' | dhall Integer 10
è¤æ°ã®å¼æ°ãåãé¢æ°ã¯1ã¤ã®å¼æ°ãåãé¢æ°ããã¹ããããã¨ã§è¨è¿°ã§ãã¾ãã
ããã¯ä¸è¦é¢åã«ãè¦ãã¾ãããç¡å Record
ãå¼æ°ã«åããã¨ãã§ããã®ã§å®éã®ã¨ããåé¡ã«ã¯ãªãã¾ããã
ã¾ããDhallã®é¢æ°ã¯ åãå¼æ°ã«åã ãã¨ãã§ãã¾ãã
å¼æ°ã«åãåã¯æ¨æºã®ãã®ã ãã§ãªãèªä½ã®åã§ãOKã§ãã
以ä¸ã®ããã«ããã°åè¿°ã® id
é¢æ°ãä»»æã®åã®å¤ãåããããã«ãªãã¾ãã
$ echo 'let id = \(t:Type) -> \(x:t) -> x in id Double 1.0' | dhall Double 1.0
便å©ãªæ¼ç®åã»æ¨æºé¢æ°
æ¼ç®å //
ã¯2ã¤ã® Record
ãä½µåãã¾ãã
å®ç¨ä¸ã¯èªä½åã®ããã©ã«ãå¤ãå°ãæ¸ãæãããããªå ´åã«ãã使ãã¾ãã
$ echo '{x=1, y=2} // {y=-1, z=-2}' | dhall { y : Integer, z : Integer, x : Integer } { y = -1, z = -2, x = 1 }
ä¸ã®æ¹ã§ Union
ã®å¤ãè¨è¿°ããã¨ãã¯ä½¿ããªãèå¥åãæ¸ããã°ãªããç
©éã§ãããã¨ãè¿°ã¹ã¾ããã
constructors
é¢æ°ã¯ Union
ã®ã³ã³ã¹ãã©ã¯ã¿ãçæãã¦å¤ã®è¨è¿°ã楽ã«ãã¦ããã¾ãã
$ echo 'let NN = constructors <Number:Integer | Name:Text> in NN.Number 1' | dhall < Name : Text | Number : Integer > < Number = 1 | Name : Text >
merge
é¢æ°ã¯ Union
ãä½ããã®ç¹å®ã®åã«å¤æããã¨ãã«ä½¿ãã¾ãã
å®ç¨ä¸ã¯ã人éãè¨å®ãè¨è¿°ããã¨ãã¯å¤ãªå¤ãå
¥ããªãããã«åã§å¶éããããã©ãæçµçã«æ¬²ããã®ã¯æååã§ãããããªå ´åã«ãã使ãã¾ã({=}
ã¯ç©ºã® Record
å¤ã表ãã¾ã)ã
$ dhall[Enter] let OS = <iOS:{} | Android:{}> in let OSs = constructors OS in let handlers = {iOS=\(_:{})->"iOS", Android=\(_:{})->"Android"} in let osToText = \(o:OS) -> merge handlers o in osToText (OSs.Android {=}) [Ctrl-d] Text "Android"
ã㨠Dhall ã® Text
㯠string interpolation ãã§ãã¾ãã
$ echo 'let hello = \(name:Text) -> "Hello, ${name}!" in hello "Dhall"' | dhall Text "Hello, Dhall!"
Dhallå®è·µç·¨: Kubernetesè¨å®ãã¡ã¤ã«
Dhall å®è·µç·¨ã¨ãã¦ã dhall-kubernetes ã§ã¯ããã¾ãããç°¡å㪠Kubernetes ã® YAML è¨å®ãã¡ã¤ã«ã Dhall ã§ä½æãã¦ã¿ã¾ãã ç®æ¨ã¨ãã YAML 㯠https://kubernetes.io/docs/concepts/services-networking/service/ ã«ãã以ä¸ã®ãã®ã§ãã
kind: Service apiVersion: v1 metadata: name: my-service spec: selector: app: MyApp ports: - protocol: TCP port: 80 targetPort: 9376
ã¾ãã¯ãããåãã§ãã¯ããªã«ããªãã·ã³ãã«ãª Dhall ã§è¡¨ãã¦ã¿ã¾ãã
service.dhall:
{ kind = "Service" , apiVersion = "v1" , metadata = { name = "my-service" } , spec = { selector = { app = "MyApp" } , ports = [ { protocol = "TCP", port = 80, targetPort = 9376 } ] } }
ããã dhall-json ã«éãã¦ã¿ã¾ãã
$ cat service.dhall | dhall-to-yaml apiVersion: v1 kind: Service spec: selector: app: MyApp ports: - targetPort: 9376 protocol: TCP port: 80 metadata: name: my-service
ç®æ¨ã¨ãã YAML ãå¾ããã¾ããã
ãã ããã ã¨ãä¾ãã° "Service" ã "Servise" 㨠typo ãã¦ãã¾ã£ãã¨ãã¦ãã¨ã©ã¼ãæãã¦ããããã¯ãã¾ããã
ãã㧠Dhall ã®æã¤éçãã§ãã¯ãé¢æ°ãã¤ã³ãã¼ãã®æ©è½ãé§ä½¿ãã¦è¨è¿°ããµãã¼ããã¦ããã¾ãããã è¨å®ãã¡ã¤ã«ã®è¨è¿°ããµãã¼ãããããã®ãã¡ã¤ã«ã¯ k8s_types.dhall ã¨ããååã§ä½ãã å®éã®è¨å®ãè¨è¿°ãããã¡ã¤ã«ããããã¤ã³ãã¼ãããããã«ãã¾ãã
k8s_types.dhall:
let Kind_ = < Service : {} | Deployment : {} | Pod : {} > in let kindHandlers = { Service = λ(_ : {}) â "Service" , Deployment = λ(_ : {}) â "Deployment" , Pod = λ(_ : {}) â "Pod" } in let ApiVersion = < v1 : {} > in let apiVersionHandlers = { v1 = λ(_ : {}) â "v1" } in let Metadata : Type = { name : Text } in let Selector : Type = { app : Text } in let Protocol = < TCP : {} | UDP : {} > in let protocolHandlers = { TCP = λ(_ : {}) â "TCP", UDP = λ(_ : {}) â "UDP" } in let Port : Type = { protocol : Protocol, port : Integer, targetPort : Integer } in let PortMerged : Type = { protocol : Text, port : Integer, targetPort : Integer } in let _mergePort = λ(p : Port) â { protocol = merge protocolHandlers p.protocol , port = p.port , targetPort = p.port } in let Spec : Type = { selector : Selector, ports : List Port } in let SpecMerged : Type = { selector : Selector, ports : List PortMerged } in let List/map = https://raw.githubusercontent.com/dhall-lang/Prelude/35deff0d41f2bf86c42089c6ca16665537f54d75/List/map in let _mergeSpec = λ(s : Spec) â ( { selector = s.selector , ports = List/map Port PortMerged _mergePort s.ports } : SpecMerged ) in let Config : Type = { kind : Kind_ , apiVersion : ApiVersion , metadata : Metadata , spec : Spec } in let ConfigMerged : Type = { kind : Text , apiVersion : Text , metadata : Metadata , spec : SpecMerged } in let _mergeConfig = λ(c : Config) â ( { kind = merge kindHandlers c.kind , apiVersion = merge apiVersionHandlers c.apiVersion , metadata = c.metadata , spec = _mergeSpec c.spec } : ConfigMerged ) in { Kinds = constructors Kind_ , ApiVersions = constructors ApiVersion , Protocols = constructors Protocol , Config = Config , mergeConfig = _mergeConfig }
ããã使ã£ã¦å®éã®è¨å®ãè¨è¿°ãã¾ãã
({=}
ã¯ç©ºã® Record
å¤ã表ãã¾ã)ã
service_typed.dhall:
let k8s = ./k8s_types.dhall in let myService = { kind = k8s.Kinds.Service {=} , apiVersion = k8s.ApiVersions.v1 {=} , metadata = { name = "my-service" } , spec = { selector = { app = "MyApp" } , ports = [ { protocol = k8s.Protocols.TCP {=} , port = 80 , targetPort = 9376 } ] } } : k8s.Config in k8s.mergeConfig myService
å
ã»ã©ã¨åãããã« dhall-to-yaml
ã«éãã¾ãã
$ cat service_typed.dhall | dhall-to-yaml apiVersion: v1 kind: Service spec: selector: app: MyApp ports: - targetPort: 80 protocol: TCP port: 80 metadata: name: my-service
çµæãå¤ããã«éçãªãã§ãã¯ã追å ãããã¨ãã§ãã¾ãã! ãã¡ãã "Service" ãªã©ã typo ãããã¨ã©ã¼ãåºã¦æãã¦ããã¾ãã
ãªããä»åã¯ããã¾ã§è¨å®ãã¡ã¤ã«ã«ééã£ãå¤ãå ¥ãè¾¼ã¾ãªãããã«ãããã¨ã«ä¸»ç¼ãç½®ãã¾ãããã è¨å®ãã¡ã¤ã«ãããé·ããã®ã«ãªã£ã¦ããã¨ã
- åã®ããã©ã«ãå¤ãå®ç¾©ãã
- ç¹°ãè¿ã使ãå¤ãå®æ°ã«ãã
- éå¤ãªãã¤ã©ã¼ãã¬ã¼ããªè¨è¿°ããã«ãã¼é¢æ°ã«åãåºã
ãªã©ã Dhall ã®ãããªãæ©æµãåãããã¨ãã§ãã¾ãã
åèè³æ
- dhall-lang: å ¬å¼ãµã¤ã
- Dhall in production: Dhallå°å ¥äºä¾é
- dhall-json: Dhallãã¡ã¤ã«ãJSON/YAMLã«å¤æ
- dhall-to-cabal: Dhallæ¬æ ¼å©ç¨ã®ããã®ãã¦ãã¦ã®å®åº«
- dhall-kubernetes: Dhallãã¡ã¤ã«ã§Kubernetesã®è¨å®ãè¨è¿°
- dhall-mode: èªåãã©ã¼ãããããã¦ãããEmacsã¢ã¼ã
- dhall-lang Cheatsheet: ãã¼ãã·ã¼ã
- Dhall Tutorial: ãã¥ã¼ããªã¢ã«