vmchale / atspkg Goto Github PK
View Code? Open in Web Editor NEWBuild tool for ATS.
Build tool for ATS.
Building 3.4.0.9
from tarball using cabal v2-build ats-pkg --happy-options='-gcsa' --alex-options='-g'
fails with the following error:
[1 of 1] Compiling Development.Shake.C ( src/Development/Shake/C.hs, /atspkg-3.4.0.9/dist-newstyle/build/x86_64-linux/ghc-8.8.3/shake-c-0.4.3.0/opt/build/Development/Shake/C.o )
src/Development/Shake/C.hs:42:1: error: [-Wdodgy-imports, -Werror=dodgy-imports]
Module ‘Development.Shake’ does not export ‘(*>)’
|
42 | import Development.Shake hiding ((*>))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Current work around is to add --ghc-options="-fno-warn-dodgy-imports"
Tests for language-ats 17.6.1 are broken in hydra. It seems to me that test failure is legit:
Failures:
src/Test/Hspec/Dirstream.hs:143:5:
1) pretty-print test/data/wc2.dats
expected: Right "Up to date\nstaload \"SATS/wc.sats\"\nstaload \"SATS/memchr.sats\"\nstaload \"SATS/bytecount.sats\"\nstaload \"prelude/SATS/pointer.sats\"\nstaload UN = \"prelude/SATS/unsafe.sats\"\n\n#include \"DATS/bytecount.dats\"\n#include \"DATS/memchr.dats\"\n\n#define BUFSZ 32768\n\n%{\nsize_t sub_ptr1_ptr1_size(atstype_ptr p1, atstype_ptr p2) {\n return ((char *)p1 - (char *)p2);\n}\n%}\n\nextern\nfn sub_ptr1_ptr1_size { l0, l1 : addr | l0 >= l1 }( p1 : ptr(l0)\n , p2 : ptr(l1)\n ) :<> size_t(l0-l1) =\n \"ext#\"\n\nextern\ncastfn bounded(size_t) : [n:nat] size_t(n)\n\nfn bptr_succ {l:addr}(p : ptr(l)) :<> ptr(l+1) =\n $UN.cast(ptr1_succ<byte>(p))\n\nfn freadc\n{ l : addr | l != null }{ sz : nat | sz >= 1 }(pf : !bytes_v(l, sz)\n | inp : !FILEptr1, bufsize : size_t(sz), p : ptr(l)) : size_t =\n let\n extern\n castfn as_fileref(x : !FILEptr1) :<> FILEref\n \n var n = $extfcall( size_t\n , \"fread\"\n , p\n , sizeof<byte>\n , bufsize\n , as_fileref(inp)\n )\n in\n n\n end\n\nfn freadc_\n{ l : addr | l != null }{ sz : nat | sz >= 1 }{ n : nat | n <= sz }( pf : !bytes_v(l, sz)\n | inp : !FILEptr1\n , bufsize : size_t(sz)\n , p : ptr(l)\n ) : size_t(n) =\n $UN.cast(freadc(pf | inp, bufsize, p))\n\nimplement free_st (st) =\n case+ st of\n | ~in_string () => ()\n | ~in_block_comment () => ()\n | ~line_comment() => ()\n | ~post_asterisk_in_block_comment() => ()\n | ~post_backslash_in_string() => ()\n | ~post_slash() => ()\n | ~regular() => ()\n | ~post_newline_whitespace() => ()\n | ~post_block_comment() => ()\n | ~post_tick() => ()\n\nimplement empty_file =\n @{ lines = 0, blanks = 0, comments = 0, doc_comments = 0 } : file\n\nimplement add_file (f0, f1) =\n @{ lines = f0.lines + f1.lines\n , blanks = f0.blanks + f1.blanks\n , comments = f0.comments + f1.comments\n , doc_comments = f0.doc_comments + f1.doc_comments\n } : file\n\nfn byteview_read_as_char\n{l0:addr}{m:nat}{ l1 : addr | l1 <= l0+m }(pf : !bytes_v(l0, m)\n| p : ptr(l1)) : char =\n $UN.ptr0_get<char>(p)\n\nfn count_for_loop\n{ l : addr | l != null }{m:nat}{ n : nat | n <= m }(pf : !bytes_v(l, m)\n | p : ptr(l), parse_st : &parse_state >> _, bufsz : size_t(n)) :\n file =\n let\n fn advance_char( c : char\n , st : &parse_state >> _\n , file_st : &file >> _\n ) : void =\n case+ st of\n | regular() => \n begin\n case+ c of\n | '\\n' => ( free(st)\n ; file_st.lines := file_st.lines + 1\n ; st := post_newline_whitespace\n )\n | '\\'' => (free(st) ; st := post_tick)\n | '\"' => (free(st) ; st := in_string)\n | '/' => (free(st) ; st := post_slash)\n | _ => ()\n end\n | in_string() => \n begin\n case+ c of\n | '\\n' => file_st.lines := file_st.lines + 1\n | '\\\\' => (free(st) ; st := post_backslash_in_string)\n | '\"' => (free(st) ; st := regular)\n | _ => ()\n end\n | post_asterisk_in_block_comment() => \n begin\n case+ c of\n | '/' => (free(st) ; st := post_block_comment)\n | '\\n' => ( free(st)\n ; file_st.comments := file_st.comments + 1\n ; st := in_block_comment\n )\n | '*' => ()\n | _ => (free(st) ; st := in_block_comment)\n end\n | in_block_comment() => \n begin\n case+ c of\n | '*' => (free(st) ; st := post_asterisk_in_block_comment)\n | '\\n' => file_st.comments := file_st.comments + 1\n | _ => ()\n end\n | line_comment() => \n begin\n case+ c of\n | '\\n' => ( free(st)\n ; file_st.comments := file_st.comments + 1\n ; st := post_newline_whitespace\n )\n | _ => ()\n end\n | post_backslash_in_string() => \n begin\n case+ c of\n | '\\n' => ( free(st)\n ; file_st.lines := file_st.lines + 1\n ; st := in_string\n )\n | _ => ()\n end\n | ~post_slash() => \n begin\n case+ c of\n | '/' => st := line_comment\n | '\\n' => ( file_st.lines := file_st.lines + 1\n ; st := post_newline_whitespace\n )\n | '*' => st := in_block_comment\n | _ => st := regular\n end\n | post_newline_whitespace() => \n begin\n case+ c of\n | '\\n' => (file_st.blanks := file_st.blanks + 1)\n | '\\t' => ()\n | ' ' => ()\n | '/' => (free(st) ; st := post_slash)\n | '\\'' => (free(st) ; st := post_tick)\n | '\"' => (free(st) ; st := in_string)\n | _ => (free(st) ; st := regular)\n end\n | post_block_comment() => \n begin\n // TODO: block comments at the end of a line\n case+ c of\n | '\\n' => ( free(st)\n ; file_st.comments := file_st.comments + 1\n ; st := post_newline_whitespace\n )\n | '/' => (free(st) ; st := post_slash)\n | '\"' => (free(st) ; st := in_string)\n | _ => ()\n end\n | ~post_tick() => st := regular\n \n var res: file = empty_file\n var i: size_t\n val () = for* { i : nat | i <= m } .<i>. (i : size_t(i)) =>\n (i := bufsz ; i != 0 ; i := i - 1)\n (let\n var current_char = byteview_read_as_char(pf | add_ptr_bsz(p, i))\n in\n advance_char(current_char, parse_st, res)\n end)\n var current_char = byteview_read_as_char(pf | p)\n val () = advance_char(current_char, parse_st, res)\n in\n res\n end\n\nfn count_lines_for_loop\n{ l : addr | l != null }{m:nat}{ n : nat | n <= m }(pf : !bytes_v(l, m)\n | ptr : ptr(l), bufsz : size_t(n)) : int =\n let\n var res: int = 0\n var i: size_t\n val () = for* { i : nat | i <= n } .<n-i>. (i : size_t(i)) =>\n (i := i2sz(0) ; i < bufsz ; i := i + 1)\n (let\n var current_char = byteview_read_as_char(pf | add_ptr_bsz(ptr, i))\n in\n case+ current_char of\n | '\\n' => res := res + 1\n | _ => ()\n end)\n in\n res\n end\n\nfn count_file_for_loop(inp : !FILEptr1) : int =\n let\n val (pfat, pfgc | p) = malloc_gc(g1i2u(BUFSZ))\n prval () = pfat := b0ytes2bytes_v(pfat)\n \n fun loop { l : addr | l != null }(pf : !bytes_v(l, BUFSZ)\n | inp : !FILEptr1, p : ptr(l)) : int =\n let\n var file_bytes = freadc(pf | inp, i2sz(BUFSZ), p)\n \n extern\n praxi lt_bufsz {m:nat} (size_t(m)) : [m <= BUFSZ] void\n in\n if file_bytes = 0 then\n 0\n else\n let\n var fb_prf = bounded(file_bytes)\n prval () = lt_bufsz(fb_prf)\n var acc = count_lines_for_loop(pf | p, fb_prf)\n in\n acc + loop(pf | inp, p)\n end\n end\n \n var ret = loop(pfat | inp, p)\n val () = mfree_gc(pfat, pfgc | p)\n in\n ret\n end\n\nfn count_file(inp : !FILEptr1) : file =\n let\n val (pfat, pfgc | p) = malloc_gc(g1i2u(BUFSZ))\n prval () = pfat := b0ytes2bytes_v(pfat)\n var init_st: parse_state = post_newline_whitespace\n \n fun loop { l : addr | l != null }(pf : !bytes_v(l, BUFSZ)\n | inp : !FILEptr1, st : &parse_state >> _, p : ptr(l)) : file =\n let\n var file_bytes = freadc(pf | inp, i2sz(BUFSZ), p)\n \n extern\n praxi lt_bufsz {m:nat} (size_t(m)) : [m <= BUFSZ] void\n in\n if file_bytes = 0 then\n empty_file\n else\n let\n var fb_prf = bounded(file_bytes)\n prval () = lt_bufsz(fb_prf)\n var acc = count_for_loop(pf | p, st, fb_prf)\n in\n acc + loop(pf | inp, st, p)\n end\n end\n \n var ret = loop(pfat | inp, init_st, p)\n val () = free(init_st)\n val () = mfree_gc(pfat, pfgc | p)\n in\n ret\n end\n"
but got: Right "staload \"SATS/wc.sats\"\nstaload \"SATS/memchr.sats\"\nstaload \"SATS/bytecount.sats\"\nstaload \"prelude/SATS/pointer.sats\"\nstaload UN = \"prelude/SATS/unsafe.sats\"\n\n#include \"DATS/bytecount.dats\"\n#include \"DATS/memchr.dats\"\n\n#define BUFSZ 32768\n\n%{\nsize_t sub_ptr1_ptr1_size(atstype_ptr p1, atstype_ptr p2) {\n return ((char *)p1 - (char *)p2);\n}\n%}\n\nextern\nfn sub_ptr1_ptr1_size { l0, l1 : addr | l0 >= l1 }( p1 : ptr(l0)\n , p2 : ptr(l1)\n ) :<> size_t(l0-l1) =\n \"ext#\"\n\nextern\ncastfn bounded(size_t) : [n:nat] size_t(n)\n\nfn bptr_succ {l:addr}(p : ptr(l)) :<> ptr(l+1) =\n $UN.cast(ptr1_succ<byte>(p))\n\nfn freadc\n{ l : addr | l != null }{ sz : nat | sz >= 1 }(pf : !bytes_v(l, sz)\n | inp : !FILEptr1, bufsize : size_t(sz), p : ptr(l)) : size_t =\n let\n extern\n castfn as_fileref(x : !FILEptr1) :<> FILEref\n \n var n = $extfcall( size_t\n , \"fread\"\n , p\n , sizeof<byte>\n , bufsize\n , as_fileref(inp)\n )\n in\n n\n end\n\nfn freadc_\n{ l : addr | l != null }{ sz : nat | sz >= 1 }{ n : nat | n <= sz }( pf : !bytes_v(l, sz)\n | inp : !FILEptr1\n , bufsize : size_t(sz)\n , p : ptr(l)\n ) : size_t(n) =\n $UN.cast(freadc(pf | inp, bufsize, p))\n\nimplement free_st (st) =\n case+ st of\n | ~in_string () => ()\n | ~in_block_comment () => ()\n | ~line_comment() => ()\n | ~post_asterisk_in_block_comment() => ()\n | ~post_backslash_in_string() => ()\n | ~post_slash() => ()\n | ~regular() => ()\n | ~post_newline_whitespace() => ()\n | ~post_block_comment() => ()\n | ~post_tick() => ()\n\nimplement empty_file =\n @{ lines = 0, blanks = 0, comments = 0, doc_comments = 0 } : file\n\nimplement add_file (f0, f1) =\n @{ lines = f0.lines + f1.lines\n , blanks = f0.blanks + f1.blanks\n , comments = f0.comments + f1.comments\n , doc_comments = f0.doc_comments + f1.doc_comments\n } : file\n\nfn byteview_read_as_char\n{l0:addr}{m:nat}{ l1 : addr | l1 <= l0+m }(pf : !bytes_v(l0, m)\n| p : ptr(l1)) : char =\n $UN.ptr0_get<char>(p)\n\nfn count_for_loop\n{ l : addr | l != null }{m:nat}{ n : nat | n <= m }(pf : !bytes_v(l, m)\n | p : ptr(l), parse_st : &parse_state >> _, bufsz : size_t(n)) :\n file =\n let\n fn advance_char( c : char\n , st : &parse_state >> _\n , file_st : &file >> _\n ) : void =\n case+ st of\n | regular() => \n begin\n case+ c of\n | '\\n' => ( free(st)\n ; file_st.lines := file_st.lines + 1\n ; st := post_newline_whitespace\n )\n | '\\'' => (free(st) ; st := post_tick)\n | '\"' => (free(st) ; st := in_string)\n | '/' => (free(st) ; st := post_slash)\n | _ => ()\n end\n | in_string() => \n begin\n case+ c of\n | '\\n' => file_st.lines := file_st.lines + 1\n | '\\\\' => (free(st) ; st := post_backslash_in_string)\n | '\"' => (free(st) ; st := regular)\n | _ => ()\n end\n | post_asterisk_in_block_comment() => \n begin\n case+ c of\n | '/' => (free(st) ; st := post_block_comment)\n | '\\n' => ( free(st)\n ; file_st.comments := file_st.comments + 1\n ; st := in_block_comment\n )\n | '*' => ()\n | _ => (free(st) ; st := in_block_comment)\n end\n | in_block_comment() => \n begin\n case+ c of\n | '*' => (free(st) ; st := post_asterisk_in_block_comment)\n | '\\n' => file_st.comments := file_st.comments + 1\n | _ => ()\n end\n | line_comment() => \n begin\n case+ c of\n | '\\n' => ( free(st)\n ; file_st.comments := file_st.comments + 1\n ; st := post_newline_whitespace\n )\n | _ => ()\n end\n | post_backslash_in_string() => \n begin\n case+ c of\n | '\\n' => ( free(st)\n ; file_st.lines := file_st.lines + 1\n ; st := in_string\n )\n | _ => ()\n end\n | ~post_slash() => \n begin\n case+ c of\n | '/' => st := line_comment\n | '\\n' => ( file_st.lines := file_st.lines + 1\n ; st := post_newline_whitespace\n )\n | '*' => st := in_block_comment\n | _ => st := regular\n end\n | post_newline_whitespace() => \n begin\n case+ c of\n | '\\n' => (file_st.blanks := file_st.blanks + 1)\n | '\\t' => ()\n | ' ' => ()\n | '/' => (free(st) ; st := post_slash)\n | '\\'' => (free(st) ; st := post_tick)\n | '\"' => (free(st) ; st := in_string)\n | _ => (free(st) ; st := regular)\n end\n | post_block_comment() => \n begin\n // TODO: block comments at the end of a line\n case+ c of\n | '\\n' => ( free(st)\n ; file_st.comments := file_st.comments + 1\n ; st := post_newline_whitespace\n )\n | '/' => (free(st) ; st := post_slash)\n | '\"' => (free(st) ; st := in_string)\n | _ => ()\n end\n | ~post_tick() => st := regular\n \n var res: file = empty_file\n var i: size_t\n val () = for* { i : nat | i <= m } .<i>. (i : size_t(i)) =>\n (i := bufsz ; i != 0 ; i := i - 1)\n (let\n var current_char = byteview_read_as_char(pf | add_ptr_bsz(p, i))\n in\n advance_char(current_char, parse_st, res)\n end)\n var current_char = byteview_read_as_char(pf | p)\n val () = advance_char(current_char, parse_st, res)\n in\n res\n end\n\nfn count_lines_for_loop\n{ l : addr | l != null }{m:nat}{ n : nat | n <= m }(pf : !bytes_v(l, m)\n | ptr : ptr(l), bufsz : size_t(n)) : int =\n let\n var res: int = 0\n var i: size_t\n val () = for* { i : nat | i <= n } .<n-i>. (i : size_t(i)) =>\n (i := i2sz(0) ; i < bufsz ; i := i + 1)\n (let\n var current_char = byteview_read_as_char(pf | add_ptr_bsz(ptr, i))\n in\n case+ current_char of\n | '\\n' => res := res + 1\n | _ => ()\n end)\n in\n res\n end\n\nfn count_file_for_loop(inp : !FILEptr1) : int =\n let\n val (pfat, pfgc | p) = malloc_gc(g1i2u(BUFSZ))\n prval () = pfat := b0ytes2bytes_v(pfat)\n \n fun loop { l : addr | l != null }(pf : !bytes_v(l, BUFSZ)\n | inp : !FILEptr1, p : ptr(l)) : int =\n let\n var file_bytes = freadc(pf | inp, i2sz(BUFSZ), p)\n \n extern\n praxi lt_bufsz {m:nat} (size_t(m)) : [m <= BUFSZ] void\n in\n if file_bytes = 0 then\n 0\n else\n let\n var fb_prf = bounded(file_bytes)\n prval () = lt_bufsz(fb_prf)\n var acc = count_lines_for_loop(pf | p, fb_prf)\n in\n acc + loop(pf | inp, p)\n end\n end\n \n var ret = loop(pfat | inp, p)\n val () = mfree_gc(pfat, pfgc | p)\n in\n ret\n end\n\nfn count_file(inp : !FILEptr1) : file =\n let\n val (pfat, pfgc | p) = malloc_gc(g1i2u(BUFSZ))\n prval () = pfat := b0ytes2bytes_v(pfat)\n var init_st: parse_state = post_newline_whitespace\n \n fun loop { l : addr | l != null }(pf : !bytes_v(l, BUFSZ)\n | inp : !FILEptr1, st : &parse_state >> _, p : ptr(l)) : file =\n let\n var file_bytes = freadc(pf | inp, i2sz(BUFSZ), p)\n \n extern\n praxi lt_bufsz {m:nat} (size_t(m)) : [m <= BUFSZ] void\n in\n if file_bytes = 0 then\n empty_file\n else\n let\n var fb_prf = bounded(file_bytes)\n prval () = lt_bufsz(fb_prf)\n var acc = count_for_loop(pf | p, st, fb_prf)\n in\n acc + loop(pf | inp, st, p)\n end\n end\n \n var ret = loop(pfat | inp, init_st, p)\n val () = free(init_st)\n val () = mfree_gc(pfat, pfgc | p)\n in\n ret\n end\n"
To rerun use: --match "/pretty-print/test/data/wc2.dats/"
This is my first stab at adding a haskell package to nix; unfortunately the build seems to fail near the end? See nixpkgs PR at NixOS/nixpkgs#44887 - any suggestions would be welcome.
I thought I'd try to build polyglot to get a sense of how to use atspkg. There seem to be some character encoding issues. I tried specifying LC_ALL directly but this did not seem to help:
$ LC_ALL=en_US.UTF-8 atspkg build
atspkg:
/home/brandon/workspace/polyglot/atspkg.dhall
/home/brandon/workspace/polyglot/atspkg.dhall: hGetContents: invalid argument (invalid byte sequence)
Implementation
is defined as following:
data Implementation a = Implement { pos :: a
-- snip--
, _iExpression :: Either (StaticExpression a) (Expression a) -- ^ Expression (or static expression) holding the function body.
}
But I found we can mix StaticExpression
and Expression
. See following:
This seems like a great effort, thanks! However, I don't quite understand how to use it. Are there any docs or examples, anywhere?
Which repository is master? GitHub or Darcs?
I would like to use your language-ats library, which is located at both of above.
Is it possible to use the system compiler if it's already available in PATH
?
Hi, I just installed atspkg
and ats, and tried to build a Hello World program,
but I got some errors which I'm pretty sure are from Dhall:
$ atspkg run
Resolving dependencies...
atspkg: Error when running Shake build system:
at want, called at src/Language/ATS/Package/Build.hs:226:15 in ts-pkg-3.5.0.2-f28b5587:Language.ATS.Package.Build
* Depends on: run
at need, called at src/Language/ATS/Package/Build.hs:157:9 in ts-pkg-3.5.0.2-f28b5587:Language.ATS.Package.Build
* Depends on: target/ch1
at need, called at src/Development/Shake/ATS.hs:192:9 in shk-ts-1.10.4.2-345f1267:Development.Shake.ATS
* Depends on: .atspkg/c/src/ch1.c
at need, called at src/Development/Shake/ATS.hs:213:9 in shk-ts-1.10.4.2-345f1267:Development.Shake.ATS
* Depends on: .atspkg/deps
* Raised the exception:
Error: Not CORS compliant
Dhall supports transitive imports, meaning that an imported expression can
import other expressions. However, a remote import (the "parent" import)
cannot import another remote import (the "child" import) unless the child
import grants permission to do using CORS. The child import must respond with
an `Access-Control-Allow-Origin` response header that matches the parent
import, otherwise Dhall rejects the import.
The child response did not include any `Access-Control-Allow-Origin` header,
so import resolution failed.
I've just got the default atspkg.dhall
and pkg.dhall
which I generated via pi new ats ch1
.
I've no idea what precisely causes this, but in case it matters, I'm on MacOS Catalina.
Sorry if this is my own fault and I messed up somehow.
For instance:
#include "share/atspre_define.hats"
#include "share/atspre_staload.hats"
val pi: double = 3.14159
fn circleArea (r: double): double = pi * (r * r)
fn ringArea (R: double, r: double) = circleArea R - circleArea r
val s = ringArea (5.0, 4.0)
val _ = print s
implement main0 () = ()
— Looks legit.
% patscc hello.dats && ./a.out
28.260000%
% atsfmt hello.dats
Error: 8:49
Unexpected 'R', expected: 'Declaration'
— The compiler agrees, but atsfmt
has an issue. Maybe add parentheses?
...
fn ringArea (R: double, r: double) = circleArea (R) - circleArea (r)
...
— But no:
% atsfmt hello.dats
Error: unexpected token '-' at 8:53
(What it actually dislikes is white space in function application.)
Either we should silently re-format function application or ignore the supposed issue, but surely not error out.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.