Skip to content

Instantly share code, notes, and snippets.

👊
omae wa mou shindeiru

Austin Seipp thoughtpolice

👊
omae wa mou shindeiru
Block or report user

Report or block thoughtpolice

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View mux.hs
f = mux cond1 r1
$ mux cond2 r2
$ mux cond3 r3
...
$ mux condN rN
$ default
where
cond1 = ...
cond2 = ...
cond3 = ...
@thoughtpolice
thoughtpolice / q.hs
Last active Dec 20, 2017
quotientBy
View q.hs
{-# OPTIONS_GHC -Wall #-}
import Data.List (groupBy, sortBy)
-- | Construct the set of equivalence classes for a given list of items, given
-- an equivalence relation to partition the input set by. The partition of all
-- equivalence classes among the items in a set \(X\) is also known as the
-- __quotient set__ or __quotient space__ of \(X\), defined by an equivalence
-- relation \(R\), and written \(X/R\).
--
-- Technically the quotient /could/ be defined in terms of @'Eq'@, but here we
View Test.hs
module Test where
import Clash.Prelude
-- this just puts zeros in front of the bit vector
f :: KnownNat a => BitVector a -> BitVector (a + 1)
f bv = zeroExtend bv
-- this gets the length of a bit vector, as an SNat
g :: KnownNat a => BitVector a -> SNat a
g _ = SNat
@thoughtpolice
thoughtpolice / Assert.hs
Last active Jul 8, 2019
Formal verification of a Clash circuit, using Yosys/SymbiYosys.
View Assert.hs
{-# LANGUAGE GADTs #-}
{-# LANGUAGE ImplicitParams #-}
{-# LANGUAGE TypeFamilies #-}
module Assert
( assertProperty
, initialAssume
, getReset
) where
import Clash.Prelude
@thoughtpolice
thoughtpolice / TopGen.hs
Created Oct 14, 2017
Autogenerate a Clash TopEntity from an annotated function type
View TopGen.hs
{-# OPTIONS_GHC -Wall -Wno-orphans #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveLift #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE ViewPatterns #-}
@thoughtpolice
thoughtpolice / RegAlloc1.hs
Last active Apr 18, 2019
Simple register allocation, see "Essentials of Compilation" for more https://jeapostrophe.github.io/courses/2017/spring/406/notes/book.pdf
View RegAlloc1.hs
{-# OPTIONS_GHC -Wall #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PartialTypeSignatures #-}
module RegAlloc1
( -- * Types
Var
@thoughtpolice
thoughtpolice / discord.js
Last active Jun 16, 2017
Discord BuckleScript Cloud Functions OMG
View discord.js
// Generated by BUCKLESCRIPT VERSION 1.7.5, PLEASE EDIT WITH CARE
'use strict';
var Request_promise = require("request-promise");
var Config = require("../../config.json");
function main(ev) {
var match = ev.data.data;
if (match !== undefined) {
if (match !== "") {
View gist:804dd8e0026bb0fd864836bdd9caec73
aseipp@ubuntu:~/t$ ghc -O2 Naperian.hs -fforce-recomp +RTS -s
[1 of 1] Compiling Naperian ( Naperian.hs, Naperian.o )
2,109,198,400 bytes allocated in the heap
361,254,792 bytes copied during GC
62,051,712 bytes maximum residency (10 sample(s))
2,566,416 bytes maximum slop
140 MB total memory in use (0 MB lost due to fragmentation)
Tot time (elapsed) Avg pause Max pause
Gen 0 238 colls, 0 par 0.631s 0.631s 0.0027s 0.0210s
View LICENSE.txt
Copyright 2017 Austin Seipp
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
View change.diff
diff --git a/Z3/Category.hs b/Z3/Category.hs
index 816d8ca..7147aba 100644
--- a/Z3/Category.hs
+++ b/Z3/Category.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE CPP #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
@@ -25,6 +26,16 @@ import Control.Arrow (Kleisli(..), arr)
You can’t perform that action at this time.