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

Foldable for Tree type, "value of instance is undefined here, so this reference is not allowed"

After defining the following simple tree structure data Tree a = Leaf | Branch (Tree a) a (Tree a) I tried defining a Foldable instance for it, only defining foldMap and using the foldrDefault and foldlDefault functions: instance…
5
votes
2 answers

how to componentize purescript-halogen application

I would like to write specific components of my frontend using Purescript's Halogen. For example, I would like to create a registration form using Halogen. It would look something like below: module RegistrationForm where import Prelude ... -- |…
illabout
  • 3,517
  • 1
  • 18
  • 39
5
votes
1 answer

Mutating state in Purescript

I am just starting to learn Purescript so I hope that this is not a stupid question. Suppose that we have an object a = {x:1,y:2} an we want to change x to equal 2. As far as I can see if we use the ST monad we will have to copy the whole object in…
Tzanko Matev
  • 259
  • 1
  • 5
5
votes
1 answer

Whats the right way to handle (deeply nested) functors?

I have the following simple code import Data.String.Regex import Data.Array last <$> match someRegex " 1" where match someRegex " 1" returns something like Just ([Just (" 1"),Just (" "),Just ("1")]) and last <$> match someRegex " …
robkuz
  • 9,488
  • 5
  • 29
  • 50
5
votes
2 answers

How to structure app in purescript

I've decided to try functional programming and Purescript. After reading "Learn you a Haskell for great good" and "PureScript by Example" and playing with code a little I think that I can say that I understand the basics, but one thing bothers me a…
starper
  • 175
  • 1
  • 8
5
votes
1 answer

Records in PureScript

I don't quite understand why this works: module Records where type Element e = { element :: String, label :: String | e } type Sel = ( value :: Number, values :: [Number] ) type Select = Element Sel while this says Cannot unify # * with *. module…
Archaeron
  • 767
  • 1
  • 7
  • 15
5
votes
1 answer

Eff monad demands row with Debug.Trace.Trace

I am writing bindings from History.js into PureScript and still struggling to understand the Eff monad, what a row of effects are and why they are valuable. Right now I have the following written with EasyFFI type Title = String type Url …
Fresheyeball
  • 29,567
  • 20
  • 102
  • 164
4
votes
4 answers

Mapping functions over data in 'sum-types' in strongly typed programming languages

Today I encountered an implementation challenge with a large DU (sum-type) in F#, where I basically wanted to be able to map a set of functions over the values of the DU without having to repeat the matched case on the right hand side. The…
Michelrandahl
  • 3,365
  • 2
  • 26
  • 41
4
votes
1 answer

SProxy in purescript?

What's the use of Sproxy in purescript? In Pursuit, it's written as data SProxy (sym :: Symbol) --| A value-level proxy for a type-level symbol. and what is meant by Symbol in purescipt?
Saravanan
  • 566
  • 5
  • 13
4
votes
1 answer

New Google sign-in button (GSI) doesn't render dynamically

I'm trying to integrate the new Google sign in button via HTML ( https://developers.google.com/identity/gsi/web/guides/display-button#button_rendering ) into an SPA. The
s with the app details and the one containing the button itself…
4
votes
1 answer

Why does type class coverage condition fail in Haskell but not PureScript

I have two implementations of what I believe to be equivalent type class and instance definitions. The PureScript version builds without error but the Haskell version fails with the error Un-determined variables: e, f. Can I make this work in…
tom
  • 85
  • 4
4
votes
2 answers

How to debug with PureScript?

Issue Following is a minimal, contrived example: read :: FilePath -> Aff String read f = do log ("File: " <> f) -- (1) readTextFile UTF8 f -- (2) I would like to do some debug logging in (1), before a potential error on (2) occurs. Executing…
4
votes
1 answer

Applicative functors and records in purescript

In Haskell, I'm used to doing stuff like this. data Foo = Foo { foo :: String, bar :: String } mFoo :: (Monad m) => m String -> m String -> m Foo mFoo foo bar = Foo <$> foo <*> bar The same does not work in purescript, however. Is there a way to…
Mike
  • 716
  • 4
  • 10
4
votes
1 answer

How do you install a specific package version with Spago?

With tools like npm we can install a specific version npm install foo@1.2.0 How do you install a specific version using spago install?
4
votes
1 answer

How to partially update a purescript record

everyone! I'm a Purescript beginner and have trouble with working on records. I have one record type: type Employee = { firstName :: String , lastName :: String , address :: String , height :: Number , weight :: Number ... } And I want to…
Niko Modric
  • 635
  • 4
  • 13