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.
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 |
name = fm | |
file_extensions [] = fm; | |
################################################################ | |
## Styles | |
################################################################ | |
styles [] { |
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.
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.
dup
, only works on boxed elements- To be able to duplicate
x
ingetCategory
, we need aboxed number
as a parameter - We are passing a boxed number to
getCategory
, unboxing it withdup
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 beforeif
.
def isTeenager: {x}
|x < 18|
def isAdult: {x}
|x < 60|
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ê:
- Remove o {var} e o ARG
- 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)