まえがき
関数型パラダイムの言語をあまり触れてこなかったので、最近Haskellを勉強中
書籍として すごいH本 を読んで勉強してます。
勉強用に実行環境を作りたかったのですが、だいたいいつも自分はちょっとした環境作成はDockerでやりたくなるので
今回もDockerでやろうと思っていたのですが
エディタ補完とかを考えると、どうしたものかと考えていたら DevContainer
という便利拡張に出会った。
こいつを使ってHaskellの実行環境を用意することに
設定ファイル等の用意
repo ├ .devcointainer │ ├ devcontainer.json │ ├ Dockerfile │ └ docker-compose.yml └ src
devcontainer.json
{ "name": "Haskell Dev Container", "dockerComposeFile": "docker-compose.yml", "service": "haskell-dev", "workspaceFolder": "/workspace", "extensions": [ "haskell.haskell", "justusadam.language-haskell", ] }
Dockerfile
# Dockerfile FROM haskell:latest # Install GHCup RUN curl https://get-ghcup.haskell.org -sSf | sh ENV PATH="/root/.ghcup/bin:${PATH}" RUN ghcup install hls # Set working directory WORKDIR /workspace # Copy project files to the container COPY . /workspace
docker-compose.yml
version: '3' services: haskell-dev: build: context: . dockerfile: Dockerfile container_name: haskell-dev volumes: - ../src:/workspace tty: true
ちなみに、ほぼChatGPT
に書かせました。
おまけ
ぶっちゃけちょっとコードを書くくらいならオンラインコンパイラが最強