Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Data.Map (containers-0.6.2.1) to common dependencies #1041

Closed
artamonovkirill opened this issue Jan 25, 2022 · 14 comments
Closed

Add Data.Map (containers-0.6.2.1) to common dependencies #1041

artamonovkirill opened this issue Jan 25, 2022 · 14 comments

Comments

@artamonovkirill
Copy link
Contributor

artamonovkirill commented Jan 25, 2022

If my solution (e.g., the Grade School) imports Data.Map, the test runner fails with:

/mnt/exercism-iteration/src/School.hs:4:1: error:
    Could not load module 'Data.Map'
    It is a member of the hidden package 'containers-0.6.2.1'.
    Perhaps you need to add 'containers' to the build-depends in your .cabal file.

Given that Data.Map is the 3rd most popular import (see #1006), would be nice to have it imported by default.

@artamonovkirill
Copy link
Contributor Author

@ErikSchierboom

@ErikSchierboom
Copy link
Member

@petertseng Is this the same issue described in #1006? Or is containers a dependency we need to add to the test runner's precompiled dependencies list: https://github.com/exercism/haskell-test-runner/blob/main/pre-compiled/package.yaml#L11?

@petertseng
Copy link
Member

petertseng commented Jan 25, 2022

The presence of containers in https://downloads.haskell.org/~ghc/9.0.1/docs/html/libraries/index.html tells us that GHC already comes with containers. Thus adding it to https://github.com/exercism/haskell-test-runner/blob/main/pre-compiled/package.yaml#L11 changes nothing. This is not related #1006. #1006's error was Cabal file info not found which as we can see is not the error described in this issue.

My advice is is that we have the same two possibilities as #1006 (comment), but I will modify that comment to be applicable to this situation.

@artamonovkirill
Copy link
Contributor Author

@petertseng submitting package.yaml works fine with the CLI, but not in the online editor.

@ErikSchierboom are there currently any tracks that allow editing multiple files in the online editor or that allow to add extra libraries in some other way?

@ErikSchierboom
Copy link
Member

The C/C++ tracks have both a .h and a .c/.cpp file the student can edit. There is no special way to add extra libraries.

@artamonovkirill
Copy link
Contributor Author

artamonovkirill commented Jan 26, 2022

Should then package.yaml be editable online for (some) Haskell exercises?

@ErikSchierboom
Copy link
Member

Possibly, yes

@isaacvando
Copy link
Contributor

Now that the online editor supports editing the package.yaml file (per #1080), I think it could be a good time to close this issue.

It seems more consistent to me to not include containers in the package.yaml file. If I was new to the track and didn't know about adding dependencies to package.yaml, it would be quite frustrating that importing Data.Map worked for grade-school but none of the other problems that didn't have containers added already.

@artamonovkirill
Copy link
Contributor Author

artamonovkirill commented Aug 24, 2022

Thanks for the update and sorry for taking so long to reply.

I can edit package.yaml online, and specifying containers dependency without a version.

But adding a version constrain (containers >= 0.6.3) breaks the build:

No information from Hackage index, 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))

If I remember correctly, the test runner does not have Internet access when running the tests.
If so, how do I know which packages / versions are available at the runtime?

@MatthijsBlom
Copy link
Contributor

MatthijsBlom commented Aug 24, 2022

The exercises use a Stackage snapshot. stack.yaml specifies which one. It looks like this isn't visible in the web editor, but when you really need to know you can find it in the track repo: example. (Likely all exercises use 18.14 right now.)

The versions included in a snapshot are listed on Stackage.

@artamonovkirill
Copy link
Contributor Author

There's already a little comment explaining adding dependencies:

  # dependencies:
  # - foo       # List here the packages you
  # - bar       # want to use in your solution.

Would it be too much information to add a disclaimer that just any version would not work? And/or a short explanation about Stackage, maybe with some links?

@MatthijsBlom
Copy link
Contributor

# dependencies:
  # - foo       # List here the packages you
  # - bar       # want to use in your solution.
                # Do not specify version bounds!
                # Versions are derived from the Stackage snapshot.
                # You can find your snapshot in `stack.yaml`.
                # The package versions are listed on the corresponding
                # web page. Example:  www.stackage.org/lts-18.14

I feel this becomes a lot, fast. I'm fine with the Do not specify version bounds!, but less so with the rest. A complication is that stack.yaml is not visible from the web editor. Also, I'm not sure what happens when the snapshot is changed. I did this succesfully multiple times, but am not sure success is guaranteed.

…Maybe this file could be / is automatically generated (?), and the text could be shortened to

# Do not specify version bounds!
# The versions used in this exercise are listed here:  www.stackage.org/lts-18.14

@artamonovkirill
Copy link
Contributor Author

Just something like

# Do not specify version bounds!
# Versions are derived from the Stackage snapshot.

should be OK, I think. If the version of Stackage would be there - even better, not required.

But this discussion is probably outside of the scope of this ticket - I'll close this one and create a new one for the disclamer.

@artamonovkirill
Copy link
Contributor Author

Created #1098

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants