Skip to content

Instantly share code, notes, and snippets.

@JanBessai
JanBessai / gist:52e0155f731b4bcc5d525fc43367fcc4
Created August 22, 2019 15:06
Ugly Haskell Code to brute force through a SCIO reading
module Schrott where
import System.Process
import Text.Read
import Data.List
import Data.Maybe
commands :: [String]
commands =
map (\ (offset, endian, size) -> "cat /tmp/scan.txt | od -v -An --endian=" ++ endian ++ " -N" ++ show (1803 - offset) ++ " -t f" ++ size ++ " -j" ++ show offset)
module Main
%default total
foo: .{x: Nat} -> Nat
foo {x = Z} = 0
foo {x = S n} = (S n) * (foo {x = n})
main : IO ()
main = do
@JanBessai
JanBessai / BNegate.idr
Created July 2, 2019 08:25
Unchecked erasure annotation
bnegate: .{b : Bool} -> Bool
bnegate {b = True} = False
bnegate {b = False} = True
let
pkgs = import <nixpkgs>{};
in
{ stdenv ? pkgs.stdenv,
coq ? pkgs.coq_8_7,
gnumake ? pkgs.gnumake,
coqPackages ? pkgs.coqPackages_8_7 }:
let
inherit (coqPackages) autosubst;
in
@JanBessai
JanBessai / Yielder.scala
Created July 18, 2018 13:09
Yielder Test, generated Code - 2.13.0-M4
package <empty> {
object Yielder extends Object {
private[this] val holidays: Seq = _;
<stable> <accessor> def holidays(): Seq = Yielder.this.holidays;
final <static> <artifact> def $anonfun$holidays$2(name$1: String, place: String): String = {
scoverage.Invoker.invoked(7, "/tmp");
name$1.+(" has been to ").+(place)
};
final <static> <artifact> def $anonfun$holidays$1(name: String): Seq = {
scoverage.Invoker.invoked(8, "/tmp");
@JanBessai
JanBessai / Cantor.v
Created June 22, 2018 11:39
Enumeration of Inductive Datatypes
Require Import Coq.Arith.PeanoNat.
Require Import Coq.Arith.Compare_dec.
Require Import Coq.NArith.NArith.
Require Import Coq.NArith.Nnat.
Require Import Coq.NArith.Ndigits.
Require Import Coq.Vectors.Vector.
Require Import Coq.Classes.RelationClasses.
Require Import Coq.Arith.Compare_dec.
Require Import VectorQuantification.
Require Import Coq.Logic.Eqdep_dec.
@JanBessai
JanBessai / MemoTree.v
Created June 18, 2018 06:51
A side-by-side comparison of coinductive memoization with trees in Coq using CoInductive constructors and records
Require Import Coq.FSets.FMapPositive.
Require Import BinPos.
Set Primitive Projections.
Import EqNotations.
Section MemoTree.
Variable P: positive -> Type.
Variable f: forall n, P n.
@JanBessai
JanBessai / tag2.tpe <:< tag1.tpe (Bar <: Test)
Created May 13, 2017 17:56
tag1.tpe <:< tag2.tpe (Test <: Bar)
Exception in thread "main" scala.reflect.internal.Symbols$CyclicReference: illegal cyclic reference involving type T
at scala.reflect.internal.Symbols$Symbol.$anonfun$info$3(Symbols.scala:1509)
at scala.Function0.apply$mcV$sp(Function0.scala:34)
at scala.reflect.internal.Symbols$Symbol.lock(Symbols.scala:564)
at scala.reflect.internal.Symbols$Symbol.info(Symbols.scala:1507)
at scala.reflect.runtime.SynchronizedSymbols$SynchronizedSymbol$$anon$10.scala$reflect$runtime$SynchronizedSymbols$SynchronizedSymbol$$super$info(SynchronizedSymbols.scala:161)
at scala.reflect.runtime.SynchronizedSymbols$SynchronizedSymbol.$anonfun$info$1(SynchronizedSymbols.scala:129)
at scala.reflect.runtime.SynchronizedSymbols$SynchronizedSymbol.gilSynchronizedIfNotThreadsafe(SynchronizedSymbols.scala:125)
at scala.reflect.runtime.SynchronizedSymbols$SynchronizedSymbol.gilSynchronizedIfNotThreadsafe$(SynchronizedSymbols.scala:121)
at scala.reflect.runtime.SynchronizedSymbols$SynchronizedSymbol$$anon$10.gilSynchronizedIfNotThre
@JanBessai
JanBessai / RunTest.scala
Created May 13, 2017 17:33
Illegal cyclic reference/inheritance
import scala.reflect.runtime.universe._
class Bar
object RunTest extends App {
def testTypes(ty1: Type, ty2: Type): Unit = {
print(s"$ty1 <:< $ty2:")
try {
println(ty1 <:< ty2)
} catch {
case ex: Throwable => println(ex.getLocalizedMessage)
@JanBessai
JanBessai / FUp.cpp
Created February 9, 2016 20:52
The broken type system of C++11
class C {
private:
class D {};
public:
D foo() { return D(); }
};
void test(int x) {}
int main(int argc, char* argv[]) {