packages feed

config-value 0.6.3 → 0.6.3.1

raw patch · 7 files changed

+75/−38 lines, 7 filesdep ~basePVP ok

version bump matches the API change (PVP)

Dependency ranges changed: base

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -1,3 +1,7 @@+0.6.3.1+---+* Build on GHC 8.4.1+ 0.6.3 --- * Add `valuePlate`
config-value.cabal view
@@ -1,5 +1,5 @@ name:                config-value-version:             0.6.3+version:             0.6.3.1 synopsis:            Simple, layout-based value language similar to YAML or JSON license:             MIT license-file:        LICENSE@@ -33,7 +33,7 @@                        Config.Pretty,                        Config.Value -  build-depends:       base       >= 4.8     && < 4.11,+  build-depends:       base       >= 4.8     && < 4.12,                        array      >= 0.4     && < 0.6,                        pretty     >= 1.1.1.0 && < 1.2,                        text       >= 1.2.0.4 && < 1.3
config-value.vim view
@@ -10,10 +10,9 @@ syn match cvDelimiter  "*\|:\|\[\|\]\|,\|{\|}\|="  " Strings and constants -- copied from haskell.vim-syn match   cvStringGap         contained "\\[\n\ \t]*\\"-syn match   cvSpecialChar       contained "\\\([0-9]\+\|o[0-7]\+\|x[0-9a-fA-F]\+\|[\"\\'&\\abfnrtv]\|\^[@A-Z^_\[\\\]]\)"+syn match   cvSpecialChar       contained "\\\([\n\t ]*\\\|[0-9]\+\|o[0-7]\+\|x[0-9a-fA-F]\+\|[\"'&\\abfnrtv]\|\^[@A-Z^_\[\\\]]\)" syn match   cvSpecialChar       contained "\\\(NUL\|SOH\|STX\|ETX\|EOT\|ENQ\|ACK\|BEL\|BS\|HT\|LF\|VT\|FF\|CR\|SO\|SI\|DLE\|DC1\|DC2\|DC3\|DC4\|NAK\|SYN\|ETB\|CAN\|EM\|SUB\|ESC\|FS\|GS\|RS\|US\|SP\|DEL\)"-syn region  cvString            start=+"+  skip=+\\\\\|\\"+  end=+"\|\n+ contains=cvStringGap,cvSpecialChar+syn region  cvString            start=+"+  skip=+\\\\\|\\"+  end=+"\|\n+ contains=cvSpecialChar syn match   cvNumber            "-\=\([0-9]\+\|0[xX][0-9a-fA-F]\+\|0[oO][0-7]\+\|0[bB][0-1]\+\)\>" syn match   cvFloat             "-\=[0-9]\+\.[0-9]\+\([eE][-+]\=[0-9]\+\)\=\>" syn match   cvFloat             "-\=[0-9]\+[eE][-+]\=[0-9]\+\>"@@ -27,7 +26,6 @@ hi def link cvDelimiter                   Delimiter  hi def link cvSpecialChar                 SpecialChar-hi def link cvStringGap                   SpecialChar hi def link cvString                      String hi def link cvNumber                      Number hi def link cvFloat                       Float
src/Config/Lens.hs view
@@ -1,4 +1,12 @@--- | Optics for compatibility with the lens package+{-|+Module      : Config.Lens+Description : Lenses and traversals for manipulating 'Value' values.+Copyright   : (c) Eric Mertens, 2017+License     : ISC+Maintainer  : emertens@gmail.com++Lenses and traversals for compatibility with the lens package+-} module Config.Lens   ( key   , text@@ -14,17 +22,17 @@ import Config.Value import Data.Text --- | Apply a function to the subsections of the given value when--- that value is a @Sections@ and the subsection name matches the--- given section name +-- | Traversal for the subsections of the given 'Value' when+-- that value is a 'Sections' and the section name matches the+-- given name. key ::   Applicative f =>   Text {- ^ section name -} ->   (Value a -> f (Value a)) -> Value a -> f (Value a) key i = sections . traverse . section i --- | Apply a function to the 'Value' contained inside the given--- 'Value' when it is a section name matches the given name.+-- | Traversal for the 'Value' contained inside the given+-- 'Section' when its section name matches the given name. section ::   Applicative f =>   Text {- ^ section name -} ->@@ -32,39 +40,37 @@ section i f s@(Section a j v) | i == j    = Section a j <$> f v                               | otherwise = pure s --- | Apply a function to the ['Section'] contained inside the given--- 'Value' when it is a @Sections@.+-- | Traversal for the ['Section'] contained inside the given+-- 'Value' when it is a 'Sections'. sections :: Applicative f => ([Section a] -> f [Section a]) -> Value a -> f (Value a) sections f (Sections a xs) = Sections a <$> f xs sections _ v               = pure v --- | Apply a function to the 'Text' contained inside the given--- 'Value' when it is a @Text@.+-- | Traversal for the 'Text' contained inside the given 'Value'. text :: Applicative f => (Text -> f Text) -> Value a -> f (Value a) text f (Text a t) = Text a <$> f t text _ v          = pure v --- | Apply a function to the 'Text' contained inside the given--- 'Value' when it is a @Text@. This traversal is only valid--- if the output atom is a valid atom!+-- | Traversal for the 'Atom' contained inside the given 'Value'. atom :: Applicative f => (Atom -> f Atom) -> Value a -> f (Value a) atom f (Atom a t) = Atom a <$> f t atom _ v          = pure v --- | Apply a function to the 'Integer' contained inside the given--- 'Value' when it is a @Number@.+-- | Traversal for the 'Integer' contained inside the given+-- 'Value' when it is a 'Number'. number :: Applicative f => (Integer -> f Integer) -> Value a -> f (Value a) number f (Number a b n) = Number a b <$> f n number _ v              = pure v --- | Apply a function to the ['Value'] contained inside the given--- 'Value' when it is a @List@.+-- | Traversal for the ['Value'] contained inside the given+-- 'Value' when it is a 'List'. list :: Applicative f => ([Value a] -> f [Value a]) -> Value a -> f (Value a) list f (List a xs) = List a <$> f xs list _ v           = pure v --- | Apply a function to any of the immediate values in a list or--- a sections list. This is intended to be used with Control.Lens.Plated.+-- | Traversal for the immediate values in a list or a sections list.+--+-- This is intended to be used with "Control.Lens.Plated". valuePlate :: Applicative f => (Value a -> f (Value a)) -> Value a -> f (Value a) valuePlate f (List     a xs) = List     a <$> traverse             f  xs valuePlate f (Sections a xs) = Sections a <$> traverse (sectionVal f) xs@@ -73,14 +79,17 @@ sectionVal :: Functor f => (Value a -> f (Value a)) -> Section a -> f (Section a) sectionVal f (Section a k v) = Section a k <$> f v --- | Apply a function to the 'Value' elements inside the given--- 'Value' when it is a @List@.+-- | Traversal for the 'Value' elements inside the given+-- 'Value' when it is a 'List'. ----- > values = list . traverse+-- @+-- 'values' = 'list' . 'traverse'+-- @ values :: Applicative f => (Value a -> f (Value a)) -> Value a -> f (Value a) values = list . traverse  +-- | Lens for the annotation component of a 'Value' ann :: Functor f => (a -> f a) -> Value a -> f (Value a) ann f v =   case v of
src/Config/LexerUtils.hs view
@@ -3,8 +3,31 @@ -- to segregate the automatically generated code from the -- hand written code. The automatically generated code -- causes lots of warnings which mask the interesting warnings.-module Config.LexerUtils where+module Config.LexerUtils+  (+  -- * Alex wrapper+    AlexInput+  , alexGetByte +  -- * Lexer modes+  , LexerMode(..)+  , startString+  , nestMode+  , endMode++  -- * Token builders+  , token+  , token_+  , section+  , number+  , floating++  -- * Final actions+  , untermString+  , eofAction+  , errorAction+  ) where+ import Data.Char            (GeneralCategory(..), generalCategory, digitToInt,                              isAscii, isSpace, ord, isDigit) import Data.Text            (Text)@@ -30,10 +53,6 @@        return (b, inp)  ---------------------------------------------------------------------------- | The initial 'Position' for the start of a file-startPos :: Position-startPos = Position { posIndex = 0, posLine = 1, posColumn = 1 }  -- | Advance the position according to the kind of character lexed. move :: Position -> Char -> Position
src/Config/Pretty.hs view
@@ -1,11 +1,12 @@ -- | Pretty-printing implementation for 'Value'-module Config.Pretty where+module Config.Pretty (pretty) where  import           Data.Char (isPrint, isDigit,intToDigit) import           Data.List (mapAccumL) import qualified Data.Text as Text import           Text.PrettyPrint import           Numeric(showIntAtBase)+import           Prelude hiding ((<>))  import Config.Value 
src/Config/Tokens.hs view
@@ -4,6 +4,7 @@   ( Token(..)   , Located(..)   , Position(..)+  , startPos   , Error(..)   , layoutPass   ) where@@ -15,6 +16,10 @@   { posIndex, posLine, posColumn :: {-# UNPACK #-} !Int }   deriving (Read, Show, Ord, Eq) +-- | The initial 'Position' for the start of a file+startPos :: Position+startPos = Position { posIndex = 0, posLine = 1, posColumn = 1 }+ -- | A value annotated with its text file position data Located a = Located   { locPosition :: {-# UNPACK #-} !Position@@ -68,10 +73,10 @@  -- | Single step of the layout pass step ::-  Located Token              {- ^ current token          -} ->-  ([Layout] -> [Located Token]) {- ^ continuation           -} ->-  [Layout]                      {- ^ stack of layout scopes -} ->-  [Located Token]            {- ^ token stream with layout -}+  Located Token                 {- ^ current token            -} ->+  ([Layout] -> [Located Token]) {- ^ continuation             -} ->+  [Layout]                      {- ^ stack of layout scopes   -} ->+  [Located Token]               {- ^ token stream with layout -}  -- start blocks must be indented -- tokens before the current layout end the current layout@@ -85,6 +90,7 @@     Layout{}:_       | usesLayout t   -> t : next (Layout (toCol t) : cols)     _                                 -> t : next cols +-- | Extract the column number from a located thing. toCol :: Located a -> Int toCol = posColumn . locPosition