Questions tagged [purescript]

PureScript is a functional language with strong, static types which compiles to JavaScript.

PureScript is a small strongly, statically typed programming language with expressive types, written in and inspired by , and compiling to .

PureScript has a number of interesting features, such as:

  • Type Inference
  • Higher Kinded Polymorphism
  • Support for basic Javascript types
  • Extensible records
  • Extensible effects
  • Optimizer rules for generation of efficient Javascript
  • Pattern matching
  • Simple FFI
  • Modules
  • Rank N Types
  • Do Notation
  • Tail-call elimination
  • Type Classes

Sample "Hello word" :

import Control.Monad.Eff.Console

main = do
    log "Hello, PureScript"

Would be compiled into:

var Control_Monad_Eff_Console = require("Control.Monad.Eff.Console");
var main = Control_Monad_Eff_Console.log("Hello sailor!");
module.exports = {
    main: main
};

References:

591 questions
0
votes
1 answer

Coerce Eff or Aff to a satisfy a function expecting a larger set of effects

I have an effectful asynchronous action with a type, let's say, effectful :: Aff e r I would like to build an action that takes some asynchronous action and sends the result to a Channel from purescript-signal. The send function has the…
Koterpillar
  • 7,883
  • 2
  • 25
  • 41
0
votes
1 answer

How to use `elemIndex` from Data.List on Strings in PureScript?

The problem I am trying to solve looks like this, take an address string: "Street, City, State" and split it into ["Street", "City", "State"], in order to do this I am trying to use elemIndex like: elemIndex "," "a, b, c" but I realize that this…
vamsiampolu
  • 6,328
  • 19
  • 82
  • 183
0
votes
1 answer

How do I use foldrDefault and foldlDefault with my foldMap?

I'm trying to complete Exercise 5 from section 6.7 of Phil Freeman's PureScript book. The exercise wants me to write a Foldable instance for the following type. data NonEmpty a = NonEmpty a (Array a) I've written this instance by implementing…
imperfectgrist
  • 621
  • 4
  • 20
0
votes
1 answer

Parentheses change code execution

I'm trying to attempt an Aff computation. Consider the following code: result <- pool # withPool \connection -> do execute_ ("insert into user (email, password) values ('" <> unwrap userInfo.email <> "', '" <> unwrap…
bklaric
  • 447
  • 6
  • 15
0
votes
1 answer

Accessing the row variable within the function

My understanding of row polymorphism in ML is that we can access the row variable within the function. fun f {x : real, y : real, R} = {x = 2 * x, y = 2 * y, R}; => (* f : {x : real, y : real, _ : ..a} -> {x : real, y : real, _ : ..a} *) f {x =…
RAbraham
  • 5,956
  • 8
  • 45
  • 80
0
votes
1 answer

Verbatim strings in PureScript

Does PureScript support verbatim string literals? Something like @"regex \s no escapes" in C#. Alternatively is there support for regex literals as in JavaScript?
bklaric
  • 447
  • 6
  • 15
0
votes
1 answer

How To Know Whether a mouse moved left or right

I am new to Purescript and currently working with Mouse Events. I would like to know how to identify when the mouse moved left and when the mouse moved right and what Events it would generate.
0
votes
1 answer

Difference Between MouseEvents

I am new to Purescript. I am working with MouseEvents from "import DOM.HTML.Event.EventTypes" and I couldn't understand the difference between Mouseup, Mousedown,Mouseout and Mouseleave. I searched for documentation but couldn't find an…
0
votes
1 answer

How to implement a path with more than one subdomain using Pux.Router?

I'm using Pux.Router and can't get a path such as auth/facebook to work. auth works and facebook works but not together. For example FacebookAuth <$> (lit "facebook" *> param "access_token") <*> (param "expires_in") <* end works but not FacebookAuth…
torchhound
  • 510
  • 6
  • 15
0
votes
1 answer

How to create a stateless and static Halogen component?

Consider this snippet from github, https://github.com/slamdata/purescript-halogen/blob/master/examples/basic/src/Button.purs#L42 which tries to render an html button using halogen library. render :: State -> H.ComponentHTML Query render state = …
mithocondria
  • 101
  • 4
0
votes
2 answers

How to find appropriate functions for PureScript?

PureScript have lots of functions available like filter lenth and more. But how can we find the function that we need and its examples with implementation? I am facing problem solving exercises of the book purescript by examples. Any tips how show I…
Stif Spear Subba
  • 55
  • 1
  • 1
  • 10
0
votes
1 answer

Running untrusted PureScript code

Is it possible to use PureScript to safely* run untrusted user-submitted code? Is it possible to reliably enforce purity and other constraints using the type system (like in Safe Haskell)? In other words, is it possible to use PureScript to…
0
votes
1 answer

(PureScript) How to create a Union of two separately defined rows of effects

I'm essentially needing to know how to write a function like this... joinCommands :: forall e1 e2 e3 . Union e1 e2 e3 => Eff e1 Unit -> Eff e2 Unit -> Eff e3 Unit joinCommands fn1 fn2 = do fn1 fn2 Which doesn't work. I get this…
Albtzrly
  • 924
  • 1
  • 6
  • 15
0
votes
1 answer

How to express typeclass that has a function returning a value of the same typeclass

I have the following purescript code: class Node a where parentNode :: forall b. (Node b) => a -> b but when compiling this I get the following error: A cycle appears in the definition of type synonym Node Cycles are disallowed because they can…
Rouan van Dalen
  • 748
  • 4
  • 14
0
votes
1 answer

purescript-argonaut-generic gDecodeJson: 'tag' property is missing"

I'm learning Argonaut and I'm able to decode json manually: foo = """{"f":"xxx"}""" newtype Foo = Foo { f :: String } derive instance genericFoo :: Generic Foo instance decodeJsonFoo :: DecodeJson Foo where decodeJson json = do obj <-…
pt2121
  • 11,720
  • 8
  • 52
  • 69