diff --git a/src/Toml/Schema/FromValue.hs b/src/Toml/Schema/FromValue.hs index 5c743b3..528f4b7 100644 --- a/src/Toml/Schema/FromValue.hs +++ b/src/Toml/Schema/FromValue.hs @@ -38,6 +38,9 @@ module Toml.Schema.FromValue ( optKey, optKeyOf, + -- * Errors + typeError, + ) where import Control.Monad (zipWithM, liftM2) diff --git a/src/Toml/Schema/Generic/FromValue.hs b/src/Toml/Schema/Generic/FromValue.hs index d0f4c5a..5b428ae 100644 --- a/src/Toml/Schema/Generic/FromValue.hs +++ b/src/Toml/Schema/Generic/FromValue.hs @@ -24,10 +24,10 @@ import Control.Monad.Trans.State (StateT(..)) import Data.Coerce (coerce) import Data.Text qualified as Text import GHC.Generics -import Toml.Schema.FromValue (FromValue, fromValue, optKey, reqKey, parseTableFromValue) +import Toml.Schema.FromValue (FromValue, fromValue, optKey, reqKey, parseTableFromValue, typeError) import Toml.Schema.Matcher (Matcher, failAt) import Toml.Schema.ParseTable (ParseTable) -import Toml.Semantics (valueAnn, valueType, Value'(List')) +import Toml.Semantics (Value'(List')) -- | Match a 'Toml.Semantics.Table'' using the field names in a record. -- @@ -53,7 +53,7 @@ genericFromArray (List' a xs) = pure (to gen) else failAt a ("array " ++ show (length xs') ++ " elements too long") -genericFromArray v = failAt (valueAnn v) ("type error. wanted: array got: " ++ valueType v) +genericFromArray v = typeError "array" v {-# INLINE genericFromArray #-}