Skip to content

Instantly share code, notes, and snippets.

View thomashoneyman's full-sized avatar

Thomas Honeyman thomashoneyman

View GitHub Profile
@thomashoneyman
thomashoneyman / log.md
Created August 11, 2024 13:55
Pursuit externs discussions

https://discord.com/channels/864614189094928394/872650895744176188/1174406612711125022


thomashoneyman — 11/13/2023 3:24 PM Does anyone know why docs.json files always leave the "reExports" key as an empty array, and it isn't until purs publish is called that we actually go through and associate those re-exports?

natefaubion — 11/13/2023 3:29 PM I'm not sure. It could be at one point re-exports were desugared really early or something.

; We have to have a namespace to define a keyset in the repl...
(begin-tx)
(module guards GOV
(defcap GOV () true)
(defun success () true)
(defconst GUARD_SUCCESS (create-user-guard (success))))
(define-namespace 'test guards.GUARD_SUCCESS guards.GUARD_SUCCESS)
(print "Defined namespace: test")
(commit-tx)
@thomashoneyman
thomashoneyman / guarded.pact
Last active January 8, 2024 17:14
guard by module
(begin-tx)
(env-data { "admin": [ "admin-key" ] })
(module guards GOV
(defcap GOV () true)
(defconst GUARD_SUCCESS (create-user-guard (success)))
(defun success () true))
(define-namespace "free" guards.GUARD_SUCCESS guards.GUARD_SUCCESS)
(namespace "free")
(define-keyset "free.admin-keyset" (read-keyset "admin"))
(env-data {})
conformLegacyManifest
:: forall r
. Manifest
-> CompilerIndex
-> DependencyIndex
-> ValidateDepsError
-> Run (COMMENT + REGISTRY + STORAGE + LOG + EXCEPT String + AFF + EFFECT + r) (Tuple Manifest (Map PackageName Version))
conformLegacyManifest (Manifest manifest) currentIndex legacyIndex problem = do
let
purs :: PackageName
@thomashoneyman
thomashoneyman / Solve2.purs
Created November 9, 2023 21:36
solve with compilers
-- | A 'DependencyIndex' enriched to include the compiler versions supported by
-- | each package version as a dependency.
newtype CompilerIndex = CompilerIndex DependencyIndex
-- | Associate the compiler versions supported by each package version by
-- | inserting them as a range in the version's dependencies.
associateCompilers :: Map PackageName Metadata -> DependencyIndex -> CompilerIndex
associateCompilers allMetadata index = CompilerIndex do
foldlWithIndex
( \package prevIndex versions -> do
@thomashoneyman
thomashoneyman / refs.pact
Created January 25, 2023 01:44
Mutual reference in Pact modules
(interface gov-iface
(defun is-allowed:bool (token:string))
(defun multiplier:integer ()))
(interface token-iface
(defun supply:integer ()))
(module gov GOV
(implements gov-iface)
(defcap GOV () true)
@thomashoneyman
thomashoneyman / Cache Comparison
Last active January 3, 2023 16:00
Cache Comparison
This gist compares two implementations of a typed cache for an effects system, one in Run and one in MTL. This is a tricky effect, because:
1. The cache is typed: the key type determines the value type.
2. The cache key is polymorphic: users can define their own key types outside the module.
3. The cache is extensible: users can define multiple independent caches, each with their own implementation (such as being in-memory only, or backed by a database only, or a combination).
Both implementations preserve these properties and demonstrate how a user could implement their own key type and choose an implementation for it in their chosen effect system.
@thomashoneyman
thomashoneyman / Cache.purs
Created November 26, 2022 15:51
Typed CACHE Effect
module Registry.Effect.Cache where
import Prelude
import Data.Argonaut.Core as Argonaut.Core
import Data.Argonaut.Parser as Argonaut.Parser
import Data.Codec.Argonaut (JsonCodec)
import Data.Codec.Argonaut as CA
import Data.Const (Const(..))
import Data.Either (hush)
@thomashoneyman
thomashoneyman / chromium.nix
Created May 3, 2022 02:54
chromium on mac
{ pkgs }:
if pkgs.stdenv.isLinux then
pkgs.chromium
else
let
wrapped = pkgs.writeShellScriptBin "chromium" ''
${chromium-mac}/Chromium.app/Contents/MacOS/Chromium $@
'';
@thomashoneyman
thomashoneyman / Main.purs
Last active December 3, 2021 03:20
Emit
module Main where
import Prelude
import Halogen.Subscription (Emitter)
import Run (Run)
import Run as Run
import Type.Proxy (Proxy(..))
import Type.Row (type (+))
import Unsafe.Coerce (unsafeCoerce)