Skip to content

Commit 7a6b1a8

Browse files
author
ikrima
committed
[plt] notes on algebraic effects, lenses, and transducers
1 parent ef1cc0f commit 7a6b1a8

File tree

6 files changed

+325
-125
lines changed

6 files changed

+325
-125
lines changed

content/.pages

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,4 @@ nav:
55
- Math: math
66
- Graphics: graphics
77
- Houdini: houdini
8-
- Blog: blog
9-
- Blog: blog
8+
- Blog: blog

content/dev-notes/index.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# General Development Notes
2+
3+
Assorted notes on general development

content/dev-notes/prog-lang-theory/lenses-transducers.md

-89
This file was deleted.

content/dev-notes/prog-lang-theory/plt-interpreters.md

+30-33
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
* Describe language grammar as functions that take a free-bound "evaluator" function param instead of data types (a "final algebra"/"object algebra")
77
* ✔: Performance (no tag dispatch), allows for partial evaluation extension, and expression problem solution
88
* Explanations:
9-
* ELIU in C# https://higherlogics.blogspot.com/2008/09/mostly-tagless-interpreters-in-c.html
10-
* http://lambda-the-ultimate.org/node/4572
11-
* Papers:
12-
http://okmij.org/ftp/tagless-final/JFP.pdf
13-
http://www.cs.utexas.edu/~wcook/Drafts/2012/ecoop2012.pdf
9+
* ELIU in C# <https://higherlogics.blogspot.com/2008/09/mostly-tagless-interpreters-in-c.html>
10+
* <http://lambda-the-ultimate.org/node/4572>
11+
* Papers:
12+
<http://okmij.org/ftp/tagless-final/JFP.pdf>
13+
<http://www.cs.utexas.edu/~wcook/Drafts/2012/ecoop2012.pdf>
1414
* Sample implementations:
1515
* Simple C++ example
1616
````cpp
@@ -233,13 +233,13 @@
233233
}
234234
````
235235

236-
* Implementations in different languages: https://i.cs.hku.hk/~bruno/oa/
237-
* C# (2008)
238-
* Snippet: http://lambda-the-ultimate.org/node/4572#comment-72110
239-
* More complete: http://lambda-the-ultimate.org/node/2569#comment-43805
240-
* Expanded Version (2009): https://higherlogics.blogspot.com/2009/06/mobile-code-in-c-via-finally-tagless.html
241-
* Advanced Query language in C#: https://higherlogics.blogspot.com/2019/09/building-query-dsl-in-c.html
242-
* Snippet with Pratt parser (http://lambda-the-ultimate.org/node/4572#comment-72110)
236+
* Implementations in different languages: <https://i.cs.hku.hk/~bruno/oa/>
237+
* C# (2008)
238+
* Snippet: <http://lambda-the-ultimate.org/node/4572#comment-72110>
239+
* More complete: <http://lambda-the-ultimate.org/node/2569#comment-43805>
240+
* Expanded Version (2009): <https://higherlogics.blogspot.com/2009/06/mobile-code-in-c-via-finally-tagless.html>
241+
* Advanced Query language in C#: <https://higherlogics.blogspot.com/2019/09/building-query-dsl-in-c.html>
242+
* Snippet with Pratt parser (<http://lambda-the-ultimate.org/node/4572#comment-72110>)
243243
* Syntax to semantic constructors
244244

245245
````csharp
@@ -258,17 +258,17 @@
258258

259259
class MathGrammar<T> : Grammar<T>
260260
{
261-
public MathGrammar(IMathSemantics<T> math)
262-
{
263-
Infix("+", 10, math.Add); Infix("-", 10, math.Sub);
264-
Infix("*", 20, math.Mul); Infix("/", 20, math.Div);
265-
InfixR("^", 30, math.Pow); Postfix("!", 30, math.Fact);
266-
Prefix("-", 100, math.Neg); Prefix("+", 100, math.Pos);
261+
public MathGrammar(IMathSemantics<T> math)
262+
{
263+
Infix("+", 10, math.Add); Infix("-", 10, math.Sub);
264+
Infix("*", 20, math.Mul); Infix("/", 20, math.Div);
265+
InfixR("^", 30, math.Pow); Postfix("!", 30, math.Fact);
266+
Prefix("-", 100, math.Neg); Prefix("+", 100, math.Pos);
267267

268-
Group("(", ")", int.MaxValue);
269-
Match("(digit)", char.IsDigit, 0, math.Int);
270-
SkipWhile(char.IsWhiteSpace);
271-
}
268+
Group("(", ")", int.MaxValue);
269+
Match("(digit)", char.IsDigit, 0, math.Int);
270+
SkipWhile(char.IsWhiteSpace);
271+
}
272272
}
273273
````
274274

@@ -285,10 +285,7 @@
285285
public int Pow(int lhs, int rhs) { return (int)Math.Pow(lhs, rhs); }
286286
public int Neg(int arg) { return -arg; }
287287
public int Pos(int arg) { return arg; }
288-
public int Fact(int arg)
289-
{
290-
return arg == 0 || arg == 1 ? 1 : arg * Fact(arg - 1);
291-
}
288+
public int Fact(int arg) { return arg == 0 || arg == 1 ? 1 : arg * Fact(arg - 1); }
292289
}
293290
````
294291

@@ -297,15 +294,15 @@
297294
````csharp
298295
interface IEquationSemantics<T> : IMathSemantics<T>
299296
{
300-
T Var(string name);
301-
T Let(T x, T value, T body);
297+
T Var(string name);
298+
T Let(T x, T value, T body);
302299
}
303300
class EquationParser<T> : MathGrammar<T>
304301
{
305-
public EquationParser(IEquationSemantics<T> eq) : base(eq)
306-
{
307-
Match("(ident)", char.IsLetter, 0, eq.Var);
308-
TernaryPrefix("let", "=", "in", 90, eq.Let);
309-
}
302+
public EquationParser(IEquationSemantics<T> eq) : base(eq)
303+
{
304+
Match("(ident)", char.IsLetter, 0, eq.Var);
305+
TernaryPrefix("let", "=", "in", 90, eq.Let);
306+
}
310307
}
311308
````

0 commit comments

Comments
 (0)