git.iko.soy/typeable/cabal2nix
on master help sign in
language-nix: move this library into its separate repository and use it from Hackage
commit4e6aefa9bb6473832e609d3ac698df8c0de81b8e authorPeter Simons <simons@cryp.to> dateThu 10 Sep 2015, 16:58 (11 years ago) parent7b222ac
12 files changed+6−305
GNUmakefile+2−7 language-nix/LICENSE−30 language-nix/Setup.lhs−8 language-nix/language-nix.cabal−53 language-nix/package.yaml−34 language-nix/src/Language/Nix.hs−11 language-nix/src/Language/Nix/Binding.hs−34 language-nix/src/Language/Nix/Identifier.hs−64 language-nix/src/Language/Nix/Path.hs−51 language-nix/test/Main.hs−6 release.nix−4 stack.yaml+4−3
GNUmakefile+2−7
@@ -4,8 +4,7 @@ srcdir := $(CURDIR)
44
55.PHONY: all clean hlint
66
7−all:: language-nix/language-nix.cabal \
8− distribution-nixpkgs/distribution-nixpkgs.cabal \
7+all:: distribution-nixpkgs/distribution-nixpkgs.cabal \
98 cabal2nix/cabal2nix.cabal \
109 hackage2nix/hackage2nix.cabal
1110
@@ -24,10 +23,6 @@ hackage2nix/hackage2nix.cabal : hackage2nix/package.yaml
2423 cd $(dir $@) && hpack && cabal check
2524 touch $@
2625
27−language-nix/language-nix.cabal : language-nix/package.yaml
28− cd $(dir $@) && hpack && cabal check
29− touch $@
30−
3126clean::
32− @rm -f language-nix/language-nix.cabal distribution-nixpkgs/distribution-nixpkgs.cabal \
27+ @rm -f distribution-nixpkgs/distribution-nixpkgs.cabal
3328 @rm -f cabal2nix/cabal2nix.cabal hackage2nix/hackage2nix.cabal
language-nix/LICENSEdeleted−30
@@ -1,30 +0,0 @@
1−Redistribution and use in source and binary forms, with or
2−without modification, are permitted provided that the
3−following conditions are met:
4−
5− * Redistributions of source code must retain the above
6− copyright notice, this list of conditions and the
7− following disclaimer.
8−
9− * Redistributions in binary form must reproduce the above
10− copyright notice, this list of conditions and the
11− following disclaimer in the documentation and/or other
12− materials provided with the distribution.
13−
14− * The names of its contributors may not be used to endorse
15− or promote products derived from this software without
16− specific prior written permission.
17−
18−THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
19−CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
20−INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21−MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22−DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23−CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24−SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25−NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26−LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27−HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28−CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29−OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30−SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
language-nix/Setup.lhsdeleted−8
@@ -1,8 +0,0 @@
1−#!/usr/bin/env runhaskell
2−
3−> module Main (main) where
4−>
5−> import Distribution.Simple
6−>
7−> main :: IO ()
8−> main = defaultMain
language-nix/language-nix.cabaldeleted−53
@@ -1,53 +0,0 @@
1−-- This file has been generated from package.yaml by hpack version 0.7.0.
2−--
3−-- see: https://github.com/sol/hpack
4−
5−name: language-nix
6−version: 20150903
7−synopsis: Data types and useful functions to represent and manipulate the Nix language.
8−description: Data types and useful functions to represent and manipulate the Nix language.
9−category: Distribution, Language
10−homepage: https://github.com/nixos/cabal2nix#readme
11−bug-reports: https://github.com/nixos/cabal2nix/issues
12−maintainer: Peter Simons <simons@cryp.to>
13−license: BSD3
14−license-file: LICENSE
15−build-type: Simple
16−cabal-version: >= 1.10
17−
18−source-repository head
19− type: git
20− location: https://github.com/nixos/cabal2nix
21−
22−library
23− hs-source-dirs:
24− src
25− ghc-options: -Wall
26− build-depends:
27− base < 5
28− , deepseq
29− , lens
30− , pretty >= 1.1.2
31− , regex-posix
32− exposed-modules:
33− Language.Nix
34− Language.Nix.Binding
35− Language.Nix.Identifier
36− Language.Nix.Path
37− default-language: Haskell2010
38−
39−test-suite spec
40− type: exitcode-stdio-1.0
41− main-is: Main.hs
42− hs-source-dirs:
43− test
44− ghc-options: -Wall
45− build-depends:
46− base < 5
47− , deepseq
48− , lens
49− , pretty >= 1.1.2
50− , regex-posix
51− , doctest
52− , QuickCheck
53− default-language: Haskell2010
language-nix/package.yamldeleted−34
@@ -1,34 +0,0 @@
1−name: language-nix
2−version: "20150903"
3−synopsis: Data types and useful functions to represent and manipulate the Nix language.
4−description: Data types and useful functions to represent and manipulate the Nix language.
5−maintainer: Peter Simons <simons@cryp.to>
6−license: BSD3
7−github: nixos/cabal2nix
8−category: Distribution, Language
9−
10−ghc-options: -Wall
11−
12−dependencies:
13− - base < 5
14− - deepseq
15− - lens
16− - pretty >= 1.1.2
17− - regex-posix
18−
19−library:
20− source-dirs: src
21− exposed-modules:
22− - Language.Nix
23− - Language.Nix.Binding
24− - Language.Nix.Identifier
25− - Language.Nix.Path
26−
27−tests:
28− spec:
29− main: Main.hs
30− source-dirs:
31− - test
32− dependencies:
33− - doctest
34− - QuickCheck
language-nix/src/Language/Nix.hsdeleted−11
@@ -1,11 +0,0 @@
1−module Language.Nix
2− ( module Language.Nix.Identifier
3− , module Language.Nix.Path
4− , module Language.Nix.Binding
5− ) where
6−
7−import Language.Nix.Identifier
8−import Language.Nix.Path
9−import Language.Nix.Binding
10−
11−{-# ANN module "HLint: ignore Use import/export shortcut" #-}
language-nix/src/Language/Nix/Binding.hsdeleted−34
@@ -1,34 +0,0 @@
1−{-# LANGUAGE DeriveGeneric #-}
2−{-# LANGUAGE TemplateHaskell #-}
3−
4−module Language.Nix.Binding ( Binding, binding, localName, reference ) where
5−
6−import Control.DeepSeq
7−import Control.Lens
8−import Text.PrettyPrint.HughesPJClass
9−import Language.Nix.Identifier
10−import Language.Nix.Path
11−
12−-- | A 'Binding' represents an identifier that refers to some other 'Path'.
13−
14−declareLenses [d| data Binding = Bind { localName :: Identifier, reference :: Path }
15− deriving (Show, Eq, Ord)
16− |]
17−
18−binding :: Iso' Binding (Identifier,Path)
19−binding = iso (\(Bind l r) -> (l,r)) (uncurry Bind)
20−
21−instance NFData Binding where rnf (Bind l r) = l `deepseq` rnf r
22−
23−instance Pretty Binding where
24− pPrint b = case (init ps, last ps) of
25− ([], i') -> if i == i'
26− then text "inherit" <+> pPrint i' <> semi
27− else pPrint i <+> equals <+> pPrint p <> semi
28− (p', i') -> if i == i'
29− then text "inherit" <+> parens (pPrint (path # p')) <+> pPrint i' <> semi
30− else pPrint i <+> equals <+> pPrint p <> semi
31−
32− where
33− (i, p) = view binding b
34− ps = view path p
language-nix/src/Language/Nix/Identifier.hsdeleted−64
@@ -1,64 +0,0 @@
1−{-# LANGUAGE GeneralizedNewtypeDeriving #-}
2−{-# LANGUAGE TemplateHaskell #-}
3−
4−module Language.Nix.Identifier
5− (
6− -- | Identifiers in Nix are essentially strings. They can be constructed
7− -- (and viewed) with the 'ident' isomorphism. For the sake of convenience,
8− -- @Identifier@s are an instance of the 'IsString' class.
9− --
10− -- Reasonable people restrict themselves to identifiers of the form
11− -- @[a-zA-Z\_][a-zA-Z0-9\_\'\-]*@, because these don't need quoting. The
12− -- methods of the 'Pretty' class can be used to pretty-print an identifier
13− -- with proper quoting:
14− --
15− -- >>> pPrint (ident # "test")
16− -- test
17− -- >>> pPrint (ident # "foo.bar")
18− -- "foo.bar"
19− Identifier
20−
21− , -- | An isomorphism that allows conversion of 'Identifier' from/to the
22− -- standard 'String' type via 'review'.
23− --
24− -- prop> \str -> fromString str == ident # str
25− -- prop> \str -> set ident str undefined == ident # str
26− -- prop> \str -> view ident (review ident str) == str
27− ident
28−
29− , -- | Helper function to quote a given identifier string if necessary.
30− --
31− -- >>> putStrLn (quote "abc")
32− -- abc
33− -- >>> putStrLn (quote "abc.def")
34− -- "abc.def"
35− quote
36−
37− , -- | Checks whether a given string needs quoting when interpreted as an
38− -- 'Identifier'.
39− needsQuoting
40−
41− ) where
42−
43−import Control.DeepSeq
44−import Control.Lens
45−import Data.String
46−import Text.PrettyPrint.HughesPJClass
47−import Text.Regex.Posix
48−
49−declareLenses [d| newtype Identifier = Identifier { ident :: String }
50− deriving (Show, Eq, Ord, IsString)
51− |]
52−
53−instance Pretty Identifier where
54− pPrint i = text (i ^. ident . to quote)
55−
56−instance NFData Identifier where rnf (Identifier str) = rnf str
57−
58−needsQuoting :: String -> Bool
59−needsQuoting str = not (str =~ grammar)
60− where grammar :: String -- TODO: should be a compiled regular expression
61− grammar = "^[a-zA-Z\\_][a-zA-Z0-9\\_\\'\\-]*$"
62−
63−quote :: String -> String
64−quote s = if needsQuoting s then show s else s
language-nix/src/Language/Nix/Path.hsdeleted−51
@@ -1,51 +0,0 @@
1−{-# LANGUAGE TemplateHaskell #-}
2−
3−module Language.Nix.Path ( Path, path ) where
4−
5−import Control.DeepSeq
6−import Control.Lens
7−import Language.Nix.Identifier
8−import Text.PrettyPrint.HughesPJClass ( Pretty (..), char, hcat, punctuate )
9−
10−-- | Paths are non-empty lists of identifiers in Nix.
11−--
12−-- >>> path # [ident # "yo"]
13−-- Path [Identifier "yo"]
14−--
15−-- Any attempt to construct the empty path throws an 'error':
16−--
17−-- >>> path # []
18−-- Path *** Exception: Nix paths cannot be empty
19−--
20−-- 'Identifier' is an instance of 'IsString':
21−--
22−-- >>> :set -XOverloadedStrings
23−-- >>> pPrint $ path # ["yo","bar"]
24−-- yo.bar
25−--
26−-- Freaky quoted identifiers are fine except in the first segment:
27−--
28−-- >>> pPrint $ path # ["yo","b\"ar"]
29−-- yo."b\"ar"
30−-- >>> pPrint $ path # ["5ident"]
31−-- *** Exception: invalid Nix path: [Identifier "5ident"]
32−-- >>> pPrint $ path # ["5ident","foo","bar"]
33−-- *** Exception: invalid Nix path: [Identifier "5ident",Identifier "foo",Identifier "bar"]
34−
35−declareLenses [d| newtype Path = Path [Identifier]
36− deriving (Show, Eq, Ord)
37− |]
38−
39−instance NFData Path where rnf (Path p) = rnf p
40−
41−instance Pretty Path where
42− pPrint p = hcat $ punctuate (char '.') $ pPrint <$> p^.path
43−
44−path :: Iso' Path [Identifier]
45−path = iso (\(Path p) -> p) mkPath
46− where
47− mkPath :: [Identifier] -> Path
48− mkPath [] = error "Nix paths cannot be empty"
49− mkPath p@(s0:_)
50− | s0^.ident.to needsQuoting = error ("invalid Nix path: " ++ show p)
51− | otherwise = Path p
language-nix/test/Main.hsdeleted−6
@@ -1,6 +0,0 @@
1−module Main ( main ) where
2−
3−import Test.DocTest
4−
5−main :: IO ()
6−main = doctest [ "-isrc", "src" ]
release.nix−4
@@ -19,8 +19,6 @@ let
1919 });
2020 });
2121
22− language-nix = self.mkJob "language-nix";
23−
2422 distribution-nixpkgs = self.mkJob "distribution-nixpkgs";
2523
2624 cabal2nix = self.mkJob "cabal2nix";
@@ -34,8 +32,6 @@ let
3432in
3533{
3634
37− language-nix = mkJob "language-nix";
38−
3935 distribution-nixpkgs = mkJob "distribution-nixpkgs";
4036
4137 cabal2nix = mkJob "cabal2nix";
stack.yaml+4−3
@@ -1,8 +1,9 @@
11flags: {}
22packages:
33 - distribution-nixpkgs
4− - hackage2nix
54 - cabal2nix
6− - language-nix
7−extra-deps: []
5+ - hackage2nix
6+extra-deps:
7+ - nix-paths-1
8+ - language-nix-2
89resolver: lts-3.4