Syntactic use of curly braces

2017-02-04 Thread August Alm
Hi! This is my first post. I recently started learning ATS2 and have some trouble grokking what is syntactically correct and what isn't when it comes to the use of braces. Apart from simply understanding the logic of the syntax I would also like to give feedback for future design choices. Let

Re: Syntactic use of curly braces

2017-02-04 Thread August Alm
x27;s own template to make it available also for other functions with non-void return type, so that all function bodies could be delimited by braces? Den lördag 4 februari 2017 kl. 23:00:32 UTC+1 skrev August Alm: > > Hi! > > This is my first post. I recently started learning A

Re: Syntactic use of curly braces

2017-02-05 Thread August Alm
. >>abstype xyz = ... >> } >> >> Usually, { ... } should follow the keyword 'where'. If used alone as an >> expression, >> { ... } means: >> >> () where { ... } >> >> Supporting 'where ... end' should be straight

compiling the files in $(PATSHOME)/doc/EXAMPLE/ATSLIB

2017-02-08 Thread August Alm
Hi! I reinstalled ATS2 yesterday, using the script C9-ATS2-install-latest.sh from https://github.com/ats-lang/ats-lang.github.io/tree/master/SCRIPT. (The recently added syntax [where]-[end] makes me very happy!) The installation of Postiats works. However, included in the installation is a bun

Re: compiling the files in $(PATSHOME)/doc/EXAMPLE/ATSLIB

2017-02-09 Thread August Alm
E/ATSLIB > > You could try 'sudo make all' (and then 'sudo make cleanall'). > > > On Wed, Feb 8, 2017 at 9:09 PM, August Alm > wrote: > >> Hi! >> >> I reinstalled ATS2 yesterday, using the script C9-ATS2-install-latest.sh >> from

Re: compiling the files in $(PATSHOME)/doc/EXAMPLE/ATSLIB

2017-02-09 Thread August Alm
Hurray! The doors to the treasury just flung open. Thank you for your patience. Den torsdag 9 februari 2017 kl. 22:58:25 UTC+1 skrev gmhwxi: > > Hi August, > > A quick fix for this issue is to simply do: > > sudo make PATSHOME=${PATSHOME} all > > On Thu, Feb 9, 201

Compiler error when using fprint_list_vt

2017-02-15 Thread August Alm
Hi! Consider the following minimal working example: #include "share/atspre_define.hats" #include "share/atspre_staload.hats" implement main0 () = { val stringy = "abcdefghijkl;mnopq;rstu;vx" val test = string_explode (stringy)

Typechecking error involving Either datatype

2017-02-18 Thread August Alm
Hi! I am fooling around with rewriting some Haskell code in ATS2 and hit a stumbling block. Consider the following snippet: datatype Either_bool (a: t0ype+, b: t0ype+, bool) = Left(a, b, true) of a | Right(a, b, false) of b typedef

Case-when not exhaustive

2017-02-23 Thread August Alm
Hi! It seems to me that Postiats can't recognize that case-when expressions are exhaustive. For example, the function fun case_when (x: int): bool = case x of | _ when (x > 0) => true | _ when (x <= 0) => false works as expected but is not r

Segfault when using streamize_fileref_char

2017-03-02 Thread August Alm
Hi! I'm in over my head and tried writing a CSV-parser using linear lazy streams. My code thus far is 600 lines and almost to my own surprise I get it to compile! However, there is something fishy because I get a segfault when applying my program to an actual CSV-file. I've been trying to debug

Re: Compiling timer.dats example

2017-03-02 Thread August Alm
This works for me: $ patscc -O2 -D_GNU_SOURCE -DATS_MEMALLOC_LIBC -latslib -lrt -o timer timer.dats Den fredag 3 mars 2017 kl. 02:16:49 UTC+1 skrev spearman: > > What is the command to compile the `timer.dats` example from the > Introduction to ATS book? > > > https://github.com/ats-lang/ats-l

Re: Segfault when using streamize_fileref_char

2017-03-02 Thread August Alm
sion in that? Thank you, August Den torsdag 2 mars 2017 kl. 23:04:35 UTC+1 skrev August Alm: > > Hi! > > I'm in over my head and tried writing a CSV-parser using linear lazy > streams. My code thus far is 600 lines and almost to my own surprise I get > it to compile! Howe

Re: Segfault when using streamize_fileref_char

2017-03-02 Thread August Alm
Just "a;b", or? (Attached.) Den fredag 3 mars 2017 kl. 03:03:08 UTC+1 skrev gmhwxi: > > I suspect that the file you used contains other characters. > > What is in "small.csv"? > > On Thu, Mar 2, 2017 at 8:52 PM, August Alm > wrote: > >> The fil

