Instantiate haskell template
This commit is contained in:
commit
5d02a9e424
9 changed files with 242 additions and 0 deletions
1
.envrc
Normal file
1
.envrc
Normal file
|
|
@ -0,0 +1 @@
|
|||
use flake
|
||||
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
.pre-commit-config.yaml
|
||||
result
|
||||
.direnv
|
||||
7
README.org
Normal file
7
README.org
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
#+TITLE: FilePack - A library and tool to bundle up files
|
||||
|
||||
* What is it?
|
||||
|
||||
#+begin_quote
|
||||
Throughout this chapter, you’ll work through building a library for a tool called filepack. The FilePack library that we build will allow users to create archives of files that can be saved to disk, stored in a database, or sent over the internet. The examples you build as you work through this chapter will only support the programmatic creation and extraction of archives, but you are encouraged to create a complete application around this library as an additional example.
|
||||
#+end_quote
|
||||
6
app/filepack.hs
Normal file
6
app/filepack.hs
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
module Main (main) where
|
||||
|
||||
import FilePack (greet)
|
||||
|
||||
main :: IO ()
|
||||
main = greet "Hello, World!"
|
||||
39
filepack.cabal
Normal file
39
filepack.cabal
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
cabal-version: 1.12
|
||||
|
||||
-- This file has been generated from package.yaml by hpack version 0.34.7.
|
||||
--
|
||||
-- see: https://github.com/sol/hpack
|
||||
|
||||
name: filepack
|
||||
version: 0.0.1.0
|
||||
author: Alexander Kobjolke
|
||||
maintainer: alex@jakalx.net
|
||||
copyright: Alexander Kobjolke 2022
|
||||
license: MIT
|
||||
build-type: Simple
|
||||
extra-source-files:
|
||||
README.org
|
||||
|
||||
library
|
||||
exposed-modules:
|
||||
FilePack
|
||||
other-modules:
|
||||
Paths_filepack
|
||||
hs-source-dirs:
|
||||
src
|
||||
ghc-options: -Wall
|
||||
build-depends:
|
||||
base >=4.13 && <5
|
||||
default-language: GHC2021
|
||||
|
||||
executable filepack
|
||||
main-is: filepack.hs
|
||||
other-modules:
|
||||
Paths_filepack
|
||||
hs-source-dirs:
|
||||
app
|
||||
ghc-options: -Wall
|
||||
build-depends:
|
||||
base >=4.13 && <5
|
||||
, filepack
|
||||
default-language: GHC2021
|
||||
79
flake.lock
generated
Normal file
79
flake.lock
generated
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
{
|
||||
"nodes": {
|
||||
"flake-utils": {
|
||||
"locked": {
|
||||
"lastModified": 1659877975,
|
||||
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils_2": {
|
||||
"locked": {
|
||||
"lastModified": 1644229661,
|
||||
"narHash": "sha256-1YdnJAsNy69bpcjuoKdOYQX0YxZBiCYZo4Twxerqv7k=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "3cecb5b042f7f209c56ffd8371b2711a290ec797",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1661626419,
|
||||
"narHash": "sha256-CjdPtdwH7I5Es4SjdCGuNfeulIyaM1LP0dXGWi4dyuQ=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "a5e05d62460ff0b7627559a8b55ab421041ebf0a",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"pre-commit-hooks": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils_2",
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1660830093,
|
||||
"narHash": "sha256-HUhx3a82C7bgp2REdGFeHJdhEAzMGCk3V8xIvfBqg1I=",
|
||||
"owner": "cachix",
|
||||
"repo": "pre-commit-hooks.nix",
|
||||
"rev": "8cb8ea5f1c7bc2984f460587fddd5f2e558f6eb8",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "cachix",
|
||||
"repo": "pre-commit-hooks.nix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"pre-commit-hooks": "pre-commit-hooks"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
||||
67
flake.nix
Normal file
67
flake.nix
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
{
|
||||
description = "Haskell Nix Template";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs";
|
||||
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
|
||||
pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
|
||||
pre-commit-hooks.inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, flake-utils, pre-commit-hooks }:
|
||||
flake-utils.lib.eachSystem [ "x86_64-linux" ] (system:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
|
||||
overlay = final: prev: {
|
||||
filepack = final.callCabal2nix "filepack" ./. { };
|
||||
};
|
||||
|
||||
haskellPackages = pkgs.haskell.packages.ghc924.extend overlay;
|
||||
in {
|
||||
packages.default = haskellPackages.filepack;
|
||||
|
||||
apps = {
|
||||
default = {
|
||||
type = "app";
|
||||
program = "${self.defaultPackage.${system}}/bin/hello";
|
||||
};
|
||||
};
|
||||
|
||||
checks = {
|
||||
pre-commit-check = pre-commit-hooks.lib.${system}.run {
|
||||
src = ./.;
|
||||
settings = { ormolu.defaultExtensions = [ "GHC2021" ]; };
|
||||
tools.fourmolu = haskellPackages.fourmolu;
|
||||
hooks = {
|
||||
nixfmt.enable = true;
|
||||
fourmolu.enable = true;
|
||||
hpack.enable = true;
|
||||
hlint.enable = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
devShells.default = haskellPackages.shellFor {
|
||||
inherit (self.checks.${system}.pre-commit-check) shellHook;
|
||||
|
||||
packages = p: [ p.filepack ];
|
||||
|
||||
withHoogle = true;
|
||||
|
||||
nativeBuildInputs = with pkgs; [
|
||||
haskellPackages.haskell-language-server
|
||||
haskellPackages.fourmolu
|
||||
haskellPackages.hspec-discover
|
||||
haskellPackages.doctest
|
||||
cabal-install
|
||||
ghcid
|
||||
nixfmt
|
||||
hpack
|
||||
hlint
|
||||
];
|
||||
};
|
||||
});
|
||||
}
|
||||
29
package.yaml
Normal file
29
package.yaml
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
name: filepack
|
||||
version: 0.0.1.0
|
||||
license: MIT
|
||||
author: "Alexander Kobjolke"
|
||||
maintainer: "alex@jakalx.net"
|
||||
copyright: "Alexander Kobjolke 2022"
|
||||
|
||||
extra-source-files:
|
||||
- README.org
|
||||
|
||||
dependencies:
|
||||
- base >= 4.13 && < 5
|
||||
|
||||
ghc-options:
|
||||
- -Wall
|
||||
|
||||
library:
|
||||
source-dirs: src
|
||||
verbatim:
|
||||
default-language: GHC2021
|
||||
|
||||
executables:
|
||||
filepack:
|
||||
source-dirs: app
|
||||
main: filepack.hs
|
||||
dependencies:
|
||||
- filepack
|
||||
verbatim:
|
||||
default-language: GHC2021
|
||||
11
src/FilePack.hs
Normal file
11
src/FilePack.hs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
module FilePack (
|
||||
greet,
|
||||
) where
|
||||
|
||||
import Control.Monad.IO.Class (
|
||||
MonadIO,
|
||||
liftIO,
|
||||
)
|
||||
|
||||
greet :: MonadIO m => String -> m ()
|
||||
greet = liftIO <$> putStrLn
|
||||
Loading…
Add table
Add a link
Reference in a new issue