Giter VIP home page Giter VIP logo

purescript-native's People

Contributors

5outh avatar andreypopp avatar andyarvanitis avatar ardumont avatar bogdanp avatar brandonhamilton avatar dylex avatar epost avatar erdeszt avatar faineance avatar frigoeu avatar garyb avatar hdgarrood avatar japesinator avatar joneshf avatar kritzcreek avatar liamgoodacre avatar michaelficarra avatar michaelxavier avatar mjgpy3 avatar natefaubion avatar nicodelpiano avatar nwolverson avatar paf31 avatar panhania avatar phadej avatar puffnfresh avatar soupi avatar vkorablin avatar zudov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

purescript-native's Issues

error building purescript-dotlang

I'm trying to add https://github.com/csicar/purescript-dotlang as a dependency, and I get the following error:

go: finding module for package project.localhost/purescript-native/output/Color.1
output/Data.DotLang.Attr.Edge/Data_DotLang_Attr_Edge.go:11:5: cannot find module providing package project.localhost/purescript-native/output/Color.1: unrecognized import path "project.localhost/purescript-native/output/Color.1": https fetch: Get "https://project.localhost/purescript-native/output/Color.1?go-get=1": dial tcp: lookup project.localhost: no such host
psgo: callProcess: go "build" "project.localhost/purescript-native/output/Main" (exit 1): failed

Checking the file output/Data.DotLang.Attr.Edge/Data_DotLang_Attr_Edge.go, I see that the "colors" project is referenced as "project.localhost/purescript-native/output/Color.1", but it exists under the folder Color: output/Color/Color.go. I'm not very familiar with go modules. Is there a reason the suffix .1 is being attached to the module name?

purescript-native does not work with the default package-set

As indicated in the paste below, there seems to be inconsistent name mangling (generally involving the '$' prefix).

  • As this pcc version seems to only support purescript 0.10.x, I've downgraded my psc-package set to use older package sets.

Platform: Mac OS 10.12.6.
clang --version
Apple LLVM version 9.0.0 (clang-900.0.37)
Target: x86_64-apple-darwin16.7.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

Compiling Data.Show
Compiling Data.NaturalTransformation
Compiling Data.Boolean
Compiling Control.Semigroupoid
Compiling Control.Category
Compiling Data.Void
Compiling Data.Unit
Compiling Data.HeytingAlgebra
Compiling Data.Semiring
Compiling Data.Function
Compiling Data.Semigroup
Compiling Data.Eq
Compiling Data.Functor
Compiling Data.Ring
Compiling Data.CommutativeRing
Compiling Data.BooleanAlgebra
Compiling Data.Ordering
Compiling Control.Apply
Compiling Data.EuclideanRing
Compiling Data.Ord.Unsafe
Compiling Data.Field
Compiling Data.Ord
Compiling Control.Applicative
Compiling Control.Bind
Compiling Control.Monad
Compiling Data.Bounded
Compiling Control.Monad.Eff
Compiling Prelude
Compiling Control.Monad.Eff.Class
Compiling Control.Monad.Eff.Unsafe
Compiling Control.Monad.Eff.Console
Compiling Main
Compiling PSCI.Support
Creating output/Control.Applicative/Applicative.o
In file included from output/Control.Applicative/Applicative.cc:3:
In file included from output/Control.Applicative/Applicative.hh:6:
In file included from output/Control.Apply/Apply.hh:6:
In file included from output/Data.Functor/Functor.hh:7:
In file included from output/Data.Unit/Unit.hh:6:
output/Data.Show/Show.hh:49:12: error: use of undeclared identifier 'showCharImpl'; did you mean '$showCharImpl'?
    return showCharImpl($6);
           ^~~~~~~~~~~~
           $showCharImpl
