Coder Social home page Coder Social logo

fp-course's Issues

`make test-ghci` errors.

$ 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

Test for List Applicative instance is ambigious

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).

`stack test` and `make test` should only run HSpec

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.

Incremental development workflow

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/

State.distinct and Applicative.filtering

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...

Pin nixpkgs

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:

image

And this may be related to the failure: ghc802 not found in my system's nixpkgs?

https://nix.dev/tutorials/towards-reproducibility-pinning-nixpkgs

Weird pattern matching type error.

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.