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

How can I write a purescript effect handler that subracts an effect from the set

PureScript by Example, in the section The Eff Monad -> Handlers and Actions states that "[an effect] handler usually subtracts effects from the set". However, the examples are rather opaque and I can't work out how to write my own handler to achieve…
mjkaye
  • 106
  • 7
6
votes
1 answer

Is the Eff-monad in purescript inspired by www.eff-lang.org?

Reading about the Eff-Language, I wondered if there are similar ideas already in use. The Eff-Language mentions a paper called "Inferring Algebraic Effects", which describes the algorithm that Eff uses to infer effects. Are there similarities?
v217
  • 765
  • 1
  • 6
  • 17
6
votes
1 answer

What does the triple less-than sign (`<<<`) do in PureScript?

I've seen this code in a PureScript program, what does <<< do? pinkieLogic :: (Tuple Boolean GameObject) -> GameObject -> GameObject pinkieLogic (Tuple jumpPressed hater) p = hated hater p (solidGround <<< gravity <<< velocity <<< jump…
Andrea
  • 19,134
  • 4
  • 43
  • 65
5
votes
2 answers

getElementById in Purescript

I am very new to Purescript so this might be a naive question. I want to write a Purescript function that reads input from HTML input elements on the browser and writes some output to another HTML input element. With plain Javascript it's as…
Random dude
  • 519
  • 2
  • 11
5
votes
0 answers

Purescript: why can't genericEncodeJSON encode types inside a container?

I don't understand why the below program fails to compile. module Main where import Prelude import Effect (Effect) import Effect.Console (log) import Data.Generic.Rep (class Generic) import Foreign.Generic (defaultOptions, genericEncodeJSON) main…
duggi
  • 556
  • 5
  • 13
5
votes
1 answer

Is Behavior a Comonad?

Conal Elliott talks about Streams and Comonads here: http://conal.net/blog/posts/sequences-streams-and-segments However, he doesn't mention Behavior directly. So.. is Behavior a Comonad, and if so - what does that mean practically? For starters - I…
davidkomer
  • 3,020
  • 2
  • 23
  • 58
5
votes
3 answers

How do I configure a TypeScript project that uses JavaScript modules compiled from PureScript?

TL;DR I want to create TypeScript typings for compiled PureScript modules, and distribute them in my npm package. I'm more than happy to maintain these typings manually, I just can't figure out what I need to put in tsconfig.json (up and downstream)…
David Siegel
  • 1,604
  • 11
  • 13
5
votes
2 answers

Scroll action in PureScript Halogen

I'm using purescript-halogen, and I want to scroll to bottom of div when the child component's message were caught. However, it seems not present that scroll action control in Halogen. So, how can I Scroll to bottom of div? One solution I think is…
Neve
  • 53
  • 2
5
votes
0 answers

How can I QuickCheck value wrapped by effect in PureScript?

I have a shuffle function for Array: shuffle:: forall e. Array -> Eff (random :: RANDOM | e) Array It shuffles an array in a Control.Monad.Eff.Random monad and returns the wrapped one. I want to test the array is shuffled, like to compare the…
snowmantw
  • 1,611
  • 1
  • 13
  • 25
5
votes
1 answer

Get current time/date in purescript

This seems to me a weird question, but I have gone through the purescript-datetime and purescript-js-date and I just cannot find a way to get current DateTime. Is there some hidden library function or do I have to go through FFI?
ondra
  • 9,122
  • 1
  • 25
  • 34
5
votes
1 answer

Standard unicode operators in purescript

Looking at this: https://github.com/purescript/purescript/issues/1929 I see there is support for unicode in purescript, e.g. id :: ∀ a. a -> a Is there a list of default operators somewhere?
levant pied
  • 3,886
  • 5
  • 37
  • 56
5
votes
1 answer

PureScript - How to reload a module in psci?

Is there a way to reload a module or all modules in PureScript's REPL? If I make a change to a module, I've got to :quit and then import all the modules I'm working with each time.
at.
  • 50,922
  • 104
  • 292
  • 461
5
votes
1 answer

Thinking Functionally. Building a New Array in Haskell / Purescript

I'm new to functional programming, and I've decided to build an app in Purescript. I've hit my first hurdle, and I'm not sure how to think about this conceptually. I'm not looking for code as much as a way to think functionally about this…
clo_jur
  • 1,359
  • 1
  • 11
  • 27
5
votes
1 answer

How do I collapse an Either in PureScript?

I have an object of type Either String (Either String Int). I would like to collapse it to an object of type Either String Int. Is there a provided function for this in PureScript?
sdgfsdh
  • 33,689
  • 26
  • 132
  • 245
5
votes
2 answers

Force show a record in PureScript

Is it possible to force-show (i.e., create a string representation) an arbitrary record in PureScript for debugging purpose regardless of it having a type-class instance for Show? I would like to show the contents of the Pux Event object but it…
Sridhar Ratnakumar
  • 81,433
  • 63
  • 146
  • 187
1 2
3
39 40