Skip to content

Instantly share code, notes, and snippets.

View MaisaMilena's full-sized avatar
🖖

Maisa MaisaMilena

🖖
View GitHub Profile

Beta-Reduction: Sempre que você tem uma expressão na forma ({var}BODY ARG), você:

  1. Remove o {var} e o ARG
  2. Substitui todas as ocorrencias de var por ARG dentro de BODY

CHURCH {Cons Nil}(Cons 1 (Cons 2 (Cons 3 Nil)))
SCOTT {Cons Nil}(Cons 1 {Cons Nil}(Cons 2 {Cons Nil}(Cons 3 {Cons Nil}Nil)))

@MaisaMilena
MaisaMilena / can-atk-target.fmc
Last active June 4, 2019 23:04
Playing with pattern match in FormalityCore
def WHITE : 0
def BLACK : 1
def BOARD : 2
// Flips a value to "true" (1) or "false" (0)
def not: {b}
if |b == 1| then: 0 else: 1
// ======= Game elements =======
def Air:
  1. dup, only works on boxed elements
  2. To be able to duplicate x in getCategory, we need a boxed number as a parameter
  3. We are passing a boxed number to getCategory, unboxing it with dup and we should box it again before return (read more about Stratification Condition). As we should box any return, the best place to put the # if before if.
def isTeenager: {x}
  |x < 18|

def isAdult: {x}
  |x < 60|

Formality-Core Tutorial

This tutorial aims to teach how to effectively develop Formality-Core code, assuming experience in functional programming languages, in special Haskell. Formality-Core is a minimal language based on elementary affine logic, making it compatible with optimal reductions. It can be seen as the GHC Core to the upcoming Formality language. Its minimalism, the lack of a type system, and its unusual boxed duplication system make it a very bare-bones language that isn't easy to work with directly, demanding that the programmer learns some delicate techniques to be productive.

1. Core features

Before proceeding, you should have Formality-Core installed, and be familiar with its core features and syntax. If you're not yet, please read the entire Language section of the wiki.

2. Algebraic Datatypes

name = fm
file_extensions [] = fm;
################################################################
## Styles
################################################################
styles [] {

Creating a Textmate

I highly recommend using Iro when creating a new language syntax highlight. It allows a simple interface for defining rules and generates files for Textmate (plist), Atom, Ace, Sublime3.

References for Textmate:

Regex and scope naming

import Base@0
// Etapa 1: vê o tipo do "e" (no caso, `0 == 1`)
// Etapa 2: troca "x" no template pela esquerda do "e" (no caso, fica "P(0)")
// Etapa 3: verifica se o "p" tem o tipo "P(0)"
// Etapa 4: se sim, ele troca "x" no template pela direita do "e" (no caso, fica "P(1)")
// Etapa 5: muda o tipo do "p" pra "P(1)"
exemplo : {e : 0 == 1, p : P(0)} -> P(1)
p :: rewrite x in P(x) with e
import Nat@0
import Base
fold : {N : Ind2, ~A : Type, ~B : Type, id : !(A -> B), op : !(B -> B -> B)} -> ! {arr : Array(A, $ind2_depth(N))} -> B
dup op = op
dup id = id
let moti = {n} Array(A, $ind2_depth(n)) -> B
let step = {~n, a, b, arr}
get [x, y] = arr
op(a(x), b(y))
// ## Kaelin
//
// A simple, blockhain-enabled MOBA implemented in Formality-Core.
//
// Kaelin aims to capture some of the spirit of a MOBA, inluding map awareness,
// micro and macro strategies, resource control, team-fights, skillshots and so
// on, while aiming blockchain-compatible by being very lightweight (the entire
// game state has only 8192 bits) and based on ~20 second turns. This allows it
// to run on state-channels and use Ethereum for conflict resolution.
//
- Criar um contador pra fazer várias ações dentro da habilidade. Ex: clico 4x o botão e acontece algo.
- Testar a criação de um elemento que fica muito tempo no jogo
- Um clone repetir ação do personagem original
- Adicionar efeitos de fear
- Dentro de um input ter um contador pra: acumular energia, fazer um efeito extra (no primeiro clique faz X coisas no segundo outra)
- trava aleatoriamente 3 direçoes do jogador inimigo
1: cria um caminho que jogadores inimigos não podem passar.
2: cria uma marca no chão onde inverte os comandos dos jogadores inimigos fazendo andar pros lados errados.
3: buffa os aliados, deixando mais rapidos