Skip to content

Commit

Permalink
expose typeError
Browse files Browse the repository at this point in the history
  • Loading branch information
glguy committed Feb 22, 2024
1 parent 3f5a8e4 commit 009b181
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/Toml/Schema/FromValue.hs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ module Toml.Schema.FromValue (
optKey,
optKeyOf,

-- * Errors
typeError,

) where

import Control.Monad (zipWithM, liftM2)
Expand Down
6 changes: 3 additions & 3 deletions src/Toml/Schema/Generic/FromValue.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
--
Expand All @@ -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 #-}

Expand Down

0 comments on commit 009b181

Please sign in to comment.