dp wiz avatar dp wiz committed 6074dee

export conversion functions

Comments (0)

Files changed (2)

     Value(..), TaggedValue, Tagged(..),
 
     -- ** Type conversion
-    ToEDN, FromEDN,
+    ToEDN, FromEDN, toEDN, fromEDN, fromEDNv,
 
     -- * Tag manipulation
     setTag, getTag, stripTag,
 ) where
 
 import Data.EDN.Types
-import Data.EDN.Types.Class (FromEDN, ToEDN)
+import Data.EDN.Types.Class (FromEDN, ToEDN, toEDN, fromEDN, fromEDNv)
 import Data.EDN.Encode (encode, fromValue, fromTagged)
 import Data.EDN.Parser (decode, parseValue, parseTagged)

src/Data/EDN/Types/Class.hs

 {-# LANGUAGE OverloadedStrings, FlexibleInstances #-}
 
-module Data.EDN.Types.Class where
+module Data.EDN.Types.Class (
+    ToEDN, FromEDN, toEDN, fromEDN, fromEDNv
+) where
 
 import Control.Applicative (pure, (<$>))
 import qualified Data.Text as T
 import qualified Data.Set as S
 import qualified Data.Map as M
 
-import Data.Parser as P
+import qualified Data.Parser as P
 import qualified Data.EDN.Types as E
 
 class ToEDN a where
 instance FromEDN E.TaggedValue where
     parseEDN = pure
 
+-- | Convert a value from 'E.TaggedValue', failing if the types do not match.
+fromEDN :: FromEDN a => E.TaggedValue -> P.Result a
+fromEDN = P.parse parseEDN
+{-# INLINE fromEDN #-}
+
+-- | Convert a value from 'E.Value', failing if the types do not match.
+fromEDNv :: FromEDN a => E.Value -> P.Result a
+fromEDNv = P.parse parseEDNv
+{-# INLINE fromEDNv #-}
+
 -- | Fail parsing due to a type mismatch, with a descriptive message.
 typeMismatch :: String -- ^ The name of the type you are trying to parse.
              -> E.Value -- ^ The actual value encountered.
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.