Skip to main content
Filter by
Sorted by
Tagged with
0 votes
1 answer
30 views

How to make different record `type`s unequal

I am learning PureScript due to not being satisfied (in particular) with TypeScript's type safety of what's called "records" in PS. While doing so I stumble upon the exact same problem in PS,...
Hi-Angel's user avatar
  • 5,469
1 vote
1 answer
114 views

Error installing spago@next using npm on node:22 Docker image

I am trying to set up a Docker development environment with PureScript. While trying to install Spago I get an error from the Docker builder. I am using the "node:22" image as a starting ...
John F. Miller's user avatar
2 votes
2 answers
96 views

What does "parameterised type in the positive / negative position" mean in the context of invariant functors?

From PureScript's Data.Functor.Invariant documentation (emphasis mine): A type of functor that can be used to adapt the type of a wrapped function where the parameterised type occurs in both the ...
toraritte's user avatar
  • 7,807
5 votes
0 answers
117 views

Where does the name of the `pure` function in the `Applicative` type class come from?

At this point in my learning journey, I simply accepted that this function is called pure (both in Haskell and in PureScript), but it would have helped a lot if I had known the reasoning behind this ...
toraritte's user avatar
  • 7,807
0 votes
1 answer
45 views

Why is the `Data.Int` type not a `Semigroup` in PureScript but `String` is?

> "lo" <> "fa" "lofa" > 1 <> 2 Error found: in module $PSCI at :1:1 - 1:7 (line 1, column 1 - line 1, column 7) No type class instance was found for ...
toraritte's user avatar
  • 7,807
0 votes
0 answers
78 views

Why can't I use a row-polymorphic variable?

Take a look at this PureScript code: type MyOtherProps = (value :: String) type MyProps = (a :: String) a :: forall props phantom allProps . Union MyProps MyOtherProps allProps => Union ...
Jose Quesada's user avatar
0 votes
0 answers
101 views

Is there a way to integrate PureScript and Vite together?

I use spago to build src/Main.purs to output/Main/index.js. I am trying to use Vite for the bundling tool and have successfully loaded output/Main/index.js in src/main.ts. Vite can import image files, ...
topica's user avatar
  • 319
2 votes
1 answer
106 views

Is `Pair` a valid instance of `MonadRec`?

In the paper Stack Safety for Free, Phil Freeman defines the MonadRec type class as follows. class (Monad m) <= MonadRec m where tailRecM :: forall a b. (a -> m (Either a b)) -> a -> m b ...
Aadit M Shah's user avatar
  • 73.9k
6 votes
2 answers
189 views

What is the name used in literature and libraries for the abstraction of "zero profunctors"

