Skip to content

Instantly share code, notes, and snippets.

{ projectRoot ? projectArgs.src
, materializedRelative ? "nix/materialized"
, systems
, projectArgs ? null
, projectArgsBySystem ? _: projectArgs
, lib ? pkgs.lib
, pkgsBySystem ? system:
if system == pkgs.pkgsBuildBuild.system
then pkgs
else import pkgs.path {
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE QuantifiedConstraints #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE StandaloneKindSignatures #-}
{-# LANGUAGE UndecidableInstances #-}
module AnyMonad where
@shlevy
shlevy / Playground.hs
Created December 20, 2021 17:11
Plutus Playground Smart Contract
-- A game with two players. Player 1 thinks of a secret word
-- and uses its hash, and the game validator script, to lock
-- some funds (the prize) in a pay-to-script transaction output.
-- Player 2 guesses the word by attempting to spend the transaction
-- output. If the guess is correct, the validator script releases the funds.
-- If it isn't, the funds stay locked.
import Control.Monad (void)
import qualified Data.ByteString.Char8 as C
import Data.Map (Map)
import qualified Data.Map as Map
%default total
data DecreasingArg : List a -> Type where
Base : DecreasingArg []
Recurse : DecreasingArg xs -> ({y : List a} -> [] = y -> DecreasingArg y) -> DecreasingArg {a} (x :: xs)
toDecreasingArg : (l : List a) -> DecreasingArg l
toDecreasingArg [] = Base
toDecreasingArg (_ :: xs) =
Recurse (toDecreasingArg xs) g
/* Primitives for unforgeable values in Nix. As long as the make-unforgeable primitive isn't
* available to arbitrary expressions (e.g. it's defined in a let within your entry point
* and only made available through a more constrained interface), you can use this to build
* general functionality to enforcethat some value must have been created by some trusted
* component.
*
* This is stupidly hacky and relies on a number of questionable assumptions.
*/
rec {
make-unforgeable = x: { value = x; };
from __future__ import print_function
import sys
import tokenize
_is_declarative = True
with (getattr(tokenize, 'open', open))('setup.py') as setup_py:
_lines = []
for line in setup_py:
if _is_declarative and line.strip() not in ['import setuptools', 'from setuptools import setup', 'setup()', '']:
{ config, pkgs, ... }:
let subvol-mount = path: { name = path;
value = { fsType = "btrfs";
label = "root";
options = [ "defaults"
"subvol=${path}"
];
};
};
subvols = builtins.listToAttrs (map subvol-mount
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FlexibleInstances #-}
module Test where
foo :: forall f b . (forall a . Maybe (f a)) -> ((forall a . f a) -> b) -> b -> b
foo x yesCont noCont = case x @() of
Just _ -> yesCont v'
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeApplications #-}
module Test where
newtype Value a = Value a
class MaybeHasValue x where
maybeValue :: Maybe (Value x)
data Void
--- scripts/install-darwin-multi-user.sh 2018-03-16 18:22:40.297097664 -0400
+++ install-multi-user.sh 2018-03-29 15:50:21.041138715 -0400
@@ -23,7 +23,6 @@
readonly YELLOW='\033[38;33m'
readonly YELLOW_UL='\033[38;4;33m'
-readonly CORES=$(sysctl -n hw.ncpu)
readonly NIX_USER_COUNT="32"
readonly NIX_BUILD_GROUP_ID="30000"
readonly NIX_BUILD_GROUP_NAME="nixbld"