bravit / hid-examples Goto Github PK
View Code? Open in Web Editor NEWExamples to accompany the book "Haskell in Depth"
License: BSD 3-Clause "New" or "Revised" License
Examples to accompany the book "Haskell in Depth"
License: BSD 3-Clause "New" or "Revised" License
When I do cabal build
, I get:
[tedkord@fedora hid-examples]$ cabal build
Resolving dependencies...
cabal: Could not resolve dependencies:
[__0] trying: hid-examples-0.5 (user goal)
[__1] rejecting: hid-examples:!test (constraint from config file, command line
flag, or user target requires opposite flag selection)
[__1] trying: hid-examples:*test
[__2] trying: doctest-0.18.1 (dependency of hid-examples *test)
[__3] trying: ghc-8.8.4/installed-8.8... (dependency of doctest)
[__4] trying: req-3.9.1 (dependency of hid-examples)
[__5] trying: transformers-base-0.4.6 (dependency of req)
[__6] trying: transformers-compat-0.7 (dependency of transformers-base)
[__7] trying: http-client-tls-0.3.5.3 (dependency of req)
[__8] trying: network-uri-2.6.4.1 (dependency of http-client-tls)
[__9] trying: parsec-3.1.14.0/installed-3.1... (dependency of network-uri)
[_10] trying: Chart-diagrams-1.9.3 (dependency of hid-examples)
[_11] trying: diagrams-postscript-1.5 (dependency of Chart-diagrams)
[_12] next goal: statestack (dependency of diagrams-postscript)
[_12] rejecting: statestack-0.3, statestack-0.2.0.5 (conflict:
transformers-compat==0.7, statestack => transformers-compat>=0.4 && <0.7)
[_12] rejecting: statestack-0.2.0.4, statestack-0.2.0.3 (conflict: ghc =>
transformers==0.5.6.2/installed-0.5..., statestack => transformers>=0.3 &&
<0.5)
[_12] rejecting: statestack-0.2 (conflict: parsec =>
mtl==2.2.2/installed-2.2..., statestack => mtl>=2.1 && <2.2)
[_12] rejecting: statestack-0.1.1, statestack-0.1 (conflict:
diagrams-postscript => statestack>=0.2 && <0.4)
[_12] fail (backjumping, conflict set: diagrams-postscript, ghc, parsec,
statestack, transformers-compat)
Backjump limit reached (currently 4000, change with --max-backjumps or try to
run with --reorder-goals).
With stack build
, these lines and others similar make the build fail:
Only > : error:
Only > Warning: Couldn't figure out linker information!
Only > Make sure you're using GNU ld, GNU gold or the built in OS X linker, etc.
Only > collect2: fatal error: cannot find ‘ld’
Only > compilation terminated.
Only >gcc' failed in phase
Linker'. (Exit code: 1)
My stack version is:
Version 2.7.3, Git revision 7927a3aec32e2b2e5e4fb5be76d0d50eddcc197f x86_64 hpack-0.34.4
and my cabal version is:
cabal-install version 3.0.0.0 compiled using version 3.0.1.0 of the Cabal library
Running stack build
I'm getting an error:
Downloaded lts-10.10 build plan.
AesonException "Error in $.packages.cassava.constraints.flags['bytestring--lt-0_10_4']: Invalid flag name: \"bytestring--lt-0_10_4\""
diagrams-lib > [36 of 73] Compiling Diagrams.Trail
diagrams-lib >
diagrams-lib > /tmp/stack-01e77da6031f7a18/diagrams-lib-1.4.4/src/Diagrams/Trail.hs:314:32: error:
diagrams-lib > • Couldn't match type ‘Option a0’ with ‘Maybe m’
diagrams-lib > Expected type: t -> Maybe m
diagrams-lib > Actual type: t -> Option a0
diagrams-lib > • In the second argument of ‘(.)’, namely ‘get . FT.measure’
diagrams-lib > In the expression: maybe d f . get . FT.measure
diagrams-lib > In an equation for ‘trailMeasure’:
diagrams-lib > trailMeasure d f = maybe d f . get . FT.measure
diagrams-lib > • Relevant bindings include
diagrams-lib > f :: m -> a (bound at src/Diagrams/Trail.hs:314:16)
diagrams-lib > trailMeasure :: a -> (m -> a) -> t -> a
diagrams-lib > (bound at src/Diagrams/Trail.hs:314:1)
diagrams-lib > |
diagrams-lib > 314 | trailMeasure d f = maybe d f . get . FT.measure
Hi, I'm having some problems with the latest version of the source code:
stack build
succeeds but it warns that "This package indirectly depends on multiple versions of the same package" (see attached build.txt).
Executables seem to run fine with stack exec
.
stack ghci [any file]
fails with the message cannot satisfy -package z-hid-examples-z-ipgen-lib
(see attached ghci.txt).
I am using homebrew stack version 1.9.3 x86_64. Thanks for any advice.
Readme file gives an example of running a program:
stack exec stockquotes -- data/quotes.csv -p -v
But if you do that you'll get:
stack exec stockquotes -- data/quotes.csv -p -v
Invalid option `-p'
Usage: stockquotes FILE [-n|--name ARG] [-c|--chart] [--html FILE] [-s|--silent]
Stock quotes data processing
Maybe it should be?
$ stack exec stockquotes -- data/quotes.csv -c
+-------------+-------------+----------+----------+----------------------+
| Quote Field | Mean | Min | Max | Days between Min/Max |
+-------------+-------------+----------+----------+----------------------+
| Open | 202.04 | 175.44 | 224.80 | 100 |
| Close | 202.16 | 173.30 | 223.59 | 100 |
| High | 204.10 | 177.92 | 226.42 | 101 |
| Low | 200.32 | 170.27 | 222.86 | 101 |
| Volume | 27869192.38 | 11362000 | 69281400 | 28 |
+-------------+-------------+----------+----------+----------------------+
stack exec stockquotes -- data/quotes.csv -c
$ file chart.svg
chart.svg: SVG Scalable Vector Graphics image
Same issue applies to the cabal example
Another problem:
$ cabal repl hello
...
$ cabal repl stockquotes
ghci> :load Statistics
Running it gives:
cabal repl stockquotes
Build profile: -w ghc-8.10.1 -O1
In order, the following will be built (use -v for more details):
- hid-examples-0.5 (exe:stockquotes) (ephemeral targets)
Preprocessing executable 'stockquotes' for hid-examples-0.5..
GHCi, version 8.10.1: https://www.haskell.org/ghc/ :? for help
[1 of 7] Compiling Params ( stockquotes/Params.hs, interpreted )
[2 of 7] Compiling Paths_hid_examples ( /Users/qnikst/workspace/hid-examples/dist-newstyle/build/x86_64-osx/ghc-8.10.1/hid-examples-0.5/x/stockquotes/build/stockquotes/autogen/Paths_hid_examples.hs, interpreted )
[3 of 7] Compiling QuoteData ( stockquotes/QuoteData.hs, interpreted )
[4 of 7] Compiling Charts ( stockquotes/Charts.hs, interpreted )
[5 of 7] Compiling StatReport ( stockquotes/StatReport.hs, interpreted )
[6 of 7] Compiling HtmlReport ( stockquotes/HtmlReport.hs, interpreted )
[7 of 7] Compiling Main ( stockquotes/Main.hs, interpreted )
Ok, 7 modules loaded.
*Charts> :l StatReport
*Charts> :load Statistics
<no location info>: error:
module ‘Statistics’ cannot be found locally
Failed, no modules loaded.
Prelude>
I expect that it should StatReport
there?
cabal test locator-test
cabal: Cannot run the package locator-test, it is not in this project (either
directly or indirectly). If you want to add it to the project then edit the
cabal.project file.
cabal -V
cabal-install version 3.0.0.0
compiled using version 3.0.0.0 of the Cabal library
stack build
command failed with the following message:
diagrams-lib > : can't load framework: Cocoa (not found)
I believe this has to do with the new macos version big sur.
I've read something about it here. https://gitlab.haskell.org/ghc/ghc/-/issues/18592
I've tried locally to update the resolver
(stack.yml) from lts-14.27
to newer ones (i.e: resolver: lts-16.31) but I started to stumble upon some issues with dependencies' versions.
I really like the book but I would like to run the examples on my machine. I am really interested in learning to develop production with haskell and this book looks like a good fit for my adventure.
Is there something I can do on my side?
Thanks
Info:
❯ stack exec -- which ghc
/Users/xxx/.stack/programs/x86_64-osx/ghc-8.6.5/bin/ghc
System Version: macOS 11.2.1 (20D74)
Kernel Version: Darwin 20.3.0
After cloning and cd-ing in the created directory, here the output I get when running "stack build"
HttpExceptionRequest Request {
host = "s3.amazonaws.com"
port = 443
secure = True
requestHeaders = [("User-Agent","Haskell pantry package")]
path = "/hackage.fpcomplete.com/package/streaming-utils-0.2.0.0.tar.gz"
queryString = ""
method = "GET"
proxy = Nothing
rawBody = False
redirectCount = 10
responseTimeout = ResponseTimeoutDefault
requestVersion = HTTP/1.1
}
ConnectionTimeout
Hey I'm just starting the book and getting my dev environment setup. I use NixOS even though I don't understand it very well and I probably have no business making demands about accommodating it. I just wanted to let you know that my experience so far has been discouraging:
$ stack build
error: attribute 'ghc8104' missing, at (string):1:43
Ok so I either need to figure out the nix-fu to get that older resolver installed, or I need to update stack.yml
to use my system GHC. I went for the later.
# stack.yaml
resolver:
compiler: ghc-8.10.7
nix:
enable: true
...
Ok, try again:
$ stack build
Error: While constructing the build plan, the following exceptions were encountered:
In the dependencies for Chart-diagrams-1.9.3:
Chart must match >=1.9 && <1.10, but the stack configuration has no specified version (latest matching version is 1.9.3)
blaze-markup must match >=0.7 && <0.9, but the stack configuration has no specified version (latest matching version is 0.8.2.8)
colour must match >=2.2.1 && <2.4, but the stack configuration has no specified version (latest matching version is 2.3.6)
data-default-class must match <0.2, but the stack configuration has no specified version (latest matching version is 0.1.2.0)
lens must match >=3.9 && <5.1, but the stack configuration has no specified version (latest matching version is 5.0.1)
old-locale needed, but the stack configuration has no specified version (latest matching version is 1.0.0.7)
operational must match >=0.2.2 && <0.3, but the stack configuration has no specified version (latest matching version is 0.2.4.1)
needed due to hid-examples-0.5 -> Chart-diagrams-1.9.3
< ... and a bunch of other redacted dependency issues ... >
My understanding is that stack has first-class support for nix, so I was hoping this would all just work out of the box. It seems that I could write some custom config for nix-shell
to ensure the correct environment, but that's beyond my abilities at this point.
Here's a recommended directory structure for managing multiple executables in a Stack project:
.
├── App1
│ ├── Main.hs
│ └── stack.yaml
├── App2
│ ├── Main.hs
│ └── stack.yaml
├── App3
│ ├── Main.hs
│ └── stack.yaml
└── stack.yaml
Each App# directory contains the Haskell source code and Stack configuration for a specific executable. This allows you to build and run each executable independently using the following commands:
stack build App1
stack build App2
stack build App3
You can also run each executable directly from the corresponding directory:
cd App1
stack exec Main
This approach promotes modularity and makes it easier to reuse code between different executables. You can also define shared libraries and dependencies using Stack's configuration files.
It ends with the error:
ld: file not found: /usr/lib/system/libcache.dylib for architecture x86_64
When I do "stack build", I get the following errors:
directory must match >=1.2 && <1.4, but this GHC boot package has been pruned (issue
#4510); you need to add the package explicitly to extra-deps (latest
matching version is 1.3.4.0)
process must match >=1.1.0.2 && <1.7, but this GHC boot package has been pruned
(issue #4510); you need to add the package explicitly to extra-deps (latest
matching version is 1.6.7.0)
Install & build fails.
PS C:\Users\guthrie\Desktop\hTest\hid-examples-0.5> cabal new-build
Resolving dependencies...
Build profile: -w ghc-8.10.2 -O1
In order, the following will be built (use -v for more details):
PS C:\Users\guthrie\Desktop\hTest\hid-examples-0.5> cabal run stockquotes -- data/quotes.csv -p -v
Build profile: -w ghc-8.10.2 -O1
...
Installing hsc2hs-0.68.8 (exe:hsc2hs)
Completed hsc2hs-0.68.8 (exe:hsc2hs)
cabal.exe: Failed to unpack microlens-0.4.12.0 (which is required by
exe:stockquotes from hid-examples-0.5). The exception was:
C:\Users\guthrie\Desktop\hTest\hid-examples-0.5\dist-newstyle\tmp\src-35411\microlens-0.4.12.0\micEC17.tmp:
renameFile:renamePath:MoveFileEx
"\\?\C:\Users\guthrie\Desktop\hTest\hid-examples-0.5\dist-newstyle\tmp\src-35411\microlens-0.4.12.0\micEC17.tmp"
Just
"\\?\C:\Users\guthrie\Desktop\hTest\hid-examples-0.5\dist-newstyle\tmp\src-35411\microlens-0.4.12.0\microlens.cabal":
permission denied (Access is denied.)
Full Details::
PS C:\Users\guthrie\Desktop\hTest\hid-examples-0.5> cabal new-build
Resolving dependencies...
Build profile: -w ghc-8.10.2 -O1
In order, the following will be built (use -v for more details):
PS C:\Users\guthrie\Desktop\hTest\hid-examples-0.5>
PS C:\Users\guthrie\Desktop\hTest\hid-examples-0.5>
PS C:\Users\guthrie\Desktop\hTest\hid-examples-0.5> cabal run stockquotes -- data/quotes.csv -p -v
Build profile: -w ghc-8.10.2 -O1
In order, the following will be built (use -v for more details):
I cannot properly run the course package with stack
(as per comment on #2) or with cabal
. It seems my version of base
is incompatible with the ones accepted by hid-examples
.
➜ hid-examples-0.4 cabal new-configure
Resolving dependencies...
cabal: Could not resolve dependencies:
[__0] trying: hid-examples-0.4 (user goal)
[__1] next goal: base (dependency of hid-examples)
[__1] rejecting: base-4.9.1.0/installed-4.9... (conflict: hid-examples =>
base>=4.10 && <4.13)
[__1] rejecting: base-4.12.0.0, base-4.11.1.0, base-4.11.0.0, base-4.10.1.0,
base-4.10.0.0, base-4.9.1.0, base-4.9.0.0, base-4.8.2.0, base-4.8.1.0,
base-4.8.0.0, base-4.7.0.2, base-4.7.0.1, base-4.7.0.0, base-4.6.0.1,
base-4.6.0.0, base-4.5.1.0, base-4.5.0.0, base-4.4.1.0, base-4.4.0.0,
base-4.3.1.0, base-4.3.0.0, base-4.2.0.2, base-4.2.0.1, base-4.2.0.0,
base-4.1.0.0, base-4.0.0.0, base-3.0.3.2, base-3.0.3.1 (constraint from
non-upgradeable package requires installed instance)
[__1] fail (backjumping, conflict set: base, hid-examples)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: base, hid-examples
My GHC version is 8.0.2. I am not sure where this comes from, I think it is from the Ubuntu 18.04 version of the cabal-install
package.
What should I do? Can I use cabal
to get a new ghc
version? Which one should I get? Would that replace the one I currently have, or live alongside it creating conflicts?
Trying to build: $ stack build
Error: [S-7282]
Stack failed to execute the build plan.
While executing the build plan, Stack encountered the following errors:
[S-7011]
While building package streaming-utils-0.2.1.0 (scroll up to its section
to see the error) using:
/home/xodiqus/.stack/setup-exe-cache/x86_64-linux-tinfo6/Cabal-simple_SvXsv1f__3.2.1.0_ghc-8.10.7 --verbose=1 --builddir=.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.2.1.0 configure --with-ghc=/home/xodiqus/.stack/programs/x86_64-linux/ghc-tinfo6-8.10.7/bin/ghc-8.10.7 --with-ghc-pkg=/home/xodiqus/.stack/programs/x86_64-linux/ghc-tinfo6-8.10.7/bin/ghc-pkg-8.10.7 --user --package-db=clear --package-db=global --package-db=/home/xodiqus/.stack/snapshots/x86_64-linux-tinfo6/643cd9fed3fa515e293793015f5dec796a167f11c8c345f1bf81c2662ed90b39/8.10.7/pkgdb --libdir=/home/xodiqus/.stack/snapshots/x86_64-linux-tinfo6/643cd9fed3fa515e293793015f5dec796a167f11c8c345f1bf81c2662ed90b39/8.10.7/lib --bindir=/home/xodiqus/.stack/snapshots/x86_64-linux-tinfo6/643cd9fed3fa515e293793015f5dec796a167f11c8c345f1bf81c2662ed90b39/8.10.7/bin --datadir=/home/xodiqus/.stack/snapshots/x86_64-linux-tinfo6/643cd9fed3fa515e293793015f5dec796a167f11c8c345f1bf81c2662ed90b39/8.10.7/share --libexecdir=/home/xodiqus/.stack/snapshots/x86_64-linux-tinfo6/643cd9fed3fa515e293793015f5dec796a167f11c8c345f1bf81c2662ed90b39/8.10.7/libexec --sysconfdir=/home/xodiqus/.stack/snapshots/x86_64-linux-tinfo6/643cd9fed3fa515e293793015f5dec796a167f11c8c345f1bf81c2662ed90b39/8.10.7/etc --docdir=/home/xodiqus/.stack/snapshots/x86_64-linux-tinfo6/643cd9fed3fa515e293793015f5dec796a167f11c8c345f1bf81c2662ed90b39/8.10.7/doc/streaming-utils-0.2.1.0 --htmldir=/home/xodiqus/.stack/snapshots/x86_64-linux-tinfo6/643cd9fed3fa515e293793015f5dec796a167f11c8c345f1bf81c2662ed90b39/8.10.7/doc/streaming-utils-0.2.1.0 --haddockdir=/home/xodiqus/.stack/snapshots/x86_64-linux-tinfo6/643cd9fed3fa515e293793015f5dec796a167f11c8c345f1bf81c2662ed90b39/8.10.7/doc/streaming-utils-0.2.1.0 --dependency=aeson=aeson-1.5.6.0-DkwLMaMFAoKEbTeMR8x6ex --dependency=attoparsec=attoparsec-0.13.2.5-8izDPW0DwnMA1uBRNCYnOn --dependency=base=base-4.14.3.0 --dependency=bytestring=bytestring-0.10.12.0 --dependency=http-client=http-client-0.6.4.1-L2WcCX1S6G93IdjWhCRWqB --dependency=http-client-tls=http-client-tls-0.3.5.3-HTIy4TwCUHGEAIs303kndw --dependency=json-stream=json-stream-0.4.2.4-GP7H9k6ydGpFhkWpAV7fhV --dependency=mtl=mtl-2.2.2 --dependency=network=network-3.1.1.1-3xFSBe7XCrO7SWRn35NgL3 --dependency=network-simple=network-simple-0.4.5-H8Jo56Izwck74qgHRp8fkL --dependency=pipes=pipes-4.3.16-Ae9yuHIGpRS6XXQM8QsguE --dependency=resourcet=resourcet-1.2.4.3-EZpbKEiS8a8G4IXFok6D1M --dependency=streaming=streaming-0.2.3.1-CtrX5s6nvJ7aJwf6Heg8A --dependency=streaming-bytestring=streaming-bytestring-0.2.1-I9SmIejUQYt8JNbBT9Ypd9 --dependency=streaming-commons=streaming-commons-0.2.2.3-AQIpgNlfUfQ17AfvJCMo3o --dependency=transformers=transformers-0.5.6.2 --exact-configuration --ghc-option=-fhide-source-paths
Process exited with code: ExitFailure 1
What am I doing wrong? Thanks for any help.
Stack: Version 2.9.3, Git revision 6cf638947a863f49857f9cfbf72a38a48b183e7e x86_64 hpack-0.35.1
Ubuntu: 22.04.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.