Split Package in Exercism

Hi. Here is my code for acronym.

“”"
import Data.List.Split (splitOn)
import Data.Char

abbreviate :: String → String
abbreviate xs = map (toUpper . (!! 0)) listOfWords
where listOfWords = splitOn " " xs
“”"

It is working fine in my local system, but giving an error in exercism. Am I not allowed to import Split here? Do I need to solve this another way?

I don’t speak Haskell, but haskell-test-runner/pre-compiled/package.yaml at a65f454eccca77b40147d4ad37099da1d3a31de9 · exercism/haskell-test-runner · GitHub indicates it should be available within the test runner. The test runner doesn’t have network access so you’re restricted to the packages inside the yaml. Hopefully a maintainer can diagnose your issue further.

I also don’t speak for Haskell, but maybe you need to submit some sort of package list with your submission too? (exercism submit $code_file $package_file) (fill in the $stuff with the correct filepaths)? Maybe a lock file too?

Hi, you have two files in the exercism editor, one with the haskell file and one with the package file, the package file says which dependencies your solution has, so you have to update the package.yaml file accordingly to the libraries you import.

But as Jeremy said, the likeliest cause is that you didn’t import the package file.

Hope this helps!

1 Like

Thanks. I added split under dependencies to the yaml file. it worked. I’ll be mindful regarding this from now on.

2 Likes