From b4019a0b9316e58e0281f849b5abf591e9e24af5 Mon Sep 17 00:00:00 2001 From: Eric Mertens Date: Wed, 21 Feb 2024 09:36:01 -0800 Subject: [PATCH] Fix old ghc --- README.md | 27 ++++++++++++++------------- src/Toml/Schema/FromValue.hs | 4 ++-- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index a709175..f699626 100644 --- a/README.md +++ b/README.md @@ -18,22 +18,23 @@ stateDiagram-v2 TOML:::important --> ApplicationTypes:::important : decode ApplicationTypes --> TOML : encode - TOML --> [Token]: Toml.Syntax.Lexer - [Token] --> [Expr]: Toml.Syntax.Parser - [Expr] --> Table : Toml.Semantics - Table --> ApplicationTypes : Toml.FromValue - ApplicationTypes --> Table : Toml.ToValue - Table --> TOML : Toml.Pretty - + TOML --> [Token]: Lexer + [Token] --> [Expr]: Parser + [Expr] --> Table : Semantics + Table --> ApplicationTypes : FromValue + ApplicationTypes --> Table : ToValue + Table --> TOML : Pretty ``` -The highest-level interface to this package is to define `FromValue` and `ToTable` -instances for your application-specific datatypes. These can be used with `encode` -and `decode` to convert to and from TOML. +Most users will only need to import **Toml** or **Toml.Schema**. Other top-level +modules are for low-level hacking on the TOML format itself. All modules below +these top-level modules are exposed to provide direct access to library implementation +details. -For low-level access to the TOML format, the lexer, parser, and validator are available -for direct use. The diagram above shows how the different modules enable you to -advance through the increasingly high-level TOML representations. +- **Toml** - Basic encoding and decoding TOML +- **Toml.Schema** - TOML schemas for application types +- **Toml.Semantics** - Low-level semantic operations on TOML syntax +- **Toml.Syntax** - Low-level parsing of text into TOML raw syntax ## Examples diff --git a/src/Toml/Schema/FromValue.hs b/src/Toml/Schema/FromValue.hs index 5550b1a..5c743b3 100644 --- a/src/Toml/Schema/FromValue.hs +++ b/src/Toml/Schema/FromValue.hs @@ -40,7 +40,7 @@ module Toml.Schema.FromValue ( ) where -import Control.Monad (zipWithM) +import Control.Monad (zipWithM, liftM2) import Data.Int (Int8, Int16, Int32, Int64) import Data.List.NonEmpty (NonEmpty) import Data.List.NonEmpty qualified as NonEmpty @@ -71,7 +71,7 @@ mapOf matchKey matchVal = \case Table' _ (MkTable t) -> Map.fromList <$> sequence kvs where - kvs = [liftA2 (,) (matchKey l k) (inKey k (matchVal k v)) | (k, (l, v)) <- Map.assocs t] + kvs = [liftM2 (,) (matchKey l k) (inKey k (matchVal k v)) | (k, (l, v)) <- Map.assocs t] v -> typeError "table" v -- | List matching function used to help implemented 'fromValue' for arrays.