Code Monkey home page Code Monkey logo

purescript-effect's Introduction

PureScript

A small strongly typed programming language with expressive types that compiles to JavaScript, written in and inspired by Haskell.

Hackage Build Status

Language info

Resources

Help!

Community Spaces

The following spaces are governed by the PureScript Community Code of Conduct. The majority of PureScript users use these spaces to discuss and collaborate on PureScript-related topics:

Unaffiliated Spaces

Some PureScript users also collaborate in the below spaces. These do not fall under the code of conduct linked above. They may have no code of conduct or one very different than the one linked above.

purescript-effect's People

Contributors

garyb avatar hdgarrood avatar jordanmartinez avatar kl0tl avatar kritzcreek avatar liamgoodacre avatar masaeedu avatar matthewleon avatar mhmdanas avatar milesfrain avatar paf31 avatar paldepind avatar thomashoneyman avatar xuwei-k avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

purescript-effect's Issues

Can we document Effect?

Great work in getting so many libraries updated for 0.12.

The link in Effect.purs to

See [Handling Native Effects with the Effect Monad](http://www.purescript.org/learn/eff/)

is broken. I imagine because no-one's yet had time to do the documentation. But I think it's quite important to do this quite soon after the release - it's a major change.

Mistake in the example?

Hi, looking at the example on the README:

// Counter.js
exports.incrCounter = function() {
  if (!window.globalCounter) {
    window.globalCounter = 0;
  }
  return ++window.globalCounter;
}

and then looking at the implementation of pure, shouldn't incrCounter be thunked?:

// Counter.js
exports.incrCounter = function() {
  return function() {
    if (!window.globalCounter) {
      window.globalCounter = 0;
    }
    return ++window.globalCounter;
  }
}

I'm trying to figure out how Effect works, so my apologies in advance if this It's just me not understanding properly.

Re-export `liftEffect`

liftEffect is commonly used, I believe it would be better to re-export it from Effect.Class in Effect module, instead of having to type this:

import Effect (Effect)
import Effect.Class (liftEffect)

Effect.Uncurried documentation incorrect?

From the docs:

EffectFn{N} means, a curried function which accepts N arguments and performs some effects. The first type argument is the row of effects, which works exactly the same way as in Effect. The last type argument is the return type. All other arguments are the actual function's arguments.

This seems like it was copied over from Eff without regard to the removal of effect rows.

Furthermore, the number of arguments seems somehow incorrect:

data EffectFn1 :: Type -> Type -> Type

I would expect one fewer type argument per EffectFn function. The function above takes two arguments, not one.

While this could be addressed by a documentation change, this leaves the EffectFns not matching their corresponding Fns from purescript-functions.

Add a way to defer an effect

Due to strict evaluation, if a function takes an Effect a as an argument, it's often desirable to defer evaluation under a lambda literal, particularly if there are non-trivial let bindings.

example = doThis do
  let foo = ...
  let bar = ...
  doThat foo bar

This will likely evaluate foo/bar in the process of allocating the effect. If there was a Lazy instance, one could do:

example = doThis $ defer \_ -> do
  let foo = ...
  let bar = ...
  doThat foo bar

Definitely deferring evaluation of foo/bar until the effect is actually invoked. We can't implement an instance for Lazy (control depends on effect), and this module doesn't export this as a primitive so the implementation would need to rely on unsafeCoerce.

Proposed implementation:

foreign import defer :: forall a. (Unit -> Effect a) -> Effect a
exports.defer = function(k) {
  return function() {
    return k()();
  };
};

Should we reduce the namespace back to just `Effect`?

There has been discussion a few times of whether Data, Control, and so on is actually a useful way of grouping stuff, plus ideas about flattening the namespace a bit to match namespace with library names to try and prevent namespace collisions.

Since this is a new library, and will be introduced into the usage of the core libraries soon, it might be time to consider making the change now? Also relevant comment here: purescript/purescript-exceptions#26 (comment)

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.