Skip to content

Conversation

@m-renaud
Copy link
Contributor

@m-renaud m-renaud commented Nov 22, 2018

Overview

Partially addresses #5696.

Implement's @gbaz's suggestion in #5696 (comment).

This new PackageType addresses the common use case of getting a package set up as quickly as possible without needing to go through the full interactive prompt. We move the getLibOrExec prompt to the front of the list, and if SimpleProject is selected we bypass the rest of the interactive prompt and use the defaults.

This behaviour can also be invoked via: cabal init --simple

Testing

This change was manually tested, let me know if there's any automated testing for this you'd like me to update.

New cabal init behaviour:

$ cabal-dev init
Should I generate a simple project with sensible defaults?? [default: y] y

Guessing dependencies...

Generating LICENSE...
Warning: unknown license type, you must put a copy in LICENSE yourself.
Generating Setup.hs...
Generating CHANGELOG.md...
Generating Main.hs...
Generating myapp.cabal...

Warning: no synopsis given. You should edit the .cabal file and add one.
You may want to edit the .cabal file and add a Description field.

$ cat myapp.cabal 
cabal-version:       >=1.10
-- Initial package description 'myapp.cabal' generated by 'cabal init'.
-- For further documentation, see http://haskell.org/cabal/users-guide/

name:                myapp
version:             0.1.0.0
-- synopsis:
-- description:
-- bug-reports:
-- license:
license-file:        LICENSE
author:              Matt Renaud
maintainer:          matt@m-renaud.com
-- copyright:
-- category:
build-type:          Simple
extra-source-files:  CHANGELOG.md

library
  -- exposed-modules:
  -- other-modules:
  -- other-extensions:
  build-depends:       base >=4.12 && <4.13
  -- hs-source-dirs:
  default-language:    Haskell2010

executable myapp
  main-is:             Main.hs
  -- other-modules:
  -- other-extensions:
  build-depends:       base >=4.12 && <4.13
  -- hs-source-dirs:
  default-language:    Haskell2010
$ cabal-dev init --simple

Guessing dependencies...

Generating LICENSE...
Warning: unknown license type, you must put a copy in LICENSE yourself.
Generating Setup.hs...
Generating CHANGELOG.md...
Generating Main.hs...
Generating myapp.cabal...

Warning: no synopsis given. You should edit the .cabal file and add one.
You may want to edit the .cabal file and add a Description field.

Documentation

  • New command line argument --simple documented in Distribution.Client.Setup
  • CHANGELOG to be updated once changes finalized
  • Cabal user guide to be updated once changes finalized

Follow-ups (out of scope of this PR)

  • Select more "modern" defaults in getLibOrExec (such as using src/ dir for libraries and app/ dir for Main.hs, default to the most recent 2.4 cabal version, create cabal.project file, etc.)

Please include the following checklist in your PR:

  • Patches conform to the coding conventions.
  • Any changes that could be relevant to users have been recorded in the changelog.
  • The documentation has been updated, if necessary.
  • If the change is docs-only, [ci skip] is used to avoid triggering the build bots.

Please also shortly describe how you tested your change. Bonus points for added tests!

/cc @gbaz @23Skidoo @hvr

This new 'PackageType' addresses the common use case of getting a package set up
as quickly as possible without needing to go through the full interactive
prompt. We move the 'getLibOrExec' prompt to the front of the list, and if
'SimpleProject' is selected we bypass the rest of the interactive prompt and use
the defaults.

This behaviour can also be invoked via: cabal init --simple

