1
Fork 0

Begin purescript rewrite

This commit is contained in:
prescientmoon 2024-02-22 08:19:48 +01:00
parent 6b8aa73fd2
commit 1be6c283d1
Signed by: prescientmoon
SSH key fingerprint: SHA256:UUF9JT2s8Xfyv76b8ZuVL7XrmimH4o49p4b+iexbVH4
12 changed files with 1385 additions and 16 deletions

View file

@ -1,5 +1,21 @@
{
"nodes": {
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1696426674,
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-utils": {
"locked": {
"lastModified": 1667395993,
@ -17,21 +33,68 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1695360818,
"narHash": "sha256-JlkN3R/SSoMTa+CasbxS1gq+GpGxXQlNZRUh9+LIy/0=",
"path": "/nix/store/09yvj6yyxspzfivv91bcxwrjxawpk1g2-source",
"rev": "e35dcc04a3853da485a396bdd332217d0ac9054f",
"type": "path"
"lastModified": 1708532945,
"narHash": "sha256-0KucnySzsz5Zgonjjm8cQMql+HGHa/OhB0fnKmGeD+0=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "ac4c5a60bebfb783f1106d126b9f39cc8e809e0e",
"type": "github"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
"owner": "nixos",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"purescript-overlay": {
"inputs": {
"flake-compat": "flake-compat",
"nixpkgs": [
"nixpkgs"
],
"slimlock": "slimlock"
},
"locked": {
"lastModified": 1708554905,
"narHash": "sha256-KXXSaeOgHOE/2YCZNfvw3efe1OZkPH8T6HqziPs2/Q8=",
"owner": "thomashoneyman",
"repo": "purescript-overlay",
"rev": "c7d9df1e916aa976125f4459d1bc2a480b75e43b",
"type": "github"
},
"original": {
"owner": "thomashoneyman",
"repo": "purescript-overlay",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
"nixpkgs": "nixpkgs",
"purescript-overlay": "purescript-overlay"
}
},
"slimlock": {
"inputs": {
"nixpkgs": [
"purescript-overlay",
"nixpkgs"
]
},
"locked": {
"lastModified": 1688756706,
"narHash": "sha256-xzkkMv3neJJJ89zo3o2ojp7nFeaZc2G0fYwNXNJRFlo=",
"owner": "thomashoneyman",
"repo": "slimlock",
"rev": "cf72723f59e2340d24881fd7bf61cb113b4c407c",
"type": "github"
},
"original": {
"owner": "thomashoneyman",
"repo": "slimlock",
"type": "github"
}
}
},

View file

@ -1,12 +1,19 @@
{
description = "Kayboard layout diagram generation";
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs = {
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
purescript-overlay = {
url = "github:thomashoneyman/purescript-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { nixpkgs, flake-utils, ... }:
outputs = { nixpkgs, flake-utils, ... }@inputs:
flake-utils.lib.eachDefaultSystem
(system:
let
pkgs = nixpkgs.legacyPackages.${system};
pkgs = nixpkgs.legacyPackages.${system}.extend inputs.purescript-overlay.overlays.default;
layout-lens = pkgs.callPackage ./layout-lens/default.nix { };
in
rec {

View file

@ -1 +1,11 @@
node_modules
bower_components/
node_modules/
.pulp-cache/
output/
output-es/
generated-docs/
.psc-package/
.psc*
.purs*
.psa*
.spago

View file

@ -1,9 +1,14 @@
{ pkgs ? import <nixpkgs> { } }:
{ pkgs ? import <nixpkgs>, ... }:
with pkgs;
mkShell {
buildInputs = with pkgs; with nodePackages_latest; [
typescript
buildInputs = [
nodePackages_latest.typescript
nodePackages_latest.ts-node
nodejs
ts-node
purs
spago-unstable
purs-tidy-bin.purs-tidy-0_10_0
purs-backend-es
purescript-language-server
];
}

1046
layout-lens/spago.lock Normal file

File diff suppressed because it is too large Load diff

21
layout-lens/spago.yaml Normal file
View file

@ -0,0 +1,21 @@
package:
name: layout-lens
dependencies:
- console
- effect
- prelude
- tuples
- maybe
- debugged
- colors
- unordered-collections
test:
main: Test.Main
dependencies: []
workspace:
package_set:
registry: 50.1.0
extra_packages:
debugged:
git: https://github.com/mateiadrielrafael/purescript-debugged.git
ref: 0d5a4149279129f10c8fe2a3ef280b9fde4d5116

View file

@ -0,0 +1,18 @@
module LayoutLens.Data.Config where
import LayoutLens.Prelude
data LayerVisualPosition = Center | TopLeft | TopRight | BottomLeft | BottomRight
derive instance Eq LayerVisualPosition
derive instance Generic LayerVisualPosition _
instance Debug LayerVisualPosition where
debug = genericDebug
instance Hashable LayerVisualPosition where
hash Center = 0
hash TopLeft = 1
hash TopRight = 2
hash BottomLeft = 3
hash BottomRight = 4

View file

@ -0,0 +1,131 @@
module LayoutLens.Data.RawConfig where
import LayoutLens.Prelude
import LayoutLens.Data.Config (LayerVisualPosition)
import LayoutLens.Data.Vec2 (Vec2, Radians)
data RawPhysicalActionStep
= Place
{ offset :: Vec2
, rotateBy :: Radians
, rotateAround :: Vec2
}
| Point
{ position :: Vec2
, size :: Vec2
, rotateBy :: Radians
, rotateAround :: Vec2
}
data RawPhysicalStep
= Block (Array RawPhysicalActionStep)
| PhysicalAction RawPhysicalActionStep
newtype RawPhysical = RawPhysical (Array RawPhysicalStep)
newtype RawKeySymbol = RawKeySymbol String
newtype RawChord = RawChord
{ from :: Array RawKeySymbol
, to :: Array RawKeySymbol
, fill :: Color
, fontSizeModifier :: Number
}
newtype RawLayer = RawLayer
{ name :: String
, textColor :: Maybe Color
, keys :: Array RawKeySymbol
}
data RawElement
= RawLayerGroup (HashMap LayerVisualPosition RawLayer)
| RawChordGroup (Array RawChord)
newtype RawSection = RawSection
{ columns :: Int
, elements :: Array RawElement
}
data RawActionDisplay
= DisplaySymbol RawKeySymbol
| DisplayLayerColor
data RawActionEffect
= LayerSwitch String
| StickyLayerSwitch String
newtype RawAction = RawAction
{ name :: String
, visualSymbol :: RawActionDisplay
, effect :: RawActionEffect
}
newtype RawConfig = RawConfig
{ physical :: RawPhysical
, actions :: Array RawAction
, sections :: RawSection
}
derive instance Eq RawPhysicalActionStep
derive instance Eq RawPhysicalStep
derive instance Eq RawPhysical
derive instance Eq RawKeySymbol
derive instance Eq RawChord
derive instance Eq RawLayer
derive instance Eq RawElement
derive instance Eq RawSection
derive instance Eq RawActionDisplay
derive instance Eq RawActionEffect
derive instance Eq RawAction
derive instance Eq RawConfig
derive instance Generic RawPhysicalActionStep _
derive instance Generic RawPhysicalStep _
derive instance Generic RawPhysical _
derive instance Generic RawKeySymbol _
derive instance Generic RawChord _
derive instance Generic RawLayer _
derive instance Generic RawElement _
derive instance Generic RawSection _
derive instance Generic RawActionDisplay _
derive instance Generic RawActionEffect _
derive instance Generic RawAction _
derive instance Generic RawConfig _
instance Debug RawPhysicalActionStep where
debug = genericDebug
instance Debug RawPhysicalStep where
debug = genericDebug
instance Debug RawPhysical where
debug = genericDebug
instance Debug RawKeySymbol where
debug = genericDebug
instance Debug RawChord where
debug = genericDebug
instance Debug RawLayer where
debug = genericDebug
instance Debug RawElement where
debug = genericDebug
instance Debug RawActionDisplay where
debug = genericDebug
instance Debug RawActionEffect where
debug = genericDebug
instance Debug RawAction where
debug = genericDebug
instance Debug RawSection where
debug = genericDebug
instance Debug RawConfig where
debug = genericDebug

View file

@ -0,0 +1,18 @@
module LayoutLens.Data.Vec2 where
import LayoutLens.Prelude
newtype Radians = Radians Number
data Vec2 = Vec2 Number Number
derive instance Eq Vec2
derive instance Eq Radians
derive instance Generic Vec2 _
derive instance Generic Radians _
instance Debug Vec2 where
debug = genericDebug
instance Debug Radians where
debug = genericDebug

10
layout-lens/src/Main.purs Normal file
View file

@ -0,0 +1,10 @@
module Main where
import Prelude
import Effect (Effect)
import Effect.Console (log)
main :: Effect Unit
main = do
log "🍝"

View file

@ -0,0 +1,29 @@
module LayoutLens.Prelude
( module Prelude
, module Data.Maybe
, module Data.Tuple
, module Data.Tuple.Nested
, module Effect
, module Effect.Class
, module Effect.Class.Console
, module Data.Generic.Rep
, module Data.Debug
, module Color
, module Data.HashMap
, module Data.HashSet
, module Data.Hashable
) where
import Prelude
import Data.Maybe (Maybe(..), fromJust, fromMaybe, fromMaybe', isJust, isNothing, maybe, maybe', optional)
import Data.Tuple (Tuple(..), curry, fst, snd, swap, uncurry)
import Data.Tuple.Nested (type (/\), T10, T11, T2, T3, T4, T5, T6, T7, T8, T9, Tuple1, Tuple10, Tuple2, Tuple3, Tuple4, Tuple5, Tuple6, Tuple7, Tuple8, Tuple9, curry1, curry10, curry2, curry3, curry4, curry5, curry6, curry7, curry8, curry9, get1, get10, get2, get3, get4, get5, get6, get7, get8, get9, over1, over10, over2, over3, over4, over5, over6, over7, over8, over9, tuple1, tuple10, tuple2, tuple3, tuple4, tuple5, tuple6, tuple7, tuple8, tuple9, uncurry1, uncurry10, uncurry2, uncurry3, uncurry4, uncurry5, uncurry6, uncurry7, uncurry8, uncurry9, (/\))
import Effect (Effect, forE, foreachE, untilE, whileE)
import Effect.Class (class MonadEffect, liftEffect)
import Effect.Class.Console (clear, error, errorShow, group, groupCollapsed, groupEnd, grouped, info, infoShow, log, logShow, time, timeEnd, timeLog, warn, warnShow)
import Data.Generic.Rep (class Generic, Argument(..), Constructor(..), NoArguments(..), NoConstructors, Product(..), Sum(..), from, repOf, to)
import Data.Debug (class Debug, class DebugRowList, class GenericDebug, class GenericDebugArgs, DiffOptions, PrettyPrintOptions, Repr, ReprDelta, array, assoc, boolean, char, collection, constructor, debug, debugRowList, defaultDiffOptions, defaultPrettyPrintOptions, diff, diffRepr, diffReprWith, genericDebug, genericDebug', genericDebugArgs, int, number, opaque, opaqueLiteral, opaque_, prettyPrint, prettyPrintDelta, prettyPrintDeltaWith, prettyPrintWith, record, string)
import Color (Color, ColorSpace(..), Interpolator, black, brightness, complementary, contrast, cssStringHSLA, cssStringRGBA, darken, desaturate, distance, fromHexString, fromInt, graytone, hsl, hsla, hsv, hsva, isLight, isReadable, lab, lch, lighten, luminance, mix, mixCubehelix, rgb, rgb', rgba, rgba', rotateHue, saturate, textColor, toGray, toHSLA, toHSVA, toHexString, toLCh, toLab, toRGBA, toRGBA', toXYZ, white, xyz)
import Data.HashMap (HashMap)
import Data.HashSet (HashSet)
import Data.Hashable (class Hashable)

View file

@ -0,0 +1,11 @@
module Test.Main where
import Prelude
import Effect (Effect)
import Effect.Class.Console (log)
main :: Effect Unit
main = do
log "🍕"
log "You should add some tests."