Re: Segfault when using streamize_fileref_char

2017-03-03 Thread August Alm
gt; val ins = streamize_fileref_char(inp) >> val ins = stream2list_vt(ins) >> val ins = g0ofg1(list_vt2t(ins))97 >> val ( ) = println! ("length(ins) = ", length(ins)) >> val ( ) = (ins).foreach()(lam c => println!(char2int0(c))) >> (* >> val lexed

Re: Segfault when using streamize_fileref_char

2017-03-03 Thread August Alm
d. You > just need to identify the function or functions that cause the deep stack > usage. Then try to rewrite using tail-recursion. > > > > On Fri, Mar 3, 2017 at 5:25 PM, August Alm > wrote: > >> Hi! >> I had indeed made a logical error that caused any stream

Re: Segfault when using streamize_fileref_char

2017-03-04 Thread August Alm
d at GitHub: https://github.com/August-Alm/ats_csv_lexer Any and all comments on how to improve are appreciated. Best wishes, August. Den fredag 3 mars 2017 kl. 23:57:54 UTC+1 skrev gmhwxi: > > One possibility is to build a npm package and then publish it. > > If you go to https://w

Re: Segfault when using streamize_fileref_char

2017-03-05 Thread August Alm
d stream is neede. >> Sometimes, this is call full laziness. Without full laziness, a stream may >> behave like a list, defeating the very purpose of using a stream. >> >> On Saturday, March 4, 2017 at 7:27:03 PM UTC-5, August Alm wrote: >>> >>> I've

Re: Segfault when using streamize_fileref_char

2017-03-06 Thread August Alm
ng example (for computing Mersenne primes) can > run for days without run-time GC: > > > https://github.com/githwxi/ATS-Postiats/blob/master/doc/EXAMPLE/RosettaCode/Lucas-Lehmer_test2.dats > > It convincingly attests to the power of linear streams. > > Cheers! > > >

Re: Segfault when using streamize_fileref_char

2017-03-06 Thread August Alm
.stringbuf, cs: llstring): stream_vt(DT) = > > The 'acc' stringbuf needs to be consumed by 'test'. The implementation > of 'test' looks like this: > > $ldelay > ( > > , > (freeing(acc); freeing(cs)) // this part is executed when the stream is

Re: Segfault when using streamize_fileref_char

2017-03-06 Thread August Alm
The code now seems to work as inteded! https://github.com/August-Alm/ats_csv_lexer Thank you for all the help. I still don't fully grokk why the function needs to consume each of its arguments--will have to meditate more on that--but at least I know how to write code like this from n

Re: Segfault when using streamize_fileref_char

2017-03-07 Thread August Alm
> implement{} lex_csv$QNLIN() = false > implement{} lex_csv$DELIM() = ',' // default value > > Writing function templates (instead of functions) enables you to move > your code around very conveniently. You can even move template code > into the body of another functi

Re: Segfault when using streamize_fileref_char

2017-03-08 Thread August Alm
tate) = let > // > val+CSVState(x0) = state in x0.tableRow > // > end // end of [CSVState_get_tableRow] > implement > {} > CSVState_set_tableRow > (state, i0) = let > // > val+@CSVState(x0) = state in x0.tableRow := i0; fold@(state) > // > end // end of [CSVState_se

Re: Segfault when using streamize_fileref_char

2017-03-08 Thread August Alm
as readability of code is concerned. How does my vtypedef-version compare with your datavtype-version in terms of efficiency? Is there a clear optimization reason to choose one over the other? Den onsdag 8 mars 2017 kl. 10:18:45 UTC+1 skrev August Alm: > > I see. Yes, being able

Re: Segfault when using streamize_fileref_char

2017-03-08 Thread August Alm
t project(s) I will try to heed your words. I know that this may sound a bit vague but that is my point. Being vague > makes people > think more and more deeply :) > > Cheers! > > > On Tuesday, March 7, 2017 at 4:52:58 PM UTC-5, August Alm wrote: >> >> I'm glad

Re: Segfault when using streamize_fileref_char

2017-03-13 Thread August Alm
Always segfault. Compiling with the "-verbose" flag prints exec(patsopt --output csv_lexer_dats.c --dynamic csv_lexer.dats) Segmentation fault exec(patsopt --output csv_lexer_dats.c --dynamic csv_lexer.dats) = 35584 which does not tell me anything. My code can be found at https://gith

Re: Segfault when using streamize_fileref_char

2017-03-13 Thread August Alm
erence in ATS is quite limited :) > > On Mon, Mar 13, 2017 at 4:51 PM, August Alm > wrote: > >> So... I added some "second stage" parsing functionality, to get the en >> result in tabular form rahter than as a single [stream_vt], and to check >> for global

Re: Segfault when using streamize_fileref_char

2017-03-13 Thread August Alm
nt_vtype of CSVError? Den måndag 13 mars 2017 kl. 23:42:03 UTC+1 skrev gmhwxi: > > Once INV annotation is done properly, template annotation can be pretty > much removed. > > > On Mon, Mar 13, 2017 at 6:39 PM, August Alm > wrote: > >> Thanks for the hint! I added te

Re: Segfault when using streamize_fileref_char

2017-03-13 Thread August Alm
uot; Den tisdag 14 mars 2017 kl. 00:57:18 UTC+1 skrev August Alm: > > Yes, as you guessed I am having problems with covariance. Some I have > solved but this one leaves me very puzzled: > > I'll copy the code here in the order that it appears in my file. First (in > "csv

Re: Segfault when using streamize_fileref_char

2017-03-14 Thread August Alm
gt; > > On Mon, Mar 13, 2017 at 9:09 PM, Hongwei Xi > wrote: > > This is because CSVErrors is a dependent type. > > The right way to do it is to make CSVErrors abstract. > > If you are using ATS2-0.3.3, then you can use the feature of 'reassume'. > I will show

Re: Segfault when using streamize_fileref_char

2017-03-14 Thread August Alm
iable: > > implement {CSVErrors} extfree(errs) = ... > > What you need is > > implement extfree(errs) = free(errs) > > On Tuesday, March 14, 2017 at 9:35:36 AM UTC-4, August Alm wrote: >> >> Great application of "reassume"! =D I had to reinstall ATS2

Re: Segfault when using streamize_fileref_char

2017-03-14 Thread August Alm
other places where you need this kind of change. Then you > should be able to compile the entire program. I just did. > > On Thursday, March 2, 2017 at 5:04:35 PM UTC-5, August Alm wrote: >> >> Hi! >> >> I'm in over my head and tried writing a CSV-parser using

(Co)monads in ATS

2017-03-16 Thread August Alm
Hi all! I just wrote down some sketchy thoughts on monads and comonads in ATS. ATS has a very unique type system, so there are (co)monads in ATS that simply do not exist in other languages. I'm wondering if this might be useful. See the attached and let me know if you have ideas. Best wishes,

Re: (Co)monads in ATS

2017-03-17 Thread August Alm
C: type -> viewtype. There is a sort of trivial inclusion J: type -> viewtype given by wrapping in a dataviewtype (so datavtype J(a: type) = J of a) and one can regard C as a comonad relative to J. Den fredag 17 mars 2017 kl. 21:52:42 UTC+1 skrev Steinway Wu: > > Great note! > >

Re: (Co)monads in ATS

2017-03-18 Thread August Alm
e exists a view V and a type T such that > > VT = (V | T) > > > *The linearity of a viewtype entirely comes from the linearity of the > viewinside it.* > > On Thursday, March 16, 2017 at 11:20:54 AM UTC-4, August Alm wrote: >> >> Hi all! >> >> I just wrot

Re: (Co)monads in ATS

2017-03-18 Thread August Alm
g the error messages myself. Best wishes, August Den lördag 18 mars 2017 kl. 09:06:34 UTC+1 skrev Artyom Shalkhakov: > > Hi August, > > On Thursday, March 16, 2017 at 9:20:54 PM UTC+6, August Alm wrote: >> >> Hi all! >> >> I just wrote down some sketchy thoughts on mo

Re: (Co)monads in ATS

2017-03-21 Thread August Alm
a (non-linear value). > > Of course, this is all intuition. It would require a huge effort to > actually build > a model for only the core of ATS. > > > On Saturday, March 18, 2017 at 9:00:33 PM UTC-4, August Alm wrote: >> >> I know T in VT = (V | T) can be gotte

How to evade scope restriction on linear values?

2017-03-22 Thread August Alm
Hi! I am trying to write a function as follows: fun return {s: vt0p}{a: vt0p} (x: a): (s - (s, a)) = let val x = $UN.castvwtp0{ptr}(x) in lam(st) = let val x = $UN.castvwtp0{a} in (st, x) end end With non-linear types it'd be fine to write [ret

Re: How to evade scope restriction on linear values?

