Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example in documentation does not compile #89

Closed
thurn opened this issue May 8, 2019 · 5 comments

Comments

Projects
None yet
2 participants
@thurn
Copy link

commented May 8, 2019

Hi, I attempted to copy and paste the example from the purescript-spec documentation and run it under PureScript 0.12.5, but the code does not compile. Here is the error:

Error found:
in module Main
at src/Main.purs:35:8 - 49:51 (line 35, column 8 - line 49, column 51)

  Could not match type

    Effect

  with type

    Aff

while trying to match type Effect Unit
  with type Aff t0
while checking that expression (run [ consoleReporter
                                    ]
                               )
                               ((describe "purescript-spec") ((discard (...)) (\$__unused ->
                                                                                 ...
                                                                              )
                                                             )
                               )
  has type Aff t0
in value declaration main

where t0 is an unknown type

See https://github.com/purescript/documentation/blob/master/errors/TypesDoNotUnify.md for more information,
or to contribute content related to this error.

This is for the code here: https://purescript-spec.github.io/purescript-spec/#full-example, i.e.

module Main where

import Prelude

import Data.Time.Duration (Milliseconds(..))
import Effect (Effect)
import Effect.Aff (launchAff_, delay)
import Test.Spec (pending, describe, it)
import Test.Spec.Assertions (shouldEqual)
import Test.Spec.Reporter.Console (consoleReporter)
import Test.Spec.Runner (run)

main :: Effect Unit
main = launchAff_ $ run [consoleReporter] do
  describe "purescript-spec" do
    describe "Attributes" do
      it "awesome" do
        let isAwesome = true
        isAwesome `shouldEqual` true
      pending "feature complete"
    describe "Features" do
      it "runs in NodeJS" $ pure unit
      it "runs in the browser" $ pure unit
      it "supports streaming reporters" $ pure unit
      it "supports async specs" do
        res <- delay (Milliseconds 100.0) $> "Alligator"
        res `shouldEqual` "Alligator"
      it "is PureScript 0.12.x compatible" $ pure unit
@thurn

This comment has been minimized.

Copy link
Author

commented May 8, 2019

I believe the correct example would just be to not launchAff_? It looks like that works.

@thurn

This comment has been minimized.

Copy link
Author

commented May 8, 2019

Also, this example:

it "adds 1 and 1" do
  1 + 1 `shouldEqual` 2

Is missing parentheses, because shouldEqual has higher precedence than +. It should probably be:

it "adds 1 and 1" do
  (1 + 1) `shouldEqual` 2
@safareli

This comment has been minimized.

Copy link
Member

commented May 10, 2019

Which version of purescript-spec are you running?

@thurn

This comment has been minimized.

Copy link
Author

commented May 11, 2019

This is v3.1.0.

@safareli

This comment has been minimized.

@safareli safareli closed this May 13, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.