-
Notifications
You must be signed in to change notification settings - Fork 17
Add utility function mapSourceRepos #93
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
7d58a1d
add mapping over source repos of a project
jneira 4a08b6f
add SourceRepo type
jneira fc8d056
Add constructors for RepoKind and RepoType and mapSourceRepos utility
jneira e4df506
test case for mapSourceRepos
jneira 704fb4d
move utility functions to its own folder/package
jneira 4fd330f
add new utils dhall source files
jneira 06be34d
delete trace file
jneira 53e8f52
set the default warning for *nix
jneira File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
let Version = | ||
../types/Version.dhall | ||
in let VersionRange = | ||
../types/VersionRange.dhall | ||
in let Versions = | ||
{ UnionVersionRanges = | ||
../types/VersionRange/UnionVersionRanges.dhall | ||
, MajorBoundVersion = | ||
../types/VersionRange/MajorBoundVersion.dhall | ||
, NoVersion = | ||
../types/VersionRange/NoVersion.dhall | ||
} | ||
|
||
in let majorVersions | ||
: Text | ||
→ List Version | ||
→ { package : Text, bounds : VersionRange } | ||
= λ(package : Text) | ||
→ λ(versions : List Version ) | ||
→ { package = | ||
package | ||
, bounds = | ||
Optional/fold | ||
VersionRange | ||
( List/fold | ||
Version | ||
versions | ||
(Optional VersionRange ) | ||
( λ(v : Version ) | ||
→ λ(r : Optional VersionRange ) | ||
→ Optional/fold | ||
VersionRange | ||
r | ||
(Optional VersionRange ) | ||
( λ(r : VersionRange ) | ||
→ [ Versions.UnionVersionRanges | ||
( Versions.MajorBoundVersion v ) | ||
r | ||
] : Optional VersionRange | ||
) | ||
( [ Versions.MajorBoundVersion v | ||
] : Optional VersionRange | ||
) | ||
) | ||
([] : Optional VersionRange ) | ||
) | ||
VersionRange | ||
(λ(a : VersionRange ) → a) | ||
Versions.NoVersion | ||
} | ||
|
||
in majorVersions |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
let SourceRepo = ../types/SourceRepo.dhall | ||
|
||
in let Package = ../types/Package.dhall | ||
|
||
in let mapSourceRepos | ||
: (SourceRepo → SourceRepo) → Package → Package | ||
= λ(f : SourceRepo → SourceRepo) | ||
→ λ(pkg : Package) | ||
→ pkg | ||
⫽ { source-repos = | ||
List/build | ||
SourceRepo | ||
( λ(list : Type) | ||
→ λ(cons : SourceRepo → list → list) | ||
→ List/fold | ||
SourceRepo | ||
pkg.source-repos | ||
list | ||
(λ(x : SourceRepo) → cons (f x)) | ||
) | ||
} | ||
|
||
in mapSourceRepos |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ GitHub-project = | ||
./GitHub-project.dhall | ||
, majorVersions = | ||
./majorVersions.dhall | ||
, mapSourceRepos = | ||
./mapSourceRepos.dhall | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
name: repo | ||
version: 1.0.0 | ||
cabal-version: 2.0 | ||
build-type: Simple | ||
license: UnspecifiedLicense | ||
homepage: https://github.com/owner/repo | ||
bug-reports: https://github.com/owner/repo/issues | ||
|
||
source-repository this | ||
type: git | ||
location: https://github.com/owner/repo | ||
tag: 1.0.0 | ||
|
||
executable foo | ||
main-is: Main.hs | ||
scope: public | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think what we actually really want is a test that
mapSourceRepo
produces some normalized Dhall, but it might be a little out of scope for this PR. If you want to add a new section to the golden tests (that basically golden test one Dhall file normalizes to another), I'd be on board with that. If not, it can be done later.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That section would be usefult to test other prelude functions in isolation (among other things), right?
I agree it would be usefult but if you dont mind i would prefer to add it in another pr.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another PR is good with me!