Skip to content

Commit

Permalink
Add export list for Toml.FromValue.ParseTable
Browse files Browse the repository at this point in the history
  • Loading branch information
glguy committed Jul 9, 2023
1 parent 5cfb0c0 commit cda14a5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/Toml/FromValue.hs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ module Toml.FromValue (
optKey,
reqKey,
warnTable,
Alt(..),
KeyAlt(..),
pickKey,

-- * Table matching primitives
Expand Down
4 changes: 2 additions & 2 deletions src/Toml/FromValue/Matcher.hs
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ instance MonadFail Matcher where

-- | Update the scope with the message corresponding to a table key
--
-- @since 1.1.2.0
-- @since 1.2.0.0
inKey :: String -> Matcher a -> Matcher a
inKey key = withScope ('.' : show (prettySimpleKey key))

-- | Update the scope with the message corresponding to an array index
--
-- @since 1.1.2.0
-- @since 1.2.0.0
inIndex :: Int -> Matcher a -> Matcher a
inIndex i = withScope ("[" ++ show i ++ "]")
20 changes: 16 additions & 4 deletions src/Toml/FromValue/ParseTable.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,19 @@ most of the basic functionality is exported directly from
"Toml.FromValue".
-}
module Toml.FromValue.ParseTable where
module Toml.FromValue.ParseTable (
-- * Base interface
ParseTable,
KeyAlt(..),
pickKey,
runParseTable,

-- * Primitives
liftMatcher,
warnTable,
setTable,
getTable,
) where

import Control.Applicative (Alternative)
import Control.Monad (MonadPlus)
Expand Down Expand Up @@ -75,7 +87,7 @@ warnTable = ParseTable . lift . warning
-- | Key and value matching function
--
-- @since 1.2.0.0
data Alt a
data KeyAlt a
= Key String (Value -> Matcher a) -- ^ pick alternative based on key match
| Else (Matcher a) -- ^ default case when no previous cases matched

Expand All @@ -92,8 +104,8 @@ data Alt a
-- each unmatched alternative as well as the error associate with the
-- matched alternative.
--
-- @since 1.1.2.0
pickKey :: [Alt a] -> ParseTable a
-- @since 1.2.0.0
pickKey :: [KeyAlt a] -> ParseTable a
pickKey xs =
do t <- getTable
foldr (f t) (fail errMsg) xs
Expand Down

0 comments on commit cda14a5

Please sign in to comment.