Skip to content

Can't find variable: EMPTY #4

@dgendill

Description

@dgendill

I'm not sure if this issue should go into purescript-aff or this repo, but when I use purescript-aff#4.0.0 and use the makeVar function, the Control.Monad.Eff.AVar module is missing the EMPTY variable in the compiled JavaScript. I think these steps can reproduce the issue. Here's a sample module...

module Test.Main where

import Prelude

import Control.Monad.Aff (message, runAff_)
import Control.Monad.Aff.AVar (makeEmptyVar, makeVar)
import Control.Monad.Eff.Console (log)
import Control.Monad.Eff.Exception (stack)
import Data.Either (Either(..))

main = runAff_ (case _ of
    Left err -> do
      log $ "ERROR: " <> message err
      log $ show (stack err)
    Right r -> log "OK"
  ) $ do
    a <- makeVar "s"
    pure unit

If you compile using pulp build --main Test.Main --to test.js, the resulting test.js has this compiled Control.Monad.Eff.AVar module.

(function(exports) {
  /* globals exports, setTimeout */
  /* jshint -W097 */
  "use strict";

  // ...

  function drainVar (util, avar) {

    // ...

    if (value === EMPTY && (p = takeHead(ps))) {
      avar.value = value = p.value;
    }
  }
  // ...
})(PS["Control.Monad.Eff.AVar"] = PS["Control.Monad.Eff.AVar"] || {});

However, if I substitute makeEmptyVar for makeVar, then I get this output...

(function(exports) {
  /* globals exports, setTimeout */
  /* jshint -W097 */

  "use strict";

  var EMPTY = {};
  // ...

I'm using compile 0.11.6.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions