Skip to content

Commit

Permalink
Add instance IsString Value
Browse files Browse the repository at this point in the history
  • Loading branch information
glguy committed Jan 17, 2024
1 parent 394f7ad commit 4f1a95f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
4 changes: 4 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Revision history for toml-parser

## 1.3.3.0

* Added `IsString Value` instance.

## 1.3.2.0

* Added `Toml.Generic` to make instances easily derivable via DerivingVia.
Expand Down
11 changes: 11 additions & 0 deletions src/Toml/Value.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ module Toml.Value (

import Data.Data (Data)
import Data.Map (Map)
import Data.String (IsString(fromString))
import Data.Time (Day, LocalTime, TimeOfDay, ZonedTime(zonedTimeToLocalTime, zonedTimeZone), timeZoneMinutes)
import GHC.Generics (Generic)

Expand Down Expand Up @@ -61,3 +62,13 @@ instance Eq Value where
-- Extract the relevant parts to build an Eq instance
projectZT :: ZonedTime -> (LocalTime, Int)
projectZT x = (zonedTimeToLocalTime x, timeZoneMinutes (zonedTimeZone x))

-- | Constructs a TOML string literal.
--
-- @
-- fromString = String
-- @
--
-- @since 1.3.3.0
instance IsString Value where
fromString = String
2 changes: 1 addition & 1 deletion toml-parser.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 3.0
name: toml-parser
version: 1.3.2.0
version: 1.3.3.0
synopsis: TOML 1.0.0 parser
description:
TOML parser using generated lexers and parsers with
Expand Down

0 comments on commit 4f1a95f

Please sign in to comment.