Haskell tests failing on site

I’m having a problem submitting my solution to the Bob exercise on the Haskell track. I added a dependency (text-latin1) to package.yaml so I could import Text.Ascii into my solution. This seems to cause the site’s test suite to fail, though they all pass in the cli.

package.yaml:

name: bob
version: 1.4.0.10

dependencies:
  - base
  - text
  - text-latin1

library:
  exposed-modules: Bob
  source-dirs: src
  ghc-options: -Wall
  dependencies:
  - text
  - text-latin1

tests:
  test:
    main: Tests.hs
    source-dirs: test
    dependencies:
      - bob
      - hspec

my solution:

{-# Language OverloadedStrings #-}
module Bob (responseFor) where

import qualified Data.Text as T
import           Data.Text ( Text )
import qualified Text.Ascii as A

responseFor :: String -> Text
responseFor xs
  | silence   = "Fine. Be that way!"
  | wtf       = "Calm down, I know what I'm doing!"
  | shout     = "Whoa, chill out!"
  | query     = "Sure."
  | otherwise = "Whatever."
    where
      txt        = T.strip $ T.pack xs
      silence    = T.null txt
      query      = T.last txt == '?'
      hasAlpha   = T.any A.isAlpha txt
      hasNoLower = not $ T.any A.isLower txt
      shout      = hasAlpha && hasNoLower
      wtf        = shout && query

error message on the site:

Cabal file info not found for text-latin1-0.3.1@sha256:f7da16a5447d51d5de0992a5ecb11ecf3e03d2da9a4f3f66da4e8b3f59a3f3e7,1215, updating
Selected mirror https://hackage.haskell.org/
Downloading root
HttpExceptionRequest Request {
  host                 = "hackage.haskell.org"
  port                 = 443
  secure               = True
  requestHeaders       = [("Accept-Encoding",""),("User-Agent","Haskell pantry package")]
  path                 = "/root.json"
  queryString          = ""
  method               = "GET"
  proxy                = Nothing
  rawBody              = False
  redirectCount        = 10
  responseTimeout      = ResponseTimeoutDefault
  requestVersion       = HTTP/1.1
}
 (ConnectionFailure Network.Socket.getAddrInfo (called with preferred socket type/protocol: AddrInfo {addrFlags = [AI_ADDRCONFIG], addrFamily = AF_UNSPEC, addrSocketType = Stream, addrProtocol = 0, addrAddress = <assumed to be undefined>, addrCanonName = <assumed to be undefined>}, host name: Just "hackage.haskell.org", service name: Just "443"): does not exist (Try again))

Hi, yes, it will do. The test runner doesn’t have access to the internet, so it will fail trying to download a package that’s not preinstalled.

The currently preinstalled packages are here: haskell-test-runner/package.yaml at main · exercism/haskell-test-runner · GitHub

Do you think that text-latin1 warrants adding?

2 Likes

Hey, thanks for directly linking to the list of Haskell libraries installed in Exercism! I didn’t realize the test runner had a limited set of libraries pre-installed; good to know.

Though I’m only a fledgling Haskeller, the text-latin1 library does not seem worthy of inclusion. The same functions I found while horsing around in Text.Ascii on Hoogle for use in my solution were also available in the base library. Kinda embarrassed I hadn’t even checked for that possibility before posting. :sweat_smile:

2 Likes

Ha! Always good to learn what’s in the base library! No probs :slightly_smiling_face:

@DeCentN2Madness To be sure you are actually looking at base functions, you can include +base in your Hoogle queries. With + you can narrow searches down to single packages. Example.

2 Likes