packages feed

hedn 0.2.0.0 → 0.2.0.1

raw patch · 12 files changed

+60/−172 lines, 12 filesdep +uuid-typesdep −uuiddep ~hedgehogPVP ok

version bump matches the API change (PVP)

Dependencies added: uuid-types

Dependencies removed: uuid

Dependency ranges changed: hedgehog

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -3,6 +3,16 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## [0.2.0.1] - 2019-02-18++### Changed++- `uuid` swapped for lighter `uuid-types`++### Added++- `tintin`-generated documentation+ ## [0.2.0.0] - 2019-01-18  ### Changed@@ -51,6 +61,7 @@  - Use utf8-string parsing for unicode literals. +[0.2.0.1]: https://gitlab.com/dpwiz/hedn/tree/v0.2.0.1 [0.2.0.0]: https://gitlab.com/dpwiz/hedn/tree/0.2.0.0 [0.1.9.1]: https://gitlab.com/dpwiz/hedn/tree/0.1.9.1 [0.1.9.0]: https://gitlab.com/dpwiz/hedn/tree/0.1.9.0
README.md view
@@ -1,15 +1,17 @@ # Haskell EDN -An EDN parsing and encoding library inspired by `aeson`.+An EDN parsing and encoding library.  Based on [spec] and [hints] published on GitHub. +[spec]: https://github.com/edn-format/edn+[hints]: https://github.com/wagjo/serialization-formats+ Hackage: https://hackage.haskell.org/package/hedn  Stackage: https://www.stackage.org/package/hedn -[spec]: https://github.com/edn-format/edn-[hints]: https://github.com/wagjo/serialization-formats+Tutorial: https://dpwiz.gitlab.io/hedn  # Examples @@ -59,126 +61,4 @@                  )                ]))      ])-```--## Conversion--More examples in `tests/Data/EDN/Class/Test.hs`.--```haskell-data Person = Person-  { personFirst :: Text-  , personLast  :: Text-  } deriving (Eq, Show)--instance ToEDN Person where-  toEDN Person{..} =-    toEDNtagged "myapp" "Person" $ Map.fromList-      [ (EDN.Keyword "first", toEDN personFirst)-      , (EDN.Keyword "last", toEDN personLast)-      ]--instance FromEDN Person where-  parseEDN = \case-    EDN.Tagged "myapp" "Person" v -> Person-      <$> EDN.mapGetKeyword "first" v-      <*> EDN.mapGetKeyword "last" v-    _ ->-      fail "myapp/Person expected"-```--```haskell-import qualified Data.EDN as EDN-import qualified Data.Text.IO as Text--main = Text.putStrLn $-  encodeText (Person "Fred" "Mertz")-```--```clojure-#myapp/Person {:first "Fred" :last "Mertz"}-```--## Quasiquoter--Embed EDN AST literals with `edn`:--```haskell-fredEDN = [edn|-  #myapp/Person {:first "Fred" :last "Mertz"}-|]-```--Additionally there are QQs for untagged collections.-They simply wrap the block in appropriate symbols.--* Lists, `()`-    ```haskell-    EDN.List (items :: [TaggedValue]) =-      [ednList|-        this is a list of symbols, commas are whitespace-      |]-    ```-* Vectors, `[]`-    ```haskell-    EDN.Vec (items :: Vector TaggedValue) =-      [ednVec|-        42 is #the/answer true-      |]-    ```-* Sets, `#{}`-    ```haskell-    EDN.Set (items :: Set TaggedValue) =-      [ednSet|-        badger badger badger badger-        badger badger badger badger-        mushroom mushroom-      |]-    ```-* Maps, `{}`-    ```haskell-    EDN.Map (dict :: Map TaggedValue TaggedValue) =-      [ednMap|-        :keywords "as you like it"-        or/symbols "I won't judge"-        #uuid "d748ab62-9cb1-41fb-b8dc-e23f3ffc5f9b"-        (tagged values, collections, anything goes)-      |]-    ```--### EDN as DSL syntax--You can add quasiquoters for your values by specializing `fromEDN` QuasiQuoter.--> Usual TH shenanigans apply.-> Define things in a separate module.-> Either `Data.Data.Data` or `Language.Haskell.TH.Syntax.Lift` instance required to convert values to Haskell AST.--```haskell-module My.Data.QQ (myData) where--import Data.EDN.QQ (fromEDN)-import My.Data.Types (MyData)--myData :: QuasiQuoter-myData = fromEDN @MyData-```--```haskell-module Main where--import My.Data.QQ (myData)--main :: IO ()-main = cobc-  [myData|-    {:identification-division-        [#program/id hello]-     :procedure-division-        ((display "Hello, world!"-          end-display)-         stop-run-        )-    }-  |] ```
hedn.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: ca74a2494ad480664d2ec10fd783cd811fee1231966abb8f2415d6c92159be1a+-- hash: 3422cbfa0f065b597c1a18d7b765dcd6ddddbea6b62aceab67212f90c480a468  name:           hedn-version:        0.2.0.0+version:        0.2.0.1 synopsis:       EDN parsing and encoding description:    A EDN parsing and encoding library.                 .@@ -59,7 +59,7 @@     , template-haskell >=2.11 && <3     , text >=1.2 && <2     , time >=1.6 && <2-    , uuid >=1.3 && <2+    , uuid-types >=1.0 && <2     , vector >=0.11 && <1   default-language: Haskell2010 @@ -84,6 +84,6 @@     , megaparsec >=7.0 && <8     , text >=1.2 && <2     , time >=1.6 && <2-    , uuid >=1.3 && <2+    , uuid-types >=1.0 && <2     , vector >=0.11 && <1   default-language: Haskell2010
lib/Data/EDN/AST/Printer.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE LambdaCase #-}+{-# LANGUAGE LambdaCase        #-} {-# LANGUAGE OverloadedStrings #-}  module Data.EDN.AST.Printer@@ -54,7 +54,7 @@       _ ->         case show char of           '\'' : '\\' : _ ->-            pretty (printf "u%04X" (ord char) :: [Char])+            pretty (printf "u%04X" (ord char) :: String)           _ ->             pretty char   EDN.Symbol "" name ->
lib/Data/EDN/AST/Types/Tagged.hs view
@@ -1,5 +1,5 @@ {-# LANGUAGE DeriveDataTypeable #-}-{-# LANGUAGE DeriveFunctor #-}+{-# LANGUAGE DeriveFunctor      #-}  module Data.EDN.AST.Types.Tagged   ( Tagged(..)@@ -9,10 +9,10 @@ import Data.Data (Data)  data Tagged tag a-  = Tagged !tag !tag !a-  | NoTag !a+  = Tagged !tag !tag !a -- ^ @ #prefix/tag value @+  | NoTag !a            -- ^ @             value @   deriving (Eq, Ord, Show, Data, Functor)  stripTag :: Tagged tag a -> a-stripTag (NoTag value) = value+stripTag (NoTag value)           = value stripTag (Tagged _ns _tag value) = value
lib/Data/EDN/AST/Types/Value.hs view
@@ -17,27 +17,27 @@ import Data.Foldable (toList) import Data.Text (Text) -import qualified Data.Vector as V import qualified Data.Map.Strict as M import qualified Data.Set as S+import qualified Data.Vector as V  import Data.EDN.AST.Types.Tagged (Tagged)  type TaggedValue = Tagged Text Value  data Value-  = Nil-  | Boolean   !Bool-  | String    !Text-  | Character !Char-  | Symbol    !Text !Text-  | Keyword   !Text-  | Integer   !Int-  | Floating  !Double-  | List      !EDNList-  | Vec       !EDNVec-  | Map       !EDNMap-  | Set       !EDNSet+  = Nil                   -- ^ @ nil               @+  | Boolean   !Bool       -- ^ @ true | false      @+  | String    !Text       -- ^ @ "a string"        @+  | Character !Char       -- ^ @ \c                @+  | Symbol    !Text !Text -- ^ @ a-prefix/a-symbol @+  | Keyword   !Text       -- ^ @ :a-keyword        @+  | Integer   !Int        -- ^ @ 42                @+  | Floating  !Double     -- ^ @ 3.14              @+  | List      !EDNList    -- ^ @ (a list)          @+  | Vec       !EDNVec     -- ^ @ [a vector]        @+  | Map       !EDNMap     -- ^ @ {:a map}          @+  | Set       !EDNSet     -- ^ @ #{a set}          @   deriving (Eq, Ord, Show, Data)  type EDNList = [TaggedValue]
lib/Data/EDN/Class.hs view
@@ -1,7 +1,7 @@-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE LambdaCase #-}-{-# LANGUAGE OverloadedLists #-}-{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE FlexibleInstances    #-}+{-# LANGUAGE LambdaCase           #-}+{-# LANGUAGE OverloadedLists      #-}+{-# LANGUAGE OverloadedStrings    #-} {-# LANGUAGE TypeSynonymInstances #-}  module Data.EDN.Class@@ -39,19 +39,19 @@  import Control.Applicative ((<|>)) import Data.Map (Map)-import Data.Set (Set)-import Data.Vector (Vector)-import Data.Void (Void, absurd) import Data.Semigroup ((<>))+import Data.Set (Set) import Data.Text (Text) import Data.Time (UTCTime, defaultTimeLocale, formatTime, parseTimeM)-import Data.UUID (UUID)+import Data.UUID.Types (UUID)+import Data.Vector (Vector)+import Data.Void (Void, absurd)  import qualified Data.Map as Map import qualified Data.Set as Set import qualified Data.Text as Text import qualified Data.Text.Lazy as LText-import qualified Data.UUID as UUID+import qualified Data.UUID.Types as UUID import qualified Data.Vector as Vector  import Data.EDN.AST.Printer (renderText)@@ -107,7 +107,7 @@   toEDNv = EDN.Floating  instance ToEDN a => ToEDN (Maybe a) where-  toEDN Nothing = EDN.NoTag EDN.Nil+  toEDN Nothing  = EDN.NoTag EDN.Nil   toEDN (Just a) = toEDN a  instance ToEDN a => ToEDN [a] where
lib/Data/EDN/Class/Parser.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE DeriveFunctor #-} {-# LANGUAGE RankNTypes #-}  -- | Generic continuation-based parser
lib/Data/EDN/QQ.hs view
@@ -1,10 +1,10 @@ {-# LANGUAGE AllowAmbiguousTypes #-}-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE LambdaCase #-}-{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE FlexibleInstances   #-}+{-# LANGUAGE LambdaCase          #-}+{-# LANGUAGE OverloadedStrings   #-} {-# LANGUAGE ScopedTypeVariables #-}-{-# LANGUAGE TemplateHaskell #-}-{-# LANGUAGE TypeApplications #-}+{-# LANGUAGE TemplateHaskell     #-}+{-# LANGUAGE TypeApplications    #-}  -- XXX: Lift instances. Don't want to pollute main module with TH shenanigans. {-# OPTIONS_GHC -fno-warn-orphans #-}@@ -28,7 +28,7 @@ import qualified Data.Text as Text import qualified Data.Vector as Vector -import Data.EDN (FromEDN, parseText, decodeText)+import Data.EDN (FromEDN, decodeText, parseText) import Data.EDN.AST.Types (Tagged(..), Value(..))  -- | Quasiquoter for 'Data.EDN.TaggedValue'.
tests/Data/EDN/AST/Gen.hs view
@@ -4,17 +4,17 @@   ( module Data.EDN.AST.Gen   ) where -import Data.Text (Text) import Data.Function (on) import Data.List (nubBy)+import Data.Text (Text) import Hedgehog (Gen)  import qualified Data.Text as Text import qualified Hedgehog.Gen as Gen import qualified Hedgehog.Range as Range -import qualified Data.EDN.AST.Types as EDN import qualified Data.EDN.AST.Parser as EDN+import qualified Data.EDN.AST.Types as EDN  genTaggedValue :: Gen EDN.TaggedValue genTaggedValue = genTagged genValue@@ -36,7 +36,7 @@       <$> pure ""       <*> genTagIdent       <*> gen-    +     withoutTag = EDN.NoTag <$> gen  genTagIdent :: Gen Text@@ -81,7 +81,7 @@   <$> Gen.unicode  genInteger :: Gen EDN.Value-genInteger = (EDN.Integer . fromIntegral)+genInteger = EDN.Integer . fromIntegral   <$> Gen.int64 Range.exponentialBounded  genFloating :: Gen EDN.Value
tests/Data/EDN/Class/Gen.hs view
@@ -1,5 +1,3 @@-{-# LANGUAGE OverloadedStrings #-}- -- TODO: generate values for types with EDN instances  module Data.EDN.Class.Gen
tests/Data/EDN/Class/Test.hs view
@@ -16,7 +16,7 @@   ) import Data.Text (Text) import Data.Time (UTCTime, defaultTimeLocale, parseTimeOrError)-import Data.UUID (UUID)+import Data.UUID.Types (UUID) import Data.Void (Void)  import qualified Data.Vector as Vector