From 3ca280558da6e786cf9847a923b2bd0b138f007b Mon Sep 17 00:00:00 2001 From: dneaves Date: Fri, 29 Mar 2024 19:37:53 -0400 Subject: [PATCH] Lots of Bits --- README.md | 4 ++- TODO.md | 8 +++++ app/Cli.hs | 14 ++++----- app/Instances.hs | 2 +- datatypetool.cabal | 74 +++++++++++++++++++++++--------------------- docs/developing.md | 10 +++++- justfile | 21 +++++++++++++ nix/dependencies.nix | 19 +++++++----- nix/pkgs.nix | 2 +- shell.nix | 9 +++--- 10 files changed, 103 insertions(+), 60 deletions(-) create mode 100644 TODO.md create mode 100644 justfile diff --git a/README.md b/README.md index 3a9dcc0..41ae0d8 100644 --- a/README.md +++ b/README.md @@ -1 +1,3 @@ -Describe datatypes in one or more ".type" file, then create appropriate datatypes for (eventually) any language. \ No newline at end of file +Describe datatypes in one or more ".type" file, then create appropriate datatypes for (eventually) any language. + +There's stuff in `docs/` until I write this out completely. \ No newline at end of file diff --git a/TODO.md b/TODO.md new file mode 100644 index 0000000..73628c5 --- /dev/null +++ b/TODO.md @@ -0,0 +1,8 @@ +- Finish Parser +- More languages +- Allow for more complex "enums" (ML-style types with internal data) +- More languages +- Serializer/deserializer generation +- More languages +- ??? +- More languages \ No newline at end of file diff --git a/app/Cli.hs b/app/Cli.hs index 8412b73..cf648d8 100644 --- a/app/Cli.hs +++ b/app/Cli.hs @@ -1,15 +1,15 @@ module Cli where +import Control.Applicative ((<|>)) +import Data.Function ((&)) +import Data.String (fromString) +import Options.Applicative ((<**>)) import qualified Options.Applicative as Opts -import Control.Applicative ((<|>)) -import Data.Function ((&)) -import Data.String (fromString) -import Options.Applicative ((<**>)) -import System.IO (FilePath) +import System.IO (FilePath) data Flags = Flags - { tomlPath :: FilePath + { tomlPath :: FilePath , verbosity :: Verbosity } deriving (Show, Eq, Ord) @@ -63,4 +63,4 @@ parseFlags = Flags 2 -> Debug _ -> Silly ) - ) \ No newline at end of file + ) diff --git a/app/Instances.hs b/app/Instances.hs index 6fae0ac..3f3a873 100644 --- a/app/Instances.hs +++ b/app/Instances.hs @@ -11,4 +11,4 @@ instance Ord (a -> b) where (>) _ _ = False (>=) _ _ = True min _ f2 = f2 - max f1 _ = f1 \ No newline at end of file + max f1 _ = f1 diff --git a/datatypetool.cabal b/datatypetool.cabal index 31bc1cd..8c2d71b 100644 --- a/datatypetool.cabal +++ b/datatypetool.cabal @@ -1,44 +1,46 @@ cabal-version: 3.6 name: datatypetool version: 0.1.0.0 -synopsis: Create Cross-Language Datatypes +synopsis: Create Cross-Language Datatypes description: - Describe datatypes in one or more ".type" file, then create appropriate datatypes for any language. --- bug-reports: --- license: -author: dneaves -maintainer: dneavesdev@pm.me + Describe datatypes in one or more ".type" file, then create appropriate datatypes for any language. --- copyright: --- category: +homepage: https://codeberg.org/dneaves/datatypetool +bug-reports: https://codeberg.org/dneaves/datatypetool/issues +license: AGPL-3.0-or-later +license-file: LICENSE extra-source-files: README.md +author: dneaves +maintainer: dneavesdev@pm.me executable datatypetool - main-is: Main.hs - other-modules: Cli - , Instances - , Config.Config - , Config.Extras - , Common.Lang.Elm - , Common.Lang.Gleam - , Common.Lang.Haskell - , Common.Lang.Python - , Parsing.File - , Parsing.Parser - , Parsing.Types - -- other-extensions: - build-depends: base - , aeson - , casing - , containers - , directory - , filepath - , megaparsec - , optparse-applicative - , path - , text - , tomland - , unordered-containers - hs-source-dirs: app - default-language: GHC2021 - default-extensions: LambdaCase + main-is: Main.hs + hs-source-dirs: app + default-language: GHC2021 + default-extensions: LambdaCase + other-modules: + Cli + Common.Lang.Elm + Common.Lang.Gleam + Common.Lang.Haskell + Common.Lang.Python + Config.Config + Config.Extras + Instances + Parsing.File + Parsing.Parser + Parsing.Types + + build-depends: + , aeson + , base + , casing + , containers + , directory + , filepath + , megaparsec + , optparse-applicative + , path + , text + , tomland + , unordered-containers diff --git a/docs/developing.md b/docs/developing.md index c220937..f92861a 100644 --- a/docs/developing.md +++ b/docs/developing.md @@ -1 +1,9 @@ -Hopefully everything necessary is in the nix-shell. If not, feel free to modify nix-stuff and make it work. \ No newline at end of file +Hopefully everything necessary is in the nix-shell. If not, feel free to modify nix-stuff and make it work. + +Common things are kept in the `justfile`, for ease of execution. Just is in the nix-shell, if you don't have it and have nix. + +Formatting of Haskell should be done with stylish-haskell, which is in the nix-shell if you don't have it. + +Formatting of the cabal file can be done with cabal-fmt, which is also in the nix-shell. This is the command I used: `cabal-fmt --inplace --indent 2 ./datatypetool.cabal` + +Formatting of Nix should be done with nixfmt, which is also in the nix-shell. This is the command I used: `nixfmt shell.nix nix/*` \ No newline at end of file diff --git a/justfile b/justfile new file mode 100644 index 0000000..0eb932c --- /dev/null +++ b/justfile @@ -0,0 +1,21 @@ +# Print available commands +@help: + just --justfile {{justfile()}} --list + +# Enter a Nix shell. +@shell: + nix-shell --pure --show-trace + +# Format all the things +@format: + stylish-haskell --inplace app/*.hs + cabal-fmt --inplace --indent 2 ./datatypetool.cabal + nixfmt shell.nix nix/* + +# Run the app with cabal +@run *args: + cabal run datatypetool -- {{args}} + +# Build, then run from the heavily-nested dist directory. This command breaks if the version changes, so change this command appropriately. +@build_and_run *args: + cabal build && ./dist-newstyle/build/x86_64-linux/ghc-9.8.2/datatypetool-0.1.0.0/x/datatypetool/build/datatypetool/datatypetool \ No newline at end of file diff --git a/nix/dependencies.nix b/nix/dependencies.nix index 000a6f4..f8cbd40 100644 --- a/nix/dependencies.nix +++ b/nix/dependencies.nix @@ -1,8 +1,11 @@ -{ pkgs }: -with pkgs; [ - nix - ghc98 - ghcid - cabal-install - stylish-haskell -] \ No newline at end of file +{ pkgs }: [ + pkgs.nix + pkgs.just + pkgs.toybox + pkgs.haskell.compiler.ghc98 + pkgs.ghcid + pkgs.cabal-install + pkgs.stylish-haskell + pkgs.haskellPackages.cabal-fmt + pkgs.nixfmt +] diff --git a/nix/pkgs.nix b/nix/pkgs.nix index 05793f2..a023ded 100644 --- a/nix/pkgs.nix +++ b/nix/pkgs.nix @@ -1 +1 @@ -import (fetchTarball channel:nixos-23.11) \ No newline at end of file +import (fetchTarball "channel:nixos-23.11") diff --git a/shell.nix b/shell.nix index b202514..ce89d20 100644 --- a/shell.nix +++ b/shell.nix @@ -1,8 +1,7 @@ let - pkgs = import nix/pkgs.nix {}; - deps = import nix/depencencies.nix { pkgs = pkgs; }; -in -pkgs.mkShell { + pkgs = import nix/pkgs.nix { }; + deps = import nix/dependencies.nix { pkgs = pkgs; }; +in pkgs.mkShell { name = "DTT shell"; packages = deps; -} \ No newline at end of file +} -- knotmirror 0.0.1