Skip to content

Instantly share code, notes, and snippets.

View marcoonroad's full-sized avatar
🦋
the Future() has been CANCELLED and we .Restart() the DEAD Event[] from the past

Marco Aurélio da Silva marcoonroad

🦋
the Future() has been CANCELLED and we .Restart() the DEAD Event[] from the past
View GitHub Profile
local prototype = { }
local reason = { }
local metatable = { }
prototype.erase = '__please_erase_this_property_in_lookup_rules__'
prototype.protected = true
reason.protected = "Protected against delegated mutation [%s <- %s] by [protected = true]!"
reason.missing = "No such property/value for selector [%s]!"
reason.mutation = "Unable to perform property addition/mutation [%s <- %s]!"
@marcoonroad
marcoonroad / typechecker.pl
Last active August 11, 2016 06:42
Simple gradual typechecker with parametricity & inference written in Prolog.
% begin
% --- typing environment ---
% empty context always fails on queries,
% that is, there are unbound variables...
% find :: env * var * type -> prop
find([ type(X, T) | _ ], X, T).
find([ _ | E ], X, T) :-
package bug;
public class Main {
public static void main (String[ ] args) {
SuperClass a = new SuperClass ( ); // 1
SubClass b = new SubClass ( ); // 2 e 1.0
SuperClass c = new SuperClass ( ); // 3
SubClass d = new SubClass ( ); // 4 e 2.0
a.printSelf (c); // 3
@marcoonroad
marcoonroad / computation.hs
Last active February 3, 2016 07:17
Proving halting on computations attached on streams...
{-# LANGUAGE GADTs #-}
-- dependently typing structures that either does halt or doesn't --
class Natural a where
natural :: a -> a
natural = id
class Finite a where
finite :: a -> a
@marcoonroad
marcoonroad / junction.lua
Last active February 3, 2016 08:07
Attempt to encode Perl6 Junctions in Lua.
-- begin --
local export = { }
local kind = {
only = 1, all = 2, any = 3,
one = 4, none = 5,
}
local antikind = {
@marcoonroad
marcoonroad / rectypes.eff.ml
Last active September 26, 2020 16:29
Example of fold/unfold operations...
(* type-level recursion with fold/unfold *)
(* $ eff --effects -l rectypes.eff *)
(* there's an unique isomorphism between fold and unfold such that:
fold :: ...1 Unfix (...2 Fix (func) ...3) ...4 <=> ...1 Fix (func) ...4 :: unfold
where func = \fix -> ...2 fix ...3
so, conceptually:
@marcoonroad
marcoonroad / ext-type-sys.hs
Last active January 21, 2016 01:30
Extended type system...
{-# LANGUAGE GADTs, TypeFamilies, DataKinds, PolyKinds, KindSignatures, TypeOperators, RankNTypes, UndecidableInstances, AllowAmbiguousTypes, ExistentialQuantification, StandaloneDeriving, UnicodeSyntax, Arrows, MultiParamTypeClasses, ScopedTypeVariables #-}
data Kind = Self
| Kind `To` Kind
data SingleKind :: Kind -> * where
SingleSelf :: SingleKind Self
SingleTo :: SingleKind a -> SingleKind b -> SingleKind (a `To` b)
instance Show (SingleKind (k :: Kind)) where
{-# LANGUAGE DataKinds, KindSignatures, TypeOperators, GADTs, TypeFamilies, UndecidableInstances #-}
{- about invariants -}
data NatPos = One | Succ NatPos
data SingleNatPos :: NatPos -> * where
SingleOne :: SingleNatPos One
SingleSucc :: SingleNatPos natpos -> SingleNatPos (Succ natpos)
type family (m :: NatPos) |+| (n :: NatPos) :: NatPos where
-- para matrizes de rank 2 --
-- implementando-as como arvores --
data Tree a = Leaf | Node (Tree a) a (Tree a) deriving Eq
{-
| |
| A11 A12 A13 |
a = | |
@marcoonroad
marcoonroad / dependent.hs
Last active December 23, 2015 01:49
Attempt to encode dependently typed data structures in Haskell...
{-# LANGUAGE GADTs #-}
module Dependent (
Nat, O, S,
Z, Zero, SuccPos, SuccNeg,
Prop, V, X,
List, Nil, Cons,
Vector, Exist, Times,
Option, Some, None,
Coprod, OnLeft, OnRight,