Skip to content

Instantly share code, notes, and snippets.

View MaisaMilena's full-sized avatar
🖖

Maisa MaisaMilena

🖖
View GitHub Profile
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

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

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

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

  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|
@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:

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)))

data Page
= Home String -- name
| MusicLibrary -- RecentlyPlayed, Discover
| SongPlaying String String -- music, artist
deriving Show
data MusicLibrary
= RecentlyPlayed -- [String] a localList
| Discover -- [String] a default list
def Car: [type] [color]
  [Car] [Horse] [Boat]
  (Car type color)

def Horse: [name]
  [Car] [Horse] [Boat]
  (Horse name)

def Boat:
def inverse: [t]
  (t [a] [b] [c] [d]
    [x] (x d c b a)
  )
  
def lastEle: [t]
  (t [a] [b] [c] [d] d)