packages feed

ihaskell-parsec 0.2.1.0 → 0.3.0.0

raw patch · 2 files changed

+27/−28 lines, 2 filesdep +textdep −classy-preludedep ~base

Dependencies added: text

Dependencies removed: classy-prelude

Dependency ranges changed: base

Files

IHaskell/Display/Parsec.hs view
@@ -1,23 +1,26 @@-{-# LANGUAGE NoImplicitPrelude, TypeSynonymInstances, QuasiQuotes, FlexibleInstances, OverloadedStrings #-}+{-# LANGUAGE TypeSynonymInstances, QuasiQuotes, FlexibleInstances, OverloadedStrings #-}+ module IHaskell.Display.Parsec () where -import ClassyPrelude hiding (fromList)-import System.Random-import Data.String.Here-import Data.HashMap.Strict as Map+import           System.Random+import           Data.String.Here+import           Data.HashMap.Strict as Map+import           Control.Applicative ((<$>)) -import Text.Parsec (parse, sourceLine, sourceColumn)---import Text.Parsec.Prim (Parser)-import Text.Parsec.String (Parser)-import Text.Parsec.Error (errorPos, ParseError)+import qualified Data.Text as T+import           Data.Text (Text) -import Data.Aeson+import           Text.Parsec (parse, sourceLine, sourceColumn)+import           Text.Parsec.String (Parser)+import           Text.Parsec.Error (errorPos, ParseError) -import IHaskell.Display+import           Data.Aeson +import           IHaskell.Display+ instance Show a => IHaskellDisplay (Parser a) where   display renderable = return $ many [Display [javascript js], Display [html dom]]-    where +    where       dom = [hereFile|widget.html|]       js = [hereFile|widget.js|] @@ -26,28 +29,24 @@  instance FromJSON ParseText where   parseJSON (Object v) = ParseText <$> v .: "text"-  parseJSON _          = fail "Expecting object"+  parseJSON _ = fail "Expecting object"  -- | Output of parsing. instance Show a => ToJSON (Either ParseError a) where-  toJSON (Left err) = object [-                        "status" .= ("error" :: String),-                        "line" .= sourceLine (errorPos err),-                        "col" .= sourceColumn (errorPos err),-                        "msg" .= show err-                      ]-  toJSON (Right result) = object [-                               "status" .= ("success" :: String),-                               "result" .= show result-                            ]+  toJSON (Left err) = object+                        [ "status" .= ("error" :: String)+                        , "line" .= sourceLine (errorPos err)+                        , "col" .= sourceColumn (errorPos err)+                        , "msg" .= show err+                        ]+  toJSON (Right result) = object ["status" .= ("success" :: String), "result" .= show result]  instance Show a => IHaskellWidget (Parser a) where   -- Name for this widget.   targetName _ = "parsec"-   -- When we rece   comm widget (Object dict) publisher = do     let key = "text" :: Text         Just (String text) = Map.lookup key dict-        result = parse widget "<interactive>" $ unpack text+        result = parse widget "<interactive>" $ T.unpack text     publisher $ toJSON result
ihaskell-parsec.cabal view
@@ -7,7 +7,7 @@ -- PVP summary:      +-+------- breaking API changes --                   | | +----- non-breaking API additions --                   | | | +--- code changes with no API change-version:             0.2.1.0+version:             0.3.0.0  -- A short (one-line) description of the package. synopsis:            IHaskell display instances for Parsec@@ -58,10 +58,10 @@               OverloadedStrings                 -- Other library packages from which modules are imported.-  build-depends:       base ==4.6.* || ==4.7.*,+  build-depends:       base >=4.6 && <4.9,                        aeson >=0.7 && <0.9,+                       text,                        unordered-containers,-                       classy-prelude,                        random >= 1,                        parsec,                        here,