Skip to content

Instantly share code, notes, and snippets.

@Garciat
Garciat / Vect.hs
Last active November 12, 2018 12:17
{-# Language DataKinds #-}
{-# Language GADTs #-}
{-# Language KindSignatures #-}
{-# Language NoImplicitPrelude #-}
{-# Language StandaloneDeriving #-}
{-# Language TypeFamilies #-}
{-# OPTIONS_GHC -fwarn-incomplete-patterns #-}
module Vect where
module StackExpr where
data Instr
= Const Integer
| Add
| Sub
| Mul
| Neg
| Abs
| Sig
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
import java.util.function.*;
// Scott encoding of a Haskell's Maybe
interface Maybe<T> {
<R> R match(Supplier<R> nothing, Function<T, R> just);
@Garciat
Garciat / screenshot-1x1.png
Last active January 31, 2025 23:12
Wall Tiles // Simulates lighting on some tiles. The light math is completely off, but I tried.
screenshot-1x1.png
@Garciat
Garciat / videogram.html
Last active January 30, 2025 11:02
[hide] Videogram // Renders a video on a canvas, masked by random circles controlled by the mouse.
<!DOCTYPE html>
<html>
<head>
<title>Videogram</title>
<style>html,body{margin:0;height:100%;}</style>
</head>
<body>
<video src="https://dl11.webmfiles.org/big-buck-bunny_trailer.webm" style="display:none" autoplay loop></video>
<script defer>
import Data.Maybe (catMaybes)
import qualified Data.Set as Set
(|>) = flip ($)
between :: Ord a => a -> (a, a) -> Bool
between x (a, b) = a <= x && x <= b
class Clamp a where
clampedBy :: a -> (a, a) -> a
import Control.Monad (guard, when)
import Data.Array (Array, (!), (//), bounds, listArray)
import System.Console.ANSI
import System.IO (stdin, hReady)
import System.Random
import System.Timeout (timeout)
import Debug.Trace
data Pos
= Pos
package com.company;
import java.util.Optional;
import java.util.function.Function;
class Validity { }
class Valid extends Validity { }
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
import Control.Arrow
import Control.Monad
import Data.Array
import Data.Function
import Data.List
import Data.Maybe
import System.Environment