purescript-spec/purescript-spec

Example in documentation does not compile

Closed this issue · 5 comments

thurn commented

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 commented

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

thurn commented

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?

thurn commented

This is v3.1.0.