state thing a
thing -> (thing, a)
b -> state thing a
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
/** | |
* Grammar for this parser | |
* | |
* S -> E | |
* E -> E '+' F | F | |
* F -> number | '(' E ')' | |
* | |
* Without immediate left recursion |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- | | |
-- | CPSC 521 Tutorial: 06.04.2020 | |
-- | | |
data TypeExpr v = Fun (TypeExpr v) (TypeExpr v) | |
| Var String | |
-- | Prod (LType v) (LType v) | |
-- | List (LType v) (LType v) | |
-- | Nat | |
-- | Unit | |
deriving (Show, Eq) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module TutAssignment where | |
{- | |
introducing basic data types for A3 | |
-} | |
-- First step: Notes have inductive definition of extended Lambda calculus | |
-- NOTE: Wrong, since it's typed | |
-- data BExp x |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from collections import Counter | |
from itertools import cycle | |
import string | |
import re | |
def get_text(): | |
with open('ulysses', 'r') as f: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%{ | |
#include ... // your includes | |
// ensure that string_builder is initialized within the scanner, otherwise reading string tokens will fail | |
static string_builder_t *sb = sb_init(); | |
%} | |
...the rest of your lexer stuff | |
%% |
-
a renaming
- state monad
Fun (f, _, expr) -- replace f with f_n where n is the variable(?) -- then, fun.num++; -- in expr, substitute all occurrences of f with f_n
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun somefun (a,b,c) = | |
let | |
fun add (x,y) = x + y | |
fun sub (y,z) = y - z | |
in | |
add (a,b) + sub (b,c) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module AST where | |
newtype Prog a b = Prog [Fun a b] | |
newtype Fun a b = Fun (a, [b], Exp a b) | |
data BoolExp a b = Lt (Exp a b) (Exp a b) | |
| Gt (Exp a b) (Exp a b) | |
| Eq (Exp a b) (Exp a b) | |
| AND (BoolExp a b) (BoolExp a b) | |
| OR (BoolExp a b) (BoolExp a b) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
stack --stack-yaml=install/shake.yaml --numeric-version | |
git submodule sync | |
git submodule update --init | |
stack --stack-yaml=stack-8.6.5.yaml install | |
******************************************************************************** | |
Building failed, Try running `stack clean` and restart the build | |
If this does not work, open an issue at | |
https://github.com/haskell/haskell-ide-engine | |
******************************************************************************** |