Purescript 0.12 Getting Started - purescript

i`m trying to run the very basic flow:
1) install tools:
npm install -g pulp bower
Pulp version 12.2.0
purs version 0.12.0 using C:\Users\panda.psvm\current\bin\purs.EXE
C:\Users\panda>bower --version
1.8.4
2) following steps from this answer i installed purs https://stackoverflow.com/a/50554135/1358421
C:\Users\panda>purs --version
0.12.0
Ok, lets create a project.
c:\home\projects\sandbox\purr>mkdir hello-purr
c:\home\projects\sandbox\purr>cd hello-purr
c:\home\projects\sandbox\purr\hello-purr>
pulp init
c:\home\projects\sandbox\purr\hello-purr>pulp init
* Generating project skeleton in c:\home\projects\sandbox\purr\hello-purr
bower purescript-console#* cached https://github.com/purescript/purescript-console.git#4.1.0
bower purescript-console#* validate 4.1.0 against https://github.com/purescript/purescript-console.git#*
bower purescript-prelude#* cached https://github.com/purescript/purescript-prelude.git#4.0.0
bower purescript-prelude#* validate 4.0.0 against https://github.com/purescript/purescript-prelude.git#*
bower purescript-prelude#^4.0.0 cached https://github.com/purescript/purescript-prelude.git#4.0.0
bower purescript-prelude#^4.0.0 validate 4.0.0 against https://github.com/purescript/purescript-prelude.git#^4.0.0
bower purescript-effect#^2.0.0 cached https://github.com/purescript/purescript-effect.git#2.0.0
bower purescript-effect#^2.0.0 validate 2.0.0 against https://github.com/purescript/purescript-effect.git#^2.0.0
bower purescript-console#^4.1.0 install purescript-console#4.1.0
bower purescript-prelude#^4.0.0 install purescript-prelude#4.0.0
bower purescript-effect#^2.0.0 install purescript-effect#2.0.0
purescript-console#4.1.0 bower_components\purescript-console
├── purescript-effect#2.0.0
└── purescript-prelude#4.0.0
purescript-prelude#4.0.0 bower_components\purescript-prelude
purescript-effect#2.0.0 bower_components\purescript-effect
└── purescript-prelude#4.0.0
bower purescript-psci-support#* cached https://github.com/purescript/purescript-psci-support.git#4.0.0
bower purescript-psci-support#* validate 4.0.0 against https://github.com/purescript/purescript-psci-support.git#*
bower purescript-psci-support#^4.0.0 install purescript-psci-support#4.0.0
purescript-psci-support#4.0.0 bower_components\purescript-psci-support
├── purescript-console#4.1.0
├── purescript-effect#2.0.0
└── purescript-prelude#4.0.0
Skeleton of project successfully generated.
Trying to run it:
pulp run
* Building project in c:\home\projects\sandbox\purr\hello-purr
Error 1 of 2:
in module Main
at src\Main.purs line 4, column 1 - line 4, column 31
Module Control.Monad.Eff was not found.
Make sure the source file exists, and that it has been provided as an input to the compiler.
See https://github.com/purescript/documentation/blob/master/errors/ModuleNotFound.md for more information,
or to contribute content related to this error.
Error 2 of 2:
in module Main
at src\Main.purs line 5, column 1 - line 5, column 48
Module Control.Monad.Eff.Console was not found.
Make sure the source file exists, and that it has been provided as an input to the compiler.
See https://github.com/purescript/documentation/blob/master/errors/ModuleNotFound.md for more information,
or to contribute content related to this error.
* ERROR: Subcommand terminated with exit code 1
No luck :(
pulp test
pulp build
The same errors - It can`t find modules.
Did i miss something? Please, advice.
Thanks

