Skip to content

Instantly share code, notes, and snippets.

with import <nixpkgs> { };
let
latest =
import (fetchTarball https://github.com/nixos/nixpkgs-channels/archive/129f8d7e999b1a1f0fceaecadca30211e34d85a6.tar.gz) {};
in
latest.haskellPackages.callPackage
./hpython.nix
{
inherit (import ./papa.nix latest.haskellPackages);
tasty-hedgehog = import ../tasty-hedgehog { pkgs = latest; };
{
packageoverrides = super: let self = super.pkgs; in
{
haskellPackages = super.haskellPackages.override // {
overrides = self: super: {
tasty-hedgehog = self.callPackage /home/isaac/data61/tasty-hedgehog {};
hedgehog = self.callPackage /home/isaac/.config/nixpkgs/hedgehog_0_5.nix {};
};
};
};
class HasIdentifier s a | s -> a where
identifier :: Traversal' s (Identifier a)
instance HasIdentifier (Identifier a) a where
identifier f = f
instance HasIdentifier (Atom a) a where
identifier f (AtomIdentifier a ann) = AtomIdentifier <$> f a <*> pure ann
identifier _ a = pure a
data Context = Regular | Async
data Expr :: Context -> * where
AwaitExpr :: Expr a -> Expr 'Async -- "await" <expr>
IfThenElse:: Expr a -> Expr a -> Expr a -> Expr a -- "if" <expr> "then" <expr> "else" <expr>
...
data Statement :: Context -> * where
ExprStatement :: Expr a -> Statement a
...
@LightAndLight
LightAndLight / wat.py
Last active September 19, 2021 23:01
Python `wat`s
#########
# What happens when you run this?
print(1 + 0001)
# Does this code run? If not- why? If so- what is the value of `result`?
class Foo:
foo = 0
data Context = Foo | Bar
data Thing :: Context -> * where
ThingFoo :: Int -> Thing 'Foo
ThingBar :: Bool -> Thing 'Bar
parseThingFoo :: CharParsing m => m (Thing 'Foo)
parseThingBar :: CharParsing m => m (Thing 'Bar)
-- This pattern seems like it would be unwieldy for more type variables or data-kind constructors
[32 of 32] Compiling Language.Python.Parser.IR.Checker ( src/Language/Python/Parser/IR/Checker.hs, dist/build/Language/Python/Parser/IR/Checker.o )
/nix/store/ysa06zk7hz9k4f9l03681vfnnbscp5l5-stdenv/setup: line 883: 10486 Segmentation fault ./Setup build
builder for ‘/nix/store/jkla2x6cwfgd5ldpx7zjlyyzm279x74q-hpython-0.0.1.0.drv’ failed with exit code 139
@LightAndLight
LightAndLight / hpython-ideas.txt
Created September 10, 2017 22:17
Things to use hpython for:
- Checked exceptions
- Linting
- Optimisation
- wat detection
@LightAndLight
LightAndLight / NoDigit.hs
Created September 12, 2017 23:26
Template Haskell for programmer UX
module NoDigit (NoDigit, _NoDigit, mkNoDigit, nodigit) where
newtype NoDigit = NoDigit { _getNoDigit :: String }
-- Succeeds if string does not contain a digit
mkNoDigit :: String -> Maybe NoDigit
mkNoDigit s
| any isDigit s = Nothing
| otherwise = Just $ NoDigit s
data Dict : Constraint -> Type where
data Name : Type -> Type where
data (=>) : Constraint -> Type -> Type where
data Expr : Type -> Type where
Var : Name a -> Expr a
Abs : (Name a -> Expr b) -> Expr (a -> b)
App : Expr (a -> b) -> Expr a -> Expr b
DictAbs : (Dict d -> Expr a) -> Expr (d => a)
DictApp : Expr (d => a) -> Dict d -> Expr a