diff --git a/src/posts/0010-Haskell-Now/project/.envrc b/src/posts/0010-Haskell-Now/project/.envrc new file mode 100644 index 0000000..1d953f4 --- /dev/null +++ b/src/posts/0010-Haskell-Now/project/.envrc @@ -0,0 +1 @@ +use nix diff --git a/src/posts/0010-Haskell-Now/project/.gitignore b/src/posts/0010-Haskell-Now/project/.gitignore new file mode 100644 index 0000000..6d7e2df --- /dev/null +++ b/src/posts/0010-Haskell-Now/project/.gitignore @@ -0,0 +1,2 @@ +dist-newstyle/ +result diff --git a/src/posts/0010-Haskell-Now/project/CHANGELOG.md b/src/posts/0010-Haskell-Now/project/CHANGELOG.md new file mode 100644 index 0000000..dead6d1 --- /dev/null +++ b/src/posts/0010-Haskell-Now/project/CHANGELOG.md @@ -0,0 +1,5 @@ +# Revision history for project + +## 0.1.0.0 -- YYYY-mm-dd + +* First version. Released on an unsuspecting world. diff --git a/src/posts/0010-Haskell-Now/project/LICENSE b/src/posts/0010-Haskell-Now/project/LICENSE new file mode 100644 index 0000000..1343de7 --- /dev/null +++ b/src/posts/0010-Haskell-Now/project/LICENSE @@ -0,0 +1,30 @@ +Copyright (c) 2019, Yann Esposito (Yogsototh) + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + + * Neither the name of Yann Esposito (Yogsototh) nor the names of other + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/src/posts/0010-Haskell-Now/project/Setup.hs b/src/posts/0010-Haskell-Now/project/Setup.hs new file mode 100644 index 0000000..9a994af --- /dev/null +++ b/src/posts/0010-Haskell-Now/project/Setup.hs @@ -0,0 +1,2 @@ +import Distribution.Simple +main = defaultMain diff --git a/src/posts/0010-Haskell-Now/project/app/Main.hs b/src/posts/0010-Haskell-Now/project/app/Main.hs new file mode 100644 index 0000000..60d904e --- /dev/null +++ b/src/posts/0010-Haskell-Now/project/app/Main.hs @@ -0,0 +1,8 @@ +module Main where + +import qualified MyLib (someFunc) + +main :: IO () +main = do + putStrLn "Hello, Haskell!" + MyLib.someFunc diff --git a/src/posts/0010-Haskell-Now/project/cabal.project.local b/src/posts/0010-Haskell-Now/project/cabal.project.local new file mode 100644 index 0000000..e69de29 diff --git a/src/posts/0010-Haskell-Now/project/default.nix b/src/posts/0010-Haskell-Now/project/default.nix new file mode 100644 index 0000000..d890b2c --- /dev/null +++ b/src/posts/0010-Haskell-Now/project/default.nix @@ -0,0 +1,32 @@ +{ nixpkgs ? import ./nixpkgs.nix +, compiler ? "default" +, doBenchmark ? false }: +let + inherit (nixpkgs) pkgs; + name = "project"; + haskellPackages = pkgs.haskellPackages; + variant = if doBenchmark + then pkgs.haskell.lib.doBenchmark + else pkgs.lib.id; + drv = haskellPackages.callCabal2nix name ./. {}; +in +{ + my_project = drv; + shell = haskellPackages.shellFor { + # generate hoogle doc + withHoogle = true; + packages = p: [drv]; + # packages dependencies (by default haskellPackages) + buildInputs = with haskellPackages; + [ hlint + ghcid + cabal-install + cabal2nix + hindent + ]; + # nice prompt for the nix-shell + shellHook = '' + export PS1="\n[${name}:\033[1;32m\]\W\[\033[0m\]]> " + ''; + }; +} diff --git a/src/posts/0010-Haskell-Now/project/nixpkgs.nix b/src/posts/0010-Haskell-Now/project/nixpkgs.nix new file mode 100644 index 0000000..aae2b1d --- /dev/null +++ b/src/posts/0010-Haskell-Now/project/nixpkgs.nix @@ -0,0 +1 @@ +import (fetchTarball https://github.com/NixOS/nixpkgs/archive/19.09.tar.gz) {} diff --git a/src/posts/0010-Haskell-Now/project/project.cabal b/src/posts/0010-Haskell-Now/project/project.cabal new file mode 100644 index 0000000..7e93d85 --- /dev/null +++ b/src/posts/0010-Haskell-Now/project/project.cabal @@ -0,0 +1,105 @@ +cabal-version: 2.4 + +-- Initial package description 'project.cabal' generated by 'cabal init'. +-- For further documentation, see http://haskell.org/cabal/users-guide/ + +-- The name of the package. +name: project + +-- The package version. See the Haskell package versioning policy (PVP) +-- for standards guiding when and how versions should be incremented. +-- https://pvp.haskell.org +-- PVP summary: +-+------- breaking API changes +-- | | +----- non-breaking API additions +-- | | | +--- code changes with no API change +version: 0.1.0.0 + +-- 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: + +-- The license under which the package is released. +license: BSD-3-Clause + +-- The file containing the license text. +license-file: LICENSE + +-- The package author(s). +author: Yann Esposito (Yogsototh) + +-- An email address to which users can send suggestions, bug reports, and +-- patches. +maintainer: yann.esposito@gmail.com + +-- A copyright notice. +-- copyright: + +-- category: + +-- Extra files to be distributed with the package, such as examples or a +-- README. +extra-source-files: CHANGELOG.md + + +library + -- Modules exported by the library. + exposed-modules: MyLib + + -- Modules included in this library but not exported. + -- other-modules: + + -- LANGUAGE extensions used by modules in this package. + other-extensions: NoImplicitPrelude + + -- Other library packages from which modules are imported. + build-depends: base ^>=4.12.0.0, + protolude + + -- Directories containing source files. + hs-source-dirs: src + + -- Base language which the package is written in. + default-language: Haskell2010 + + +executable project + -- .hs or .lhs file containing the Main module. + main-is: Main.hs + + -- Modules included in this executable, other than Main. + -- other-modules: + + -- LANGUAGE extensions used by modules in this package. + other-extensions: NoImplicitPrelude + + -- Other library packages from which modules are imported. + build-depends: base ^>=4.12.0.0, project + + -- Directories containing source files. + hs-source-dirs: app + + -- Base language which the package is written in. + default-language: Haskell2010 + + +test-suite project-test + -- Base language which the package is written in. + default-language: Haskell2010 + + -- The interface type and version of the test suite. + type: exitcode-stdio-1.0 + + -- The directory where the test specifications are found. + hs-source-dirs: test + + -- The entrypoint to the test suite. + main-is: MyLibTest.hs + + -- Test dependencies. + build-depends: base ^>=4.12.0.0 + diff --git a/src/posts/0010-Haskell-Now/project/release.nix b/src/posts/0010-Haskell-Now/project/release.nix new file mode 100644 index 0000000..8a1ee52 --- /dev/null +++ b/src/posts/0010-Haskell-Now/project/release.nix @@ -0,0 +1,4 @@ +let + def = import ./. {}; +in + { my_project = def.my_project; } diff --git a/src/posts/0010-Haskell-Now/project/shell.nix b/src/posts/0010-Haskell-Now/project/shell.nix new file mode 100644 index 0000000..0d9af5e --- /dev/null +++ b/src/posts/0010-Haskell-Now/project/shell.nix @@ -0,0 +1 @@ +(import ./. {}).shell diff --git a/src/posts/0010-Haskell-Now/project/src/MyLib.hs b/src/posts/0010-Haskell-Now/project/src/MyLib.hs new file mode 100644 index 0000000..7c4e29f --- /dev/null +++ b/src/posts/0010-Haskell-Now/project/src/MyLib.hs @@ -0,0 +1,7 @@ +{-# LANGUAGE NoImplicitPrelude #-} +module MyLib (someFunc) where + +import Protolude + +someFunc :: IO () +someFunc = putStrLn "someFunc" diff --git a/src/posts/0010-Haskell-Now/project/test/MyLibTest.hs b/src/posts/0010-Haskell-Now/project/test/MyLibTest.hs new file mode 100644 index 0000000..3e2059e --- /dev/null +++ b/src/posts/0010-Haskell-Now/project/test/MyLibTest.hs @@ -0,0 +1,4 @@ +module Main (main) where + +main :: IO () +main = putStrLn "Test suite not yet implemented."