---
- name: packages | Initialize cabal config
  command:
    cmd: /usr/bin/cabal user-config init
    creates: '{{ ansible_env.CABAL_CONFIG }}'
  tags: cabal-init

- name: packages | Update cabal package list
  command:
    cmd: /usr/bin/cabal update
    removes: /usr/bin/cabal
  tags: cabal-update

- name: packages | Install hadolint
  tags: [hadolint, linters]
  command:
    cmd: /usr/bin/cabal install {{ cabal_arguments }} hadolint
    removes: /usr/bin/cabal

# NOTE: only works with projects using the same GHC version
# Ref: https://haskell-language-server.readthedocs.io/en/latest/installation.html
- name: packages | Install haskell-language-server
  tags: [haskell-language-server, lspservers]
  command:
    cmd: /usr/bin/cabal install {{ cabal_arguments }} haskell-language-server
    removes: /usr/bin/cabal

# dhall-nix requires libsodium-dev
- name: packages | Install dhall packages
  tags: dhall
  command:
    cmd: /usr/bin/cabal install {{ cabal_arguments }} {{ item }}
    removes: /usr/bin/cabal
  loop:
    - dhall
    - dhall-json
    - dhall-yaml
    - dhall-nix
    - dhall-lsp-server
    - dhall-docs
    - dhall-toml
    - dhall-csv
