This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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 {}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- | 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ pkgs }: | |
if pkgs.stdenv.isLinux then | |
pkgs.chromium | |
else | |
let | |
wrapped = pkgs.writeShellScriptBin "chromium" '' | |
${chromium-mac}/Chromium.app/Contents/MacOS/Chromium $@ | |
''; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- | This example shows using Halogen Store with Formless, but the form is the only | |
-- | component that interacts with the global state, not the parent. | |
module Main where | |
import Prelude | |
import Data.Newtype (class Newtype, unwrap) | |
import Data.Either (Either(..)) | |
import Data.Int as Int | |
import Data.Maybe (Maybe(..)) |
NewerOlder