[Haskell-cafe] [Haskell-community] technical thoughts on stack

Michael Snoyman michael at snoyman.com
Thu Sep 15 04:26:36 UTC 2016


I can give more technical details on warning output: it's purely an issue
of compromise between many different (and annoying) ways of displaying
things. Firstly, the behavior Chris Allen is commenting: if there is a
single local target package that you're building, then all of its GHC
output is displayed to the console, including warnings. The dependency
output is still sent to log files instead, keeping the console relatively
free of output most people will not care about (general feeling I've seen
is if a dependency has warnings, you don't want to see them, much less a
list of all modules being compiled).

The issue is: what happens if you're building multiple local packages?
There are a number of options, all of which seem to get in _someone's_ way:

1. What we do today: send all output to the logs
2. Spit output to the console as it occurs, which will interleave content
from multiple builds
3. Save the output to a log file, and then display all of the log files to
the user at the end, which would result in looking for a needle in a
haystack in many cases

When I put together the initial code for running builds, I chose (1), which
we still have today. It may be interesting to note that I did this mostly
based off of my experience with cabal-install doing the same thing
(whenever possible, I defaulted with cabal-install behavior, since it got
many things right, and regardless is what people were used to). I tested
this in the http-client repo by introducing a warning and running:

    cabal install ./http-client ./http-client-tls/ --ghc-option -Wall

You can see the results at:

    https://gist.github.com/snoyberg/a50f4fc9505aa32aec835630dd749b77

By contrast, `stack build http-client-tls` spits out all of the warnings to
the console as they happen.

So my recommendation for people who are warning-sensitive and using Stack:

