Aelve Codesearch

grep over package repositories
Please provide a string to search for.
3+ characters are required.
Index updated 2 months ago

total matches: 92

bond-0.11.0.3
2 matches
IO.hs
import qualified Data.Text as T
import Language.Bond.Codegen.TypeMapping
import Language.Bond.Parser
import Language.Bond.Syntax.JSON()
import Language.Bond.Syntax.Types (Bond(..))
import Prelude
import System.Directory
import System.Exit
import System.FilePath

            
IO.hs

parseFile :: [FilePath] -> FilePath -> IO(Bond)
parseFile importDirs file =
    if takeExtension file == ".json" then
        parseASTFile file else
        parseBondFile importDirs file


parseBondFile :: [FilePath] -> FilePath -> IO(Bond)

            
concrete-haskell-0.1.0.16
6 matches
src/Data/Concrete/Parsers/JSON.hs
{-# LANGUAGE DeriveGeneric, OverloadedStrings #-}
module Data.Concrete.Parsers.JSON
       ( parseCommunication
       , sequenceSource
       , arraySource
       ) where


            
src/Data/Concrete/Parsers/JSON.hs
import Conduit
import qualified Data.List.NonEmpty as NE

-- | Parses a sequence of JSON objects into a stream
sequenceSource :: Text -> ConduitM () Communication IO ()
sequenceSource = unfoldParse parseCommunication

-- | Parses an array of JSON objects into a stream
arraySource :: Text -> ConduitM () Communication IO ()
arraySource = unfoldParseArray parseCommunication

-- | Parser for turning a single JSON object into a Communication
parseCommunication :: CommunicationParser Communication
parseCommunication = communicationRule id objectP -- >> return default_Communication

jsonP = lexeme' $ choice [nullP, numberP, stringP, boolP, objectP, arrayP]


            
src/Data/Concrete/Parsers/PTB.hs
import Conduit

--sequenceSource = undefined
-- | Parses a sequence of JSON objects into a stream
sequenceSource :: Text -> ConduitM () Communication IO ()
sequenceSource = unfoldParse (communicationRule id (parens (some sentence)))

parser :: CommunicationParser ()
parser = do

            
src/Data/Concrete/Parsers.hs
import Data.Void (Void)
import Data.Vector (Vector, fromList, snoc, empty)
import Data.Concrete.Parsers.Utils (finalizeCommunication)
import qualified Data.Concrete.Parsers.JSON as JSON
import Control.Monad.Identity (Identity(..))
import Data.Conduit.List (unfold)
import Conduit

import Text.Printf (printf)

            
src/Data/Concrete/Parsers.hs
import Data.Text.Lazy.Encoding (decodeUtf8)

-- | List of ingest configurations and default parameters
communicationParsers = [( "JSON-ARRAY"
                        , ( "JSON array of objects"
                          , JSON.arraySource
                          , [ "catchphrase"
                            , "relatives.0.name"
                            ]
                          , "json_${name}"
                          )

            
src/Data/Concrete/Parsers.hs
                          , "json_${name}"
                          )
                        )
                       , ( "JSON-SEQUENCE"
                         , ( "One JSON object per line"
                           , JSON.sequenceSource
                           , [ "author"
                             , "subreddit"
                             ]
                           , "json-lines_${name}"
                           )
                         )
                       , ("CONLL-U"
                         , ( "CONLL-U format"
                           , CONLL.sequenceSource CONLL.ufields

            
curl-runnings-0.11.0
5 matches
src/Testing/CurlRunnings/Internal/Parser.hs

-- | Internal module for parsing string based directives inside of curl runnings
-- suites. Use this module at your own risk, it may change. Currently, string
-- interpolation can be performed, where interpolated values are json quries
-- into responses from past test cases.
--
-- > "$<RESPONSES[0].key[0].another_key>"
--
-- here the `RESPONSES` keyword references the results of previous test cases. Here, the

            
src/Testing/CurlRunnings/Internal/Parser.hs
--
-- here the `RESPONSES` keyword references the results of previous test cases. Here, the
-- whole string is a query, so if the value referenced by this query is itself a
-- json value, the entire value will replace this string in a json matcher.
-- Additionally, interpolation of the form:
--
-- >
-- > "some text to interpolate with $<RESPONSES[0].key.key>"
-- >

            
src/Testing/CurlRunnings/Internal/Parser.hs
-- will substitute a string found at the specified query
-- and subsitute the string.
--
-- Rules for the language are similar to JQ or regular JSON indexing rules. All
-- queries must start with a RESPONSES[integer] index, and be written between a
--
-- >
-- >  $< ... >
-- >

            
src/Testing/CurlRunnings/Internal/Parser.hs

-- | Once we have parsed a query successfully, ensure that it is a legal query
validateQuery :: [InterpolatedQuery] -> Either QueryError [InterpolatedQuery]
-- If we have a json indexing query, it needs to start by indexing the special
-- RESPONSES array
validateQuery q@(InterpolatedQuery _ (Query (CaseResultIndex _:_)):_) = Right q
validateQuery q@(NonInterpolatedQuery  (Query (CaseResultIndex _:_)):_) = Right q
-- If the RESPONSES array is not indexed, it's not valid, as we don't know which
-- response to look at

            
src/Testing/CurlRunnings/Internal/Parser.hs
validateQuery q@(NonInterpolatedQuery  (Query (CaseResultIndex _:_)):_) = Right q
-- If the RESPONSES array is not indexed, it's not valid, as we don't know which
-- response to look at
validateQuery (InterpolatedQuery _ (Query  _):_) = Left $ QueryValidationError "JSON interpolation must begin by indexing into RESPONSES"
validateQuery (NonInterpolatedQuery (Query _):_) = Left $ QueryValidationError "JSON interpolation must begin by indexing into RESPONSES"
-- Otherwise, we're good!
validateQuery q = Right q

type Parser = Parsec Void T.Text


            
dhall-lsp-server-1.0.0
1 matches
src/Dhall/LSP/Handlers.hs

getCommandArguments :: J.FromJSON a => J.ExecuteCommandRequest -> HandlerM a
getCommandArguments request = do
  json <- case request ^. J.params . J.arguments of
    Just (J.List (x : _)) -> return x
    _ -> throwE (Error, "Failed to execute command; arguments missing.")
  case J.fromJSON json of
    J.Success args -> return args
    _ -> throwE (Error, "Failed to execute command; failed to parse arguments.")


-- implements dhall.server.lint

            
elsa-0.2.1.2
5 matches
src/Language/Elsa/UX.hs
import qualified Data.List as L
import           Text.Printf (printf)
import           Text.Megaparsec
import           Text.JSON hiding (Error)
import           Language.Elsa.Utils

type Text = String

class PPrint a where

            
src/Language/Elsa/UX.hs
-- | Usage Mode
--------------------------------------------------------------------------------
data Mode
  = Json
  | Cmdline
  | Server
  deriving (Eq, Show)

--------------------------------------------------------------------------------

            
src/Language/Elsa/UX.hs
--------------------------------------------------------------------------------
renderErrors :: Mode -> [UserError] -> IO Text
--------------------------------------------------------------------------------
renderErrors Json    es = return (renderErrorsJson es)
renderErrors Server  es = return (renderResultJson es)
renderErrors Cmdline es = renderErrorsText es

renderErrorsText :: [UserError] -> IO Text
renderErrorsText [] =

            
src/Language/Elsa/UX.hs
    status _        = showJSON ("unsafe" :: String)


instance JSON UserError where
  readJSON     = undefined
  showJSON err = jObj [ ("start"  , showJSON $ start err)
                      , ("stop"   , showJSON $ stop err )
                      , ("message", showJSON $ eMsg err )
                      ]

            
src/Language/Elsa/UX.hs

jObj = JSObject . toJSObject

instance JSON SourcePos where
  readJSON    = undefined
  showJSON sp = jObj [ ("line"  , showJSON (unPos l))
                     , ("column", showJSON (unPos c))
                     ]
    where

            
hadolint-1.17.1
2 matches
src/Hadolint/Formatter/Json.hs
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE OverloadedStrings #-}

module Hadolint.Formatter.Json
    ( printResult
    , formatResult
    ) where

import Data.Aeson hiding (Result)

            
src/Hadolint/Rules.hs
  where
    code = "DL3025"
    severity = WarningC
    message = "Use arguments JSON notation for CMD and ENTRYPOINT arguments"
    check (Cmd (ArgumentsText _)) = False
    check (Entrypoint (ArgumentsText _)) = False
    check _ = True

noApt :: Rule

            
hledger-web-1.14.1
1 matches
Hledger/Web/Widget/AddForm.hs
import qualified Data.Text as T
import Data.Time (Day)
import Text.Blaze.Internal (Markup, preEscapedString)
import Text.JSON
import Text.Megaparsec (bundleErrors, eof, parseErrorTextPretty, runParser)
import Yesod

import Hledger
import Hledger.Web.Settings (widgetFile)

            
language-conf-0.2.2.0
2 matches
bin/FromConf.hs
                    Left e -> error ("Failed to parse " <> fp <> "\n" <> show e)
                confv = Aeson.toJSON conf
            case takeExtension output of
                ".json" -> ByteString.writeFile output (Aeson.encode confv)
                ".yaml" -> Yaml.encodeFile output confv
                _ -> error "Unsupported output format"
        _ -> error "Usage: fromconf <inputfile> <outputfile>"

            
bin/ToConf.hs
        (fp:output:_) -> do
            mv <- case takeExtension fp of
                ".yaml" -> Yaml.decodeFile fp
                ".json" -> Aeson.decode <$> ByteString.readFile fp
            case mv of
                Just v -> do
                    let conf :: Aeson.Result Conf.Conf
                        conf = Aeson.fromJSON v
                    writeFile output $ show $ case conf of

            
language-puppet-1.4.5
2 matches
src/Hiera/Server.hs
         mkBackend3 name = do
           (backendConstructor, skey) <- case name of
                                             "yaml" -> return (YamlBackend, ":yaml")
                                             "json" -> return (JsonBackend, ":json")
                                             _      -> fail ("Unknown backend " <> toS name)
           datadir <- case Object v ^? key skey . key ":datadir" of
                             Just (String dir) -> return dir
                             Just _            -> fail ":datadir should be a string"
                             Nothing           -> return "/etc/puppet/hieradata"

            
src/Hiera/Server.hs
        let decodeInfo :: (FilePath -> IO (Either String Value), String, String)
            decodeInfo =
              case backend of
                JsonBackend dir -> (fmap Aeson.eitherDecode' . BS.readFile       , dir, ".json")
                YamlBackend dir -> (fmap (_Left %~ show) . Yaml.decodeFileEither, dir, ".yaml")
        pure (decodeInfo, toS h)
  -- step 2, read all the files, returning a raw data structure
  mvals <- liftIO $ forM searchin $ \((decodefunction, datadir, extension), h) -> do
    let extension' = if snd (FilePath.splitExtension h) == ".yaml"

            
mmark-cli-0.0.5.0
2 matches
app/Main.hs
  , optOutputFile :: !(Maybe FilePath)
    -- ^ File to which to save output (otherwise use stdout)
  , optJson :: !Bool
    -- ^ Whether to output JSON
  , optTemplate :: !(Maybe FilePath)
    -- ^ Use the template located at this path

  , optExtComment :: !(Maybe Text)
    -- ^ Enable extension: 'Ext.commentParagraph'

            
app/Main.hs
    , help    "Save rendered HTML document to this file (otherwise write to stdout)"
    ]
  <*> (switch . mconcat)
    [ long    "json"
    , short   'j'
    , help    "Output parse errors and result in JSON format"
    ]
  <*> (optional . strOption . mconcat)
    [ long    "template"
    , short   't'
    , metavar "FILE"

            
penrose-0.1.1.1
2 matches
src/Penrose/Serializer.hs
instance FromJSONKey Var

--------------------------------------------------------------------------------
-- TODO: slowly move all the JSON decls other than the ones in Server to
--       this module
deriveJSON defaultOptions ''SourcePosition

deriveJSON defaultOptions ''Pos


            
src/Penrose/ShadowMain.hs
  let configBstr = decode configStr :: Maybe G.OptConfig
  let optConfig =
        case configBstr of
          Nothing -> error "couldn't read opt config JSON"
          Just x  -> x
  putStrLn "Opt config:\n"
  print optConfig
  let state = initState {G.oConfig = optConfig}
  if useFrontend