Skip to content

Instantly share code, notes, and snippets.

View pema99's full-sized avatar

Pema Malling pema99

View GitHub Profile
{-# 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
@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
// 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
// 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))
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 {
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++)
{
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++)
{
Shader "Unlit/AudioLinkUI"
{
Properties
{
}
SubShader
{
Pass
{
CGPROGRAM
Shader "Unlit/Shadowed"
{
SubShader
{
Pass
{
Tags { "LightMode"="Always" }
CGPROGRAM
#pragma vertex vert
#pragma fragment frag