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
2 answers

How to export a PureScript value to the built JS from a file that is not Main.purs?

In my PureScript 'Main' module, in file Main.purs, something like this:- test :: Boolean test = true will be exported in the compiled, bundled and optimised JavaScript output, and will be available to my JS code. But if I have another .purs file…
Bellarmine Head
  • 3,397
  • 2
  • 22
  • 31
0
votes
1 answer

Purescript, understanding why no type class instance was found

I'm trying to build a simple Purescript app, and I cannot figure out why I keep getting a typeclass instance error. Specifically, inside of my Component I am defining the eval function to operate on my query algebra. In the process, I just log…
0
votes
1 answer

Is it possible to render a component during eval in halogen?

In my halogen project have this eval branch: eval (SetTest tName next) = do H.set (State Nothing) detail <- H.fromAff $ toAff settings $ getTestsByTestname (tName ^. unTestName) H.set (State (Just detail)) pure next The…
Ben Ford
  • 2,087
  • 21
  • 26
0
votes
1 answer

Is it possible to run something in Eff in a halogen ComponentHTML funcion?

There are a couple of bindings to moment.js I'd like to use for rendering time spans in my Halogen UI which have types something like diffMins :: forall eff. Moment -> Moment -> Eff (now :: NOW | eff) Number If I want to use this function in my UI…
Ben Ford
  • 2,087
  • 21
  • 26
0
votes
1 answer

Representing a ledger data-structure

Given that my Purescript program contains different types representing items that can be exchanged, for example Vegetable, Milk, Meat etc., what is the best way to represent a ledger data-structure that tracks the exchanges between participants? To…
z1naOK9nu8iY5A
  • 903
  • 7
  • 22
0
votes
1 answer

Fixed size matrix and Maybe

I am writing a board game in PureScript that involves a matrix of exact size 2x7 (in certain variations it can be 4x7). The package I’m using has a Matrix.getRow function that returns a Maybe (Array a). What is the best approach to not have to…
Sridhar Ratnakumar
  • 81,433
  • 63
  • 146
  • 187
0
votes
1 answer

Purescript signal repeatedly starting at beginning of time

I'm building a game in Purescript, using purescript-signal, which includes movement. The user presses the left/right key to move left/right. Minimal code is below. It looks like purescript is evaluating the signal over "from the beginning of time"…
holdenlee
  • 969
  • 1
  • 8
  • 21
0
votes
1 answer

Show as Unrecognized Typeclass

So I'm playing "Purescript by Example" again and with the ch7 applicative validation code in particular. Was going through updating the code in the supplied modules since the language has since evolved ( ++ operator deprecated, qualified imports are…
0
votes
0 answers

Purescript Thermite - Updating state using record types

I am trying to understand why the updated state is not visualized. type State = {a :: Int, b :: Int} data Action = IncrementA | IncrementB render :: T.Render State _ Action render perform props state _ = [ text (show (toNumber…
Markus Barthlen
  • 389
  • 4
  • 15
0
votes
2 answers

How do I access both the value and accumulator of a Writer monad within a 'do' block (PureScript)?

I'm learning about the Writer monad right now, and I'm not sure if it's correct to want to read both the value and the accumulator of the monad within a do block. For example, in the coltzSeq function below I want to read the length of the Array…
Albtzrly
  • 924
  • 1
  • 6
  • 15
0
votes
1 answer

Purescript Halogen Input Element and Custom Autocorrect Property

I'm trying to disable autocorrect in inputs for safari on iOS. There isn't currently an "autocorrect" property in purescript halogen, so I created one, and modified the indexed input element record to use it. My problem is that the new property…
sportanova
  • 125
  • 3
  • 8
0
votes
1 answer

How should I model a type-safe index in Purescript?

In my application, I'd like to index sets of objects in a type-safe way using a structure similar to a relational database index. For example, I might want to index a set of User objects based on age and name: import Data.Map as M import Data.Set…
Joel Dice
  • 121
  • 1
  • 6
0
votes
1 answer

slamdata: how to calculate standard deviation and square root?

I have a dataset stored in mongodb database. i would like to calculate the standard deviation and square root of some data. How should i do this? i have done some research about purescript but i still dont know how to start. can anyone help me…
Mickey Lau
  • 19
  • 1
0
votes
2 answers

Typeclass instance with row type in instance head?

While I was playing with PureScript, I found that I wanted to write a typeclass Sync that would wait for arbitrary asynchronous values to resolve in the Aff monad. The typeclass I wrote looked like this: class Sync s eff a where sync :: s -> Aff…
Alexis King
  • 43,109
  • 15
  • 131
  • 205
0
votes
2 answers

Can I condense this expression by using some `map` or `apply`?

I have this code which I'd like to condense runFn someFn $ toArray a1 $ toArray a2 $ toArray a3 $ toArray a4 I would envision something like runFn someFn <$> fmap toArray [a1, a2, a3, a4] In that case runFn someFn would create a partially applied…
robkuz
  • 9,488
  • 5
  • 29
  • 50