<commit_before>module Travis
  module Build
    class Script
      class Haskell < Script
        DEFAULTS = {
          cabal: Travis::Build.config.cabal_default.to_s.untaint,
          ghc: Travis::Build.config.ghc_default.to_s.untaint
        }.freeze
        GHC_VERSION_ALIASES = Travis::Build.config.ghc_version_aliases_hash.merge(
          'default' => DEFAULTS[:ghc]
        ).freeze

        def configure
          super
          sh.raw(
            template(
              'haskell.sh',
              default_ghc: DEFAULTS[:ghc],
              default_cabal: DEFAULTS[:cabal],
              root: '/'
            )
          )
          # Automatic installation of exact versions *only*.
          if version =~ /^(\d+\.\d+\.\d+|head)$/ && cabal_version =~ /^(\d+\.\d+|head)$/
            sh.raw "if ! travis_ghc_find '#{version}' &>/dev/null; then"
            sh.raw 'travis_fold start ghc.install'
            sh.echo "ghc-#{version} is not installed; attempting installation", ansi: :yellow
            sh.raw "travis_ghc_install '#{version}' '#{cabal_version}'"
            sh.raw 'travis_fold end ghc.install'
            sh.raw 'fi'
          end
        end

        def setup
          super
          sh.export 'TRAVIS_HASKELL_VERSION', "$(travis_ghc_find '#{version}')"
          sh.export 'PATH', "/opt/ghc/bin:${TRAVIS_GHC_ROOT}/${TRAVIS_HASKELL_VERSION}/bin:${PATH}", assert: true
          sh.if "-x /opt/ghc/${TRAVIS_HASKELL_VERSION}/bin/ghc" do
            sh.export "PATH", "/opt/ghc/${TRAVIS_HASKELL_VERSION}/bin:${PATH}"
          end
          sh.if "! $(ghc --numeric-version 2>/dev/null) = #{version}*" do
            sh.terminate 2, "GHC #{version} not found. Terminating."
          end
          sh.if "-x /opt/cabal/#{cabal_version}/bin/cabal" do
            sh.export "PATH", "/opt/cabal/#{cabal_version}/bin:${PATH}"
          end
          sh.if "! $(cabal --numeric-version 2>/dev/null) = #{cabal_version}*" do
            sh.terminate 2, "cabal #{cabal_version} not found. Terminating."
          end
          sh.cmd 'cabal update', fold: 'cabal', retry: true
        end

        def announce
          super
          sh.cmd 'ghc --version'
          sh.cmd 'cabal --version'
        end

        def install
          sh.cmd 'cabal install --only-dependencies --enable-tests', fold: 'install', retry: true
        end

        def script<commit_msg>Drop /opt/ghc/bin from $PATH<commit_after>module Travis
  module Build
    class Script
      class Haskell < Script
        DEFAULTS = {
          cabal: Travis::Build.config.cabal_default.to_s.untaint,
          ghc: Travis::Build.config.ghc_default.to_s.untaint
        }.freeze
        GHC_VERSION_ALIASES = Travis::Build.config.ghc_version_aliases_hash.merge(
          'default' => DEFAULTS[:ghc]
        ).freeze

        def configure
          super
          sh.raw(
            template(
              'haskell.sh',
              default_ghc: DEFAULTS[:ghc],
              default_cabal: DEFAULTS[:cabal],
              root: '/'
            )
          )
          # Automatic installation of exact versions *only*.
          if version =~ /^(\d+\.\d+\.\d+|head)$/ && cabal_version =~ /^(\d+\.\d+|head)$/
            sh.raw "if ! travis_ghc_find '#{version}' &>/dev/null; then"
            sh.raw 'travis_fold start ghc.install'
            sh.echo "ghc-#{version} is not installed; attempting installation", ansi: :yellow
            sh.raw "travis_ghc_install '#{version}' '#{cabal_version}'"
            sh.raw 'travis_fold end ghc.install'
            sh.raw 'fi'
          end
        end

        def setup
          super
          sh.export 'TRAVIS_HASKELL_VERSION', "$(travis_ghc_find '#{version}')"
          sh.export 'PATH', "${TRAVIS_GHC_ROOT}/${TRAVIS_HASKELL_VERSION}/bin:${PATH}", assert: true
          sh.if "-x /opt/ghc/${TRAVIS_HASKELL_VERSION}/bin/ghc" do
            sh.export "PATH", "/opt/ghc/${TRAVIS_HASKELL_VERSION}/bin:${PATH}"
          end
          sh.if "! $(ghc --numeric-version 2>/dev/null) = #{version}*" do
            sh.terminate 2, "GHC #{version} not found. Terminating."
          end
          sh.if "-x /opt/cabal/#{cabal_version}/bin/cabal" do
            sh.export "PATH", "/opt/cabal/#{cabal_version}/bin:${PATH}"
          end
          sh.if "! $(cabal --numeric-version 2>/dev/null) = #{cabal_version}*" do
            sh.terminate 2, "cabal #{cabal_version} not found. Terminating."
          end
          sh.cmd 'cabal update', fold: 'cabal', retry: true
        end

        def announce
          super
          sh.cmd 'ghc --version'
          sh.cmd 'cabal --version'
        end

        def install
          sh.cmd 'cabal install --only-dependencies --enable-tests', fold: 'install', retry: true
        end

        def script
{'fraction_non_alphanumeric': 0.13964151729887453, 'fraction_numerical': 0.0016673614005835765, 'mean_word_length': 1.8031542056074767, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3378922', 'n_tokens_mistral': 1587, 'n_tokens_neox': 1566, 'n_words': 324}