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

TypeError: readImpl(...) is not a function

I'm getting TypeError: readImpl(...) is not a function from compiled code, and I'm not using FFI nor unsafeCoerce, which usually lead to these issues.
Reactormonk
  • 21,472
  • 14
  • 74
  • 123
0
votes
1 answer

Extend one Traversal lens with another Traversal lens

Let's say I have a Node and it can have children and siblings and I have traversal lens implementations for them. How do I compose them into a single lens that traverses both children and siblings? _children :: Traversal' Node Node _children =…
MnZrK
  • 1,330
  • 11
  • 23
0
votes
1 answer

How to use mapWithIndex in Purescript?

I'm a naive at Purescript, so I have a very basic issue while working with one of Purescript based frameworks. I'm using PrestoDOM and I wonder how to use mapWithIndex function from Data.Array package. I tried like the following, import Data.Array…
Niko Modric
  • 635
  • 4
  • 13
0
votes
1 answer

Pattern matching in purescript

How can I implement head or singleton function in purescript by pattern matching? The problem is that the compiler requires the explicit definition of the broadest pattern, but I can't generate a default value for a type that I don't know.…
Sergey Sosnin
  • 1,313
  • 13
  • 30
0
votes
1 answer

How do you access highlighted text in Purescript?

I'm creating an application in Purescript and I want to have a text box displaying some documentation, and then I want to perform some NLP tasks on the server based on the sentences highlighted by the mouse on that text. How could I extract that…
tonicebrian
  • 4,715
  • 5
  • 41
  • 65
0
votes
1 answer

Apears-to-be-useless guard in do block saves from maximum stack error

Doing exercises from "PureScript by Example" I tryed to do some modifications to the code. I can't understand few things: module Main where import Prelude import Data.Array ((..),(:)) import Control.MonadZero (guard) factors n = do x <- 1 .. n …
Stas Shepelev
  • 145
  • 1
  • 11
0
votes
1 answer

How does one derive a `BoundedEnum (Maybe a)` from a `BoundedEnum a`?

I'm getting an error on "no typeclass instance was found for Data.Enum.BoundedEnum (Maybe InstitutionContactType)", but due to the existence of instance enumMaybe :: BoundedEnum a => Enum (Maybe a), instance boundedMaybe :: Bounded a => Bounded…
bbarker
  • 11,636
  • 9
  • 38
  • 62
0
votes
1 answer

Error: Target container is not a DOM element (when running Purescript Pux Program)

I've compiled this program with Purescript 0.12.5 but when I look at the index.html in Firefox 67.0.2 I get the following error in the web console: Error: Target container is not a DOM element. app.js:5160:15 Here is the index.html file:
user1023733
  • 805
  • 5
  • 14
0
votes
0 answers

Illegal Character Escape in Text.Smolder.Renderer.String.purs

In an attempt to compile my program, I received the following error regarding the file String.purs from the Text.Smolder.Renderer module: Error found: at bower_components\purescript-smolder\src\Text\Smolder\Renderer\String.purs:76: 56 - 76:57 (line…
user1023733
  • 805
  • 5
  • 14
0
votes
0 answers

How to handle multi-project builds/repos in purescript?

We have a Purescript project that has grown organically, and it would be natural to split it up into two "binaries" and two libraries. Since the packages are still closely related, it would be convenient to maintain them in the same git repository.…
aij
  • 5,903
  • 3
  • 37
  • 41
0
votes
1 answer

purescript halogen: Append IProp to HTML

Is there a way to append IProp's to HTML? Here's an example of what i'm trying to do: foo :: forall p i. H.HTML p i -> H.HTML p i foo myElement = addProp (HP.id_ "SomeId") myElement Where addProp takes myElement, gives it the Id (or any other…
Vance Palacio
  • 1,280
  • 12
  • 17
0
votes
1 answer

What does a Purescript `data` type with no constructor mean?

For example (from purescript-halogen): data Slot (query :: Type -> Type) output slot Is that declaring an uninhabited type? (If so, I would assume it would be useful exclusively as a phantom type.)
aij
  • 5,903
  • 3
  • 37
  • 41
0
votes
1 answer

get nth array from 2nd array

I tried to get nth array from 2d array but I couldn't. For example, I need to get second array. {[1,2,3], [4,5,6], [7,8,9]} getElementIndex :: Array (Array Int) Int -> Array Int How should I implement this function? Thanks in advance.
Voro
  • 235
  • 1
  • 12
0
votes
2 answers

OAUTH for purescript

I'm new to Purescript. I'm searching for an OAuth client and found this. I'm not sure how to build it, but this is what I've tried. I've copied the source under the first project I've created following the getting started guide. The first error…
user10794413
0
votes
2 answers

Type kind error when creating instance of Functor typeclass

I'm trying to implement Functor typeclass instance for a very trivial type Foo: data Foo a = Foo a instance functorFoo :: Functor (Foo a) where map fn (Foo a) = Foo (fn a) Purescript gives me not-so-helpful error message: Could not match kind …
Rene Saarsoo
  • 13,580
  • 8
  • 57
  • 85