-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
638 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Revision history for indexed-containers | ||
|
||
## 0.1.0.0 -- 2020-02-18 | ||
|
||
* Initial release. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module Main where | ||
|
||
main :: IO () | ||
main = putStrLn "Hello, Haskell!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,7 @@ | ||
# indexed-containers | ||
# indexed-containers: simple, no-frills indexed lists. | ||
|
||
This library contains lists whose types are indexed by their lengths. The implementation is a simple | ||
wrapper around a regular list. | ||
|
||
If the lengths of your lists are known statically, using indexed lists improves type safety | ||
with no runtime overhead. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import Distribution.Simple | ||
main = defaultMain |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/usr/bin/env stack | ||
-- stack --resolver lts-15.0 script --package filepath --package directory --package extra | ||
-- To run: ./TestGen.hs | ||
|
||
module TestGen (main) where | ||
|
||
import Data.List.Extra (replace, stripPrefix, trim) | ||
import Data.Maybe (mapMaybe) | ||
import System.Directory | ||
import System.FilePath | ||
|
||
import Prelude hiding (mod) | ||
|
||
main :: IO () | ||
main = genTestsFor "Data.NList" | ||
|
||
genTestsFor :: String -> IO () | ||
genTestsFor mod = do | ||
let inputFile = "src" </> replace "." [pathSeparator] mod <.> "hs" | ||
outputFile = "test/hspec" </> (replace "." [pathSeparator] mod ++ "Spec.hs") | ||
src <- readFile inputFile | ||
createDirectoryIfMissing True (takeDirectory outputFile) | ||
let lns = fmap trim (lines src) | ||
tests = mapMaybe (stripPrefix "-- > ") lns | ||
writeFile outputFile . unlines $ header mod ++ fmap (indent 6) tests | ||
|
||
header :: String -> [String] | ||
header mod = | ||
[ "-- Generated code, do not modify by hand. Generate by running TestGen.hs." | ||
, "" | ||
, "{-# LANGUAGE DataKinds #-}" | ||
, "{-# LANGUAGE TypeApplications #-}" | ||
, "{-# LANGUAGE TypeFamilies #-}" | ||
, "{-# OPTIONS_GHC -w #-}" | ||
, "module " ++ mod ++ "Spec where" | ||
, "" | ||
, "import Test.Hspec" | ||
, "import Prelude hiding (concat, drop, head, init, last, length, replicate, reverse, splitAt, tail, take, unzip, zip, zipWith)" | ||
] ++ ["import " ++ mod] ++ | ||
[ "" | ||
, "infix 4 ===" | ||
, "(===) :: (HasCallStack, Show a, Eq a) => a -> a -> Expectation" | ||
, "(===) = shouldBe" | ||
, "" | ||
, "spec :: Spec" | ||
, "spec = do" | ||
, " describe \"Testing " ++ mod ++ "\" $ do" | ||
, " it \"\" $ do" | ||
] | ||
|
||
indent :: Int -> String -> String | ||
indent n = (replicate n ' ' ++) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ nixpkgs ? import <nixpkgs> {}, compiler ? "default", doBenchmark ? false }: | ||
|
||
let | ||
|
||
inherit (nixpkgs) pkgs; | ||
|
||
f = { mkDerivation, base, hspec, hspec-discover, stdenv }: | ||
mkDerivation { | ||
pname = "indexed-containers"; | ||
version = "0.1.0.0"; | ||
src = ./.; | ||
libraryHaskellDepends = [ base ]; | ||
testHaskellDepends = [ base hspec ]; | ||
testToolDepends = [ hspec-discover ]; | ||
homepage = "https://github.com/zliu41/indexed-containers#readme"; | ||
description = "Simple, no-frills indexed lists"; | ||
license = stdenv.lib.licenses.bsd3; | ||
}; | ||
|
||
haskellPackages = if compiler == "default" | ||
then pkgs.haskellPackages | ||
else pkgs.haskell.packages.${compiler}; | ||
|
||
variant = if doBenchmark then pkgs.haskell.lib.doBenchmark else pkgs.lib.id; | ||
|
||
drv = variant (haskellPackages.callPackage f {}); | ||
|
||
in | ||
|
||
if pkgs.lib.inNixShell then drv.env else drv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
cabal-version: 2.4 | ||
-- Initial package description 'indexed-containers.cabal' generated by | ||
-- 'cabal init'. For further documentation, see | ||
-- http://haskell.org/cabal/users-guide/ | ||
|
||
name: indexed-containers | ||
version: 0.1.0.0 | ||
synopsis: Simple, no-frills indexed lists. | ||
description: If the lengths of your lists are known statically, using indexed lists improves type safety with no runtime overhead. | ||
category: Data Structures | ||
homepage: https://github.com/zliu41/indexed-containers#readme | ||
bug-reports: https://github.com/zliu41/indexed-containers/issues | ||
author: Ziyang Liu <[email protected]> | ||
maintainer: Ziyang Liu <[email protected]> | ||
copyright: 2020 Ziyang Liu | ||
license: BSD-3-Clause | ||
license-file: LICENSE | ||
build-type: Simple | ||
extra-source-files: CHANGELOG.md, README.md | ||
tested-with: GHC==8.10.1, GHC==8.8.2, GHC==8.6.5, GHC==8.4.4 | ||
|
||
library | ||
exposed-modules: | ||
Data.NList | ||
hs-source-dirs: | ||
src | ||
ghc-options: -Wall | ||
build-depends: | ||
base >=4.7 && <5 | ||
default-language: Haskell2010 | ||
|
||
test-suite hspec | ||
type: exitcode-stdio-1.0 | ||
main-is: Main.hs | ||
other-modules: | ||
Data.NListSpec | ||
hs-source-dirs: | ||
test/hspec | ||
ghc-options: -Wall -threaded -rtsopts -with-rtsopts=-N | ||
build-depends: | ||
base >=4.7 && <5 | ||
, hspec >=2.4.8 && <2.8 | ||
, indexed-containers | ||
default-language: Haskell2010 | ||
build-tool-depends: hspec-discover:hspec-discover == 2.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ compiler ? "default" }: | ||
|
||
let | ||
pkgs = import <nixpkgs> { }; | ||
|
||
in | ||
{ indexed-containers = pkgs.haskellPackages.callPackage ./default.nix { inherit compiler; }; | ||
} |
Oops, something went wrong.