bitemyapp / fp-course Goto Github PK
View Code? Open in Web Editor NEWFork of the original Data61 course to be more Stack friendly
Fork of the original Data61 course to be more Stack friendly
The test suite for Applicative.hs accepts the following code:
(<*>) (f :. fs) xs = (f <$> xs) ++ (fs <*> xs)
(<*>) _ _ = Nil
and rejects the following code:
(<*>) (f :. fs) (x :. xs) = (f x) :. (fs <*> xs)
(<*>) _ _ = Nil
I'm under the impression that these are both valid applicative instances (I think the second one is essentially the ZipList applicative instance, but I'm not actually sure).
If so, it might be useful to somehow alert the students that, while the second instance is valid, they should search for an entirely different instance (and not stare at that one and try to get it to work).
In my setup: when using make test-ghci
module reloading (:r
) doesn't necessarily reload the source files under the /src
directory. It seems like it only considers the /test
directory as interpreted. So if I change a code in src/Course/Functor.hs
and run :r
in the test ghci session, it doesn't reload the newly modified Functor.hs
file.
However, running the following command works as expected.
$ stack exec ghci -- -isrc -itest test/Spec.hs
λ: :main --match=Course.Functor/
λ: -- modify src/Course/Functor.hs
λ: :r
λ: :main --match=Course.Functor/
Use of arbitrary is pretty minimal so it shouldn't be that hard.
Does the network project work in this fork?
I am using intero
with following GHC version.
$ stack ghc -- --version
The Glorious Glasgow Haskell Compilation System, version 8.0.2
While solving FileIO.hs
the following main
implementation gives a weird error.
main ::
IO ()
main = do
(fp :. _) <- getArgs
run fp
[-Wdeferred-type-errors]
• Couldn't match type ‘[Char]’ with ‘List Char’
Expected type: Chars
Actual type: [Char]
• In a stmt of a 'do' block: (fp :. _) <- getArgs
In the expression:
do { (fp :. _) <- getArgs;
run fp }
In an equation for ‘main’:
main
= do { (fp :. _) <- getArgs;
run fp }
While the following implementation works.
main ::
IO ()
main = do
args <- getArgs
case args of
Nil -> return ()
(fp :. _) -> run fp
Why in the first implementation GHC infers getArgs
as IO [Char]
. It is not just intero
, stack ghci
also yields the same error. NoImplicitPrelude
seems to be enabled by default.
stack
version is 1.7.1
.
per @parsonsmatt
The only tricky thing we might want to do is make stack test only run the hspec tests, and not the doctest test suite. Or maybe the doctests can just be an executable that we build and run in CI
We should continue to run the doctests in CI but doctests should get flagged out of getting run by default by stack test
unless explicitly asked for.
The comments suggest writing distinct
based on filtering
. However, the only filtering
available comes from the Applicative interface, which cannot thread state. Possible ways of addressing it would be to add a filterM :: Monad f => (a -> f Bool) -> List a -> f (List a)
to Monad.hs and use it instead of filtering
, or drop the suggestion from the distinct
comment. Or maybe I am missing something...
I'm on Nixos, when I try to run $ make ghci
it fails with the following message
STACK_YAML="stack.yaml" stack ghci course:lib
Getting project config file from STACK_YAML environment
error: attribute 'ghc802' missing, at (string):1:43
(use '--show-trace' to show detailed location information)
make: *** [Makefile:22: ghci] Error 1
I was looking at the source code and I found you are using an impure version of nixpkgs here:
And this may be related to the failure: ghc802 not found in my system's nixpkgs?
https://nix.dev/tutorials/towards-reproducibility-pinning-nixpkgs
$ make test-ghci
STACK_YAML="stack.yaml" stack ghci course:test:course-tests
Getting project config file from STACK_YAML environment
Using main module: 1. Package `course' component course:test:course-tests with main-is file: /Users/xxx/gits/fp-course/test/Spec.hs
The following GHC options are incompatible with GHCi and have not been passed to it: -threaded
Configuring GHCi with the following packages: course
GHCi, version 8.0.2: http://www.haskell.org/ghc/ :? for help
<command line>: can't load .so/.DLL for: /Users/xxx/.stack/snapshots/x86_64-osx/e5555a29f16b11d36296dadc4046142ee96805049489014717b4b47dc561d5c1/8.0.2/lib/x86_64-osx-ghc-8.0.2/libHSsetenv-0.1.1.3-8dEhk6JWvlmCmVyBammSpu-ghc8.0.2.dylib (dlopen(/Users/xxx/.stack/snapshots/x86_64-osx/e5555a29f16b11d36296dadc4046142ee96805049489014717b4b47dc561d5c1/8.0.2/lib/x86_64-osx-ghc-8.0.2/libHSsetenv-0.1.1.3-8dEhk6JWvlmCmVyBammSpu-ghc8.0.2.dylib, 5): REBASE_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB has segment 2 which is not a writable segment (__LINKEDIT) in /Users/xxx/.stack/snapshots/x86_64-osx/e5555a29f16b11d36296dadc4046142ee96805049489014717b4b47dc561d5c1/8.0.2/lib/x86_64-osx-ghc-8.0.2/libHSsetenv-0.1.1.3-8dEhk6JWvlmCmVyBammSpu-ghc8.0.2.dylib)
make: *** [test-ghci] Error 1
Line 319 of List.hs
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.