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
8
votes
1 answer

forall notation: what does the period / dot mean?

What does the period / dot mean? forall a. Num a => a -> a -> a Is it merely a separator?
M. Walker
  • 603
  • 4
  • 14
8
votes
2 answers

Purescript default `Show` instance for records

I saw this question: Force show a record in PureScript where I found out I can use purescript-debug to print it, e.g. by using: > traceAny {a:1} id { a: 1 } unit I was wondering however what is the rationale behind not having a default Show…
levant pied
  • 3,886
  • 5
  • 37
  • 56
8
votes
2 answers

Does PureScript have a pipe operator?

Coming from the F# world, I am used to using |> to pipe data into functions: [1..10] |> List.filter (fun n -> n % 2 = 0) |> List.map (fun n -> n * n); I assume that PureScript, being inspired by Haskell, has something similar. How do I use the…
sdgfsdh
  • 33,689
  • 26
  • 132
  • 245
8
votes
1 answer

PureScript Halogen and websockets

I'm trying to use purescript-halogen in combination with websockets, but after several attempts I'm unable to make them work together. I've seen this question on Thermite and websockets and Phil's answer regarding the Driver function. Halogen also…
user742071
7
votes
2 answers

How to get to inner Maybe monad to extract class name from html button in purescript?

I am attempting to learn purescript. I have a button in some HTML that I am trying to print the class name of. I am building and browserifying using pulp. The function I am using is querySelector: import Web.DOM.ParentNode (querySelector) This…
vt5491
  • 2,254
  • 2
  • 22
  • 34
7
votes
3 answers

ProcessReleaseResources

I am trying to build my react-native project and using react-native-fbsdk. I am using react-native@0.38.0 and, react-native-fbsdk@0.5.0. When I build my project I got this error on execution screen. **Execution failed for task**…
7
votes
1 answer

PureScript and typeclasses

I'm having trouble with PureScript typeclasses. I have to say, up front, that I'm not a Haskell expert either so my apologies if these are obvious errors. I've tried several different approaches and hit a wall for each. I'm basically trying to…
Michael Tiller
  • 9,291
  • 3
  • 26
  • 41
6
votes
2 answers

Purescript Union of Rows

I've been trying to develop a component system in Purescript, using a Component typeclass which specifies an eval function. The eval function for can be recursively called by a component for each sub-component of the component, in essence fetching…
Joseph Young
  • 2,758
  • 12
  • 23
6
votes
1 answer

PureScript UI Library for production

There are several UI libraries for the PureScript, such as purescript-thermite, purescript-halogen, purescript-react-simple and other. Which library is right for the production?
QSpider
  • 537
  • 2
  • 10
6
votes
1 answer

PureScript - Pattern match arrays of unknown length

Is there a way to pattern match arrays of an unknown length in PureScript? As an example, here's how I would do it with a List in Haskell: addFirstTwo :: (Num a) => [a] -> a addFirstTwo (x:y:_) = x + y I tried something similar (using Array a…
at.
  • 50,922
  • 104
  • 292
  • 461
6
votes
1 answer

converting from Purescript Record to a JS object

I am trying to convert a Record to a vanilla JS object module MyModule where data Author = Author { name :: String, interests :: Array String } phil :: Author phil = Author { name: "Phil", interests: ["Functional Programming", "JavaScript"]…
Tim Fairbrother
  • 928
  • 2
  • 9
  • 20
6
votes
1 answer

Does PureScript support “format strings” like C / Java etc.?

I need to output a number with leading zeros and as six digits. In C or Java I would use "%06d" as a format string to do this. Does PureScript support format strings? Or how would I achieve this?
0dB
  • 675
  • 5
  • 13
6
votes
1 answer

How to update PureScript record defined with `data` instead of `type`?

Updating a record defined with type works, as explained over at Differences from Haskell type PointRec = { x :: Number, y :: Number } setX :: Number -> PointRec -> PointRec setX val point = point { x = val } but when defined with data (and thus…
0dB
  • 675
  • 5
  • 13
6
votes
1 answer

What does >>= mean in purescript?

I was reading the purescript wiki and found following section which explains do in terms of >>=. What does >>= mean? Do notation The do keyword introduces simple syntactic sugar for monadic expressions. Here is an example, using the monad for…
Nigel Thorne
  • 21,158
  • 3
  • 35
  • 51
6
votes
2 answers

How do I convert a list of chars to a string in purescript

I'm looking for an idiomatic way to write a function List Char -> String in Purescript. This seems like a simple thing to do, but I'm new to Purescript and have been browsing documentation for a while now with no progress! Background information: I…
Anupam Jain
  • 7,851
  • 2
  • 39
  • 74
1
2
3
39 40