Skip to content

Instantly share code, notes, and snippets.

View tdietert's full-sized avatar

Thomas Dietert tdietert

View GitHub Profile
@tdietert
tdietert / SingleCycle.hs
Last active April 2, 2021 22:12
RISC-V Single Cycle Example
{-# LANGUAGE ViewPatterns #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeOperators #-}
module RISCV.SingleCycle (topEntity) where
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE MultiParamTypeClasses #-}
module Issue where
import Data.Typeable (Typeable)
import GHC.Generics (Generic)
import Unbound.Generics.LocallyNameless
-- | Variables in type-inferable terms
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE RankNTypes #-}
@tdietert
tdietert / FizzBuzzFCF.hs
Last active June 13, 2019 08:46
A translation of i-am-tom's type-level Fizz Buzz solution using (Xia Li-yao's) First-class type families
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
module FizzBuzz where
import Data.Kind (Type)
{ nixpkgs ? (import <nixpkgs> { config = {
packageOverrides = nixpkgs: rec {
flow = nixpkgs.flow.override {
installPhase = ''
cp frontend/classroom/node_modules/flow-bin/flow-linux64-v*/flow flow
chmod a+rw flow
patchelf \
--set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath ".:${nixpkgs.stdenv.cc.libc}/lib" \
flow
@tdietert
tdietert / loan.s
Created March 8, 2018 16:34
A simple loan implemented in FCL
global account issuer = 'CssRnWaxBhRRwhVL7ESgXkP7cgZ9vjFzV5nmr4jj3ZAh';
global account borrower = 'vVVq8PMEa9qGLL7LEmHUZKM78ze5JUgDPnjSE6FES63';
global assetFrac2 asset_ = 'HjdMu5LtF7BW6pGzvZGsV7ABUA4dkZFB2TmXQiymNpue';
global fixed2 interest= 0.05f;
global fixed2 principal;
global fixed2 payout;
global datetime maturityDate = "2018-03-08T10:12:00+00:00";
transition initial -> amountConfirmed;
data Query' f r where
AccountInfo' :: f A.Account -> Query' f A.Account
AccountByName' :: Text -> Query' f A.Account
QId' :: (ToJSON a, FromJSON a) => a -> Query' f a
QAnd' :: (ToJSON a, FromJSON a, ToJSON b, FromJSON b) => Query' f a -> Query' f b -> Query' f (a,b)
data QueryBox' where
Qbox :: (ToJSON r, FromJSON r) => Query' Keyed r -> QueryBox'
defineToJSONQuery ''Query' ''Keyed