2017-03-22 Thread August Alm
Darn!!! I had just forgotten the "x" in the cast inside the lambda. Took way too long to notice.. Now with "x" added" it does work. Hope the post is useful to someone else. =) Den torsdag 23 mars 2017 kl. 00:14:33 UTC+1 skrev August Alm: > > Hi! > > I am

Re: How to evade scope restriction on linear values?

2017-03-22 Thread August Alm
/hwxi/teaching/monadlin/DATS/monadlin_state.dats > > If you see monads from this angle, then the get/put functions in Haskell > (for state monads) look quite strange, to say the least. > > On Wednesday, March 22, 2017 at 7:14:33 PM UTC-4, August Alm wrote: >> >> Hi! >>

Re: How to evade scope restriction on linear values?

2017-03-23 Thread August Alm
argely taken from this source: > https://wiki.haskell.org/State_Monad > > On Wednesday, March 22, 2017 at 9:31:50 PM UTC-4, August Alm wrote: > Thanx! That definitely looks cleaner than what I had. (As you probably > guessed I tried to do the divide and conquer thing -- i have

Re: How to evade scope restriction on linear values?

2017-03-23 Thread August Alm
I have written what might be considered an implementation of the divide-and-conquer schema from the Effective ATS series, using a linear state monad for doing memoization. See https://github.com/August-Alm/ATS-Experiments The code doesn't quite compile though. I've worked myself

Re: How to evade scope restriction on linear values?

2017-03-24 Thread August Alm
6620580095947431500524025327097469953187707243768259074199396322659841474981936092852239450397071654431564213\ >> >> 28157688908058783183404917434556270520223564846495196112460268313970975069382648706613264507665074611512677522748621598642530711298441182622661057163\ >> >> 51506926002986170

Toy implementation of lenses

2017-03-27 Thread August Alm
I just wrote a toy ATS implementation of lenses, as used in Scala and Haskell. See https://github.com/August-Alm/ATS-Experiments/blob/master/lens.dats Lenses are, in their most basic form, a way to functionally update immutable tuples and records. Perhaps one could use them to update the

Re: Toy implementation of lenses

2017-03-28 Thread August Alm
code wouldn't compile without them. Den tisdag 28 mars 2017 kl. 03:30:11 UTC+2 skrev gmhwxi: > > > Thanks! > > I made the code a bit more ATSish: > > > https://github.com/githwxi/ATS-Postiats-contrib/tree/master/contrib/libats-/hwxi/teaching/lens > > On Monday, March

Re: How to evade scope restriction on linear values?

2017-03-28 Thread August Alm
DivideConquer; if it is > above, then use DivideConquerPar. It is pretty much like doing > parallelization. > > On Wednesday, March 22, 2017 at 7:14:33 PM UTC-4, August Alm wrote: >> >> Hi! >> >> I am trying to write a function as follows: >> >>

Re: Template-based implementation for functors