In real world application I noticed a pattern that could be generalized to something like: purescript: class Profunctor p <= Zero p where pzero :: forall a b. p a b -- such that `forall f g. ...
Eryk Ciepiela's user avatar
1 vote
0 answers
92 views

spago docs only for project files

When I run spago docs, the documentation is generated for every dependencies in my project. Is it possible to generate a documentation only for project files? So only for .purs files in src. I am ...
christian wuensche's user avatar
1 vote
2 answers
72 views

Purescript - iterate a longish array

The following code, being executed in Chrome, fails after printing 7492: module Main where import Prelude import Effect (Effect) import Effect.Console as Console import Data.Array as Array import ...
Mikhail Brinchuk's user avatar
1 vote
1 answer
102 views

How to delete an element from an array using lenses

I'm trying to remove an element from an Array a using the index of the element but I can't find a way to do it with Lenses. I'm also wondering why Array does not provide an instance for the At lens. ...
amaille's user avatar
  • 65
0 votes
2 answers
100 views

vscode extension with a typed functional language

Is it possible to build a vscode extension from a javascript transpiler ? For example, is it possible to build an extension with "js of ocaml" or purescript. Those transpilers compiles to ...
user2187032's user avatar
4 votes
4 answers
257 views

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 ...
user avatar
0 votes
0 answers
63 views

purescript: change element inside SVG

I have a SVG image like the following: It is a simple SVG with a number in it. The SVG file looks something like this: <svg ...> <g ...> <text id="my_text" ...> ...
cdupont's user avatar
  • 1,188
0 votes
1 answer
35 views

Purescript Complex zero element (Purescipt by example exercies)

I solve Purescript exercise from the book https://book.purescript.org/chapter6.html#multi-parameter-type-classes I don't understand what "zero" statement is? I have "Complex" type, ...
Andrey Dolmatov's user avatar
0 votes
1 answer
78 views

How do I get the current browser URL with purescript?

How do I get the the browser URL in Purescript, just like when doing window.location.href in javascript?
Chris Stryczynski's user avatar
2 votes
1 answer
106 views

What is () defined as in Purescript? What does it mean?

What is () defined as? I see it in type signatures, I thought it was the unit type same as in Haskell but it seems instead Purescript uses Unit. So then what is ()? Using spago repl was not helpful ...
Chris Stryczynski's user avatar
3 votes
1 answer
74 views

Nested exhaustive pattern matching in Purescript

Consider my two attempts at writing the same function: data Foo = Bar Int | Quux Int | Baz Int f :: Foo -> Int f (Bar n) = n f other = case other of Quux n -> 2 * n Baz n -> 3 * n ...
Brennan Vincent's user avatar
0 votes
0 answers
38 views

Adding Constraint Dynamically to a function

Is there any way I can add a constraint to a type class function dynamically? Let's say my type class takes a function of type type FieldTraverseFn :: Row Type -> (Type -> Type) -> Type type ...
Saravanan's user avatar
  • 891
1 vote
1 answer
56 views

Why purescript can infer the Row.Cons contraint?

I have a newtype which takes a parameterized type, newtype MockState m = MockState { apiState :: {api1 :: m Int, api2:: m String} } derive instance newtypeMockState :: Newtype (MockState m) _ I have ...
Saravanan's user avatar
  • 891
0 votes
1 answer
40 views

StateT monad inside Handler in purescript-express

I want to persist some data in StateT monad, Within Handler of the post(any http method) function I want to modify the data stored in state... but the issue is I can't use State inside Handler... ...
Saravanan's user avatar
  • 891
0 votes
1 answer
90 views

`UnsafePartial` method works on non-partial function too - Purescript?

I'm trying to do something similar to what Partial type class does, so to understand Partial constraint better I started experimenting with it... I created a normal function, goodFn :: Int -> ...
Saravanan's user avatar
  • 891
0 votes
1 answer
77 views

Write Genric function that takes function signature of varying length of argument as argument in type level

I want to create a function, that takes function as varying argument, the only thing i know about the funtion argument(which is a function itself) is they are wrapped in the same Monad.... myFunc :: ...
Saravanan's user avatar
  • 891
2 votes
0 answers
45 views

Is there a way to refer to the result of the previous command in PSCi?

Coming from Haskell, I'm accustomed to using it to refer to the result of the previous command in GHCi: ghci> 1+1 2 ghci> :type it it :: Num a => a ghci> it*2 4 I went looking to see if ...
Alex's user avatar
  • 41
3 votes
0 answers
142 views

Webpack Code Spliting increases the overall bundle size by 300%

For explaining this issue. I have created a sample project. I am using purescript. I am doing a dynamic import and webpack is generating 2 bundles. If I comment the dynamic import and use a static ...
Avinash Verma's user avatar
0 votes
1 answer
46 views

How do composition and currying interact?

While doing exercises of chapter 3 of the Purescript by Example book was puzzled by this: The exercise is to write an isInBook :: String -> String -> AddressBook -> Boolean findEntryByName :: ...
Chris Wesseling's user avatar
0 votes
1 answer
87 views

How to implement fold right for Tree in purescript

I am new to Purescript so I was trying to implement fold left and fold right (aka reduce) for my custom Tree data structure, but I am having problem implementing logic for fold right: data Tree a = ...
Djordje Vuckovic's user avatar
0 votes
1 answer
77 views

Which is a more efficient version of "takeEnd" function

I am new to PureScript so I am re-creating some basic functions, and I wanted to recreate "takeEnd" function which takes specified number of elements from the end of the list. Here is ...
Djordje Vuckovic's user avatar
0 votes
1 answer
89 views

Purescript: How to read a string from stdin and save it?

I'm quite new to Purescript and I am trying to process some user input (received from stdin) but my best approach is this one: processInput :: String -> Effect Unit processInput input = do let ...
Alex's user avatar
  • 3
1 vote
2 answers
82 views

PureScript - Splitting Array of Positive and Negative Numbers into Tuple of 2 Arrays of Positive and Negative Numbers

I'm a newbie in PureScript now reading a book "Functional Programming Made Easier: A Step-by-Step Guide", but when I got to the section on Tuples, I realised that all that was presented ...
maxloo's user avatar
  • 491
2 votes
1 answer
99 views

Usecase of Variants in Purescript/Haskell

Can someone tell me what is the use case of purescript-variants or variants in general The documentation is very well written but I can't find any real use case scenario for it. Can someone tell how ...
Saravanan M's user avatar
0 votes
2 answers
158 views

PureScript Error: Could not match kind Type -> Type with kind Type

I'm a newbie at PureScript trying out some code at this link. I've pasted the code here: module Main where import Prelude import Data.Foldable (fold) import Data.Tuple import Data.Map as Map import ...
maxloo's user avatar
  • 491
1 vote
1 answer
90 views

purescript halogen - render elements or nothing conditionally

I have a utility function to conditinally render elements: thanRender :: ∀ w i. Boolean -> EL.HTML w i -> EL.HTML w i thanRender true h = h thanRender _ _ = EL.text "" Usage: ...
christian wuensche's user avatar
0 votes
2 answers
91 views

purescript data as array of all possible data inhabitants

I got the following data type: data Icon = IconCircle | IconSquare | IconStar I need an array of all possible Icons?: allPossible :: Array Icon allPossible = [IconCircle, IconSquare, IconStar] Is ...
christian wuensche's user avatar
0 votes
0 answers
124 views

Is there type system with subtype relation that support exclusive struct field?

TLDR: Is there a type system which allows we to express a type (constraint/interface) I = NoField<'a'>, such that for all type T, if T <: I, then T is a struct and does not have a specific ...
xiang0x48's user avatar
  • 641
0 votes
1 answer
131 views

Can I always replace do ... pure ... with ado ... in ... in Purescript?

Can I always replace a do-block like this: do ... pure ... where the last line is "pure" something, with an ado-block like this: ado ... in ... ? I know do only requires Bind and ...
Drathier's user avatar
  • 14.4k
1 vote
1 answer
107 views

How to chain actions in purescript (or maybe defer action after rendering)

I'm learning Halogen at the moment but I have a hard time finding how to chain actions. Let's say I have a simple article list component. I also have an "add" button to create a new article ...
amaille's user avatar
  • 65
0 votes
1 answer
51 views

Ascii color prefixes in PureScript doesn't work

I want to colorize my string with ASCII colors, but the following code... data Color = White | Red | Green | Yellow colorizeWith :: Color -> String -> String colorizeWith Green s = "\031[...
Max Smirnov's user avatar
0 votes
0 answers
73 views

Await with timeout using purescript-pipes

I'm trying to use a combination of purescript-pipes, and purescript-pipes-aff to write a version of await which will return Nothing if it doesn't receive a value in a specified amount of time. So far, ...
Joe's user avatar
  • 1,599
0 votes
1 answer
48 views

PureScript. Argument list lengths differ in declaration

import Prelude data Line = Front | Middle | Back derive instance eqLine :: Eq Line instance ordLine :: Ord Line where compare a b | a == b = EQ compare Front _ = LT compare Back _ = GT ...
Robb's user avatar
  • 67
0 votes
0 answers
32 views

How to convert a Record to a Page that contains that Record with purescript

I have this function that returns listScheduledPhotos :: ListScheduledPhotosOptions -> ExceptT Error Aff S3ObjectCollection listScheduledPhotos = resolvePromiseOrThrow <<< ...
Ahmed's user avatar
  • 21
1 vote
2 answers
198 views

how to get string from stdin using Purescript?

as title says, I want to know about how to get stdin using Purescript. I want to input string using my keyboard. that's all. in fact, I can find some code just googling this. but nothing runs corretly....
LKB's user avatar
  • 486
0 votes
0 answers
92 views

How can I convert Record to Row at type Level?

I have a record, I want to pass a partial record to a function which will update the current record. type Person = {name :: String, age :: Int } updatePerson :: forall fullRec partialRec. ...
Saravanan M's user avatar
1 vote
1 answer
126 views

Use records update syntax for newtype

Previously I had this type: type Directions = { top :: Boolean , right :: Boolean , bottom :: Boolean , left :: Boolean } And for this type I had this functions empty = { top: false, ...
Max Smirnov's user avatar
0 votes
1 answer
107 views

requestAnimationFrame loops with timestamps in PureScript

I am trying to pick up PureScript. Something I do a lot in JS is the following: let start; function step(timestamp) { if (start === undefined) start = timestamp; const elapsed = timestamp - ...
jand's user avatar
  • 1
1 vote
3 answers
462 views

Running spago build returns error installing dependencies

I just started with purescript. Running spago build always return an error which says - Failed to install dependency "effect" Git output: fatal: destination path '.' already exists and is ...
Atharva Joshi's user avatar
0 votes
1 answer
81 views

Compiler can't infer type while using Newtype class Constraint purescript

I was trying to write a function that can get the data that a newtype wraps. newtype Person = Person {name :: String, age :: Int} getRecord :: forall r. Newtype Person r => Person -> r ...
Saravanan M's user avatar
0 votes
0 answers
67 views

How to bundle code that defines and uses a require value in webpack

I have some PureScript code that looks like this module Types.ScriptLookups2 where import Prelude require :: Unit require = unit and it gets compiled to the JavaScript code // Generated by purs ...
Mason's user avatar
  • 868
-1 votes
1 answer
51 views

How to have row without particular field as function param

What I want is following, I have a row type: type FooBarBaz = ( foo :: Int , bar :: String , baz :: Boolean ) Then a need a function that takes this row type record but without "foo"...
WHITECOLOR's user avatar

1
2 3 4 5
13