Testing:
- Manually tested
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 22, 2018
"url":"pull/5707",
"account":"haskell",
"repo":"cabal",
"commit": "a109809d755bac83a0e43a6022a9e83263e79ea2",
"tag":"linux-7.6.3"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 22, 2018
"url":"pull/5707",
"account":"haskell",
"repo":"cabal",
"commit": "a109809d755bac83a0e43a6022a9e83263e79ea2",
"tag":"linux-7.8.4"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 22, 2018
"url":"pull/5707",
"account":"haskell",
"repo":"cabal",
"commit": "a109809d755bac83a0e43a6022a9e83263e79ea2",
"tag":"linux-7.10.3"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 22, 2018
"url":"pull/5707",
"account":"haskell",
"repo":"cabal",
"commit": "a109809d755bac83a0e43a6022a9e83263e79ea2",
"tag":"linux-8.2.2"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 22, 2018
"url":"pull/5707",
"account":"haskell",
"repo":"cabal",
"commit": "a109809d755bac83a0e43a6022a9e83263e79ea2",
"tag":"linux-8.0.2"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 22, 2018
"url":"pull/5707",
"account":"haskell",
"repo":"cabal",
"commit": "a109809d755bac83a0e43a6022a9e83263e79ea2",
"tag":"linux-8.4.4"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 22, 2018
"url":"pull/5707",
"account":"haskell",
"repo":"cabal",
"commit": "a109809d755bac83a0e43a6022a9e83263e79ea2",
"tag":"linux-8.6.2"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 22, 2018
"url":"pull/5707",
"account":"haskell",
"repo":"cabal",
"commit": "a109809d755bac83a0e43a6022a9e83263e79ea2",
"tag":"linux-8.4.4-fdebug-expensive-assertions"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 22, 2018
"url":"pull/5707",
"account":"haskell",
"repo":"cabal",
"commit": "a109809d755bac83a0e43a6022a9e83263e79ea2",
"tag":"osx-7.8.4"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 22, 2018
"url":"pull/5707",
"account":"haskell",
"repo":"cabal",
"commit": "a109809d755bac83a0e43a6022a9e83263e79ea2",
"tag":"osx-7.10.3"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 22, 2018
"url":"pull/5707",
"account":"haskell",
"repo":"cabal",
"commit": "a109809d755bac83a0e43a6022a9e83263e79ea2",
"tag":"osx-8.0.2"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 23, 2018
"url":"pull/5707",
"account":"haskell",
"repo":"cabal",
"commit": "a109809d755bac83a0e43a6022a9e83263e79ea2",
"tag":"linux-7.8.4"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 23, 2018
"url":"pull/5707",
"account":"haskell",
"repo":"cabal",
"commit": "a109809d755bac83a0e43a6022a9e83263e79ea2",
"tag":"linux-7.10.3"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 23, 2018
"url":"pull/5707",
"account":"haskell",
"repo":"cabal",
"commit": "a109809d755bac83a0e43a6022a9e83263e79ea2",
"tag":"linux-7.6.3"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 23, 2018
"url":"pull/5707",
"account":"haskell",
"repo":"cabal",
"commit": "a109809d755bac83a0e43a6022a9e83263e79ea2",
"tag":"linux-8.0.2"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 23, 2018
"url":"pull/5707",
"account":"haskell",
"repo":"cabal",
"commit": "a109809d755bac83a0e43a6022a9e83263e79ea2",
"tag":"linux-8.2.2"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 23, 2018
"url":"pull/5707",
"account":"haskell",
"repo":"cabal",
"commit": "a109809d755bac83a0e43a6022a9e83263e79ea2",
"tag":"linux-8.4.4"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 23, 2018
"url":"pull/5707",
"account":"haskell",
"repo":"cabal",
"commit": "a109809d755bac83a0e43a6022a9e83263e79ea2",
"tag":"linux-8.6.2"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 23, 2018
"url":"pull/5707",
"account":"haskell",
"repo":"cabal",
"commit": "a109809d755bac83a0e43a6022a9e83263e79ea2",
"tag":"linux-8.4.4-fdebug-expensive-assertions"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 23, 2018
"url":"pull/5707",
"account":"haskell",
"repo":"cabal",
"commit": "a109809d755bac83a0e43a6022a9e83263e79ea2",
"tag":"osx-7.8.4"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 23, 2018
"url":"pull/5707",
"account":"haskell",
"repo":"cabal",
"commit": "a109809d755bac83a0e43a6022a9e83263e79ea2",
"tag":"osx-7.10.3"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 23, 2018
"url":"pull/5707",
"account":"haskell",
"repo":"cabal",
"commit": "a109809d755bac83a0e43a6022a9e83263e79ea2",
"tag":"osx-8.0.2"
}
@m-renaud m-renaud requested a review from 23Skidoo November 23, 2018 20:54
@23Skidoo
Copy link
Member

/cc @byorgey

@23Skidoo
Copy link
Member

Is this basically the same as running cabal init -n --is-executable?

@m-renaud
Copy link
Contributor Author

Currently it's --is-libandexe, but the idea is for it to eventually fill in a more complete package scaffolding (lib, exe, test suite, etc), and also use more modern defaults.

Also, this provides a way of short circuiting the interactive prompt to give a nice default experience for beginners while only running cabal init.

@23Skidoo
Copy link
Member

23Skidoo commented Nov 25, 2018

Maybe make it a single yes/no choice before the package type choice then? Something like: "Should I just generate a simple project with sensible defaults or let you tweak the fine-grained settings? (yes/no)" . It's IMO a bit unclear what a "simple package" is and why one needs to choose between it and a lib/exe.

Adding an option for generating a test suite/benchmark and "more modern defaults" sound like good ideas in general, I think all package types could benefit from that.

@m-renaud
Copy link
Contributor Author

@23Skidoo Updated, see PR description for new prompt.

Also, to sync with updated master branch do you just do a merge or do you rebase on top of master?

Since nonInteractive is set in the getSimpleProject step we don't need to
re-check when selecting the main file.
@m-renaud
Copy link
Contributor Author

Let me know if there's anything else you'd like me to change. I have some other improvements I'd like to make on top of this so if we could get this merged in soon that would be great :)

@23Skidoo
Copy link
Member

23Skidoo commented Nov 26, 2018

Usually PRs are rebased to get rid of spurious merge commits.

@m-renaud
Copy link
Contributor Author

I ended up using GitHub's web merge tool, but good to know. This PR is ready for review/merge now.

@m-renaud
Copy link
Contributor Author

@23Skidoo the one CI failure GHCVER=7.10.3 was due to a timeout. I've restarted the job but that probably doesn't need to block.

@m-renaud
Copy link
Contributor Author

Friendly ping :)

Copy link
Member

@23Skidoo 23Skidoo left a comment

Choose a reason for hiding this comment

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

LGTM.

@23Skidoo 23Skidoo merged commit 3d16ba6 into haskell:master Dec 1, 2018
@23Skidoo
Copy link
Member

23Skidoo commented Dec 1, 2018

Merged, thanks!

@m-renaud m-renaud deleted the simple-project branch December 1, 2018 23:49
@m-renaud
Copy link
Contributor Author

m-renaud commented Dec 2, 2018

Thanks @23Skidoo for the review! There's some more cabal init improvements incoming if you have some time for more reviews :)

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

Successfully merging this pull request may close these issues.

2 participants