1. Use the `--pedantic` flag to turn on both `-Wall -Werror`. This is
doubly-good: not only will you definitely see the warnings, but you won't
accidentally miss them by an interim compile. (This can easily happen if
you're using the `--file-watch` flag.)
2. Build one package in your project at a time.

If people have ideas for other ways of handling this that I haven't listed,
let's start a separate thread to discuss them.

On Wed, Sep 14, 2016 at 11:26 PM, David McBride <toad3k at gmail.com> wrote:

> That's not what I'm observering.  I intentially put -Wall and some odd
> code in a local copy of pipes-csv, stack clean, stack build.
>
> /home/toad/working/pipes-csv-1.4.0/src/Pipes/Csv.hs:216:3: Warning:
>     A do-notation statement discarded a result of type ‘String’
>     Suppress this warning by saying ‘_ <- getLine’
>     or by using the flag -fno-warn-unused-do-bind
>
> In another project, stack clean, stack build
>
> pipes-csv-1.4.0: configure
> pipes-csv-1.4.0: build
> pipes-csv-1.4.0: copy/register
>
> Nothing at all.
>
> stack.yaml is basically this, but with a few extra packages.
>
> flags: {}
> packages:
> - '.'
> - '../pipes-csv-1.4.0'
> extra-deps: []
> resolver: lts-3.1
>
> stack --version
> Version 1.1.2 x86_64 hpack-0.14.0
>
>
> On Wed, Sep 14, 2016 at 4:10 PM, Christopher Allen <cma at bitemyapp.com>
> wrote:
>
>> I see what is meant now, but it's not really applicable. If I am
>> co-developing a package and its dependencies, I add them as packages
>> (not deps) to my stack.yaml and still get the warnings.
>>
>> Example:
>>
>> From the stack.yaml for the package that uses my previous example's
>> library:
>>
>>
>> packages:
>> - '.'
>> - ../simple-library
>>
>>
>> Then stack build'ing the project (uses-sl) that depends on
>> simple-library which as a module with a warning:
>>
>>
>> $ stack build
>> simple-library-0.1.0.0: build
>> Progress: 1/2
>> --  While building package simple-library-0.1.0.0 using:
>>       /home/callen/.stack/setup-exe-cache/x86_64-linux/setup-Simpl
>> e-Cabal-1.24.0.0-ghc-8.0.1
>> --builddir=.stack-work/dist/x86_64-linux/Cabal-1.24.0.0 build
>> lib:simple-library exe:simple-library-exe --ghc-options " -ddump-hi
>> -ddump-to-file"
>>     Process exited with code: ExitFailure 1
>>     Logs have been written to:
>> /home/callen/work/uses-sl/.stack-work/logs/simple-library-0.1.0.0.log
>>
>>     Preprocessing library simple-library-0.1.0.0...
>>     [1 of 1] Compiling SimpleLib        ( src/SimpleLib.hs,
>> .stack-work/dist/x86_64-linux/Cabal-1.24.0.0/build/SimpleLib.o )
>>
>>     /home/callen/work/simple-library/src/SimpleLib.hs:7:3: warning:
>> [-Wunused-do-bind]
>>         A do-notation statement discarded a result of type ‘[Char]’
>>         Suppress this warning by saying ‘_ <- return "hello"’
>>
>>
>>
>> One of the first things I did when figuring out Stack was to look at
>> how Yesod used it:
>> https://github.com/yesodweb/yesod/blob/master/stack.yaml
>>
>> On Wed, Sep 14, 2016 at 2:56 PM, David McBride <toad3k at gmail.com> wrote:
>> > The rule of thumb seems to be, if you do a stack build and it decides to
>> > build multiple packages, it hides this log info.
>> >
>> > I understand why it does that, I should be able to build lens without
>> > worrying about tons of spurious output, but at the same time it is
>> common
>> > for me to have an entire tree of packages I'm developing and it often
>> > obscures errors that are happening in my own packages.  At the very
>> least,
>> > if it is only building local packages, I'd very much like to see that
>> > output.
>> >
>> > On Wed, Sep 14, 2016 at 3:42 PM, Patrick Pelletier
>> > <code at funwithsoftware.org> wrote:
>> >>
>> >> On 9/14/16 12:21 PM, Christopher Allen wrote:
>> >>>
>> >>> What are you talking about?
>> >>>
>> >>> $ stack build
>> >>> simple-library-0.1.0.0: unregistering (local file changes: src/Lib.hs)
>> >>> simple-library-0.1.0.0: build
>> >>> Preprocessing library simple-library-0.1.0.0...
>> >>> [1 of 1] Compiling Lib              ( src/Lib.hs,
>> >>> .stack-work/dist/x86_64-linux/Cabal-1.24.0.0/build/Lib.o )
>> >>>
>> >>> /home/callen/work/simple-library/src/Lib.hs:7:3: warning:
>> >>> [-Wunused-do-bind]
>> >>>      A do-notation statement discarded a result of type ‘[Char]’
>> >>>      Suppress this warning by saying ‘_ <- return "woot"’
>> >>> Preprocessing executable 'simple-library-exe' for
>> >>> simple-library-0.1.0.0...
>> >>
>> >>
>> >> Weird.  That's not how it works for me:
>> >>
>> >> whiteandnerdy:normalize ppelleti$ stack build
>> >> normalization-insensitive-2.0: unregistering (local file changes:
>> >> Data/Unicode/NormalizationInsensitive.hs
>> >> Data/Unicode/NormalizationInsensitive/Internal.hs)
>> >> normalization-insensitive-2.0: configure
>> >> normalization-insensitive-2.0: build
>> >> normalization-insensitive-2.0: copy/register
>> >> photos-0.1.0.0: configure
>> >> photos-0.1.0.0: build
>> >> photos-0.1.0.0: copy/register
>> >> Completed 2 action(s).
>> >> whiteandnerdy:normalize ppelleti$ cat
>> >> .stack-work/logs/normalization-insensitive-2.0.log
>> >> Configuring normalization-insensitive-2.0...
>> >> Preprocessing library normalization-insensitive-2.0...
>> >> [1 of 3] Compiling Data.Unicode.NormalizationInsensitive.Internal (
>> >> Data/Unicode/NormalizationInsensitive/Internal.hs,
>> >> .stack-work/dist/x86_64-osx/Cabal-1.22.5.0/build/Data/Unicod
>> e/NormalizationInsensitive/Internal.o
>> >> )
>> >>
>> >> Data/Unicode/NormalizationInsensitive/Internal.hs:30:1: Warning:
>> >>     The import of ‘Data.Bool’ is redundant
>> >>       except perhaps to import instances from ‘Data.Bool’
>> >>     To import instances alone, use: import Data.Bool()
>> >>
>> >> Data/Unicode/NormalizationInsensitive/Internal.hs:38:1: Warning:
>> >>     The import of ‘otherwise, &&, <=, +’
>> >>     from module ‘Prelude’ is redundant
>> >>
>> >> Data/Unicode/NormalizationInsensitive/Internal.hs:57:1: Warning:
>> >>     Module ‘Data.ByteString.UTF8.Normalize’ is deprecated:
>> >>       Convert ByteString to Text and then normalize
>> >>
>> >> Data/Unicode/NormalizationInsensitive/Internal.hs:135:1: Warning:
>> >>     Top-level binding with no type signature: mode :: NormalizationMode
>> >>
>> >> Data/Unicode/NormalizationInsensitive/Internal.hs:143:17: Warning:
>> >>     In the use of ‘B.normalize’
>> >>     (imported from Data.ByteString.UTF8.Normalize):
>> >>     Deprecated: "Convert ByteString to Text and then normalize"
>> >>
>> >> Data/Unicode/NormalizationInsensitive/Internal.hs:147:33: Warning:
>> >>     In the use of ‘B.normalize’
>> >>     (imported from Data.ByteString.UTF8.Normalize):
>> >>     Deprecated: "Convert ByteString to Text and then normalize"
>> >> [2 of 3] Compiling Data.Unicode.NormalizationInsensitive.Unsafe (
>> >> Data/Unicode/NormalizationInsensitive/Unsafe.hs,
>> >> .stack-work/dist/x86_64-osx/Cabal-1.22.5.0/build/Data/Unicod
>> e/NormalizationInsensitive/Unsafe.o
>> >> )
>> >> [3 of 3] Compiling Data.Unicode.NormalizationInsensitive (
>> >> Data/Unicode/NormalizationInsensitive.hs,
>> >> .stack-work/dist/x86_64-osx/Cabal-1.22.5.0/build/Data/Unicod
>> e/NormalizationInsensitive.o
>> >> )
>> >>
>> >> Data/Unicode/NormalizationInsensitive.hs:25:31: Warning:
>> >>     ‘normalize’ is exported by ‘Normalizable(normalize)’ and
>> ‘normalize’
>> >> In-place registering normalization-insensitive-2.0...
>> >> Installing library in
>> >>
>> >> /Users/ppelleti/programming/haskell/normalize/.stack-work/in
>> stall/x86_64-osx/lts-6.1/7.10.3/lib/x86_64-osx-ghc-7.10.3/
>> normalization-insensitive-2.0-KLVtcrPtbow6nG8kRB6WPM
>> >> Registering normalization-insensitive-2.0...
>> >> whiteandnerdy:normalize ppelleti$
>> >>
>> >> I hadn't even been aware of these warnings in the package I was
>> >> developing, until Harendra Kumar pointed them out to me, after I had
>> >> uploaded a candidate to Hackage.
>> >>
>> >> --Patrick
>> >>
>> >>
>> >> _______________________________________________
>> >> Haskell-Cafe mailing list
>> >> To (un)subscribe, modify options or view archives go to:
>> >> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
>> >> Only members subscribed via the mailman list are allowed to post.
>> >
>> >
>>
>>
>>
>> --
>> Chris Allen
>> Currently working on http://haskellbook.com
>>
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> Only members subscribed via the mailman list are allowed to post.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20160915/a4d05920/attachment.html>


More information about the Haskell-Cafe mailing list