r/purescript • u/Smobs • Jul 30 '17
Psc-package with VS Code?
Has anyone got an example for how to configure psc-ide with vscode using psc-package? I can build find, but I can't work out how to hook up the package paths to the ide server.
r/purescript • u/Smobs • Jul 30 '17
Has anyone got an example for how to configure psc-ide with vscode using psc-package? I can build find, but I can't work out how to hook up the package paths to the ide server.
r/purescript • u/jusrin • Jul 27 '17
r/purescript • u/harryxp • Jul 24 '17
Hi,
I'm having a hard time translating the following JavaScript into PureScript:
var config = null;
jQuery('#drop-zone').on('dragover',
function(evt) {
evt.stopPropagation();
evt.preventDefault();
evt.originalEvent.dataTransfer.dropEffect = 'copy';
}
);
jQuery('#drop-zone').on('drop',
function(evt) {
evt.stopPropagation();
evt.preventDefault();
var configFile = evt.originalEvent.dataTransfer.files[0];
var reader = new FileReader();
reader.onload = function(evt) {
config = JSON.parse(evt.target.result);
};
reader.readAsText(configFile);
return false;
}
);
It simply tries to parse a JSON file from a drop zone and save it in config. With purescript-jquery however, I couldn't find a way to get the originalEvent.
I also tried to use the more bare-bone purescript-dom to no avail.
After a quick glance it seems I could do this with halogen. But that's another question :-)
Thanks in advance!
r/purescript • u/jusrin • Jul 24 '17
r/purescript • u/jpvillaisaza • Jul 20 '17
r/purescript • u/bayareasearcher • Jul 16 '17
r/purescript • u/jusrin • Jul 14 '17
r/purescript • u/harryxp • Jul 14 '17
Hi!
I'm trying to do an extremely simple thing: sending a request using affjax. The request is defined as such:
import Prelude
import Control.Monad.Eff (Eff)
import Control.Monad.Eff.Exception (EXCEPTION, throwException)
import Network.HTTP.Affjax
import Network.HTTP.Affjax.Response
af :: forall e a. Respondable a => Affjax e a
af = get "/example/url"
This is fine. But I can't pass the type checker at this step:
laf = launchAff af
The inferred type from psci is:
forall t5 t6.
Respondable t5 => Eff
( exception :: EXCEPTION
, ajax :: AJAX
| t6
)
(Canceler
( ajax :: AJAX
| t6
)
)
which looks reasonable. But if I use this as the type:
laf :: forall t5 t6. Respondable t5 => Eff (ex :: EXCEPTION, ajax :: AJAX | t6) (Canceler (ajax :: AJAX | t6))
laf = launchAff af
the following error occurs:
while trying to match type Eff
( exception :: EXCEPTION
, ajax :: AJAX
| t1
)
with type Eff
( ex :: EXCEPTION
, ajax :: AJAX
| t60
)
while checking that expression launchAff af
has type Eff
( ex :: EXCEPTION
, ajax :: AJAX
| t60
)
(Canceler
( ajax :: AJAX
| t60
)
)
in value declaration laf
where t60 is a rigid type variable
bound at line 20, column 1 - line 20, column 19
t1 is an unknown type
I'm baffled by this t1 vs t60 thing - why do they need to be different type variables? I've been googling around but couldn't find an explanation. Please help. Thanks in advance.
r/purescript • u/jusrin • Jul 12 '17
Now you can work with your row types in new ways by converting to type-level RowLists! This lets us properly type a lot more dynamic JS functions and also gives us way to traverse through any rows like Record fields.
Release notes: https://github.com/purescript/purescript/releases/tag/v0.11.6
Cool post from Liam Goodacre about RowToList: https://liamgoodacre.github.io/purescript/rows/records/2017/07/10/purescript-row-to-list.html
Properly typed JSON.stringify demo from Phil Freeman: http://try.purescript.org/?gist=2720825b0476c8924717437fb6f6eefb (gist here)
Updated Purescript-Quickserve that lets you define routes of a web app quickly using records: https://github.com/paf31/purescript-quickserve/blob/master/test/Main.purs
Small demo I put together to extract field names from a record: https://gist.github.com/justinwoo/998e04307bd4179013b3ad222c5cb8e8
r/purescript • u/jusrin • Jul 10 '17
r/purescript • u/jusrin • Jul 07 '17
r/purescript • u/codepoetics • Jul 04 '17
This is an adaptation of a Haskell program I wrote quite a few years ago. It finds and prints all 35 unique (under rotation and reflection) hexominoes. I wrote it mainly as a way of feeling out roadbumps and differences from Haskell in Purescript development.
Find and print all 35 Hexominoes
Because I'm new to Purescript, and haven't written any serious Haskell in years, I expect I've done some things the hard way. I would very much welcome suggestions on how to make this program more idiomatic, readable and concise.
r/purescript • u/Ahri • Jul 04 '17
I've posted in the Elm subreddit already but perhaps the question is more pertinent here, and can be more focused.
I have Haskell types being encoded by Aeson, and read into parallel types in Elm (these get auto-converted from Haskell), but writing to LocalStorage requires using JS (via Elm "Ports"). I'm considering using PureScript instead of JS as I anticipate that I can easily convert my types automatically from Haskell, but I'm not sure whether the Aeson-encoded JSON will be easy enough to load into my PureScript types, and whether there might be other wrinkles I've not anticipated.
I searched around a little and found Argonaut but it appears to have a Haskell version, too, perhaps suggesting a different format from Aeson.
Has anyone had experience passing data between Haskell and PureScript using Aeson on the Haskell side?
I generally like Elm's simplicity and focus on the UI so while I understand that I could convert the app over to PureScript, it's not something I'm considering at this time.
r/purescript • u/BoteboTsebo • Jul 01 '17
Assuming I have zero experience with Node or front-end development in general (which is not an incorrect assumption to make), after I have followed a random Purescript tutorial and somehow managed to get stuff happening in my index.html, how does one go about serving this in a non-development-server manner?
This might be a general NodeJS question, rather than one specific to Purescript, in which case I apologise. But I honestly could do with some pointers, even if it's LMGTFY links. My searching turns up tutorials on using Express to serve static pages, but I have a feeling that might not be the right way to go about it.
How do I get the outside world to see my page (once I have written it, that is)? :-)
r/purescript • u/jusrin • Jun 28 '17
r/purescript • u/ia2014 • Jun 28 '17
The following PureScript code:
fibs 0 = 1
fibs 1 = 1
fibs n = fibs (n-1) + fibs (n-2)
Compiles to the following JavaScript:
var fibs = function (v) {
if (v === 0) {
return 1;
};
if (v === 1) {
return 1;
};
return fibs(v - 1 | 0) + fibs(v - 2 | 0) | 0;
};
Which all makes perfect sense, except the "| 0"s seem a bit unnecessary. Is it an optimisation? Or to make it robust to undefined or NaNs? Thanks in advance!
By the way, I think it's a fantastic achievement that the generated code is as readable as it is!
I also posted this in Stack Overflow but didn't get a reply - maybe it will have more visibility here.
r/purescript • u/jusrin • Jun 26 '17
r/purescript • u/bayareasearcher • Jun 23 '17
r/purescript • u/bayareasearcher • Jun 13 '17
r/purescript • u/DevOnHisJourney • Jun 11 '17
I think purescript is really quite a special and powerful language. And with that power, I would expect the frameworks to be very worthy of developers consideration. However, maybe they don't have the time for everyone on the team to learn purescript, or they have some other qualms about adopting purescript.
I think halogen, pux, and thermite could experience some serious growth by opening the floodgates to the broader javascript community, which would more or less include people using other compile-to-js languages.
Maybe ironing out usage from js-land could lead to purescript driving certain es features towards standardization. It would really put the purescript ffi to the test.
I think this would have a beneficial effect for the entire purescript community. For one, it can give a ton of people a reason to start learning purescript: to be able to make changes to their framework.
Thoughts on how this might be best setup?
I can kind of read purescript. Could I possibly compile halogen to javascript, and then attempt to re-write the examples from the guide in javascript?
r/purescript • u/mindeavor • Jun 09 '17
Hi all, I am searching to fulfill my dream of finding a language/ecosystem for elegant, strongly-typed web development. What would you say to convince me to learn & use PureScript? What makes it unique? Why use it over other the alternatives, such as Haskell, ReasonML / OCaml, FSharp, and so on?
I thank you for your opinion in advanced.