2017-03-29 Thread August Alm
I liked the sort of reversed perspective! Two objects A and B define a "for all functors F, F_map : F(A) -> F(B)". But having to pass around "F_name" and introduce a "FUNCTOR_F_elim" seems a bit heavy-handed. Or is there a possibility that the proof terms can be passed implicitly, like [pfgc: m

Re: Template-based implementation for functors

2017-03-29 Thread August Alm
I guess what I really wanted to ask is: Why not just use an abstract [FUNCTOR(ftype)] instead of [FUNCTOR(fname: type, ftype), i.e., why insist on names? Den onsdag 29 mars 2017 kl. 20:48:51 UTC+2 skrev August Alm: > > I liked the sort of reversed perspective! Two objects A and B de

Re: Template-based implementation for functors

2017-03-29 Thread August Alm
For fun and learning I tried to do linear monads in a similar spirit, see: https://glot.io/snippets/eogc8rdiv1 I get the code to compile (without the test-case at the end which I've commented out; don't know what's wrong with that) but it does not run on glot.io, because of LIBATS/ML-dependency

Re: Template-based implementation for functors

2017-03-30 Thread August Alm
> https://github.com/githwxi/ATS-Postiats/blob/master/doc/EXAMPLE/MISC/tempfunctor.dats > > On Wednesday, March 29, 2017 at 6:36:02 PM UTC-4, August Alm wrote: > For fun and learning I tried to do linear monads in a similar spirit, see: > https://glot.io/snippets/eogc8rdiv1 I get the

Re: Template-based implementation for functors

2017-03-30 Thread August Alm
sizing > proofs of certain props. Kind of like inferring dictionaries for type > classes. > > I did not go forward right away because I wanted to see more use cases > involving > concepts from category theory. > > On Thursday, March 30, 2017 at 4:37:47 AM UTC-4, August Alm w

Re: Template-based implementation for functors

2017-03-30 Thread August Alm
ctionaries for type > classes. > > I did not go forward right away because I wanted to see more use cases > involving > concepts from category theory. > > On Thursday, March 30, 2017 at 4:37:47 AM UTC-4, August Alm wrote: >> >> Den torsdag 30 mars 2017 kl. 04:

Re: Template-based implementation for functors

2017-03-30 Thread August Alm
gt; > val xs = $list_vt{int_vt}(I(1), I(2), I(3)) > > On Thursday, March 30, 2017 at 10:13:04 AM UTC-4, August Alm wrote: >> >> Sorry, wrong link. Here is the right one: >> https://glot.io/snippets/eoh28sd2p4 >> >> Den torsdag 30 mars 2017 kl. 15:54:08 UTC+2 sk

Re: Template-based implementation for functors

2017-03-30 Thread August Alm
les. I saw the following lines after execution: > 1 > 2 > 3 > > > On Thu, Mar 30, 2017 at 5:11 PM, August Alm > wrote: > >> I think the problem is with >> >> extern fun{a, s: vt0ype} >> mapM_list_vt$fopr(a): s >> >> It doesn't see

Re: Template-based implementation for functors

2017-03-30 Thread August Alm
one of the things I am hoping to achieve is to reduce the amount of book-keeping by tucking it away in a library of some standard monadic functions. Den fredag 31 mars 2017 kl. 00:30:16 UTC+2 skrev August Alm: > > Great! But ...What just happened, what's the lesson I should take away

Re: Template-based implementation for functors

2017-03-31 Thread August Alm
I got it working with linear types and cloptr functions, see https://github.com/August-Alm/ATS-Experiments/blob/master/linear_monads.dats (I can't get the code to work on glot.io unfortunately.) This is fun! Den fredag 31 mars 2017 kl. 03:54:01 UTC+2 skrev gmhwxi: > > cloref1 vs. clo

Re: Template-based implementation for functors

2017-04-01 Thread August Alm
]] to evade scope restriction for lambdas. Is that a good guess? Den lördag 1 april 2017 kl. 03:53:47 UTC+2 skrev gmhwxi: > > Cool! > > You could just use int for int_vt, right? Maybe you also wanted > to try datavtype in this experiment. > > On Friday, March 31, 2017 at 9:

Re: Template-based implementation for functors

2017-04-01 Thread August Alm
ation. Den lördag 1 april 2017 kl. 23:16:39 UTC+2 skrev August Alm: > > Actually, no, it will not compile with [int] instead of [int_vt]. I can't > figure out > where in the code the problem appears; the compiler says > > warning: cast to pointer from integer of differe

Re: Template-based implementation for functors

2017-04-02 Thread August Alm
t;> in mapM_list_vt$aux{m}{n}(pfm| xs) end >>> >>> So the implementation of mapM_list_vt$fopr cannot be used for the purpose >>> of compiling mapM_list_vt$aux. >>> >>> On Thursday, March 30, 2017 at 6:30:16 PM UTC-4, August Alm wrote: >

Re: Template-based implementation for functors

2017-04-02 Thread August Alm
to the closure > generated from compiling foldM_list_vt. The compiler does this > automatically > most of the time but the programmer may have to use $tempenver occasionally > as the underlying algorithm I used is not complete (but more efficient for > handling > most cases).

Re: Template-based implementation for functors

2017-04-03 Thread August Alm
init) end > > > The use of $tempenver forces the compiler to push 'fopr' into the closure > generated from compiling foldM_list_vt. The compiler does this > automatically > most of the time but the programmer may have to use $tempenver occasionally > as the underlying alg

Re: Template-based implementation for functors

2017-04-03 Thread August Alm
C-4, gmhwxi wrote: >>> >>> What you reported sounds like a bug in the ATS compiler. >>> Could you make your code accessible for me to take a look? >>> >>> Thanks! >>> >>> On Monday, April 3, 2017 at 5:40:01 AM UTC-4, August Alm wrote

Re: Template-based implementation for functors

2017-04-05 Thread August Alm
gust Den måndag 3 april 2017 kl. 23:18:44 UTC+2 skrev gmhwxi: > > You could use 'unit' instead of 'void': unit(): unit > > On Monday, April 3, 2017 at 5:04:04 PM UTC-4, August Alm wrote: >> >> Great you caught it! Now I almost feel useful. >> >>

Re: Template-based implementation for functors

2017-04-05 Thread August Alm
: > > stadef > cont(r: vt0ype) = lam(a: vt0ype) => hom(a, r) - r > > > On Wed, Apr 5, 2017 at 6:35 AM, August Alm > wrote: > >> Thank you, that worked like a charm! >> >> I have now encountered a compiler error I have not seen before. >> Se

How to use [gfree_val]?

2017-04-05 Thread August Alm
Look at the following short program: #include "share/atspre_staload.hats" #staload UN = "prelude/SATS/unsafe.sats" implement main0() = let datavtype I_dvt(a: t0ype) = I(a) of a vtypedef int_vt = I_dvt(int) val z = I(5)

Re: How to use [gfree_val]?

2017-04-05 Thread August Alm
Hrrm, I see, [gfree_val] lacks implementation! It is up to me as user to give it meaning. But shouldn't the compiler warn me that it lacks implementation? Den onsdag 5 april 2017 kl. 23:42:02 UTC+2 skrev August Alm: > > Look at the following short program: > >

Re: How to use [gfree_val]?

2017-04-06 Thread August Alm
wrote: >> >>> This look like a bug. >>> >>> Let me investigate a bit further. >>> >>> >>> On Wed, Apr 5, 2017 at 6:13 PM, August Alm <...> wrote: >>> >>>> Hrrm, I see, [gfree_val] lacks implementation! It is up

Re: How to use [gfree_val]?

2017-04-06 Thread August Alm
My own solution for creating a duplicate [x'] of [x: a]: val x' = dataget{a}(x) val x' = $UN.castvwtp0{a}(x') It seems to work, at least for [a: vtype]. Den torsdag 6 april 2017 kl. 12:32:50 UTC+2 skrev August Alm: > > I just wish I had the knowledge to cont

Re: How to use [gfree_val]?

2017-04-06 Thread August Alm
se of aliasing? Den torsdag 6 april 2017 kl. 13:55:30 UTC+2 skrev gmhwxi: > > This is a typical form of aliasing: One can use both x and x' to > access the view associated with the data. So caution is needed > to avoid issues that may be caused by aliasing. > > On Thu, Apr

using static quantifiers as dynamical terms

2017-04-11 Thread August Alm
I have a function that looks as follows: fun{} parallel_composition_aux {m1, n1, m2, n2: nat} (m1: int m1, p1: processor(m1, n1), p2: processor(m2, n2)): processor(m1+m2, n1+n2) = llam(ys) = let val (xs1, xs2) = list_vt_split_at(

Re: using static quantifiers as dynamical terms

2017-04-12 Thread August Alm
Thanks! I like this solution. Den onsdag 12 april 2017 kl. 05:26:15 UTC+2 skrev Artyom Shalkhakov: > > On Wednesday, April 12, 2017 at 5:16:50 AM UTC+6, August Alm wrote: >> >> I have a function that looks as follows: >> >> fun{} >> parallel

Re: using static quantifiers as dynamical terms

2017-04-12 Thread August Alm
. The error is caused by [val m = a1+a2] and [val n = b1 + b2]. I've tried [g0ofg1] and [g1ofg0] to ensure the types really match but, no luck. Any ideas? Best wishes, August Den onsdag 12 april 2017 kl. 05:26:15 UTC+2 skrev Artyom Shalkhakov: > > On Wednesday, April 12, 2017 at 5:16:50

Re: using static quantifiers as dynamical terms

2017-04-12 Thread August Alm
not a proof. > > > Sent from my T-Mobile 4G LTE device > > > -- Original message-- > > *From: *August Alm > > *Date: *Wed, Apr 12, 2017 12:43 PM > > *To: *ats-lang-users; > > *Subject:*Re: using static quantifiers as dynamical terms > > > Hrrm, I&#

How to properly compose lincloptr functions?

2017-04-12 Thread August Alm
Hi! The code for my question can be found here: It does not compile on glot.io though, for some reason. It does on my computer. The code is: #include "share/atspre_define.hats" #include "share/atspre_staload.hats" #staload UN = "prelude/SATS/unsafe.sats"

Re: How to properly compose lincloptr functions?

2017-04-12 Thread August Alm
Sorry, missed the link; here: https://glot.io/snippets/eovl9b5fj6 Den onsdag 12 april 2017 kl. 20:26:22 UTC+2 skrev August Alm: > > Hi! > > The code for my question can be found here: > It does not compile on glot.io though, for some reason. It does on my > com

Re: How to properly compose lincloptr functions?

2017-04-13 Thread August Alm
p(f, g), lam($tup(f, g)) => (f.free(); g.free()), > lam($tup(f, g), x) => g.eval(f.eval(x))) > end // end of [compare_hom_hom] > > > On Wednesday, April 12, 2017 at 4:55:46 PM UTC-4, gmhwxi wrote: >> >> A linear function (lincloptr) must called exactly once. For ur purp

Re: How to properly compose lincloptr functions?

2017-04-13 Thread August Alm
usual compose. > > Don't worry about performance at this point; it can be readily fixed if > needed. > > If this can be worked out, then we can go ahead to implement packages > inspired > by category theory to support very low-level programming. > > Cheers! > >

Re: How to properly compose lincloptr functions?

2017-04-14 Thread August Alm
; > This kind of error message indicates that the compiler cannot figure > out the size of some type. I should be able to tell a bit more if I could > see the source code. > > On Thursday, April 13, 2017 at 5:48:51 PM UTC-4, August Alm wrote: >> >> Not as semant

Re: How to properly compose lincloptr functions?

2017-04-14 Thread August Alm
in y end > > > Also make similar changes to hom_eval and hom_compose. Then the code > should work (I saw 9 printed out). > > > On Friday, April 14, 2017 at 8:21:22 AM UTC-4, August Alm wrote: >> >> Here are two attempts (the "hom" in terms of [option_vt]

Re: How to properly compose lincloptr functions?

2017-04-14 Thread August Alm
example that I started this thread with.) Den fredag 14 april 2017 kl. 15:18:57 UTC+2 skrev August Alm: > > Great! > > The following implementation is maybe cleaner / has better integrity: > > absvtype > hom(a: vt0ype-, b: vt0ype+) > >

Stuck with -Wimplicit-function-declaration

2017-04-17 Thread August Alm
type an audio signal can be given. (Essentially, only streams of ints or floats, I believe). My idea is that it should be possible to give a very direct implementation of the block diagram algebra in ATS, that works for signals of any [viewt0ype]. My code so far is here: https://github.com/Aug

Re: Stuck with -Wimplicit-function-declaration

2017-04-17 Thread August Alm
; any subsequent call to 'f' are unable to use > either 'f1' or 'f2'. > > I really need to insert some form of checking to stop a lincloptr function > from being recursively > defined (via the use of 'fix'). > > > On Mon, Apr 17, 2017 at

[stream_vt_head_exn], strange behavior

2017-04-19 Thread August Alm
Hi! The following code compiles but segfaults when run: val from_vt_nine = from_vt(9) val nine = stream_vt_head_exn(from_vt_nine) val () = println!(nine: int) The follwing code, on the other hand, executes as expected: val from_vt_nine = from_vt(9) v

Re: [stream_vt_head_exn], strange behavior

2017-04-19 Thread August Alm
> stream_vt_head_exn tries to free a given stream. In the above case, > freeing the given stream trigger infinite computation. > > In the follow code, 'ns' is leaked: > > val from_vt_nine = from_vt(9) > val- ~stream_vt_cons(nine, ns) = !from_vt_nine > val ()

"the size of a stack-allocated array cannot be determined"

2017-04-23 Thread August Alm
I'm experimenting with some more imperative programming in ATS and since I know even less C than ATS I am having a hard time. I am currently getting the compiler error "the size of a stack-allocated array cannot be determined" and I think this indicative of a fundamentally flawed methodology on

Re: "the size of a stack-allocated array cannot be determined"

2017-04-23 Thread August Alm
inear types! Don't fear them. A lot of things just seem to work out of the box, the way you mean to write them. The only real "gotchas" are copying/aliasing and scope restriction. Den söndag 23 april 2017 kl. 21:16:03 UTC+2 skrev August Alm: > > I'm experimenting with s

[atspre_malloc_gc] on Arduino

2017-04-27 Thread August Alm
Hi! I am fiddling around with using ATS for Arduino, based on the ATS-contrib folder. Lots of fun! The following error, though, leaves me clueless as to how to fix: In function ‘void* ATSLIB_056_prelude__array_ptr_alloc__46__1(atstype_size)’: ... error: ‘atspre_malloc_gc’ was not declared in

Re: [atspre_malloc_gc] on Arduino

2017-04-27 Thread August Alm
m my T-Mobile 4G LTE device > > > > > > > > -- Original message-- > From: August Alm > Date: Thu, Apr 27, 2017 5:53 PM > To: ats-lang-users; > Subject:[atspre_malloc_gc] on Arduino > > > Hi! > I am fiddling around with using ATS for Ardu

Re: [atspre_malloc_gc] on Arduino

2017-04-28 Thread August Alm
xi wrote: >> >> I guess that the reason for the failure is due to 'malloc' being not >> available. >> >> One should probably avoid using malloc/free when coding for Arduino. If >> anything >> needs to be allocated, trying to do it at compile-t

Re: [atspre_malloc_gc] on Arduino

2017-04-28 Thread August Alm
> > -- Original message-- > > *From: *August Alm > > *Date: *Fri, Apr 28, 2017 2:25 PM > > *To: *ats-lang-users; > > *Subject:*Re: [atspre_malloc_gc] on Arduino > > > I'm still not sure what to do. > Is there even a way to define [arrayptr]-v

Re: [atspre_malloc_gc] on Arduino

2017-04-28 Thread August Alm
l allocated at the > beginning. > A function like audiobuffer_initize should only do initialization (and do > no allocation). > > On Friday, April 28, 2017 at 4:25:30 PM UTC-4, August Alm wrote: >> >> Here is a smallish working example: https://glot.io/snippets/epdbih

Re: [atspre_malloc_gc] on Arduino

2017-04-28 Thread August Alm
gt; macdef theArray = > $extval(arrayref(int,N),"theArray") > // > > In embedded programming, resources are often all allocated at the > beginning. > A function like audiobuffer_initize should only do initialization (and do > no allocation). > > On Friday, April 28,

Re: [atspre_malloc_gc] on Arduino

2017-04-30 Thread August Alm
That simple, huh! Thank you, and thank you for nudging me in other directions. :) Den lördag 29 april 2017 kl. 02:20:01 UTC+2 skrev gmhwxi: > > The code seems to compile if you just add: > > %{^ > #define atspre_malloc_gc malloc > %} > > > On Fri, Apr 28, 2017 at 6

How to use [stream_vt] on arduino?

2017-05-15 Thread August Alm
Hi! I am following the Arduino library in ATS contrib and want to try do something with linear streams. The convenience file [staloadall.hats] does not load [stream_vt.dats] and simply adding that in my preamble does not work -- I get the "not declared" errors: error: ‘atspre_lazy_vt_free’ was

Re: How to use [stream_vt] on arduino?

2017-05-16 Thread August Alm
efined in the >> included header files for arduino programming. >> >> I made some changes. Please do a git-pull first. >> >> There is a newly added example: TEST/StreamOps >> Please note the following line in the included Makefile: >> >> MYCFLAGS += -D_ATS_

Re: ATS3: ATS/Xanadu

2018-02-13 Thread August Alm
I second the preference for Haskell-style "let" and "where", which is to say no "end"s and no curly braces. Of course, this requires indentation to be syntactic and not just a matter of aesthetics/readability. I think this is a good thing, not just because it is more concise but maybe even more s

Re: ATS3: ATS/Xanadu

2018-02-13 Thread August Alm
y in a C-ish style. Den tisdag 13 februari 2018 kl. 16:56:52 UTC+1 skrev Artyom Shalkhakov: If we talk syntax, why not adopt that of C? :-) > > 13 февр. 2018 г. 8:43 ПП пользователь "August Alm" > написал: > > I second the preference for Haskell-style "let" and &q

Re: ATS3: ATS/Xanadu

2018-02-13 Thread August Alm
I realize it may have sounded as if I like the feature of being able to write the same thing in a multitude of ways. I don't. It's something both Scala and ATS have in common and that I think it's problematic. In both Haskell and C the are many ways of doing things, but not many ways/styles of w

Re: ATS3: ATS/Xanadu

2018-02-18 Thread August Alm
I have something to add to the wishlist: "better" linear functions. We had a discussion about this almost a year ago. The issue I raised back then is that there is no real way to free a linear function without applying it. This is not a concern motivated by category theory or something such, bu

At-views and isomorphisms

2020-04-24 Thread August Alm
Hi! Jumping straight to it, consider the following types (here [a: t0ype+], say): node0_t(a) = @{entry = a, next = ptr} and node1_t(a) = [l: addr] @{entry = a, next = ptr(l)} Using the pure cast-functions [g1ofg0_ptr] and [g0ofg1_ptr] I can write down corresponding pure functions [g1ofg0_node]

Re: At-views and isomorphisms

2020-04-25 Thread August Alm
functions in ATS3. Such functions are needed in ATS2 > primarily for the sake of selecting template implementations based on > (dependent) types. In ATS3. template selection is based on the erasures > of dependent types, which are algebraic (that is, no quantifiers are > involved). > >

  1   2   >