Example in documentation does not compile
Closed this issue · 5 comments
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
I believe the correct example would just be to not launchAff_
? It looks like that works.
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
Which version of purescript-spec are you running?
This is v3.1.0.
recent version is v4.0.0-rc1
https://github.com/purescript-spec/purescript-spec/blob/v4.0.0-rc1/src/Test/Spec/Runner.purs#L192-L198
in v3.1.0
, run
returns Effect so no need for launchAff_ https://github.com/purescript-spec/purescript-spec/blob/v3.1.0/src/Test/Spec/Runner.purs#L173-L177