output/Data.Show/Show.hh:48:15: note: '$showCharImpl' declared here
  inline auto $showCharImpl(const any& $6) -> any {
              ^
output/Data.Show/Show.hh:52:12: error: use of undeclared identifier 'showIntImpl'; did you mean '$showIntImpl'?
    return showIntImpl($7);
           ^~~~~~~~~~~
           $showIntImpl
output/Data.Show/Show.hh:51:15: note: '$showIntImpl' declared here
  inline auto $showIntImpl(const any& $7) -> any {
              ^
output/Data.Show/Show.hh:55:12: error: use of undeclared identifier 'showNumberImpl'; did you mean '$showNumberImpl'?
    return showNumberImpl($8);
           ^~~~~~~~~~~~~~
           $showNumberImpl
output/Data.Show/Show.hh:54:15: note: '$showNumberImpl' declared here
  inline auto $showNumberImpl(const any& $8) -> any {
              ^
output/Data.Show/Show.hh:58:12: error: use of undeclared identifier 'showStringImpl'; did you mean '$showStringImpl'?
    return showStringImpl($9);
           ^~~~~~~~~~~~~~
           $showStringImpl
output/Data.Show/Show.hh:57:15: note: '$showStringImpl' declared here
  inline auto $showStringImpl(const any& $9) -> any {
              ^
output/Control.Applicative/Applicative.cc:23:47: error: no member named 'unit' in namespace 'Data_Unit'
      return pure(dictApplicative, Data_Unit::unit);
                                   ~~~~~~~~~~~^
output/Control.Applicative/Applicative.cc:42:47: error: no member named 'unit' in namespace 'Data_Unit'
      return pure(dictApplicative, Data_Unit::unit);
                                   ~~~~~~~~~~~^
6 errors generated.
make[1]: *** [output/Control.Applicative/Applicative.o] Error 1
make: *** [release] Error 2

Instructions for spago and go do not work

Hello!
I already posted this on spago repository, but maybe it is best suited here, so please forgive me if this duplication causes any problem or overload the same team in some way.
I'm having problems on macOS to run spago build using psgo as backend.
I have Go toolchain installed and I can run go in any terminal.

Here is my spago.dhall:

{ name = "my-project"
, dependencies = [ "console", "effect", "psci-support" ]
, packages = ./packages.dhall
, sources = [ "src/**/*.purs", "test/**/*.purs" ]
, backend = "psgo"
}

And here is the error I'm getting:

➜  spago build
[info] Installation complete.
[info] Build succeeded.
/bin/sh: psgo: command not found
[error] Backend "psgo" exited with error:127

I followed all the isntruction shtat I have found and I'm not sure what else should I try or install.
Compiling to JS has no problems.
Thanks in advance.

Returning a constant from the ffi

This isn't a bug but more of a question/potential point for documentation. I've been able to successfully implement functions in the FFI, but constants are proving a bit elusive for me. If I try to implement Global.infinity this way:

exports["infinity"] = []() -> boxed {
  return 1000.0;
};

And then I print it out later like this:

std::cout << "infinity " << unbox<double>(Global::infinity()) << std::endl;

I see the following output on the console:

infinity 6.90463e-310

I'm probably doing something wrong in the export, but I'm not quite sure how to get it to print the right number (in this case 1000.0, eventually I'll use the C++ infinity, but this is just a sanity check). Thanks in advance for your advice!

Incorrect equality check in Data_Interval_Duration_Iso

The following cpp code was generated for boxed variables:

            return Math::floor()(a) != a;

I'm still learning how all this is put together, but it seems the correct generation would be:

            return Data_Eq::notEq()(Math::floor()(a))(a);

Question: compiling purescript-in-purescript

We previously put the purescript-in-purescript self-hosted compiler project on hold even though it was functional, because the generated JS was too slow. Rewrites might be a good way to speed it up, but I think that pure11 could be another good approach. If we could get it to compile, then the C++11 target could be a good way to distribute a cross-platform self-hosted compiler.

It would require porting some FFI libraries, so it would require quite a lot of work, but I'm pretty excited at the idea.

Would you be interested in working towards this as one long term goal, once we get the multiple backends/FFI stuff out of the way, and hopefully pure11 merged into psc?

Missing FFI implementation only reported on first invocation of pcc

Hey, just trying to get a hello world example compiled. New to Purescript and Pure14 so I apologise for my ignorance in advance.

The code I am trying to compile is the hello world from pulp with modified bower.json and using a Makefile.

Currently I get this error on the first invocation of make

Missing FFI implementations for module Prelude

on the second invocation, make completes without reporting any errors but if I go through using cmake and then using the generated makefile it reports:

Prelude.hh:6:26: fatal error: Prelude_ffi.hh: No such file or directory
 #include "Prelude_ffi.hh"

and I can't find this file in the output either.

stack nix integration

I was getting linker errors on ubuntu trying to stack instal psgo, as it was failing to find gmp. I noticed that gmp was already listed in the stack.nix file, so it should be picked up. I finally realized that the "enable" flag is missing under nix so the nix integration in stack is not actually active:

 nix:
+  enable: true
   shell-file: stack.nix

After enabling this, it built flawlessly. If you're not using this personally, I think it would at least be helpful to put this line in there, commented out with a comment above suggesting to uncomment if you'd like to use nix to build.

Support spago alternate entry point option

When providing an argument to the -m flag to spago run such as spago run -m Parser, I get following error

getModificationTime:getFileStatus: does not exist (No such file or directory)

This seems to do with how the module name "Main" is reserved https://github.com/andyarvanitis/purescript-native/pull/60/files#diff-bbb636505a367cfa1f620353cba3c3e3R452. Main is compiled in package main, while libraries intended to be imported and not run are compiled with a package named after the module path.

In order to use the same module as a library and make it runnable, it seems that modules that define a main of the right type should have a wrapper module generated with package main and a library module with the normal module path name. The main module can simply import the library package and call the main function in the package, so that the main function is still visible to consumers of the library as a normal main as it is in purescript js.

A workaround for this is to define multiple spago projects as described here https://github.com/purescript/spago#monorepo, one with the shared code, and one for each binary. This mirrors go's restriction of having one main per folder.

Can't compile purescript-native

As a novice developer, using the latest purescript, cloned at:

e9985182 (HEAD -> native, origin/native, origin/HEAD) Merge remote-tracking branch 'pure11/pure11' into native

After performing a stack setup, which operated without any surprises;

I can't compile the project using stack install, running on mac os x 10.12.6:

Johns-MacBook-Pro% stack install
purescript-0.10.7: configure (lib + exe)
Configuring purescript-0.10.7...
purescript-0.10.7: build (lib + exe)
Preprocessing library purescript-0.10.7...
In-place registering purescript-0.10.7...
Preprocessing executable 'pcc' for purescript-0.10.7...
[1 of 4] Compiling Makefile         ( pcc/Makefile.hs, .stack-work/dist/x86_64-osx/Cabal-1.22.5.0/build/pcc/pcc-tmp/Makefile.o )
<command line>: can't load .so/.DLL for: /Users/john/apps/purescript-native/.stack-work/dist/x86_64-osx/Cabal-1.22.5.0/build/libHSpurescript-0.10.7-AKhdPYIpW9yFjMdYGcLWK5-ghc7.10.3.dylib (dlopen(/Users/john/apps/purescript-native/.stack-work/dist/x86_64-osx/Cabal-1.22.5.0/build/libHSpurescript-0.10.7-AKhdPYIpW9yFjMdYGcLWK5-ghc7.10.3.dylib, 5): no suitable image found.  Did find:
	/Users/john/apps/purescript-native/.stack-work/dist/x86_64-osx/Cabal-1.22.5.0/build/libHSpurescript-0.10.7-AKhdPYIpW9yFjMdYGcLWK5-ghc7.10.3.dylib: malformed mach-o: load commands size (38088) > 32768
	/Users/john/apps/purescript-native/.stack-work/dist/x86_64-osx/Cabal-1.22.5.0/build/libHSpurescript-0.10.7-AKhdPYIpW9yFjMdYGcLWK5-ghc7.10.3.dylib: malformed mach-o: load commands size (38088) > 32768)

--  While building package purescript-0.10.7 using:
      /Users/john/.stack/setup-exe-cache/x86_64-osx/Cabal-simple_mPHDZzAJ_1.22.5.0_ghc-7.10.3 --builddir=.stack-work/dist/x86_64-osx/Cabal-1.22.5.0 build lib:purescript exe:pcc exe:psc exe:psc-bundle exe:psc-docs exe:psc-hierarchy exe:psc-ide-client exe:psc-ide-server exe:psc-package exe:psc-publish exe:psci --ghc-options " -ddump-hi -ddump-to-file"
    Process exited with code: ExitFailure 1

What should I look at next to attempt to resolve this issue?

Thanks.

zero-fill shift right operator doesn't exist

When building Data.Function.Memoize/Data_Function_Memoize.go, in the function ꞋtabulateNat, there is a call to zshr https://github.com/paf31/purescript-memoize/blob/v5.0.0/src/Data/Function/Memoize.purs#L135 which gets translated to >>> here:

, binary ZeroFillShiftRight ">>>" ]

but I don't believe c++ or go have this operator (whereas java and javascript do).

I get the following error:

expected operand, found '>' (and 1 more errors)

How to bind my own `go ffi`?

As mentioned in the wiki, binding your own go ffi requires a file "XXX.go", which contains package name and function exports.
But where should I put it?
Should it like common purescript JS FFI, putting files in the same folder, e.g. XXX.purs XXX.js under src/
Or could it be put anywhere and referring it with purescript-native/ffi_loader.go
In a nutshell, what is the recommended file structure (using spago)?

Support for go modules?

I successfully built a "hello world" program following the Getting Started guide.

However, I cannot build when using go modules.

For example, in my working directory, I have a go.mod containing github.com/pmahoney/example. The build then fails:

$ go version
go version go1.12.7 darwin/amd64

$ spago build -- -g corefn && psgo 
Installation complete.
Build succeeded.
can't load package: package Main: unknown import path "Main": cannot find module providing package Main

Running go build myself also fails:

$ spago build -- -g corefn && psgo --no-build
Installation complete.
Build succeeded.

$ cd output/src/Main; go build .
build github.com/pmahoney/example/output/src/Main: cannot load Effect_Console: cannot find module providing package Effect_Console

In general, I'm not sure un-namespaced imports are possible when using go modules (other than from the go standard library), where previously constructing an appropriate GOPATH allowed this. go help gopath says:

When using modules, GOPATH is no longer used for resolving imports.

Extending existing go FFI bindings

I've created a project to demonstrate an issue I'm experiencing. I noticed that the existing FFI implementation for Effect.Uncurried doesn't implement runEffectFn2, so I decided to add it myself.

If I add the required code to one of my own modules (e.g. Main), it works fine. However, if I attempt to extend the existing FFI implementations for the Effect.Uncurried module in my own code, it fails with a segfault. Based on my reading of the Foreign function, it seems that I should be able to extend bindings for existing modules.

What am I doing wrong?

Name clash when compiling Foreign.Index

I was trying to compile a simple program with psgo that uses simple-json. I expected lots of missing functions but instead, I found a compile error that arises directly from generated code:

.../output/Main/Main.go
# project.localhost/purescript-native/output/Foreign.Index
output/Foreign.Index/Foreign_Index.go:8:5: Foreign redeclared as imported package name
        previous declaration during import "github.com/purescript-native/go-runtime"
output/Foreign.Index/Foreign_Index.go:128:22: use of package Foreign without selector
psgo: callProcess: go "build" "project.localhost/purescript-native/output/Main" (exit 2): failed

Char literals

As of right now, there is limited support in Pure11: a Char literal is a single character delimited by single quotes (like Haskell). However, it is simply interpreted as and translated to a numeric literal, which works, but is inadequate in the long run. PureScript does not currently support Char literals, so any work on full support should involve a discussion with the PureScript folks.

module Main where

import Debug.Trace

hello :: [Char]
hello = ['A', 66, 67, 'D']

cchar :: Char
cchar = 'A'

translateChar :: Char -> Char
translateChar 'A' = '_'
translateChar c = c

main = do
  trace (show $ toString hello)
// Generated by pcc version 0.6.8
#ifndef Main_H
#define Main_H

#include "Debug/Trace/Trace.hh"
#include "Prelude/Prelude.hh"
//
namespace Main {
    using namespace Debug_Trace;
    using namespace Prelude;

    auto translateChar(char _0) -> char;
    auto main() -> data<Prelude::Unit>;
    auto const hello = list<char>({39, 66, 67, 39});
    auto const cchar = 39;
}
#endif // Main_H

Generated 'psc-package.json' is invalid

pcc generates the following psc-package.json:

{
    "name": "Main",
    "set": "master",
    "source": "https://github.com/pure11/package-sets.git",
    "depends": [
        "console",
        "prelude"
    ]
}

This is invalid:

$ psc-package update
Unable to parse psc-package.json: Error in $.name: Invalid package name: InvalidChars "M"

With name changed from Main to main, everything works as expected:

$ psc-package update
Updating 3 packages...
Updating console
Updating eff
Updating prelude
Update complete

Hello sailor SIGSEGVs on MacOS

Built pscpp from source on OSX 10.13.6.

module Main where
import Prelude
import Effect.Class.Console (log)

main = do
  log "Hello sailor!"
clang --version
Apple LLVM version 10.0.0 (clang-1000.10.44.2)
Target: x86_64-apple-darwin17.7.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
> output/bin/main
fish: 'output/bin/main' terminated by signal SIGSEGV (Address boundary error)

Here is the stack trace and the .crash file is attached.

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libsystem_platform.dylib      	0x00007fff735456b3 _platform_strcmp + 19
1   main                          	0x0000000106cf1f82 std::__1::__function::__func<Effect_Class::liftEffect()::$_2, std::__1::allocator<Effect_Class::liftEffect()::$_2>, purescript::boxed (purescript::boxed const&)>::operator()(purescript::boxed const&) + 66
2   main                          	0x0000000106cf3bd9 std::__1::__function::__func<Effect_Class_Console::log()::$_3, std::__1::allocator<Effect_Class_Console::log()::$_3>, purescript::boxed (purescript::boxed const&)>::operator()(purescript::boxed const&) + 105
3   main                          	0x0000000106cf7ee8 std::__1::__function::__func<Main::main()::$_0, std::__1::allocator<Main::main()::$_0>, purescript::boxed (purescript::boxed const&)>::operator()(purescript::boxed const&) + 56
4   main                          	0x0000000106cf7d79 main + 121
5   libdyld.dylib                 	0x00007fff73237015 start + 1

main_2018-09-17-182433_kirill-mbp.crash.zip

cannot compile a simple example (Windows)

I wrote a simple program as follows:

module Main where
import Prelude
import Control.Monad.Eff.Console (log, logShow)

fib :: Int -> Int
fib 0 = 0
fib 1 = 1
fib n = fib (n - 2) + fib (n - 1)

main = do
log "Here's the result of fib 10:"
logShow (fib 10)

I build it use pulp build , and it generated as follows

// Generated by pcc version 0.10.7

include "Main/Main.hh"

namespace Main {
using namespace PureScript;
using namespace Prelude;
using namespace Control_Monad_Eff_Console;
using namespace Data_Semiring;
using namespace Data_Ring;
using namespace Control_Bind;
using namespace Control_Monad_Eff;
using namespace Data_Show;

auto fib(int v) -> int {
switch (static_cast(v)) {
case 0: return 0;
case 1: return 1;
};
return fib(v - 2) + fib(v - 1);
};
auto main() -> any {
Control_Monad_Eff_Console::log("Here's the result of fib 10:")();
return Control_Monad_Eff_Console::logShow(Data_Show::showInt, fib(10))();
};
}

auto main(int, char *[]) -> int {
using namespace Main;
INITIALIZE_GC();
Main::main();
return 0;
};

And then I run make

I got these errors

"Creating" output/Control.Monad/Monad.o
In file included from output/Data.Unit/Unit.hh:6:0,
from output/Data.Functor/Functor.hh:7,
from output/Control.Apply/Apply.hh:6,
from output/Control.Applicative/Applicative.hh:6,
from output/Control.Monad/Monad.hh:6,
from output/Control.Monad/Monad.cc:3:
output/Data.Show/Show.hh: In function 'PureScript::any Data_Show::$showCharImpl(const PureScript::any&)':
output/Data.Show/Show.hh:49:27: error: 'showCharImpl' was not declared in this scope
return showCharImpl($6);
^
output/Data.Show/Show.hh: In function 'PureScript::any Data_Show::$showIntImpl(const PureScript::any&)':
output/Data.Show/Show.hh:52:26: error: 'showIntImpl' was not declared in this scope
return showIntImpl($7);
^
output/Data.Show/Show.hh: In function 'PureScript::any Data_Show::$showNumberImpl(const PureScript::any&)':
output/Data.Show/Show.hh:55:29: error: 'showNumberImpl' was not declared in this scope
return showNumberImpl($8);
^
output/Data.Show/Show.hh: In function 'PureScript::any Data_Show::$showStringImpl(const PureScript::any&)':
output/Data.Show/Show.hh:58:29: error: 'showStringImpl' was not declared in this scope
return showStringImpl($9);
^
At global scope:
cc1plus.exe: warning: unrecognized command line option '-Wno-logical-op-parentheses'
Makefile:161: recipe for target 'output/Control.Monad/Monad.o' failed
make[1]: *** [output/Control.Monad/Monad.o] Error 1
make[1]: Leaving directory 'E:/hs/pur11'
Makefile:104: recipe for target 'release' failed
make: *** [release] Error 2

here is the Show.hh

// Generated by pcc version 0.10.7
#ifndef Data_Show_HH
#define Data_Show_HH

#include "PureScript/PureScript.hh"
#include "Show_ffi.hh"

namespace Data_Show {
using namespace PureScript;

namespace ctor {
enum : int { _ };
}

struct Show {
enum { show };
};
auto showString(any::as_thunk) -> const any&;
auto showNumber(any::as_thunk) -> const any&;
auto showInt(any::as_thunk) -> const any&;
auto showChar(any::as_thunk) -> const any&;
auto showBoolean(any::as_thunk) -> const any&;

auto showArray(const any&) -> any;
auto $showArrayImpl(const any&) -> any;

/**

  • | The Show type class represents those types which can be converted into
  • | a human-readable String representation.
  • |
  • | While not required, it is recommended that for any expression x, the
  • | string show x be executable PureScript code which evaluates to the same
  • | value as the expression x.
    */

inline auto $show(const any& dict) -> any {
return dict::getShow::show(dict);
};
inline auto show(const any& dict, const any& $3) -> any {
return dict::getShow::show(dict)($3);
};

inline auto $showArray(const any& dictShow) -> any {
return showArray(dictShow);
};
inline auto $showCharImpl(const any& $6) -> any {
return showCharImpl($6);
};
inline auto $showIntImpl(const any& $7) -> any {
return showIntImpl($7);
};
inline auto $showNumberImpl(const any& $8) -> any {
return showNumberImpl($8);
};
inline auto $showStringImpl(const any& $9) -> any {
return showStringImpl($9);
};
}

#endif // Data_Show_HH
`

here is the show.cc

`// Generated by pcc version 0.10.7

#include "Data.Show/Show.hh"

DEFINE_SYMBOL(show)

namespace Data_Show {
using namespace PureScript;

auto showString(any::as_thunk) -> const any& {
static const any the_value = dict::make(
{ SYM(show), $showStringImpl }
);
return the_value;
};
auto showNumber(any::as_thunk) -> const any& {
static const any the_value = dict::make(
{ SYM(show), $showNumberImpl }
);
return the_value;
};
auto showInt(any::as_thunk) -> const any& {
static const any the_value = dict::make(
{ SYM(show), $showIntImpl }
);
return the_value;
};
auto showChar(any::as_thunk) -> const any& {
static const any the_value = dict::make(
{ SYM(show), $showCharImpl }
);
return the_value;
};
auto showBoolean(any::as_thunk) -> const any& {
static const any the_value = dict::make(
{ SYM(show), [](const any& v) -> any {
if (v) {
return any("true");
} else {
return any("false");
};
} }
);
return the_value;
};

auto showArray(const any& dictShow) -> any {
return dict::make(
{ SYM(show), $showArrayImpl($show(dictShow)) }
);
};
auto $showArrayImpl(const any& $4) -> any {
return [=](const any& $5) -> any {
return showArrayImpl($4, $5);
};
};
}

`

my purescript-native sha version is

0cab7d6cfbea0cd29ba0376da2139fea45383928

I built it use stack build command.

MAKE version is :

GNU Make 4.1
Built for i686-w64-mingw32

GCC version is

gcc (i686-posix-sjlj-rev1, Built by MinGW-W64 project) 6.3.0
Copyright (C) 2016 Free Software Foundation, Inc.`

OS is : windows 10

so, Did I do something wrong? I also convert make file to visual studio 2015 project, I got the same error!

No matching function for call to ‘purescript::boxed::boxed()’.

Hello @andyarvanitis,

I believe removing this line from the run time causes the following error.

In file included from output/src/purescript.h:23:0,
                 from output/src/Global/Global.h:6,
                 from output/src/Global/Global.cpp:2:
output/src/string_literal_dict.h: In instantiation of ‘T& string_literal_dict_t<T>::operator[](const char*) [with T = purescript::boxed]’:
output/src/purescript.h:97:52:   required from here
output/src/string_literal_dict.h:70:12: error: no matching function for call to ‘purescript::boxed::boxed()’

I don't believe this is specific to purescript-globals but it could be. The compiler throws an error here.

Rolling back to the previous commit does resolve the issue.

Thanks!

👍

"attribute 'haskell-nix' missing" when building with nix

I'm trying build the master branch from source in an existing nix project:

import
        (pkgs.fetchFromGitHub
          {
            owner = "andyarvanitis";
            repo = "purescript-native";
            rev = "7a3f114fb158a250c6130c93752719b6d69c606a";
            sha256 = "1j0d25g5j3givf4shhnvnxqj54jjxzsj2sdm53xcirp7d9w78hmj";
          })
        {}

I get the error attribute 'haskell-nix' missing, at /nix/store/jbhar7ldha5r2dmxqj0j912i2k7zvn9k-source/default.nix:18:1

I tried copying the pkgs.haskell.lib.buildStackProject expression from stack.nix directly into my project, but I got different error from stack

Received ExitFailure 1 when running                                                                                   Raw command: /private/var/folders/8b/yry_95qs2n1f4kpz_r94606w0000gn/T/nix-build-default-stack-shell.drv-0/.stack/programs/x86_64-osx-nix/ghc-8.6.5.temp/ghc-8.6.5/configure --prefix=/private/var/folders/8b/yry_95qs2n1f4kpz_r94606w0000gn/T/nix-build-default-stack-shell.drv-0/.stack/programs/x86_64-osx-nix/ghc-8.6.5/
Run from: /private/var/folders/8b/yry_95qs2n1f4kpz_r94606w0000gn/T/nix-build-default-stack-shell.drv-0/.stack/programs/x86_64-osx-nix/ghc-8.6.5.temp/ghc-8.6.5/


Error: Error encountered while configuring GHC with
         /private/var/folders/8b/yry_95qs2n1f4kpz_r94606w0000gn/T/nix-build-default-stack-shell.drv-0/.stack/programs/x86_64-osx-nix/ghc-8.6.5.temp/ghc-8.6.5/configure --prefix=/private/var/folders/8b/yry_95qs2n1f4kpz_r94606w0000gn/T/nix-build-default-stack-shell.drv-0/.stack/programs/x86_64-osx-nix/ghc-8.6.5/
         run in /private/var/folders/8b/yry_95qs2n1f4kpz_r94606w0000gn/T/nix-build-default-stack-shell.drv-0/.stack/programs/x86_64-osx-nix/ghc-8.6.5.temp/ghc-8.6.5/

       The following directories may now contain files, but won't be used by stack:
         - /private/var/folders/8b/yry_95qs2n1f4kpz_r94606w0000gn/T/nix-build-default-stack-shell.drv-0/.stack/programs/x86_64-osx-nix/ghc-8.6.5.temp/
         - /private/var/folders/8b/yry_95qs2n1f4kpz_r94606w0000gn/T/nix-build-default-stack-shell.drv-0/.stack/programs/x86_64-osx-nix/ghc-8.6.5/

       For more information consider rerunning with --verbose flag

It suggests adding the verbose flag to debug further, but I'm not sure how to pass that down from nix.

Is building the project like this not a normal pattern? I'm not too familiar with nix yet.

ffi array type interop with opaque types

I was trying to return an array from a function and use it with common Foldable and Traversable functions, and hit a wall of silent failures. Luckily, since the build doesn't detect changes in the output directory, I was able to throw some printlns in there and rebuild without it being overwritten. I found that casts in functions like Data.Array.length like

 xs, _ := xs_.([]Any)

return an empty array when the cast to interface fails.

To fix this, the type cannot simply be assigned to interface:

cannot use files (variable of type []os.FileInfo) as []interface{} value in variable declaration

so it needs to be copied, as this go wiki page points out:

https://github.com/golang/go/wiki/InterfaceSlice#what-can-i-do-instead

I'm wondering whether there's any way to get around this. Maybe define Traversable instances for an opaque type? I haven't tried this and not sure how much boilerplate it would require, but if there is some boilerplate on the go ffi side, maybe it could be provided in the small runtime library where Fn1-10 reside.

Below is the ffi function I ended up with that copies the array:

exports["readDir'"] = func(left Any) Any {
      return func(right Any) Any {
        return func(file_ Any) Any {
          file := file_.(string)
          return func() Any {
            files, err := ioutil.ReadDir(file)
            if err == nil {
              var f []interface{} = make([]interface{}, len(files))
              for i, d := range files {
                f[i] = d
              }
              return Apply(right, f)
            } else {
              return Apply(left, err.Error())
            }
          }
        }
      }
    }

Safe heap allocation via ST

This is not my area of expertise, but it seems like ST would be a nice way to use the type system to avoid reference counting. Would this be possible?

The idea is that we would malloc and delete the appropriate things in runST, and stack allocate everything else.

I'm not sure how this would affect things like sharing in data structures.

Discuss: C++-specific REPL support

My understanding is that by "No C++-specific REPL", it means there's no way to try out purescript-native in a REPL. I'll admit I haven't even used the Purescript REPL for node.js yet, but haven't had a need to as yet. However, I do have an interested in a native REPL.

What needs to be done in order to have a purescript-native REPL running, if anything? Is the existing node.js REPL a good place to start?

Thanks,

golang casting in byte operations?

Hi Andy
Found this code generated in Data_Int while goofing with Random this evening.
Looks like x should be x.(int)?

Thanks
Alex

func PS__even() Any {
    return func(x Any) Any {
        return (x & 1) == 0
    }
}

Major refactor

From the TO-DO section in the README:

  • Proper break-out of pure11 generation — just a hacked fork right now
  • Lots of testing and code cleanup!

Work is underway at https://github.com/andyarvanitis/pure11-core-imp

This should be a much better baseline for anyone who wishes to contribute, as soon as the dust settles a bit. Note that it also relies on the refactoring being done by the PureScript guys in their repo's core-imp branch (plus some other changes).

Cannot install

$ stack --version
Version 2.2.0, Git revision aa3a5f2573ffe8791f63e621447c9084d5aa0ba1 (dirty) PRE-RELEASE x86_64 hpack-0.31.1
$ stack install
Cannot complete repo information for a non SHA1 commit due to non-reproducibility: Git repo at https://github.com/purescript/purescript, commit v0.12.3

Recursive call in a let binding?

Hello @andyarvanitis,

This may be an error.

Given

module Main where

import Prelude
import Effect
import Effect.Console

main :: Effect Unit
main = do
  let loop = void do
        log "1"
        when true $ do
          log "2"
          loop
  loop
  pure unit

The output is

./output/bin/main
1
2
terminate called after throwing an instance of 'std::bad_function_call'
  what():  bad_function_call
[1]    16310 abort (core dumped)  ./output/bin/main

I came across this issue while using purescript-behaviors (AnimationFrame.purs). I added all of the FFI needed and it calls the loop once but then errors out on the second time around.

Here is the C++ output for the small test case.

namespace Main {

auto main() -> boxed {
    boxed loop = box<fn_t>();
    loop = Data_Functor::$$void()(Effect::functorEffect())([=]() -> boxed {
        Effect_Console::log()("1")();
        return Control_Applicative::when()(Effect::applicativeEffect())(true)([=]() -> boxed {
            Effect_Console::log()("2")();
            return loop();
        })();
    });
    return [=]() -> boxed {
        loop();
        return Data_Unit::unit();
    };
};


} // end namespace Main

int main(int argc, const char * argv[]) {
    Main::main()();
    return 0;
}

Here is the backtrace.

backtrace

#0  0x00007ffff6f4bd7f in raise () from /usr/lib/libc.so.6

#1  0x00007ffff6f36672 in abort () from /usr/lib/libc.so.6

#2  0x00007ffff730058e in __gnu_cxx::__verbose_terminate_handler () at /build/gcc/src/gcc/libstdc++-v3/libsupc++/vterminate.cc:95

#3  0x00007ffff7306dfa in __cxxabiv1::__terminate (handler=<optimized out>) at /build/gcc/src/gcc/libstdc++-v3/libsupc++/eh_terminate.cc:47

#4  0x00007ffff7306e57 in std::terminate () at /build/gcc/src/gcc/libstdc++-v3/libsupc++/eh_terminate.cc:57

#5  0x00007ffff73070ac in __cxxabiv1::__cxa_throw (obj=<optimized out>, tinfo=tinfo@entry=0x7ffff73f9f80 <typeinfo for std::bad_function_call>, dest=dest@entry=0x7ffff7330bc0 <std::bad_function_call::~bad_function_call()>) at /build/gcc/src/gcc/libstdc++-v3/libsupc++/eh_throw.cc:95

#6  0x00007ffff7330c38 in std::__throw_bad_function_call () at /build/gcc/src/gcc-build/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/exception.h:63

#7  0x0000555555738a80 in std::function<purescript::boxed ()>::operator()() const (this=0x5555575915f0) at /usr/include/c++/8.2.1/bits/std_function.h:686

#8  0x0000555555738958 in purescript::boxed::operator() (this=0x555557591f40) at output/src/purescript.h:105

#9  0x000055555695ec2c in Main::<lambda()>::<lambda()>::operator()(void) const (__closure=0x555557591f40) at output/src/Main/Main.cpp:21

#10 0x0000555556960591 in std::_Function_handler<purescript::boxed(), Main::main()::<lambda()>::<lambda()> >::_M_invoke(const std::_Any_data &) (__functor=...) at /usr/include/c++/8.2.1/bits/std_function.h:283

#11 0x0000555555738a98 in std::function<purescript::boxed ()>::operator()() const (this=0x555557591970) at /usr/include/c++/8.2.1/bits/std_function.h:687

#12 0x0000555555738958 in purescript::boxed::operator() (this=0x7fffffffd4f0) at output/src/purescript.h:105

#13 0x000055555695edd2 in Main::<lambda()>::operator()(void) const (__closure=0x555557591a10) at output/src/Main/Main.cpp:22

...

Looks like it is failing here and that f is not a function.

Any possible workarounds?

Thanks!

👍

A few issues on a sample project

First and foremost, thanks for purescript-native! I'm super excited about the potential of using a go backend for PureScript.

I recently created a small example project here and noticed a few interesting things.

First, the generated replace directives in the top-level go.mod used absolute paths. This seems bad. I replaced them with relative paths and everything continues to build. I believe this should be the default behavior. Thoughts?

Second, when creating my foreign implementation for foreign import myEffect :: Effect Int, I expected to be able to export a func () int. This successfully builds, but segfaults at runtime. It seems I need to return a func () Any, even though my Effect is parameterized by Int. You can see the implementations here.

Last, it feels a little strange to have so many levels of go.mod files and have the default naming scheme for the project be project.localhost/purescript-native/ffi-loader. I ended up creating a new package within the purescript-native directory and importing it in the ffi-loader here, but this feels strange. Is this the idiomatic way to introduce my own foreign functions?

Thanks!

couple of bugs

Hi Andy -- amazing project, would like to contribute at some level (but I'm not really an expert).

I'm porting some of my Haskell code to purescript, and am very intrigued to be able to interface this with a huge C++ code base we're using for data analysis (I am working on one of the Large Hadron Collider experiments at CERN in Switzerland).

I've found a couple of cases where the C++ code generated is incorrect: one where it leads to code that crashes with segmentation fault, another where the results of some record manipulation is not what's expected. In both cases the regular version of purescript gives the expected results.

Should I wait for an upcoming version that catches up with purescript 0.11 and test again, or send a bug report now?

Thanks, LatB

Address issues with "Integral" type

Right now, integer literals are inferred as a new "Integral" primitive type. It's acting as a sort of interim type, on its way to ending up an Int, Number, Integer, etc.. This is to avoid implicit (and permissive) conversions between numeric types. This mechanism needs work. A number of PureScript tests fail due to issues related to this.

Cannot find ls/ls.h and rs/rs.h

Hi!

First off, thanks a lot for this great project.

I'm trying to compile something that uses Data.Set and hitting the following error:

Creating output/src/Data_Set/Data_Set.o (C++)
output/src/Data_Set/Data_Set.cpp:13:19: fatal error: ls/ls.h: No such file or directory
 #include "ls/ls.h"
                   ^
compilation terminated.
Makefile:100: recipe for target 'output/src/Data_Set/Data_Set.o' failed
make[1]: *** [output/src/Data_Set/Data_Set.o] Error 1
make[1]: Leaving directory '/home/mike/purescript-audio-behaviors'
Makefile:58: recipe for target 'debug' failed
make: *** [debug] Error 2

I can't find ls/ls.h anywhere in the generated source or ffi. Is this part of an external library? Thanks!

purescript-native-go-ffi path?

Hi Andy
Can you clarify for me where this should be checked out when using psgo?
I am getting:

src/purescript-assert/Test_Assert.go:4:2: cannot find package "Test_Assert" in any of:
	/usr/local/Cellar/go/1.11.5/libexec/src/Test_Assert (from $GOROOT)
	/Users/mouton/Documents/code/purescript/purescript-native/ps/output/src/Test_Assert (from $GOPATH)
	/Users/mouton/Documents/code/purescript/purescript-native/ps/src/Test_Assert

I have been messing with $GOPATH, so may have changed the output but I am expecting i should see src/purescript-assert/Test_Assert, or have purescript-native-ffi dir in my GOPATH?

Excuse me if this is should beobvious
Thanks
A

Running tests on the go backend

I added some tests to my example project in this commit. However, when I run spago test it builds and runs my Main module instead.

How should I be running my tests?

Problems with nix toolchain

I'm in the golang branch, trying to build or initialize a shell does not work
with the following error

error: attribute 'nixpkgs-1903' missing, at /home/gallo/software/purescript-native/default.nix:3:16

and of course the problem is in default.nix

  nixpkgsSrc = haskellNix.sources.nixpkgs-1903; # has hsc2hs-0.68.4

where apparently the tarball downloaded does not have the nixpkgs-1903
anymore, do you know a quickfix for this? Otherwise I could look into it.

Also, the cpp branch, which I'm mostly interested in, does not have
the nix toolchain.

Thanks for the awesome project.

ObjectUpdate seems to need deep copy

It seems that object values are overwritten by shallow copy.
https://github.com/andyarvanitis/purescript-native/blob/golang/src/CodeGen/IL.hs#L183

I don't have a pr, but for now I just report.
I noticed that during my recent work.
https://github.com/opyapeus/psimp

Example

module Main where

import Prelude
import Effect (Effect)
import Effect.Console (log)

-- ObjectUpdate
passYear :: forall a. { age :: Int | a } -> { age :: Int | a }
passYear x = x { age = x.age + 1 }

main :: Effect Unit
main = do
  let
    r = { age: 1 }
  log $ show r
  log $ show $ passYear r
  log $ show r

gets:

{ age: 1 }
{ age: 2 }
{ age: 2 }

expected:

{ age: 1 }
{ age: 2 }
{ age: 1 }

creating shared objects with purescript-native-cpp

I propose to use extern "C" functions for all exposed functions.This makes it possible to use them in shared libraries and shared object files. This solves two issues which could not be addressed with the current c++ functions:

  • get rid of the dictionary lookup for ffi calls
    if you try to use an ffi function which is not implemented yet you will get an
    error at library or shared object load time, not at runtime of the missing function
  • allow for using plugins in an running application
    this is not quite a repl but it allows live coding in a runnig application. You can edit
    the plugin module, recompile and reload it in the runnig application as shared object.
    #27

A runnig example can be found here:
hello world
which is implemented by changed the pscpp
pscpp
and ported the ffi functions for the standard library to the C function interface
ffi
I just used Linux, so no effort was made to make it work on other platforms.
I apreciate your comments and wish you a mery christmas.

Missing module Unsafe.Coerce?

I've only been using go for 30 minutes, and purescript for 3 days, so I'm not quite sure what to do next.... please go easy on me...

I've got spago to run the build (removed my GOPATH, and it all worked well). I've got a Main in the project root.

spago version
0.14.0
psgo --version
master, commit b5b1635138ba5e3f5dc90df77e3a2fb043e1a7e1

When I run ./Main it dumps at my option parser -> Data.Exists -> Unsafe.Coerce

What else can I tell you?

Stacktrace:

panic: Foreign value 'unsafeCoerce' for purescript module 'Unsafe.Coerce' not found

goroutine 1 [running]:
github.com/purescript-native/go-runtime.Get(...)
	/Users/ndrew/go/pkg/mod/github.com/purescript-native/[email protected]/purescript.go:40
project.localhost/purescript-native/output/Unsafe%2eCoerce.PS__unsafeCoerce.func1()
	/Users/ndrew/Code/shokinin/shokinin-20/output/Unsafe.Coerce/Unsafe_Coerce.go:24 +0x188
sync.(*Once).doSlow(0x1518648, 0x12d32f8)
	/usr/local/opt/go/libexec/src/sync/once.go:66 +0xec
sync.(*Once).Do(...)
	/usr/local/opt/go/libexec/src/sync/once.go:57
project.localhost/purescript-native/output/Unsafe%2eCoerce.PS__unsafeCoerce(0x12745a0, 0x12d2cc0)
	/Users/ndrew/Code/shokinin/shokinin-20/output/Unsafe.Coerce/Unsafe_Coerce.go:23 +0x65
project.localhost/purescript-native/output/Data%2eExists.PS__mkExists(...)
	/Users/ndrew/Code/shokinin/shokinin-20/output/Data.Exists/Data_Exists.go:17
project.localhost/purescript-native/output/Options%2eApplicative%2eTypes.PS__parserApply.func2.1(0x1279d20, 0xc000155470, 0x12745a0, 0xc00014dde0)
	/Users/ndrew/Code/shokinin/shokinin-20/output/Options.Applicative.Types/Options_Applicative_Types.go:1163 +0x5e
github.com/purescript-native/go-runtime.Apply(0x12745a0, 0x12d0f28, 0xc00015fcf8, 0x3, 0x3, 0x1279d20, 0xc000155a10)
	/Users/ndrew/go/pkg/mod/github.com/purescript-native/[email protected]/release.go:9 +0x87
project.localhost/purescript-native/output/Control%2eApply.PS__lift2.func1.1.1.1(0x1279d20, 0xc000155470, 0x12745a0, 0xc00010a880)
	/Users/ndrew/Code/shokinin/shokinin-20/output/Control.Apply/Control_Apply.go:66 +0x280
github.com/purescript-native/go-runtime.Apply(0x12745a0, 0x12d2888, 0xc00015ff28, 0x3, 0x3, 0x12745a0, 0x12d2fa0)
	/Users/ndrew/go/pkg/mod/github.com/purescript-native/[email protected]/release.go:9 +0x87
main.PS__main(0x126afa0, 0xc00006a058)
	/Users/ndrew/Code/shokinin/shokinin-20/output/Main/Main.go:117 +0x313
main.main()
	/Users/ndrew/Code/shokinin/shokinin-20/output/Main/Main.go:128 +0x22```

run time error !

First thank you for the great project!

I did some experiment , and found that the generated code using ffi, but the ffi is not implement.

I'v add https://github.com/andyarvanitis/purescript-native-ffi to my c++ project.

example 1:

auto eqString() -> boxed {
    return Data_Eq::Eq()(Data_Eq::refEq());
};
auto refEq() -> const boxed& { static const boxed _ = foreign().at("refEq"); return _; };

but I cannot found the definition of refEq in purescript-native-ffi .

example 2:

auto indexOf() -> boxed {
    return Data_String_CodeUnits::_indexOf()(Data_Maybe::Just())(Data_Maybe::Nothing());
};
auto _indexOf() -> const boxed& { static const boxed _ = foreign().at("_indexOf"); return _; };

the ffi of _indexOf I can not found in the purescript-native-ffi too!

How can I change the ffi code to make the code running?

Unknown module Data.Function, etc.

Getting 6 errors trying to compile fib.purs sample code.

I have created a proj dir, and created src/ and packages/ in there. git cloned all packages listed in https://github.com/andyarvanitis/pure11/wiki/Packages in projdir/packages/, where * packages are cloned from https://github.com/pure11. When I run make, I got:

Compiling Data.Validation.Semigroup
Compiling Data.Profunctor
Compiling Data.Profunctor.Closed
Compiling Data.Monoid
Compiling Data.Functor.Invariant
Compiling Data.Bifunctor
Compiling Control.Monad.ST
Compiling Test.Assert
Compiling Control.Lazy
Compiling Control.Extend
Compiling Control.Alt
Error 1 of 6:

  in module Data.Monoid
  at packages/purescript-monoid/src/Data/Monoid.purs line 6, column 1 - line 7, column 1

    Unknown module Data.Function


  See https://github.com/purescript/purescript/wiki/Error-Code-UnknownModule for more information,
  or to contribute content related to this error.

Error 2 of 6:

  in module Data.Functor.Invariant
  at packages/purescript-invariant/src/Data/Functor/Invariant.purs line 3, column 1 - line 4, column 1

    Unknown module Data.Function


  See https://github.com/purescript/purescript/wiki/Error-Code-UnknownModule for more information,
  or to contribute content related to this error.

Error 3 of 6:

  in module Data.Bifunctor
  at packages/purescript-bifunctors/src/Data/Bifunctor.purs line 3, column 1 - line 18, column 1

    Unknown module Control.Category


  See https://github.com/purescript/purescript/wiki/Error-Code-UnknownModule for more information,
  or to contribute content related to this error.

Error 4 of 6:

  in module Control.Lazy
  at packages/purescript-control/src/Control/Lazy.purs line 3, column 1 - line 10, column 1

    Unknown module Data.Unit


  See https://github.com/purescript/purescript/wiki/Error-Code-UnknownModule for more information,
  or to contribute content related to this error.

Error 5 of 6:

  in module Control.Extend
  at packages/purescript-control/src/Control/Extend.purs line 9, column 1 - line 11, column 1

    Unknown module Control.Category


  See https://github.com/purescript/purescript/wiki/Error-Code-UnknownModule for more information,
  or to contribute content related to this error.

Error 6 of 6:

  in module Control.Alt
  at packages/purescript-control/src/Control/Alt.purs line 6, column 1 - line 7, column 1

    Unknown module Data.Functor


  See https://github.com/purescript/purescript/wiki/Error-Code-UnknownModule for more information,
  or to contribute content related to this error.


make: *** [codegen] Error 1

please advised, thanks.

TestMain.hs C++ compilation errors on gcc 5.1

I just assumed this is supposed to be working. Let me know if that is not the case or I am doing something stupid. I just ran runghc pcc/TestMain.hs from the root of the repo and modified TestMain.hs slightly to get the different compilers into CMake.

clang 3.6
full output

gcc 5.1

...
[ 87%] Building CXX object CMakeFiles/Main.dir/Main/Main.cc.o
In file included from /home/kaspar/projects/purescript/pure14/pcc-tests/output/Main/Main.hh:6:0,
                 from /home/kaspar/projects/purescript/pure14/pcc-tests/output/Main/Main.cc:6:
/home/kaspar/projects/purescript/pure14/pcc-tests/output/Prelude/Prelude.hh: In instantiation of ‘A Main::f(PureScript::param<T>) [with A = std::basic_string<char>; PureScript::param<T> = const std::basic_string<char>&]’:
/home/kaspar/projects/purescript/pure14/pcc-tests/output/Main/Main.cc:15:109:   required from here
/home/kaspar/projects/purescript/pure14/pcc-tests/output/Prelude/Prelude.hh:563:19: error: specialization of ‘template<template<class, class> class A, class ...> template<class T> const A<T, T> Prelude::Category<A, <template-parameter-1-2> >::id<T>’ must appear at namespace scope
     const fn<T,T> Category<fn>::id = [](param<T> x) -> T {
                   ^
make[2]: *** [CMakeFiles/Main.dir/Main/Main.cc.o] Error 1
make[1]: *** [CMakeFiles/Main.dir/all] Error 2
make: *** [all] Error 2
TestMain.hs: callProcess: make (exit 2): failed

full output

pass arguments to run

This may be a spago limitation, but I expected to be able to pass flags to spago run that would get forwarded to the binary. Instead, I have to run spago build and then run the binary directly with the args.

While trying this, I also discovered spago's --node-args, which maybe should be renamed --backend-args, since it works to send arguments to the psgo process as well: spago run --node-args "--version"

Windows embedFile errors (utf?)

On windows I had issues with the embedded runtime files becoming corrupted.
purescript.h was written out, but the compiler (clang) didn't like it.
string_literal_dict.h wasn't even able to be written to disk.

Copying the runtime files into the expected output/src directory then running make does get me a compile. (using clang+MSVC, though I had to target c++14 instead of 11).

This may be a similar issue to purescript/spago#51

make clean && make
Compiling Data.Symbol
Compiling Record.Unsafe
Compiling Type.Data.RowList
Compiling Type.Data.Row
Compiling Data.NaturalTransformation
Compiling Control.Semigroupoid
Compiling Data.Boolean
Compiling Data.Show
Compiling Control.Category
Compiling Data.Unit
Compiling Data.Void
Compiling Data.HeytingAlgebra
Compiling Data.Semiring
Compiling Data.Semigroup
Compiling Data.Ring
Compiling Data.BooleanAlgebra
Compiling Data.Eq
Compiling Data.CommutativeRing
Compiling Data.Ordering
Compiling Data.EuclideanRing
Compiling Data.Ord.Unsafe
Compiling Data.Ord
Compiling Data.DivisionRing
Compiling Data.Field
Compiling Data.Function
Compiling Data.Monoid
Compiling Data.Bounded
Compiling Data.Functor
Compiling Control.Apply
Compiling Control.Applicative
Compiling Control.Bind
Compiling Control.Monad
Compiling Prelude
Compiling Effect
Compiling Data.Semigroup.First
Compiling Data.Monoid.Dual
Compiling Data.Semigroup.Last
Compiling Data.Monoid.Additive
Compiling Data.Monoid.Conj
Compiling Data.Monoid.Disj
Compiling Data.Monoid.Multiplicative
Compiling Data.Monoid.Endo
Compiling Effect.Unsafe
Compiling Effect.Class
Compiling Effect.Uncurried
Compiling Effect.Console
Compiling Effect.Class.Console
Compiling Main
pscpp.exe: output\src\string_literal_dict.h: commitAndReleaseBuffer: invalid argument (invalid character)

libncurses5-dev required when building on ubuntu

I've built the latest upstream PS compiler using stack, but running stack install for purescript-native results in

configure: error: in `/tmp/stack31409/terminfo-0.4.0.2':
configure: error: curses headers could not be found, so this package cannot be built
See `config.log' for more details

installing libncurses5-dev solves the problem.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.