commit 531ec6e412d07ec9e5d699cb31b3dd636c6931cc Author: reijix Date: Thu Jun 1 09:24:50 2023 +0200 Initial commit from template diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..cc94b51 --- /dev/null +++ b/.envrc @@ -0,0 +1,2 @@ +nix_direnv_watch_file *.cabal +use flake diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..af4fe8b --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +flake.lock linguist-generated=true diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f2d40f4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,12 @@ +# cabal +dist +dist-* +cabal.project.local +cabal.project.local~ + +# nix +result +result-* + +# direnv +.direnv \ No newline at end of file diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..ebc5bcb --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,9 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=827846 + // for the documentation about the extensions.json format + "recommendations": [ + "haskell.haskell", + "mkhl.direnv", + "bbenoist.nix" + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..121ca83 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,8 @@ +{ + "editor.formatOnType": true, + "editor.formatOnSave": true, + "nixEnvSelector.nixFile": "${workspaceRoot}/shell.nix", + // "nixEnvSelector.args": "--pure" + "haskell.formattingProvider": "fourmolu", + "haskell.manageHLS": "PATH" +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..dcfb5e3 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,27 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [ + { + "label": "Ghcid", + "type": "shell", + // This is useful if you often see ghost ghcid left behind by VSCode reloads. + "command": "nix", + "args": [ + "develop", + "-c", + ",", + "run" + ], + "problemMatcher": [], + "group": { + "kind": "build", + "isDefault": true + }, + "runOptions": { + // "runOn": "folderOpen" + } + } + ] +} \ No newline at end of file diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..10de5af --- /dev/null +++ b/flake.lock @@ -0,0 +1,133 @@ +{ + "nodes": { + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1679737941, + "narHash": "sha256-srSD9CwsVPnUMsIZ7Kt/UegkKUEBcTyU1Rev7mO45S0=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "3502ee99d6dade045bdeaf7b0cd8ec703484c25c", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-root": { + "locked": { + "lastModified": 1671378805, + "narHash": "sha256-yqGxyzMN2GuppwG3dTWD1oiKxi+jGYP7D1qUSc5vKhI=", + "owner": "srid", + "repo": "flake-root", + "rev": "dc7ba6166e478804a9da6881aa48c45d300075cf", + "type": "github" + }, + "original": { + "owner": "srid", + "repo": "flake-root", + "type": "github" + } + }, + "haskell-flake": { + "locked": { + "lastModified": 1679690126, + "narHash": "sha256-u6pQejlTLC1QSKLMB/8Ch+2VvgILlxuZsBHAbDn0zHM=", + "owner": "srid", + "repo": "haskell-flake", + "rev": "d63943b612dbe30e2aba8aab0e60f1011c369973", + "type": "github" + }, + "original": { + "owner": "srid", + "repo": "haskell-flake", + "type": "github" + } + }, + "mission-control": { + "locked": { + "lastModified": 1679674077, + "narHash": "sha256-hGz63fsyRGthjE6LLqB08IHApcBvHhI87gWrFN/Uu5w=", + "owner": "Platonic-Systems", + "repo": "mission-control", + "rev": "d07854a616f559370b71c1c440d916ab6869f084", + "type": "github" + }, + "original": { + "owner": "Platonic-Systems", + "repo": "mission-control", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1679734080, + "narHash": "sha256-z846xfGLlon6t9lqUzlNtBOmsgQLQIZvR6Lt2dImk1M=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "dbf5322e93bcc6cfc52268367a8ad21c09d76fea", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "dir": "lib", + "lastModified": 1678375444, + "narHash": "sha256-XIgHfGvjFvZQ8hrkfocanCDxMefc/77rXeHvYdzBMc8=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "130fa0baaa2b93ec45523fdcde942f6844ee9f6e", + "type": "github" + }, + "original": { + "dir": "lib", + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-parts": "flake-parts", + "flake-root": "flake-root", + "haskell-flake": "haskell-flake", + "mission-control": "mission-control", + "nixpkgs": "nixpkgs", + "treefmt-nix": "treefmt-nix" + } + }, + "treefmt-nix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1679588014, + "narHash": "sha256-URkRSunu8HAp2vH2KgLogjAXckiufCDFrBs59g9uiLY=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "af75d6efe437858f9ca5535e622cfbedad1ba717", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..7e610a3 --- /dev/null +++ b/flake.nix @@ -0,0 +1,97 @@ +{ + description = "PCF implemented in haskell"; + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; + flake-parts.url = "github:hercules-ci/flake-parts"; + haskell-flake.url = "github:srid/haskell-flake"; + treefmt-nix.url = "github:numtide/treefmt-nix"; + treefmt-nix.inputs.nixpkgs.follows = "nixpkgs"; + flake-root.url = "github:srid/flake-root"; + mission-control.url = "github:Platonic-Systems/mission-control"; + }; + + outputs = inputs@{ self, nixpkgs, flake-parts, ... }: + flake-parts.lib.mkFlake { inherit inputs; } { + systems = nixpkgs.lib.systems.flakeExposed; + imports = [ + inputs.haskell-flake.flakeModule + inputs.treefmt-nix.flakeModule + inputs.flake-root.flakeModule + inputs.mission-control.flakeModule + ]; + perSystem = { self', system, lib, config, pkgs, ... }: { + # The "main" project. You can have multiple projects, but this template + # has only one. + haskellProjects.main = { + # packages.haskell-template.root = ./.; # Auto-discovered by haskell-flake + overrides = self: super: { }; + devShell = { + tools = hp: { + treefmt = config.treefmt.build.wrapper; + } // config.treefmt.build.programs; + hlsCheck.enable = true; + }; + }; + + # Auto formatters. This also adds a flake check to ensure that the + # source tree was auto formatted. + treefmt.config = { + inherit (config.flake-root) projectRootFile; + package = pkgs.treefmt; + flakeFormatter = false; # For https://github.com/numtide/treefmt-nix/issues/55 + + programs.ormolu.enable = true; + programs.nixpkgs-fmt.enable = true; + programs.cabal-fmt.enable = true; + programs.hlint.enable = true; + + # We use fourmolu + programs.ormolu.package = pkgs.haskellPackages.fourmolu; + settings.formatter.ormolu = { + options = [ + "--ghc-opt" + "-XImportQualifiedPost" + ]; + }; + }; + + # Dev shell scripts. + mission-control.scripts = { + docs = { + description = "Start Hoogle server for project dependencies"; + exec = '' + echo http://127.0.0.1:8888 + hoogle serve -p 8888 --local + ''; + category = "Dev Tools"; + }; + repl = { + description = "Start the cabal repl"; + exec = '' + cabal repl "$@" + ''; + category = "Dev Tools"; + }; + fmt = { + description = "Format the source tree"; + exec = config.treefmt.build.wrapper; + category = "Dev Tools"; + }; + run = { + description = "Run the project with ghcid auto-recompile"; + exec = '' + ghcid --warnings -T :main + ''; + category = "Primary"; + }; + }; + + # Default package. + packages.default = self'.packages.main-haskell-template; + + # Default shell. + devShells.default = + config.mission-control.installToDevShell self'.devShells.main; + }; + }; +} diff --git a/fourmolu.yaml b/fourmolu.yaml new file mode 100644 index 0000000..ef5582d --- /dev/null +++ b/fourmolu.yaml @@ -0,0 +1,8 @@ +indentation: 2 +comma-style: leading +record-brace-space: true +indent-wheres: true +diff-friendly-import-export: true +respectful: true +haddock-style: multi-line +newlines-between-decls: 1 \ No newline at end of file diff --git a/hie.yaml b/hie.yaml new file mode 100644 index 0000000..db1ac26 --- /dev/null +++ b/hie.yaml @@ -0,0 +1,4 @@ +cradle: + cabal: + - path: "src" + component: "exe:pcf" \ No newline at end of file diff --git a/pcf.cabal b/pcf.cabal new file mode 100644 index 0000000..d35d224 --- /dev/null +++ b/pcf.cabal @@ -0,0 +1,29 @@ +cabal-version: 2.4 +name: pcf +version: 0.1.0.0 +license: MIT +author: Leon Vatthauer +category: Web + +-- TODO: Before hackage release. +-- A short (one-line) description of the package. +-- synopsis: + +-- A longer description of the package. +-- description: + +-- A URL where users can report bugs. +-- bug-reports: + +extra-source-files: + LICENSE + README.md + +common shared + build-depends: base >=4.13.0.0 && <4.18.0.0.0 + hs-source-dirs: src + default-language: Haskell2010 + +executable pcf + import: shared + main-is: Main.hs diff --git a/src/Main.hs b/src/Main.hs new file mode 100644 index 0000000..4f50f14 --- /dev/null +++ b/src/Main.hs @@ -0,0 +1,10 @@ +module Main where + +{- | + Main entry point. + + The `, run` script will invoke this function. +-} +main :: IO () +main = do + print "Hello world"