Skip to content

Instantly share code, notes, and snippets.

@mightybyte
mightybyte / haskell-language-extensions.md
Last active August 31, 2023 07:50
A Taxonomy of Haskell Language Extensions

Haskell Language Extension Taxonomy

Caveat: It's just personal opinion, and was written to be a bit provocative and encourage discussion . It is also something that is constantly evolving. Some of the main criteria I used in constructing this taxonomy are age, how widely used it us, and how well understood it is by the average Haskell programmer. These things will change over time.

Aso, this is focused on appropriateness for use in commercial production code bases. If you are not thinking about commercial use with a team of multiple

@mightybyte
mightybyte / pact-web-share.pact
Created March 15, 2019 19:05
Pact shared with pact-web.
;;
;; Hi Doug, please find your favorite smart contract below.
;;
;; Best,
;; Robert
(define-keyset 'admin-keyset (read-keyset "admin-keyset"))
;; Define the module.
(module verificationDoug 'admin-keyset
@mightybyte
mightybyte / pact-web-share.pact
Last active March 15, 2019 19:17
Pact shared with pact-web.
;;---------------------------------
;; Doug demo testZZZ
;; Create a keyset named 'keyset' and add some key,
;; for loading this contract!
;;
;; Make sure the message is signed with this added key as well.
;;---------------------------------
(define-keyset 'module-keyset (read-keyset "keyset"))
@mightybyte
mightybyte / pact-web-share.pact
Created March 15, 2019 19:20
Pact shared with pact-web.
;; This is a test of the gist saving mechanism
;; accounts module, admin keyset, and table
; (load "examples/verified-accounts/accounts.repl")
(enforce-pact-version "2.4.1")
(define-keyset 'accounts-admin-keyset
(read-keyset "accounts-admin-keyset"))
@mightybyte
mightybyte / pact-web-share.pact
Created March 19, 2019 19:05
Pact shared with pact-web.
;;
;; A little example showing off the merits of formal
;; verification and why it pays off.
;;
;;---------------------------------
;;
;; Create an 'admin-keyset' and add some key, for loading this contract!
;;
;; Make sure the message is signed with this added key as well.
@mightybyte
mightybyte / verification.pact
Created April 15, 2019 17:32
Pact formal verification example
;;
;; A little example showing off the merits of formal
;; verification and why it pays off.
;;
;; Keysets cannot be created in code, thus we read them in
;; from the load message data.
(define-keyset 'admin-keyset (read-keyset "admin-keyset"))
;; Define the module.
@mightybyte
mightybyte / type-error.pact
Created June 3, 2019 21:08
Type error mentioned on Discord
; Simplified example of a token implementation.
; When I run `(typecheck "my-token")` I get the error:
; > Typecheck my-token: Unable to resolve all types
(module my-token GOVERNANCE
(defschema accounts-schema
balance:integer
guard:guard
)
@mightybyte
mightybyte / hello-fv.pact
Created June 5, 2019 21:45
Hello world with formal verification
;;
;; "Hello, world!" smart contract/module
;;
;; Define the module.
(module hello-world MODULE_ADMIN
"A smart contract to greet the world."
; no-op module admin for example purposes.
; in a real contract this could enforce a keyset, or
@mightybyte
mightybyte / default.nix
Created June 29, 2019 16:41
A default.nix template for nixifying Haskell projects
{ compiler ? "ghc844"
, rev ? "497e6f1705107a7d60e400e3b6dd6df5ca8bcdba"
, sha256 ? "1gwdxpx5ix3k6j5q3704xchw4cfzmmr2sd6gsqmsln9yrmjzg9p4"
, pkgs ?
import (builtins.fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/${rev}.tar.gz";
inherit sha256; }) {
config.allowBroken = false;
config.allowUnfree = true;
}
@mightybyte
mightybyte / hashing.pact
Created September 14, 2019 19:58
Playing around with hashing
(module hash MODULE_ADMIN
"A smart contract to greet the world."
(defcap MODULE_ADMIN () true)
(defun revcat (a b)
(+ b a)
)
(defun phash:string (str:string)
(let* ((h (hash str))