Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

[Haskell] Concept exercise implementation guide #200

Merged
merged 11 commits into from
Jan 21, 2020

Conversation

declarationperfume
Copy link

No description provided.

@declarationperfume
Copy link
Author

#55

Copy link
Contributor

@sshine sshine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pushing on this.

  • The current Haskell track repo uses Hpack, which means it distributes a package.yaml rather than a <NAME>.cabal file. Doing this we expect students to run stack test which then builds the .cabal file.

    This pull request appears to propose that we instead only distribute a .cabal file. While we could do that, perhaps this choice should be made in the Haskell track issue tracker so that pros and cons can be weighed.

  • The current Haskell track repo has the property that every exercise directory is a project. This means that you can enter it and type stack test. For this property to hold with the proposed directory structure, the files stack.yaml and the project file (package.yaml or <NAME>.cabal) must be present in the exercise's root.

  • The current Haskell track repo names the example solution file the same as the exercise, but places it in a separate directory. This means that the files examples/success-{foo, bar}/{package.yaml, src/<NAME>.hs} exist: Multiple sample solutions can exist, and the track repo's CI suite can test the examples by copying files.

    This pull request appears to propose that we instead name the example solution Example.hs. The drawback associated with naming it this is that we cannot re-use the test suite on the example solution, since the test suite contains a line like import <NAME> (...) which must be replaced with import Example (...) during CI.

    Another consequence of having only Example.hs is that we can only have one example solution per exercise, where the current track repo's directory structure allow both multiple examples in the form of success-foo, success-bar (example: bob), but also negative examples in the form of fail-erp, fail-derp (example: robot-name). We could consider simplifying this so that an exercise only allows for one (successful) example solution, but perhaps this choice should also be made in the Haskell track issue tracker so that pros and cons can be weighed.

If we move stack.yaml and package.yaml (or <NAME>.cabal) into the exercise directory to make it a project directory, and we decide to allow only one example per exercise and move the example into its own directory to also make it a project directory (although running the tests would necessitate copying files), and if there is no apparent need for an exercise-specific config.json (again, please enlighten me) (I was enlightened by @ErikSchierboom), then the directory structure might look like:

languages
└── Haskell
    └── concept
        └── <SLUG>
            ├── package.yaml
            ├── stack.yaml
            ├── src
            │   └── <NAME>.hs
            ├── test
            │   └── Tests.hs
            ├── .docs
            │   ├── after.md (optional)
            │   ├── hints.md
            │   ├── instructions.md
            │   └── introductions.md
            ├── .meta
            │   └── config.json (optional)
            └── example
                ├── package.yaml
                └── src
                    └── <NAME>.hs

That is, I can no longer find a need for the .meta directory, since hints are now located in .docs.

We use .meta in the current track repo for one other thing but I can only see that we have a single instance of that feature in use, so it may be something we wish to deprecate zero other things (as of exercism/haskell#891).

Let me know what you think about my proposed changes to the directory structure, and let me know which of the structural changes compared to the current track repo you wish to discuss on the Haskell issue tracker. In particular, I am fond of simplifying the examples to one-per-exercise.

@sshine
Copy link
Contributor

sshine commented Jan 20, 2020

I'm going to create some issues on the Haskell issue tracker discussing these, but I won't have time to create them until Thursday evening. Feel free to respond here and I might be able to get back before then.

@declarationperfume declarationperfume force-pushed the haskell-implementation-guide branch from 5b4956f to 5e9bd15 Compare January 20, 2020 20:44
@declarationperfume declarationperfume added the type/documentation Improvements or additions to documentation label Jan 21, 2020
@declarationperfume
Copy link
Author

Would be a good idea to merge for now, and then go back and edit it once you've reached a conclusion in the issue tracker on the Haskell track?

Copy link
Contributor

@sshine sshine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we can get back to the details.

I've left two comments on the last iteration that you can choose to react on.

| └── after.md (optional)
├── .meta
| ├── config.json (omit for now)
| └── <SLUG>.hs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does the file .meta/<SLUG>.hs do?

This was not apparent between the previous review and the current.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the example solution. I'll add a note.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or should it be <NAME>.hs?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's the example solution and the example solution should be compatible with the test suite without modifying the test suite, then yes, it should be <NAME>.hs. But as I also wrote in my first review, example solutions may draw on additional dependencies which necessitates that they have their own package.yaml. At this point we're probably better suited with, at minimum, a separate example/{package.yaml, src/<NAME>.hs} directory structure.

I don't think it's immediately clear that the difference between src/<NAME>.hs and .meta/<NAME>.hs is that one is the stub and the other is the example. Other tracks get away with naming the file [Ee]xample.*. Maybe we could, too, but it's not apparent to me how we can easily overcome the difficulties associated with testing under CI.

Whatever you pick for this pull request, we'll put it up for vote later.

Adding a note sounds good.

@sshine
Copy link
Contributor

sshine commented Jan 21, 2020

I've created exercism/haskell#892 and exercism/haskell#893 that address the loose ends between our current track and the present pull request's implicit choices. Feel free to merge this pull request and we can submit revisions that adjust it to our current defaults or whatever outcome a discussion might have.

@ErikSchierboom ErikSchierboom merged commit 9d63143 into master Jan 21, 2020
@ErikSchierboom ErikSchierboom deleted the haskell-implementation-guide branch January 21, 2020 15:51
@ErikSchierboom
Copy link
Member

@sshine Cool, thanks! I've merged the PR.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
track/haskell type/documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants