felix-language — Design of t he Felix programming language

You can subscribe to this list here.

2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 Jan Feb Mar Apr May Jun Jul (1) Aug Sep (4) Oct Nov Dec Jan Feb Mar Apr May Jun Jul Aug Sep (1) Oct Nov Dec Jan Feb Mar Apr (6) May (4) Jun (2) Jul Aug Sep Oct (3) Nov Dec Jan Feb (1) Mar (14) Apr (71) May (93) Jun (17) Jul (62) Aug (25) Sep (42) Oct (43) Nov (51) Dec (70) Jan (15) Feb (20) Mar (1) Apr (29) May (18) Jun (27) Jul (71) Aug (114) Sep (89) Oct (177) Nov (107) Dec (54) Jan (165) Feb (111) Mar (138) Apr (99) May (78) Jun (85) Jul (104) Aug (97) Sep (276) Oct (313) Nov (65) Dec (35) Jan (21) Feb (143) Mar (136) Apr (174) May (99) Jun (11) Jul (225) Aug (54) Sep (118) Oct (44) Nov (31) Dec (9) Jan (1) Feb (1) Mar (21) Apr May (23) Jun Jul (3) Aug (4) Sep (5) Oct Nov (1) Dec Jan (1) Feb (7) Mar (38) Apr (75) May (12) Jun (34) Jul Aug (6) Sep (20) Oct Nov (13) Dec (1) Jan (26) Feb Mar Apr (2) May Jun Jul Aug (1) Sep (3) Oct (140) Nov (88) Dec (63) Jan (41) Feb (35) Mar (31) Apr (20) May (4) Jun Jul Aug Sep Oct (11) Nov (30) Dec (8) Jan (28) Feb (35) Mar (27) Apr (55) May (57) Jun (23) Jul (18) Aug (86) Sep (20) Oct (16) Nov (65) Dec (59) Jan (65) Feb (77) Mar (51) Apr (16) May (46) Jun (19) Jul (18) Aug (4) Sep (18) Oct (18) Nov (25) Dec (38) Jan (71) Feb (48) Mar (32) Apr (6) May (17) Jun (2) Jul (1) Aug (82) Sep (40) Oct (2) Nov (8) Dec (5) Jan (4) Feb (12) Mar (23) Apr (12) May Jun (4) Jul Aug Sep Oct Nov Dec

Showing results of 5884

1 2 3 .. 236 > >> (Page 1 of 236)
 Re: [Felix-language] [felix] Active programming revolution From: john skaller - 2015-06-03 21:47:31 On 04/06/2015, at 2:52 AM, Ryan Gonzalez wrote: > isn't this basically stack-oriented programming without a stack? Like "Forth"? Nope. Nothing like that except it shares the "value free" associativity property. Remember pipelines are only the simple functional stage. I haven't got up to feedback loops yet. It's hard to draw a diagram but you can do, say, fibonacci series quite nicely by feeding back the value to yourself with a delay. This is a loop and hence tail recursion. -- john skaller skaller@... http://felix-lang.org 
 Re: [Felix-language] [felix] Active programming revolution From: Ryan Gonzalez - 2015-06-03 16:53:09 Attachments: Message as HTML So... ... isn't this basically stack-oriented programming without a stack? Related project of interest: http://code.google.com/p/anic On June 2, 2015 7:10:08 PM CDT, john skaller wrote: >There is about to be a major paradigm shift in the world of >programming: Active Programming. > >I have spent over 15 years developing a strong enough core to >actually implement what the original commercial job required, >and it leads to complete paradigm shift: Active Programming. > >Here's what happens. in the old world we have imperative >stateful programming languages with expressions thrown in. >Control flow was king. The pairing of data flow and control >flow was broken by C and similar languages with the notion >of functions using the machine stack (data and control passed >together on the stack). > >On the other side, functional programming touted declarative >specifications based on mathematics, and because of the mathematical >basis this style is ostensibly easier to analyse because of the wealth >of mathematical skills and knowledge available. But purely functional >languages just don't cut it in practice: performance is one issue but >the simple reality is recursion is too hard to understand and doesn't >match reality. > >Active programming MERGES stateful imperative programming >and functional programming into a single paradigm. The paradigm >is fully declarative and so amenable to analysis. > >At present I am just doing the basics. The simplest form is a pipeline: > >#((1,2,3,4,5).iterator |-> (fun (x:int) => x + 1) |-> (fun (x:int) => x >* x) |-> println[int]); > >In this form we have sources, sinks, and transducers. A source combined >with >a transducer is another source. A transducer combined with a sink is >another >sink. The pipeline operator is associative. > >A source is basically a lazy list or stream of values. A sink is >basically >a continuation. You can view the pipeline by splitting it into any >three parts >at ANY connection: > > SOURCE |-> TRANSDUCER |-> SINK > generator |-> function |-> continuation > >The model is beautifully symmetrical. A sink is the categorical dual of >a source. > >The objects here are objects of a category, and the pipe operators are >the >arrows. So in fact we have built a mechanical model of a category. > >Each of the components are called "chips" and the pipes are called >"wires". > >The chips and wires model can be much more general and is based on >the picture of a thing called a multigraph. A normal graph has vertices >which are just connection points, and edges which connect at vertices. > >A multigraph is the quite different. Here the "wires" or "edges" are >the >connections and the "chips" or "vertices" are the important things. >Chips can have multiple inputs and outputs and they do things. > >There are many ways to connect chips. The pipeline is just simplest. >We shall see pipelines subsume all functional programming, when >enhanced with recursion. > >A chip is an ACTIVE device. They are each an fthread (fibre). >Each chip is a MASTER. There are no slave subroutines. >This is the primary fault of all functional programming. > >There's nothing wrong with slaves .. the problem is when you ONLY have >master/slave relations instead of also having peer-peer relations. >In the chips and wires model, all chips are peers. > >Note that in a pipeline CONTROL FLOW IS NOT DETERMINATE. >Data flow is determinate. It flows left to right along the pipes. >But there is no requirement data be written onto a pipe first, >then the data be read. Instead, data could be requested, >and then supplied. Indeed, this is what schannels do. >They're synchronisation points: neither reader nor writer >may proceed until they exchange the data, but it isn't determined >who comes or goes first. As long as they synchronise. > >Control flow is not arbitrary. There are constraints. But the paradigm >is declarative so the details are hidden. > >The implementation details are in > > src/package/spipes.fdoc > >There's a lot more to do. One of the most astounding facts is this: >Consider a circuit board populated with chips. Got the picture? > >Ok, So PULL SOME CHIPS OUT. > >What have you got???? > > >POLYMORPHISM. > >Only, the "type variables" are now "chip variables", that is, >empty sockets, and we need to plug in chips with a particular >signature and behaviour. [Chip variables are basically the >same idea as Ocaml module signatures only the active >programming concept is much better than modules/functors >because a chip is an ACTIVE device, not merely a collection >of slave functions] > >-- >john skaller >skaller@... >http://felix-lang.org > > > >-- >You received this message because you are subscribed to the Google >Groups "Felix Language" group. >To unsubscribe from this group and stop receiving emails from it, send >an email to felix-language+unsubscribe@... >To post to this group, send email to felix-language@... >Visit this group at http://groups.google.com/group/felix-language. >For more options, visit https://groups.google.com/d/optout. -- Sent from my Android device with K-9 Mail. Please excuse my brevity.
 Re: [Felix-language] [felix] Active programming revolution From: john skaller - 2015-06-03 11:01:41 On 03/06/2015, at 6:41 PM, srean wrote: > This ought to be a blog post. Blogs are too much work. No one reads mine anyhow. No one reads the email either but its easier to do them. > And if you are still in touch with Stepanov, I think he would be quite excited to read this. I'm not in touch with anyone. -- john skaller skaller@... http://felix-lang.org 
 [Felix-language] Active programming revolution From: john skaller - 2015-06-03 00:11:04 There is about to be a major paradigm shift in the world of programming: Active Programming. I have spent over 15 years developing a strong enough core to actually implement what the original commercial job required, and it leads to complete paradigm shift: Active Programming. Here's what happens. in the old world we have imperative stateful programming languages with expressions thrown in. Control flow was king. The pairing of data flow and control flow was broken by C and similar languages with the notion of functions using the machine stack (data and control passed together on the stack). On the other side, functional programming touted declarative specifications based on mathematics, and because of the mathematical basis this style is ostensibly easier to analyse because of the wealth of mathematical skills and knowledge available. But purely functional languages just don't cut it in practice: performance is one issue but the simple reality is recursion is too hard to understand and doesn't match reality. Active programming MERGES stateful imperative programming and functional programming into a single paradigm. The paradigm is fully declarative and so amenable to analysis. At present I am just doing the basics. The simplest form is a pipeline: #((1,2,3,4,5).iterator |-> (fun (x:int) => x + 1) |-> (fun (x:int) => x * x) |-> println[int]); In this form we have sources, sinks, and transducers. A source combined with a transducer is another source. A transducer combined with a sink is another sink. The pipeline operator is associative. A source is basically a lazy list or stream of values. A sink is basically a continuation. You can view the pipeline by splitting it into any three parts at ANY connection: SOURCE |-> TRANSDUCER |-> SINK generator |-> function |-> continuation The model is beautifully symmetrical. A sink is the categorical dual of a source. The objects here are objects of a category, and the pipe operators are the arrows. So in fact we have built a mechanical model of a category. Each of the components are called "chips" and the pipes are called "wires". The chips and wires model can be much more general and is based on the picture of a thing called a multigraph. A normal graph has vertices which are just connection points, and edges which connect at vertices. A multigraph is the quite different. Here the "wires" or "edges" are the connections and the "chips" or "vertices" are the important things. Chips can have multiple inputs and outputs and they do things. There are many ways to connect chips. The pipeline is just simplest. We shall see pipelines subsume all functional programming, when enhanced with recursion. A chip is an ACTIVE device. They are each an fthread (fibre). Each chip is a MASTER. There are no slave subroutines. This is the primary fault of all functional programming. There's nothing wrong with slaves .. the problem is when you ONLY have master/slave relations instead of also having peer-peer relations. In the chips and wires model, all chips are peers. Note that in a pipeline CONTROL FLOW IS NOT DETERMINATE. Data flow is determinate. It flows left to right along the pipes. But there is no requirement data be written onto a pipe first, then the data be read. Instead, data could be requested, and then supplied. Indeed, this is what schannels do. They're synchronisation points: neither reader nor writer may proceed until they exchange the data, but it isn't determined who comes or goes first. As long as they synchronise. Control flow is not arbitrary. There are constraints. But the paradigm is declarative so the details are hidden. The implementation details are in src/package/spipes.fdoc There's a lot more to do. One of the most astounding facts is this: Consider a circuit board populated with chips. Got the picture? Ok, So PULL SOME CHIPS OUT. What have you got???? POLYMORPHISM. Only, the "type variables" are now "chip variables", that is, empty sockets, and we need to plug in chips with a particular signature and behaviour. [Chip variables are basically the same idea as Ocaml module signatures only the active programming concept is much better than modules/functors because a chip is an ACTIVE device, not merely a collection of slave functions] -- john skaller skaller@... http://felix-lang.org 
 Re: [Felix-language] code generator change From: john skaller - 2015-04-29 11:24:27 On 29/04/2015, at 5:52 PM, john skaller wrote: Scrub that.. too hard to make it work right. We would have to spell it _tt3 because of C's idiot macros. [offsetof in particular but others I defined myself for handling variants] > I am changing the code generator to use templates for some types. > This is a bit experimental. You will need to do this if you don't > want to do a complete rebuild: > > cp src/rtl/flx_compiler_support_bodies.hpp build/release/share/lib/rtl/ > > This change replaces a generated tuple for sizes 2,3,4,5 with > a template, provided the type isn't recursive. For example: > > //TYPE 65766: int * string * int > typedef _tt3_tt65766; -- john skaller skaller@... http://felix-lang.org 
 [Felix-language] code generator change From: john skaller - 2015-04-29 07:53:25 I am changing the code generator to use templates for some types. This is a bit experimental. You will need to do this if you don't want to do a complete rebuild: cp src/rtl/flx_compiler_support_bodies.hpp build/release/share/lib/rtl/ This change replaces a generated tuple for sizes 2,3,4,5 with a template, provided the type isn't recursive. For example: //TYPE 65766: int * string * int typedef _tt3_tt65766; -- john skaller skaller@... http://felix-lang.org 
 Re: [Felix-language] function product From: john skaller - 2015-04-29 05:47:40 On 28/04/2015, at 11:36 PM, john skaller wrote: > I'm giving up: I'm defining it directly in the compiler. This now works: //////////////// fun f (x:int) : int => x + 1; fun g (x:int): string => x.str+"!"; fun h (x:double) :string => x.str+"!"; var fgx = \prod (f,g,h); println$fgx (1,2,3.1); ///////////// Result: (2, 2!, 3.1!) I still have to do dup, sums, etc. \prod (f,g) is the same as f \times g. However var tup = f,g,h; var fgh = \prod tup; works with the new code, the only way to write that with \times and \otimes is tup.0 \otimes (tup.1 \times tup.2) -- john skaller skaller@... http://felix-lang.org   Re: [Felix-language] function product From: john skaller - 2015-04-28 13:37:27 On 28/04/2015, at 11:26 AM, john skaller wrote: > However \prod (f,g,h) still can't be defined, i have ravel (f,g,h) in the > library for up to 5 cases. I'm giving up: I'm defining it directly in the compiler. And sum too. Now, to get the mediating morphism of a product, for many n, we note that = x.dup2.( \prod (f,g) ) So the aim is to now define: fun dup[N,T] (x:T):T^N => x,x,x,...,x // n times which is just an array length N filled with x's... I guess that is already in the library under another name. (as an array constructor?) The function is also called \diag printed as a \delta. The sum version is called \nabla, it takes n x's and produces a single x. -- john skaller skaller@... http://felix-lang.org   [Felix-language] function product From: john skaller - 2015-04-28 01:29:06 This works: fun \times[u1,u2,r1,r2] (f1:u1->r1,f2:u2->r2) : u1 * u2 -> r1 * r2 => fun (x1:u1,x2:u2) => f1 x1, f2 x2; fun \otimes[D1,C1,D,C] (f1:(D1->C1), f:(D->C)) : (D1 ** D) -> (C1 ** C) => fun (a:D1 ** D) : C1 ** C => match a with | (x1,,x) => f1 x1,,f x endmatch ; fun i2s (x:int)=>x.str+"!"; fun i2i (x:int)=>x+1; var fs = i2s,i2i,i2s,i2s; var r = fs.0 \otimes fs.1 \otimes (fs.2 \times fs.3); println$ r (1,2,3,4); But it isn't pretty. The final \times is requires as the ground case (and need parens because of grammar issues, \otimes is right assoc). However \prod (f,g,h) still can't be defined, i have ravel (f,g,h) in the library for up to 5 cases. -- john skaller skaller@... http://felix-lang.org 
 Re: [Felix-language] [felix] mathmode From: john skaller - 2015-04-26 08:59:15 This now works: println$$$\sum (1,2,3,4)$$ ; println$ \prod (1,2,3,4); println$\sum (1,2,3,4).darray; println$ \prod (1,2,3,4).darray; println$\sum (1,2,3,4).list; println$ \prod (1,2,3,4).list; There are two overloads each: one for arrays and one for streamables. The above are all arrays (including list). If the array overload won't go, the streamable overload can be used, however it requires the value type to be specified like \sum[int] ... Of course \sum and \prod give TeX Sigma and Pi symbols :) I will call these pure sums because they take a whole data structure as an argument. Next I will try to figure out how to do indexed sums. These are sums over a formula with an index variable and so require the variable initial and final values be specified. In TeX the notation is \sum_{i=0}^{n-1} (formula (i)) This won't quite work for Felix. Instead we have to specify the type of the index, and, figure some way to specify the limits. As usual programming languages are highly ambiguous but maths is the over the top extremely ambiguous (just to confuse everyone!) You will of course note these are just special cases of folds. They're convenient in some limited circumstances the most important of which is probably showing how beautiful Felix is :) -- john skaller skaller@... http://felix-lang.org 
 [Felix-language] mathmode From: john skaller - 2015-04-25 23:16:58 I'm changing the display rules for mathmode. First, { } will not be displayed in mathmode. Use \{ \} if you want to see something. Second, a Felix identifier will usually emit \mathtt{identifier} which will cause it to be typeset in teletype font, similar to the usual program text font I hope. Next, I am thinking instead of the above, if you specify a font operator: \mathcal { ... } that overrides \mathtt. In fact I think a stack of fonts will be maintained. Fourth, i think I will make a single character identifier an exception and typeset that using \mathit. This means \mathit and \mathtt probably should NOT be used as operators! In general formulae like \mathcal X \mathcal {x + y} \mathcal (x + y) etc affect typesetting and are ALSO Felix functions. So take care to use these functions in a way that the font change make it clear that an operation is performed, and what it is performed ON. -- john skaller skaller@... http://felix-lang.org 
 Re: [Felix-language] [felix] stumped From: john skaller - 2015-04-24 23:21:10 On 25/04/2015, at 3:44 AM, Shayne Fletcher wrote: > > On Fri, Apr 24, 2015 at 1:07 PM, john skaller wrote: > fun ravel[u1,u2,r1,r2] (f1:u1->r1,f2:u2->r2) : u1 * u2 -> r1 * r2 > > ​Neat function. But I want ravel[D1,C1,D2,C2,D3,C3,....D9,C9] (f1:D1->D2, f2:D2->C2 ... f9:D9->C9): D1 * D2 *..D9 -> C1 *C2 .. C9; I can do str[D1,D2, ... D9] (p1:D1, p2:D2,.. p9:D9):string given str:T->string which should be harder, since it involves polymorphic recursion. However the latter is just a string fold of the individual components. However I don't think Ocaml can do this using any method, and I'm not sure Haskell can either (in fact Haskell doesn't even HAVE tuples AFAIK) Felix and C++ can do it. However I can't generalise it, even if you want a bool fold of some property, i.e. fix the return type. The ravel doesn't need any typeclass, it can be done with a purely parametric function, but I can't figure it out :) In Felix and C++ you have to use template instantiation to do polymorphic recursion over a typeclass, you cannot do it without a typeclass, and I see no way to do it in Felix at all. In fact, short of making "ravel" a compiler intrinsic, I see no way to do it. If I am having to add a compiler intrinsic or two, I would want to add the most general ones. Hence reading category theory papers to see what the most general ones are. -- john skaller skaller@... http://felix-lang.org 
 [Felix-language] stumped From: john skaller - 2015-04-24 17:08:03 I am stumped at the moment defining certain operators on tuples. If you look at src/lib/std/datatype/tuple.flx you will see there is general way to apply a function T -> K T * T -> K to a tuple, where K is a constant type. For example T -> string // Str T * T -> bool // Eq are defined. See also that we can do F T0, F T1 ... F TN -> F (T0, T1 .. TN) in some cases, such as in src/lib/std/algebra/set.flx we can "almost" define \otimes (set_form[T0], set_form[T1],.. set_form[TN] ) I say almost because actually we can do var x = { x: int | x > 0} \otimes { x: double | x > 0.0} \otimes { x:string | x > "H" }; println$(24,3.2,"Hello") \in x; but this is right associative. What I REALLY want to define is: \otimes (s1,s2,s3); but this doesn't work. It would be a "generic fold". Another example: //$ parallel composition // notation: f \times g fun ravel[u1,u2,r1,r2] (f1:u1->r1,f2:u2->r2) : u1 * u2 -> r1 * r2 => fun (x1:u1,x2:u2) => f1 x1, f2 x2; This function takes a pair of functions, and makes them into a single function accepting the product of the domains as its domain and the product of its codomains as the codomain. It's easy to define this for 3 or 4 components, but I want to define it for an *arbitrary* length tuple. -- john skaller skaller@... http://felix-lang.org 
 Re: [Felix-language] [felix] Maths DSSL From: Ryan Gonzalez - 2015-04-24 15:04:39 Attachments: Message as HTML Yeah, I still have to try the KaTeX stuff I was working on. Got stumped temporarily because I couldn't find an alternative to \DeclareMathOperator. On Fri, Apr 24, 2015 at 2:56 AM, john skaller wrote: > The below will give cute display in Felix code, if displayed by flx_web. > The "font" operators are just ordinary functions .. so you have to actually > define them if you want stuff to work! > > > //////////////////////////////////////////////////////////////////////////////// > // ordinary and mathmode > var x = X; // ordinary > var x = $$X$$; // mathmode > > // these are all TeX commands so x ^ \font y > // typesets correctly: note \sin is an OP symbol > // so x ^ \sin y fails, and x ^ \Gamma y works > // since \Gamma is an ORD, but the y is not raised. > > // font operators > var x = $$\mathrm X$$; // mathrm > var x = $$\mathit X$$; // mathit > var x = $$\mathfrak X$$; // mathfrak > var x = $$\mathbb X$$; // mathbb > var x = $$\mathbf X$$; // mathbf > var x = $$\mathcal X$$; // mathcal > var x = $$\mathscr X$$; // mathscr > var x = $$\mathsf X$$; // mathscr > var x = $$\mathtt X$$; // mathtt > > // modifiers > var x = $$\acute X$$; // acute > var x = $$\check X$$; // check > > var x = $$x ^ \binom {\mathtt x} {\mathtt y}$$; > /////////////////////////////////////////////////////////////// > > However there are a couple of "gotchas". The first is that in TeX > in math mode a variable is a single character. But that's NOT how > Felix would interpret > > f ABC > > is we happen to write > > $$\mathcal ABC \} > > then the \mathcal function will apply to variable ABC, but it will > only display caligraphic symbol A. This is similar to: > > xyz > > which maths thinks is three variables but Felix thinks is one. > The typeset version is math italic, and it reads OK in this case > but really, it should be typeset in teletype font and boxed into > a single atom: > > \mathtt {xyz} > > To make this work *properly* will have to fiddle with flx_web's > flx2html plugin so that the actual characters put in the HTML > are fudged even more than at present: in particular {} > inserted like above will be invisible, so the "effect" which is applied > to something had better be visible to the reader (because now the > grouping symbols will be gone). > > At present, if MathJaX isn't available the code is "more or less" raw > as you wrote it in your editor. With improved fudging for more > betterer display (sic) this distance between what you wrote and the > HTML will be much larger. > > -- > john skaller > skaller@... > http://felix-lang.org > > > > -- > You received this message because you are subscribed to the Google Groups > "Felix Language" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to felix-language+unsubscribe@... > To post to this group, send email to felix-language@... > Visit this group at http://groups.google.com/group/felix-language. > For more options, visit https://groups.google.com/d/optout. > -- Ryan [ERROR]: Your autotools build scripts are 200 lines longer than your program. Something’s wrong. http://kirbyfan64.github.io/   [Felix-language] Maths DSSL From: john skaller - 2015-04-24 07:57:59 The below will give cute display in Felix code, if displayed by flx_web. The "font" operators are just ordinary functions .. so you have to actually define them if you want stuff to work! //////////////////////////////////////////////////////////////////////////////// // ordinary and mathmode var x = X; // ordinary var x = \(X$$; // mathmode // these are all TeX commands so x ^ \font y // typesets correctly: note \sin is an OP symbol // so x ^ \sin y fails, and x ^ \Gamma y works // since \Gamma is an ORD, but the y is not raised. // font operators var x = $$\mathrm X$$; // mathrm var x = $$\mathit X$$; // mathit var x = $$\mathfrak X$$; // mathfrak var x = $$\mathbb X$$; // mathbb var x = $$\mathbf X$$; // mathbf var x = $$\mathcal X$$; // mathcal var x = $$\mathscr X$$; // mathscr var x = $$\mathsf X$$; // mathscr var x = $$\mathtt X$$; // mathtt // modifiers var x = $$\acute X$$; // acute var x = $$\check X$$; // check var x = $$x ^ \binom {\mathtt x} {\mathtt y}$$; /////////////////////////////////////////////////////////////// However there are a couple of "gotchas". The first is that in TeX in math mode a variable is a single character. But that's NOT how Felix would interpret f ABC is we happen to write $$\mathcal ABC \} then the \mathcal function will apply to variable ABC, but it will only display caligraphic symbol A. This is similar to: xyz which maths thinks is three variables but Felix thinks is one. The typeset version is math italic, and it reads OK in this case but really, it should be typeset in teletype font and boxed into a single atom: \mathtt {xyz} To make this work *properly* will have to fiddle with flx_web's flx2html plugin so that the actual characters put in the HTML are fudged even more than at present: in particular {} inserted like above will be invisible, so the "effect" which is applied to something had better be visible to the reader (because now the grouping symbols will be gone). At present, if MathJaX isn't available the code is "more or less" raw as you wrote it in your editor. With improved fudging for more betterer display (sic) this distance between what you wrote and the HTML will be much larger. -- john skaller skaller@... http://felix-lang.org   [Felix-language] negated comparisons From: john skaller - 2015-04-03 18:19:07 Next commit, you can write: x not < y and \( x \not\less y$$ Both not and \not mean the same, however not is printed "not" as written, whereas \not IN MATH MODE ONLY will cause the following TeX operator to be negated by strikeout. We need this because whilst TeX defines \nsubseteq it does not define \nsubset. You have to write \not\subset. Note \not\subseteq will work as well, however, the special form \nsubseteq is provided to make the struck out symbol more beautiful. Do not confuse \not with \lnot. The latter is boolean negation operator, it applies to expressions, and it has looks like logic not symbol, this has a different precedence than "not" applied to an expression. Do not write \not expr, it will neither work, nor typeset correctly. use \not to cancel comparison operators. -- john skaller skaller@... http://felix-lang.org 
 [Felix-language] Sets From: john skaller - 2015-03-31 13:34:55 here is some sample code using sets // find all the numbers < 10 whose squares are the sum of two primes begin var primes = (2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97 ) ; var squares = (1,4,9,16,25,36,49,64,81,100); var primepairs = {x,y : int * int | x \in primes and y \in primes}; //var sumissquare = {i,j: int^2 | i + j \in squares }; fun sum (i:int, j:int) => i + j; var sumissquare = invimg (sum, squares); var square_sum_of_primes = sumissquare \cap primepairs; for var i in 1 upto 100 do for var j in i upto 100 do if (i,j) \in square_sum_of_primes do println$(i+j).str + "="+i.str+"+"+j.str; done done done end Now, the thing to note here is that the kind of sets we have here are just fancy predicates. We can form the conjunction of two predicates like this: fun (x:int) => P x and Q x so what's the big deal with sets? Well, you don't need the "fun" binder to compose them { x:int | P x } \cap { y:int | Q y } In fact I'm going to implement this: P and Q as well :) -- john skaller skaller@... http://felix-lang.org   Re: [Felix-language] Pretty printer From: john skaller - 2015-03-30 13:50:11 On 31/03/2015, at 12:36 AM, john skaller wrote: > > flx --felix=build.fpc src/tools/flx_pretty.flx --style > > Prints the CSS required for the colourisation, in  [Felix-language] Pretty printer From: john skaller - 2015-03-30 13:38:23 For the purpose of embedding Felix code in HTML documents, I have made a new tool: src/toolsflx_pretty.flx flx --felix=build.fpc src/tools/flx_pretty.flx --style Prints the CSS required for the colourisation, in  Re: [Felix-language] [felix] fix patterns From: john skaller - 2015-03-30 11:02:11 On 30/03/2015, at 7:18 PM, Martin DeMello wrote: >> >> This won't work as you might expect because in that pattern NIL is a variable. >> Easy to miss. You have to write >> >> | A (_, #NIL) => .. >> >> to tell the parser the NIL is a type constructor. > > Would it be hard to make this an actual warning, viz > > warning: variable NIL has same name as constructor. did you mean #NIL? I don't know, it could be quite hard. It would mean at least doing a lookup on EVERY variable name used. The problem is that the "desugaring" of pattern matching is done long before it is possible to do any lookup. So by the time the compiler comes to bind the code, it has no idea it's dealing with a pattern match variable. Pattern matches are basically macros. You can, in fact, invent your own. It basically goes: if (!_match_ctor_CTOR (arg)) goto next_case; var arg1, arg2 = _ctor_arg_CTOR (arg); // do handler goto endmatch; next_case: .... See src/lib/std/datatype/ralist.flx, a purely functional random access list, with O(log N) consing and indexed lookup. Since this type is "abstract" in some sense, there is no builtin way to pattern match on it (you can pattern match on the implementation details though). But we can fix that! CHECK FOR A MATCH: fun _match_ctor_Cons[T] (x:ralist[T]) =>not ( ralist_empty x); fun _match_ctor_Empty[T] (x:ralist[T]) => ralist_empty x; IF WE GOT A MATCH, get the head and tail: fun _ctor_arg_Cons[T] (x:ralist[T]) : T * ralist[T] = and now we can write: match some_ralist with | Empty => ... | Cons (head, tail) => ... and it will work by calling the above functions in an "if then else" chain. Anyhow the point is, by the time we have to bind this code (i.,e. do lookup) it's very hard to know which variables are pattern variables. It's even hard to know if the variable "got used". -- john skaller skaller@... http://felix-lang.org   Re: [Felix-language] [felix] fix patterns From: john skaller - 2015-03-30 08:03:12 On 30/03/2015, at 1:24 PM, Ryan wrote: > find . -name \*.flx -o -name \*.fdoc -exec sed -i 's/\?([A-Za-z][A-Za-z0-9_]*)/\1/' {} \; > > Does it all in-place, though. And only allows glob matches on filenames ... enuf for this case though. BTW: WARNING. When converting code to the new format BEWARE: union X = | NIL | A of X*X; match x with | A (_, NIL) => ... .. This won't work as you might expect because in that pattern NIL is a variable. Easy to miss. You have to write | A (_, #NIL) => .. to tell the parser the NIL is a type constructor. -- john skaller skaller@... http://felix-lang.org   Re: [Felix-language] [felix] fix patterns From: Ryan - 2015-03-30 02:24:56 Attachments: Message as HTML find . -name \*.flx -o -name \*.fdoc -exec sed -i 's/\?([A-Za-z][A-Za-z0-9_]*)/\1/' {} \; Does it all in-place, though. john skaller wrote: >Using a nice tool, flx_batch_replace: > >/usr/local/lib/felix/felix-latest/host/bin/flx_batch_replace -v src >'.*\.(flx|fdoc)' 'fixup/src/${0}' '\?([A-Za-z][A-Za-z0-9_]*)' '\1' >cp -r fixup/src/* src > >Be interested how to do that with standard unix tools. > >I do note the inconsistent replacement notation ${group} for files, >but \group for strings. Internally these search and replace operations >are in fact similar. I put the${group} in because its so hard to type >\1 >inside a string and get the quoting right. OTOH in bash ${1} is the >first >command line argument so that needs to be quoted right too. > > >-- >john skaller >skaller@... >http://felix-lang.org > > > >-- >You received this message because you are subscribed to the Google >Groups "Felix Language" group. >To unsubscribe from this group and stop receiving emails from it, send >an email to felix-language+unsubscribe@... >To post to this group, send email to felix-language@... >Visit this group at http://groups.google.com/group/felix-language. >For more options, visit https://groups.google.com/d/optout. -- Sent from my Android phone with K-9 Mail. Please excuse my brevity. Check out my website: http://kirbyfan64.github.io/  [Felix-language] fix patterns From: john skaller - 2015-03-30 02:15:29 Using a nice tool, flx_batch_replace: /usr/local/lib/felix/felix-latest/host/bin/flx_batch_replace -v src '.*\.(flx|fdoc)' 'fixup/src/${0}' '\?([A-Za-z][A-Za-z0-9_]*)' '\1' cp -r fixup/src/* src Be interested how to do that with standard unix tools. I do note the inconsistent replacement notation ${group} for files, but \group for strings. Internally these search and replace operations are in fact similar. I put the${group} in because its so hard to type \1 inside a string and get the quoting right. OTOH in bash \${1} is the first command line argument so that needs to be quoted right too. -- john skaller skaller@... http://felix-lang.org 
 Re: [Felix-language] review of brackets From: john skaller - 2015-03-29 18:55:00 On 30/03/2015, at 5:42 AM, john skaller wrote: > > I am looking at some more short forms, such as > > if(x)stmt; > while(x)stmt; You can of course do this now: for(i=0; i<10; ++i;) stmt; Note the ";" after the ++i. -- john skaller skaller@... http://felix-lang.org 
 [Felix-language] review of brackets From: john skaller - 2015-03-29 18:43:06 Apart from in structs, unions, and function/procedure definitions, here is a possibly incomplete catalogue: { expr } --> function returning expr { stmt; stmt; expr } -> function returning expr { stmt; stmt; return expr; } -> function returning expr { stmt; stmt; } --> procedure { pattern : type | expr } --> set form ( expr ) --> expr ( expr, expr ) --> tuple (x=expr, y=expr) -> record struct {x = expr; y=expr; } -> record (deprecated) ( stmt; stmt; expr ) --> expr // means #{ stmt; stmt; expr } () --> unit tuple ( var expr ) --> expr (eagerly evaluated, same as (let x = expr in x)) I am looking at some more short forms, such as if(x)stmt; while(x)stmt; like C. It's not clear these will work, since they're ambiguous. An alternative (from COBOL): if x perform stmt; while x perform stmt; Note these are already allowed: if x call expr; if x goto label; if x return; cond ?? stmt; I also kind of like: 0..99 meaning a subrange of int, inclusive, and ascending order. Hece for i in 0..99 do ... but then, that's from Pascal, my training language (actually I learned Fortran first, and then Compass Assembler ..) Yep, I used Pascal for years, then C++, when it got multiple inheritance. And I learned C after that :) [I don't count learning BCPL .. :] -- john skaller skaller@... http://felix-lang.org 
1 message has been excluded from this view by a project administrator.

Showing results of 5884

1 2 3 .. 236 > >> (Page 1 of 236)