packages feed

lens-toml-parser 0.2.0.0 → 0.3.0.0

raw patch · 10 files changed

+415/−272 lines, 10 filesdep +textdep −hlintdep ~basedep ~containersdep ~timesetup-changedPVP ok

version bump matches the API change (PVP)

Dependencies added: text

Dependencies removed: hlint

Dependency ranges changed: base, containers, time, toml-parser

API changes (from Hackage documentation)

- Toml.Lens: _Array :: (Choice p, Applicative f) => p [Value] (f [Value]) -> p Value (f Value)
- Toml.Lens: _Float :: (Choice p, Applicative f) => p Double (f Double) -> p Value (f Value)
- Toml.Lens: _String :: (Choice p, Applicative f) => p String (f String) -> p Value (f Value)
+ Toml.Lens: _Bool' :: (Choice p, Applicative f) => p (a, Bool) (f (a, Bool)) -> p (Value' a) (f (Value' a))
+ Toml.Lens: _Day' :: (Choice p, Applicative f) => p (a, Day) (f (a, Day)) -> p (Value' a) (f (Value' a))
+ Toml.Lens: _Double :: (Choice p, Applicative f) => p Double (f Double) -> p Value (f Value)
+ Toml.Lens: _Double' :: (Choice p, Applicative f) => p (a, Double) (f (a, Double)) -> p (Value' a) (f (Value' a))
+ Toml.Lens: _Integer' :: (Choice p, Applicative f) => p (a, Integer) (f (a, Integer)) -> p (Value' a) (f (Value' a))
+ Toml.Lens: _List :: (Choice p, Applicative f) => p [Value] (f [Value]) -> p Value (f Value)
+ Toml.Lens: _List' :: (Choice p, Applicative f) => p (a, [Value' a]) (f (a, [Value' a])) -> p (Value' a) (f (Value' a))
+ Toml.Lens: _LocalTime' :: (Choice p, Applicative f) => p (a, LocalTime) (f (a, LocalTime)) -> p (Value' a) (f (Value' a))
+ Toml.Lens: _Table' :: (Choice p, Applicative f) => p (a, Table' a) (f (a, Table' a)) -> p (Value' a) (f (Value' a))
+ Toml.Lens: _Text :: (Choice p, Applicative f) => p Text (f Text) -> p Value (f Value)
+ Toml.Lens: _Text' :: (Choice p, Applicative f) => p (a, Text) (f (a, Text)) -> p (Value' a) (f (Value' a))
+ Toml.Lens: _TimeOfDay' :: (Choice p, Applicative f) => p (a, TimeOfDay) (f (a, TimeOfDay)) -> p (Value' a) (f (Value' a))
+ Toml.Lens: _ZonedTime' :: (Choice p, Applicative f) => p (a, ZonedTime) (f (a, ZonedTime)) -> p (Value' a) (f (Value' a))

Files

.gitignore view
@@ -1,6 +1,5 @@-*~ /dist/ /dist-newstyle/-cabal.project.local+/*result*/+/cabal.project.local* shell.nix-/result/
ChangeLog.md view
@@ -26,3 +26,10 @@ ## 0.2.0.0  -- 2023-08-26  * Updated to toml-parser >=1.1.  This is a breaking change.++## 0.3.0.0  -- 2024-02-27++* Updated to toml-parser-2.0.0.0. This is a breaking change due to the+  new toml-parser using Text and different constructor names. It also+  adds new prisms supporting annotations used by the new toml-parser+  version for tracking file locations.
LICENSE view
@@ -1,4 +1,4 @@-Copyright (c) 2017-2023 Henry Till+Copyright (c) 2017-2024 Henry Till  Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice
README.md view
@@ -5,4 +5,4 @@  Lenses for [toml-parser](https://hackage.haskell.org/package/toml-parser). -See the [tests](https://github.com/henrytill/lens-toml-parser/blob/master/tests/Main.hs) for usage examples.+See the [tests](https://github.com/henrytill/lens-toml-parser/blob/master/test/Main.hs) for usage examples.
Setup.hs view
@@ -1,2 +1,3 @@ import Distribution.Simple+ main = defaultMain
lens-toml-parser.cabal view
@@ -1,8 +1,8 @@--- Initial lens-toml-parser.cabal generated by cabal init.  For further +-- Initial lens-toml-parser.cabal generated by cabal init.  For further -- documentation, see http://haskell.org/cabal/users-guide/  name:                lens-toml-parser-version:             0.2.0.0+version:             0.3.0.0 synopsis:            Lenses for toml-parser description:         This library provides lenses for toml-parser. license:             ISC@@ -10,11 +10,11 @@ author:              Henry Till maintainer:          henrytill@gmail.com homepage:            https://github.com/henrytill/lens-toml-parser-copyright:           Copyright (c) 2017-2023, Henry Till+copyright:           Copyright (c) 2017-2024, Henry Till category:            Language, Lenses build-type:          Simple cabal-version:       >=1.10-tested-with:         GHC ==9.2.8 || ==9.4.4 || ==9.6.2+tested-with:         GHC ==9.4.8 || ==9.6.4 || ==9.8.2  extra-source-files:   .gitignore@@ -28,12 +28,13 @@  library   exposed-modules:     Toml.Lens-  -- other-modules:       -  -- other-extensions:    -  build-depends:       base        >=4.8 && <5-                     , time        >=1.5 && <1.14-                     , profunctors >=5.2 && <5.7-                     , toml-parser >=1.1 && <1.4+  -- other-modules:+  -- other-extensions:+  build-depends:       base        >=4.14 && <5+                     , profunctors >=5.2  && <5.7+                     , text        >=0.2  && <3+                     , time        >=1.9  && <1.13+                     , toml-parser >=2.0  && <2.1   hs-source-dirs:      src   default-language:    Haskell2010   ghc-options:         -Wall@@ -41,21 +42,13 @@ test-suite tests   type:                exitcode-stdio-1.0   main-is:             Main.hs-  build-depends:       base        >=4.8 && <5-                     , containers  >=0.5 && <0.7-                     , dwergaz     >=0.2 && <0.3-                     , toml-parser >=1.1 && <1.4-                     , lens-family >=2.1 && <2.2+  build-depends:       base        >=4.14 && <5+                     , containers  >=0.5  && <0.8+                     , dwergaz     >=0.2  && <0.3+                     , lens-family >=2.1  && <2.2+                     , text        >=0.2  && <3+                     , toml-parser >=2.0  && <2.1                      , lens-toml-parser-  hs-source-dirs:      tests-  default-language:    Haskell2010-  ghc-options:         -Wall--test-suite hlint-  type:                exitcode-stdio-1.0-  main-is:             HLint.hs-  build-depends:       base-                     , hlint >=3.0 && <4-  hs-source-dirs:      tests+  hs-source-dirs:      test   default-language:    Haskell2010   ghc-options:         -Wall
src/Toml/Lens.hs view
@@ -1,30 +1,43 @@ -- | -- Module      : Toml.Lens -- Description : Lenses for toml-parser--- Copyright   : (c) 2017-2022, Henry Till+-- Copyright   : (c) 2017-2024, Henry Till -- License     : ISC -- Maintainer  : henrytill@gmail.com -- Stability   : experimental -- -- Lenses for <https://hackage.haskell.org/package/toml-parser toml-parser>.--- module Toml.Lens-  ( _Table-  , _Array-  , _Float-  , _Integer-  , _String-  , _Bool-  , _ZonedTime-  , _LocalTime-  , _Day-  , _TimeOfDay-  ) where+  ( -- * Unannotated+    _Table,+    _List,+    _Double,+    _Integer,+    _Text,+    _Bool,+    _ZonedTime,+    _LocalTime,+    _Day,+    _TimeOfDay, -import           Data.Profunctor-import qualified Data.Time       as Time+    -- * Annotated+    _Table',+    _List',+    _Double',+    _Integer',+    _Text',+    _Bool',+    _ZonedTime',+    _LocalTime',+    _Day',+    _TimeOfDay',+  )+where -import           Toml+import Data.Profunctor+import Data.Text (Text)+import qualified Data.Time as Time+import Toml  -- -- With help from:@@ -39,121 +52,231 @@ -- @ -- -prism-  :: (Choice p, Applicative f)-  => (b -> t)-  -> (s -> Either t a)-  -> p a (f b)-  -> p s (f t)+prism ::+  (Choice p, Applicative f) =>+  (b -> t) ->+  (s -> Either t a) ->+  p a (f b) ->+  p s (f t) prism bt seta = dimap seta (either pure (fmap bt)) . right' {-# INLINE prism #-}  -- | @_Table :: Prism' Value Table@-_Table-  :: (Choice p, Applicative f)-  => p Table (f Table)-  -> p Value (f Value)+_Table ::+  (Choice p, Applicative f) =>+  p Table (f Table) ->+  p Value (f Value) _Table =-  prism Table $ \ n -> case n of+  prism Table $ \n -> case n of     Table v -> Right v-    _       -> Left n+    _ -> Left n {-# INLINE _Table #-} --- | @_Array :: Prism' Value [Value]@-_Array-  :: (Choice p, Applicative f)-  => p [Value] (f [Value])-  -> p Value (f Value)-_Array =-  prism Array $ \ n -> case n of-    Array v -> Right v-    _       -> Left n-{-# INLINE _Array #-}+-- | @_List :: Prism' Value [Value]@+_List ::+  (Choice p, Applicative f) =>+  p [Value] (f [Value]) ->+  p Value (f Value)+_List =+  prism List $ \n -> case n of+    List v -> Right v+    _ -> Left n+{-# INLINE _List #-} --- | @_Float :: Prism' Value Double@-_Float-  :: (Choice p, Applicative f)-  => p Double (f Double)-  -> p Value (f Value)-_Float =-  prism Float $ \ n -> case n of-    Float v -> Right v-    _       -> Left n-{-# INLINE _Float #-}+-- | @_Double :: Prism' Value Double@+_Double ::+  (Choice p, Applicative f) =>+  p Double (f Double) ->+  p Value (f Value)+_Double =+  prism Double $ \n -> case n of+    Double v -> Right v+    _ -> Left n+{-# INLINE _Double #-}  -- | @_Integer :: Prism' Value Integer@-_Integer-  :: (Choice p, Applicative f)-  => p Integer (f Integer)-  -> p Value (f Value)+_Integer ::+  (Choice p, Applicative f) =>+  p Integer (f Integer) ->+  p Value (f Value) _Integer =-  prism Integer $ \ n -> case n of+  prism Integer $ \n -> case n of     Integer v -> Right v-    _         -> Left n+    _ -> Left n {-# INLINE _Integer #-} --- | @_String :: Prism' Value String@-_String-  :: (Choice p, Applicative f)-  => p String (f String)-  -> p Value (f Value)-_String =-  prism String $ \ n -> case n of-    String v -> Right v-    _        -> Left n-{-# INLINE _String #-}+-- | @_Text :: Prism' Value Text@+_Text ::+  (Choice p, Applicative f) =>+  p Text (f Text) ->+  p Value (f Value)+_Text =+  prism Text $ \n -> case n of+    Text v -> Right v+    _ -> Left n+{-# INLINE _Text #-}  -- | @_Bool :: Prism' Value Bool@-_Bool-  :: (Choice p, Applicative f)-  => p Bool (f Bool)-  -> p Value (f Value)+_Bool ::+  (Choice p, Applicative f) =>+  p Bool (f Bool) ->+  p Value (f Value) _Bool =-  prism Bool $ \ n -> case n of+  prism Bool $ \n -> case n of     Bool v -> Right v-    _      -> Left n+    _ -> Left n {-# INLINE _Bool #-}  -- | @_ZonedTime :: Prism' Value Time.ZonedTime@-_ZonedTime-  :: (Choice p, Applicative f)-  => p Time.ZonedTime (f Time.ZonedTime)-  -> p Value (f Value)+_ZonedTime ::+  (Choice p, Applicative f) =>+  p Time.ZonedTime (f Time.ZonedTime) ->+  p Value (f Value) _ZonedTime =-  prism ZonedTime $ \ n -> case n of+  prism ZonedTime $ \n -> case n of     ZonedTime v -> Right v-    _           -> Left n+    _ -> Left n {-# INLINE _ZonedTime #-}  -- | @_LocalTime :: Prism' Value Time.LocalTime@-_LocalTime-  :: (Choice p, Applicative f)-  => p Time.LocalTime (f Time.LocalTime)-  -> p Value (f Value)+_LocalTime ::+  (Choice p, Applicative f) =>+  p Time.LocalTime (f Time.LocalTime) ->+  p Value (f Value) _LocalTime =-  prism LocalTime $ \ n -> case n of+  prism LocalTime $ \n -> case n of     LocalTime v -> Right v-    _           -> Left n+    _ -> Left n {-# INLINE _LocalTime #-}  -- | @_Day :: Prism' Value Time.Day@-_Day-  :: (Choice p, Applicative f)-  => p Time.Day (f Time.Day)-  -> p Value (f Value)+_Day ::+  (Choice p, Applicative f) =>+  p Time.Day (f Time.Day) ->+  p Value (f Value) _Day =-  prism Day $ \ n -> case n of+  prism Day $ \n -> case n of     Day v -> Right v-    _     -> Left n+    _ -> Left n {-# INLINE _Day #-}  -- | @_TimeOfDay :: Prism' Value Time.TimeOfDay@-_TimeOfDay-  :: (Choice p, Applicative f)-  => p Time.TimeOfDay (f Time.TimeOfDay)-  -> p Value (f Value)+_TimeOfDay ::+  (Choice p, Applicative f) =>+  p Time.TimeOfDay (f Time.TimeOfDay) ->+  p Value (f Value) _TimeOfDay =-  prism TimeOfDay $ \ n -> case n of+  prism TimeOfDay $ \n -> case n of     TimeOfDay v -> Right v-    _           -> Left n+    _ -> Left n {-# INLINE _TimeOfDay #-}++-- | @_Table' :: Prism' (Value' a) (a, Table' a)@+_Table' ::+  (Choice p, Applicative f) =>+  p (a, Table' a) (f (a, Table' a)) ->+  p (Value' a) (f (Value' a))+_Table' =+  prism (uncurry Table') $ \n -> case n of+    Table' a v -> Right (a, v)+    _ -> Left n+{-# INLINE _Table' #-}++-- | @_Array' :: Prism' (Value' a) (a, [Value' a])@+_List' ::+  (Choice p, Applicative f) =>+  p (a, [Value' a]) (f (a, [Value' a])) ->+  p (Value' a) (f (Value' a))+_List' =+  prism (uncurry List') $ \n -> case n of+    List' a v -> Right (a, v)+    _ -> Left n+{-# INLINE _List' #-}++-- | @_Double' :: Prism' (Value' a) (a, Double)@+_Double' ::+  (Choice p, Applicative f) =>+  p (a, Double) (f (a, Double)) ->+  p (Value' a) (f (Value' a))+_Double' =+  prism (uncurry Double') $ \n -> case n of+    Double' a v -> Right (a, v)+    _ -> Left n+{-# INLINE _Double' #-}++-- | @_Integer' :: Prism' (Value' a) (a, Integer)@+_Integer' ::+  (Choice p, Applicative f) =>+  p (a, Integer) (f (a, Integer)) ->+  p (Value' a) (f (Value' a))+_Integer' =+  prism (uncurry Integer') $ \n -> case n of+    Integer' a v -> Right (a, v)+    _ -> Left n+{-# INLINE _Integer' #-}++-- | @_Text' :: Prism' (Value' a) (a, Text)@+_Text' ::+  (Choice p, Applicative f) =>+  p (a, Text) (f (a, Text)) ->+  p (Value' a) (f (Value' a))+_Text' =+  prism (uncurry Text') $ \n -> case n of+    Text' a v -> Right (a, v)+    _ -> Left n+{-# INLINE _Text' #-}++-- | @_Bool' :: Prism' (Value' a) (a, Bool)@+_Bool' ::+  (Choice p, Applicative f) =>+  p (a, Bool) (f (a, Bool)) ->+  p (Value' a) (f (Value' a))+_Bool' =+  prism (uncurry Bool') $ \n -> case n of+    Bool' a v -> Right (a, v)+    _ -> Left n+{-# INLINE _Bool' #-}++-- | @_ZonedTime' :: Prism' (Value' a) (a, Time.ZonedTime)@+_ZonedTime' ::+  (Choice p, Applicative f) =>+  p (a, Time.ZonedTime) (f (a, Time.ZonedTime)) ->+  p (Value' a) (f (Value' a))+_ZonedTime' =+  prism (uncurry ZonedTime') $ \n -> case n of+    ZonedTime' a v -> Right (a, v)+    _ -> Left n+{-# INLINE _ZonedTime' #-}++-- | @_LocalTime' :: Prism' (Value' a) (a, Time.LocalTime)@+_LocalTime' ::+  (Choice p, Applicative f) =>+  p (a, Time.LocalTime) (f (a, Time.LocalTime)) ->+  p (Value' a) (f (Value' a))+_LocalTime' =+  prism (uncurry LocalTime') $ \n -> case n of+    LocalTime' a v -> Right (a, v)+    _ -> Left n+{-# INLINE _LocalTime' #-}++-- | @_Day' :: Prism' (Value' a) (a, Time.Day)@+_Day' ::+  (Choice p, Applicative f) =>+  p (a, Time.Day) (f (a, Time.Day)) ->+  p (Value' a) (f (Value' a))+_Day' =+  prism (uncurry Day') $ \n -> case n of+    Day' a v -> Right (a, v)+    _ -> Left n+{-# INLINE _Day' #-}++-- | @_TimeOfDay' :: Prism' (Value' a) (a, Time.TimeOfDay)@+_TimeOfDay' ::+  (Choice p, Applicative f) =>+  p (a, Time.TimeOfDay) (f (a, Time.TimeOfDay)) ->+  p (Value' a) (f (Value' a))+_TimeOfDay' =+  prism (uncurry TimeOfDay') $ \n -> case n of+    TimeOfDay' a v -> Right (a, v)+    _ -> Left n+{-# INLINE _TimeOfDay' #-}
+ test/Main.hs view
@@ -0,0 +1,168 @@+{-# LANGUAGE OverloadedStrings #-}++module Main (main) where++import Control.Monad (unless)+import Data.Map.Strict (Map)+import Data.Text (Text)+import qualified Data.Text.IO as TIO+import Lens.Family2+import Lens.Family2.Stock (at, just_, _2)+import Lens.Family2.Unchecked (adapter)+import System.Exit (exitFailure)+import Test.Dwergaz+import Toml (Table, Table' (..), Value, Value')+import qualified Toml+import Toml.Lens++allEqual :: (Eq a) => [a] -> Bool+allEqual (x : xs) = all (== x) xs+allEqual [] = error "allEqual: empty list"++table :: Adapter' (Table' a) (Map Text (a, Value' a))+table = adapter unTable MkTable+  where+    unTable (MkTable t) = t++valueAt ::+  (Applicative f) =>+  Text ->+  (Value -> f Value) ->+  Table ->+  f Table+valueAt k = under table . at k . just_ . _2++mapAt ::+  (Applicative f) =>+  Text ->+  (Table -> f Table) ->+  Table ->+  f Table+mapAt k = valueAt k . _Table++testTableKey :: Table -> Test+testTableKey kv =+  Expect+    "'key' from 'table' == Just \"value\""+    (==)+    expected+    actual+  where+    expected = Just "value"+    actual = kv ^? mapAt "table" . valueAt "key" . _Text++testTableZoo :: Table -> Test+testTableZoo kv =+  Expect+    "'zoo' from 'table' == Nothing"+    (==)+    expected+    actual+  where+    expected = Nothing+    actual = kv ^? mapAt "table" . valueAt "zoo" . _Text++testTableSubtableKey :: Table -> Test+testTableSubtableKey kv =+  Expect+    "'key' from 'subtable' from 'table' == Just \"another value\""+    (==)+    expected+    actual+  where+    expected = Just "another value"+    actual = kv ^? mapAt "table" . mapAt "subtable" . valueAt "key" . _Text++testTableInlineNameFirst :: Table -> Test+testTableInlineNameFirst kv =+  Expect+    "'first' from 'name' from 'inline' from 'table' == \"Tom\""+    (==)+    expected+    actual+  where+    expected = Just "Tom"+    actual = kv ^? mapAt "table" . mapAt "inline" . mapAt "name" . valueAt "first" . _Text++testTableInlinePointY :: Table -> Test+testTableInlinePointY kv =+  Expect+    "'y' from 'point' from 'inline' from 'table' == Just 2"+    (==)+    expected+    actual+  where+    expected = Just 2+    actual = kv ^? mapAt "table" . mapAt "inline" . mapAt "point" . valueAt "y" . _Integer++testStringBasicBasic :: Table -> Test+testStringBasicBasic kv =+  Expect+    "'basic' from 'basic' from 'string' == <some escaped nonsense>"+    (==)+    expected+    actual+  where+    expected = Just "I'm a string. \"You can quote me\". Name\tJos\233\nLocation\tSF."+    actual = kv ^? mapAt "string" . mapAt "basic" . valueAt "basic" . _Text++testStringMultiline :: Table -> Test+testStringMultiline kv =+  Predicate+    "'key1', 'key2', and 'key3' from 'multiline' from 'string' are all the same"+    allEqual+    [actual1, actual2, actual3]+  where+    actual1 = kv ^? mapAt "string" . mapAt "multiline" . valueAt "key1" . _Text+    actual2 = kv ^? mapAt "string" . mapAt "multiline" . valueAt "key2" . _Text+    actual3 = kv ^? mapAt "string" . mapAt "multiline" . valueAt "key3" . _Text++testStringMultilineContinued :: Table -> Test+testStringMultilineContinued kv =+  Predicate+    "'key1', 'key2', and 'key3' from 'continued' from 'multiline' from 'string' are all the same"+    allEqual+    [actual1, actual2, actual3]+  where+    actual1 = kv ^? mapAt "string" . mapAt "multiline" . mapAt "continued" . valueAt "key1" . _Text+    actual2 = kv ^? mapAt "string" . mapAt "multiline" . mapAt "continued" . valueAt "key2" . _Text+    actual3 = kv ^? mapAt "string" . mapAt "multiline" . mapAt "continued" . valueAt "key3" . _Text++testArrayKey1 :: Table -> Test+testArrayKey1 kv =+  Expect+    "'key1' from 'array' == [1, 2, 3]"+    (==)+    expected+    actual+  where+    expected = [1, 2, 3]+    actual = kv ^.. mapAt "array" . valueAt "key1" . _List . traverse . _Integer++runTests :: Table -> [Result]+runTests kv = runTest . ($ kv) <$> tests+  where+    tests =+      [ testTableKey,+        testTableZoo,+        testTableSubtableKey,+        testTableInlineNameFirst,+        testTableInlinePointY,+        testStringBasicBasic,+        testStringMultiline,+        testStringMultilineContinued,+        testArrayKey1+      ]++readTomlFile :: String -> IO Table+readTomlFile file = TIO.readFile file >>= parse >>= handleError+  where+    parse = pure . Toml.parse+    handleError = either (error . show) (pure . Toml.forgetTableAnns)++main :: IO ()+main = do+  ex <- readTomlFile "./example/example-v0.4.0.toml"+  let rs = runTests ex+  mapM_ print rs+  unless (all isPassed rs) exitFailure
− tests/HLint.hs
@@ -1,12 +0,0 @@-module Main (main) where--import           Control.Monad-import           Language.Haskell.HLint-import           System.Environment-import           System.Exit--main :: IO ()-main = do-  args  <- getArgs-  hints <- hlint $ ["src", "tests"] ++ args-  unless (null hints) exitFailure
− tests/Main.hs
@@ -1,136 +0,0 @@-module Main (main) where--import           Control.Monad      (unless)-import           System.Exit        (exitFailure)--import           Lens.Family2-import           Lens.Family2.Stock (at, just_)-import           Test.Dwergaz-import qualified Toml-import           Toml               (Table, Value)--import           Toml.Lens---allEqual :: Eq a => [a] -> Bool-allEqual (x:xs) = all (== x) xs-allEqual []     = error "allEqual: empty list"--mapAt-  :: Applicative f-  => String-  -> (Table -> f Table)-  -> Table-  -> f Table-mapAt k = at k . just_ . _Table--arrayAt-  :: Applicative f-  => String-  -> ([Value] -> f [Value])-  -> Table-  -> f Table-arrayAt k = at k . just_ . _Array--testTableKey :: Table -> Test-testTableKey kv-  = Expect "'key' from 'table' == Just \"value\""-           (==) expected actual-  where-    expected = Just "value"-    actual   = kv ^? mapAt "table" . at "key" . just_ . _String--testTableZoo :: Table -> Test-testTableZoo kv-  = Expect "'zoo' from 'table' == Nothing"-           (==) expected actual-  where-    expected = Nothing-    actual   = kv ^? mapAt "table" . at "zoo" . just_ . _String--testTableSubtableKey :: Table -> Test-testTableSubtableKey kv-  = Expect "'key' from 'subtable' from 'table' == Just \"another value\""-           (==) expected actual-  where-    expected = Just "another value"-    actual   = kv ^? mapAt "table" . mapAt "subtable" . at "key" . just_ . _String--testTableInlineNameFirst :: Table -> Test-testTableInlineNameFirst kv-  = Expect "'first' from 'name' from 'inline' from 'table' == \"Tom\""-           (==) expected actual-  where-    expected = Just "Tom"-    actual   = kv ^? mapAt "table" . mapAt "inline" . mapAt "name" . at "first" . just_ . _String--testTableInlinePointY :: Table -> Test-testTableInlinePointY kv-  = Expect "'y' from 'point' from 'inline' from 'table' == Just 2"-           (==) expected actual-  where-    expected = Just 2-    actual   = kv ^? mapAt "table" . mapAt "inline" . mapAt "point" . at "y" . just_ . _Integer--testStringBasicBasic :: Table -> Test-testStringBasicBasic kv-  = Expect "'basic' from 'basic' from 'string' == <some escaped nonsense>"-           (==) expected actual-  where-    expected = Just "I'm a string. \"You can quote me\". Name\tJos\233\nLocation\tSF."-    actual   = kv ^? mapAt "string" . mapAt "basic" . at "basic" . just_ . _String--testStringMultiline :: Table -> Test-testStringMultiline kv-  = Predicate "'key1', 'key2', and 'key3' from 'multiline' from 'string' are all the same"-              allEqual-              [actual1, actual2, actual3]-  where-    actual1 = kv ^? mapAt "string" . mapAt "multiline" . at "key1" . just_ . _String-    actual2 = kv ^? mapAt "string" . mapAt "multiline" . at "key2" . just_ . _String-    actual3 = kv ^? mapAt "string" . mapAt "multiline" . at "key3" . just_ . _String--testStringMultilineContinued :: Table -> Test-testStringMultilineContinued kv-  = Predicate "'key1', 'key2', and 'key3' from 'continued' from 'multiline' from 'string' are all the same"-              allEqual-              [actual1, actual2, actual3]-  where-    actual1 = kv ^? mapAt "string" . mapAt "multiline" . mapAt "continued" . at "key1" . just_ . _String-    actual2 = kv ^? mapAt "string" . mapAt "multiline" . mapAt "continued" . at "key2" . just_ . _String-    actual3 = kv ^? mapAt "string" . mapAt "multiline" . mapAt "continued" . at "key3" . just_ . _String--testArrayKey1 :: Table -> Test-testArrayKey1 kv-  = Expect "'key1' from 'array' == [1, 2, 3]"-           (==) expected actual-  where-    expected = [1, 2, 3]-    actual   = kv ^.. mapAt "array" . arrayAt "key1" . traverse . _Integer--runTests :: Table -> [Result]-runTests kv = runTest . ($ kv) <$> tests-  where-    tests = [ testTableKey-            , testTableZoo-            , testTableSubtableKey-            , testTableInlineNameFirst-            , testTableInlinePointY-            , testStringBasicBasic-            , testStringMultiline-            , testStringMultilineContinued-            , testArrayKey1-            ]--readTomlFile :: String -> IO Table-readTomlFile file = readFile file >>= parse >>= handleError-  where-    parse       = pure . Toml.parse-    handleError = either (error . show) pure--main :: IO ()-main =  do-  ex <- readTomlFile "./example/example-v0.4.0.toml"-  let rs = runTests ex-  mapM_ print rs-  unless (all isPassed rs) exitFailure