- name: Check if Haskell Platform is installed
  shell: test -d "{{ haskell_platform_installation_root_folder }}"
  register: haskell_platform_installed
  ignore_errors: True

- name: Download Haskell Platform binaries
  shell: wget "{{ haskell_platform_targz_url }}" -O "{{ haskell_platform_targz_path }}"
  when: haskell_platform_installed.rc != 0

- name: Get SHA256 checksum of downloaded Haskell Platform binaries
  shell: sha256sum "{{ haskell_platform_targz_path }}"
  register: rt__haskell_platform_targz_sha256sum
  when: haskell_platform_installed.rc != 0

- name: Ensure integrity of downloaded Haskell Platform binaries
  assert: 
    that:
      - "\"{{ haskell_platform_targz_sha256sum }}\" == rt__haskell_platform_targz_sha256sum.stdout.split()[0]"
  when: haskell_platform_installed.rc != 0

- name: Extract Haskell Platform to /usr/local
  shell: cd / && tar xzf "{{ haskell_platform_targz_path }}"
  when: haskell_platform_installed.rc != 0

- name: Activate Haskell Platform
  shell: "{{ haskell_platform_activate_bin }}"
  when: haskell_platform_installed.rc != 0

- name: Create symlink for libgmp.so to libgmp.so.10
  shell: sudo ln -s /usr/lib/x86_64-linux-gnu/libgmp.so.10 /usr/lib/x86_64-linux-gnu/libgmp.so
  when: haskell_platform_installed.rc != 0

- name: Check if Haskell Platform is installed
  shell: test -d "{{ haskell_platform_installation_root_folder }}"
  register: haskell_platform_installed
  ignore_errors: True

- name: Download Haskell Platform binaries
  get_url: url={{ haskell_platform_targz_url }}
           dest={{ haskell_platform_targz_path }}
           sha256sum={{ haskell_platform_targz_sha256sum }}
           timeout=30
  when: haskell_platform_installed.rc != 0

- name: Extract Haskell Platform to /usr/local
  shell: cd / && tar xzf "{{ haskell_platform_targz_path }}"
  when: haskell_platform_installed.rc != 0

- name: Activate Haskell Platform
  shell: "{{ haskell_platform_activate_bin }}"
  when: haskell_platform_installed.rc != 0

- name: Create symlink for libgmp.so to libgmp.so.10
  shell: sudo ln -s /usr/lib/x86_64-linux-gnu/libgmp.so.10 /usr/lib/x86_64-linux-gnu/libgmp.so
  when: haskell_platform_installed.rc != 0

Use `get_url` module to download Haskell Platform binary
Use `get_url` module to download Haskell Platform binary

Signed-off-by: Yan Han Pang <2a3dbd0474bc7e70adfd773b05f6c3249124ff3d@users.noreply.github.com>
