Skip to content

Instantly share code, notes, and snippets.

View pema99's full-sized avatar

Pema Malling pema99

View GitHub Profile
float3 drawTopArea(float2 uv)
{
float3 color = FOREGROUND_COLOR;
float areaWidth = 1.0 - FRAME_MARGIN * 2;
float areaHeight = 0.35;
float boxWidth = areaWidth / 4.0;
for (uint i = 0; i < 4; i++)
{
This file has been truncated, but you can view the full file.
Module {
types: {
[1]: Type {
name: None,
inner: Scalar {
kind: Float,
width: 4,
},
},
[2]: Type {
This file has been truncated, but you can view the full file.
Module {
types: {
[1]: Type {
name: None,
inner: Scalar {
kind: Float,
width: 4,
},
},
[2]: Type {
// Input program
sum List 'a =
| Cons 'a * List 'a
| Nil unit
let iota = [n]
let inner = rec [inner] [acc]
if acc >= n then Nil ()
else Cons (acc, inner (acc + 1))
// Hindley-Milner type inference, 2022 Pema Malling
// Resources:
// - https://course.ccs.neu.edu/cs4410sp19/lec_type-inference_notes.html
// - http://dev.stephendiehl.com/fun/006_hindley_milner.html#inference-monad
// AST and types
type Lit =
| Int of int
| Bool of bool
@pema99
pema99 / bidir.fs
Last active January 28, 2022 11:57
// Bidirectional typechecking
type Type =
| Bool
| Fun of Type * Type
type Term =
| Var of string
| App of Term * Term
| Lam of string * Term
{-# LANGUAGE FlexibleInstances #-}
import Data.Word
import Data.Bits
import Data.Kind
import Graphics.Gloss.Raster.Field
import System.Environment
import System.Exit
import Data.Char
-- Random
Shader "Unlit/Double Layer Fresnel"
{
Properties {}
SubShader {
Tags {
"RenderType"="Transparent" "Queue"="Transparent" "DisableBatching"="True" "IgnoreProjector" = "True"
}
GrabPass {}
Pass {
Name "FORWARD"
Shader "Unlit/ScreenVertPos"
{
Properties
{
[IntRange] _Width ("Texture Size (POT)", Range(0, 13)) = 7
}
SubShader
{
Pass
{
@pema99
pema99 / LambdaCalc.fs
Created May 14, 2021 15:54
Lambda calculus parsing and reduction - Using my own parsing combinator lib
module LambdaCalc
open Combinator
open Common
open Util
// Lambda calc AST
type Expr =
| Id of string
| Abs of string * Expr