Purescript 0.12 pulls in newer versions of the Effect and Console libraries, unfortunately pulp init has not yet been updated to correct the generated example to match (see https://github.com/purescript-contrib/pulp/issues/337)
just update the code in Main.purs to:
module Main where
import Prelude (Unit)
import Effect
import Effect.Console (log)
main :: Effect Unit
main = do
log "Hello sailor!"`
to get started.

Found solution.
don't need bower at all
instead, there is a psc-package (another package manager)
it didn't installed correctly on my Windows 10 with npm install -g psc-package
there was no psc-package.exe file in directory ${username}\AppData\Roaming\npm\node_modules\psc-package\vendor
So, you need to fix install.js file and replace
ignore: ['psc-package']
with
ignore: [bin.use()]
then run fixed installation with
${username}\AppData\Roaming\npm\node_modules\psc-package\lib> node install
after that, In the vendor folder you may find psc-package.exe
Then, i followed this tutorial:
https://github.com/justinwoo/purescript-0.12.0-hello-world
and
Build successful.
look, show on Record:
{ apple: "banana" }

Related

Add python project based on pyproject.toml to yocto image

I'm putting together a recipe that's supposed to add amqtt to my image (https://github.com/Yakifo/amqtt). The project only comes with a pyproject.toml but lacks a setup.py. Thus, bitbake is complaining that setup.py cannot be found I'm on branch dunfell and these are the most relevant parts of my recipe:
HOMEPAGE = "https://github.com/Yakifo/amqtt"
SRC_URI = "git://github.com/Yakifo/amqtt;protocol=https"
SRCREV = "4beb912c2a0d58d66140ce68b6a31991c2c48b30"
S = "${WORKDIR}/git"
inherit setuptools3 pypi distutils
Your input is highly appreciated.
As of Yocto Release 4.0 (Kirkstone), installation of Python packages using Poetry is supported via the python_poetry_core class - Release 4.0 Migration Guide - Python Changes
My particular scenario (using Gatesgarth 3.2.3) doesn't really justify the effort in updating to Kirkstone. Just changing the packaging system is not an option (it's not my package I'm trying to install).
My workaround: I've opted to simply use Poetry (1.2.1, the latest at time of writing) to manually build the .tar.gz. It turns out that Poetry generates a setup.py with the info contained in pyproject.toml. I commit that package archive to my Yocto project repo, and override SRC_URI in the appropriate recipe to use it instead of the version from PyPi.
Note that I did have some issues in getting poetry build to run due to TOML format difference between the version that it was written for (which I was unable to zero in on) and the latest. I had to modify the pyproject.toml a bit because of this.
If the pyproject.toml file is composed in a way that it can be used with setuptools then just creating simple setup.py
from setuptools import setup
setup()
by adding the following to the bitbake recipe fixes the problem:
do_configure:prepend() {
cat > ${S}/setup.py <<-EOF
from setuptools import setup
setup()
EOF
}
More details here
My full bitbake recipe python3-leapseconddata_2.0.0.bb:
HOMEPAGE = "https://pypi.org/project/leapseconddata/"
SUMMARY = "Python Leap Second List."
LICENSE = "GPLv3"
LIC_FILES_CHKSUM = "file://LICENSES/GPL-3.0-only.txt;md5=8da5784ab1c72e63ac74971f88658166"
PYPI_PACKAGE = "leapseconddata"
SRC_URI[sha256sum] = "c72d40f56bf7a1a98ee0c0c12ea2fca76a38a5cb7239f8e182f13e639436992d"
inherit pypi setuptools3
do_configure:prepend() {
cat > ${S}/setup.py <<-EOF
from setuptools import setup
setup()
EOF
}
I switched to the pypi installer in the end. The most important parts are:
PYPI_PACKAGE = "amqtt"
inherit pypi setuptools3

Idris not properly installing/finding packages

I'm currently trying to use Blodwen, the prototype of Idris 2, as a backend for a language I'm writing. So I'm trying to import its ttimp package for my project.
I go into the Blodwen directory and do idris --install ttimp.ipkg
Then in my project's .ipkg I have:
opts = "--cg-opt -O2 -i ~/GitHub/Blodwen/"
pkgs = ttimp
However, when I run idris --build myproject.ipkg I get the error
Entering directory `./src'
The following packages were specified but cannot be found:
- ttimp
If I remove ttimp from pkgs, then I get Can't find import Core/Binary
i.e. it can't find the modules from the package.
If I try to build ttimp with TARGET=~/.idris-libs
idris --install ttimp.ipkg
Entering directory `./src'
Can't find import Builtins
Can't find import Prelude
Can't find import Data/List
My Question: How can I make sure ttimp is being installed properly? Where does Idris install packages by default? Why isn't Idris finding the library after I've installed it?
I am not sure what your current goal is, but when you install blodwen it is using idris to a) install ttimp and to compile blodwen, which is available as the executable blodwen afterwards. So if you want to work with blodwen, you should also use blodwen to compile your files and install additional libraries.

Need help on start using purescript on NixOS

I am trying to setup hello world project with purescript on NixOs and have couple questions,
Official purescript website recommend installation via npm but there is no nixos.nodePackages.purescript, instead there are at least 2 variants I found in nixpkgs
nixos.purescript
nixos.haskellPackages.purescript
What are the different?
Official site recommend pulp and bower via npm but only nodePackages.bower is avaliable and there is undocumented psc-package.
What should be the nix way to handle purescript packages?
The sample code on official site (see hello.purs bellow) doesn't even compile,
with these error.
$ purs compile hello.purs
Error found:
at hello.purs line 1, column 1 - line 1, column 1
Unable to parse module:
unexpected "import"
expecting "module"
I add module Hello to code but still failed.
$ purs compile hello.purs
Error 1 of 2:
in module Hello
at hello.purs line 2, column 1 - line 2, column 15
Module Prelude was not found.
Make sure the source file exists, and that it has been provided as an input to psc.
See https://github.com/purescript/documentation/blob/master/errors/ModuleNotFound.md for more information,
or to contribute content related to this error.
Error 2 of 2:
in module Hello
at hello.purs line 3, column 1 - line 3, column 39
Module Control.Monad.Eff.Console was not found.
Make sure the source file exists, and that it has been provided as an input to psc.
See https://github.com/purescript/documentation/blob/master/errors/ModuleNotFound.md for more information,
or to contribute content related to this error.
How the correct workflow should be?
The goal is to have minimal example project with a single hello.purs
running in web browser.
This is hello.purs
module Hello where
import Prelude
import Control.Monad.Eff.Console (log)
greet :: String -> String
greet name = "Hello, " <> name <> "!"
main = log (greet "World")
It would be really helpful if you can also provide shell.nix for nix-shell or default.nix for nix-build.
Found this 2 years old guild, I am trying it but I still not have answer to all of my questions.
nixos.purescript is just the static executables for nixos.haskellPackages.purescript; this skips building/installing PureScript as a Haskell library
You can install Pulp via npm install pulp - the binary will be installed to node_modules/.bin/pulp
The sample code doesn't compile because you haven't downloaded the dependencies via Bower. You can install them via bower install purescript-prelude purescript-console.
But node_modules/.bin/pulp init will give you a Bower file and you can run bower install to give you a basic project. You can then do node_modules/.bin/pulp run to execute it using node.js, but you'll probably want pulp browserify --to example.js to get a file you can put in a <script> tag in HTML.

Error installing purescript-list

I'm new to Purescript and am following the tutorial for installation. Purescript itself is working and I can start the CLI using pulp psci, but installing purescript-list runs into trouble.
Having entered the command bower install purescript-lists --save, I get a long list of package names, but when it gets to purescript-eff and purescript-prelude I run into some version conflicts:
bower purescript-eff#^2.0.0 cached https://github.com/purescript/purescript-eff.git#2.0.0
bower purescript-eff#^2.0.0 validate 2.0.0 against https://github.com/purescript/purescript-eff.git#^2.0.0
Unable to find a suitable version for purescript-eff, please choose one by typing one of the numbers below:
1) purescript-eff#^1.0.0 which resolved to 1.0.0 and is required by purescript-console#1.0.0
2) purescript-eff#^2.0.0 which resolved to 2.0.0 and is required by purescript-st#2.0.0
Prefix the choice with ! to persist it to bower.json
? Answer
A similar message is shown for purescript-prelude. No matter which options I choose, both pulp build and pulp run fail with:
$ pulp build
* Building project in /Developer/purescript/training1
Error found:
in module PSCI.Support
at /Developer/purescript/training1/bower_components/purescript-psci-support/src/PSCI/Support.purs line 10, column 34 - line 10, column 53
Cannot import value unsafeInterleaveEff from module Control.Monad.Eff.Unsafe
It either does not exist or the module does not export it.
See https://github.com/purescript/purescript/wiki/Error-Code-UnknownImport for more information,
or to contribute content related to this error.
Compiling PSCI.Support
* ERROR: Subcommand terminated with exit code 1
What have I missed here?
Thanks
Chris W
If you are using psc version 0.10.* you should go with prelude, lists and eff v2*.
If you are using psc version 0.9.* you should go with prelude, lists and eff v1*.
If you are using psc 0.10.* you might want to update pulp to version 9.1.0
The problem occurs due to breaking changes between psc 0.9 and 0.10 and the relevant libraries. by writing bower install purescript-lists --save you are asking bower for the latest dependencies which conflict with the dependency versions specified in your bower.json.

coq Hello World example (with opam) can't find libraries

I was following a coq HelloWorld tutorial (code below), and couldn't get the program to compile. I followed the installation steps and installed opam install coq:io:system. My opam installation is at the default location ~/.opam. But still, I got an error about
Toplevel input, characters 53-67:
Error: The reference System.effects was not found in the current environment.
This is with either emacs/proofgeneral or coqide (8.4pl6, ubuntu 14.04). Does any one know how to fix the issue?
Here's the code which I copied into a file called hello_world.v and loaded into emacs/coqide:
Require Import Coq.Lists.List.
Require Import Io.All.
Require Import Io.System.All.
Require Import ListString.All.
Import ListNotations.
Import C.Notations.
(** The classic Hello World program. *)
Definition hello_world (argv : list LString.t) : C.t System.effects unit :=
System.log (LString.s "Hello world!").
-- Update ---
#gtzinos, I followed the readme in https://github.com/clarus/coq-hello-world. This time there was no complaint about System.effects, but there was a new error about Extraction.launch not found. I tried:
git clone https://github.com/clarus/coq-hello-world.git
cd coq-hello-world
./configure.sh && make
and got:
"coqc" -q -R src HelloWorld src/Main
File "/.../coq-hello-world/src/Main.v", line 32, characters 19-36:
Error: The reference Extraction.launch was not found in the current
environment.
I tried also to make in the extraction folder, but without success. Any pointers?
New versions of the coq:io and coq:io:system libraries were just released. Run:
opam update
opam upgrade
to make sure you have coq:io:system in version at least 2.3.0. Now Extraction.launch should be available. System.effects has been replaced by System.effect.