Compare commits

..

No commits in common. "0d7c9651b0ebba980787d020dc8a9fa357172f9b" and "cabfbf46ac3ae722dabcea78e365d40a7a68b650" have entirely different histories.

8 changed files with 8 additions and 58 deletions

3
.gitmodules vendored
View file

@ -1,3 +0,0 @@
[submodule "3rdparty/pretty-parse"]
path = 3rdparty/pretty-parse
url = https://git.jossco.de/vegowotenks/pretty-parse

@ -1 +0,0 @@
Subproject commit 5e91f4b67e2588b6f0b9a94c7d03608aad0eb41a

View file

@ -1,41 +1,9 @@
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingVia #-}
module Main (main) where
-- meta
import GHC.Generics (Generic, Generically(..))
-- containers
import Data.Text (Text)
-- classes
import Control.Monad ((<$!>))
import Pretty.Serialize (serialize, PrettySerialize)
-- json
import qualified Data.Text as Text
import qualified Data.Text.IO as TextIO
import qualified Language.Json as Json
import Language.Json.Parser (runParser)
import qualified Language.Json as Json
import qualified Language.Json.Type as Json
-- io
import qualified Data.Text.IO as TextIO
import qualified Data.Text.Lazy.IO as LazyTextIO
data JsonInfo = JsonInfo
{ json :: Json.Value
, inferredType :: Json.Type
}
deriving stock (Generic)
deriving PrettySerialize via Generically JsonInfo
main :: IO ()
main = do
info <- mkJsonInfo <$!> TextIO.getContents
LazyTextIO.putStrLn . serialize $ info
mkJsonInfo :: Text -> Maybe JsonInfo
mkJsonInfo input = do
(_, value) <- runParser Json.document input
pure $ JsonInfo {json=value, inferredType=Json.infer value}
main = TextIO.interact (Text.pack . show . runParser Json.document)

View file

@ -31,7 +31,6 @@ library
array
, base >=4.7 && <5
, containers
, pretty-parse
, text
default-language: Haskell2010
@ -47,7 +46,6 @@ executable hon-exe
, base >=4.7 && <5
, containers
, hon
, pretty-parse
, text
default-language: Haskell2010
@ -64,6 +62,5 @@ test-suite hon-test
, base >=4.7 && <5
, containers
, hon
, pretty-parse
, text
default-language: Haskell2010

View file

@ -23,7 +23,6 @@ dependencies:
- base >= 4.7 && < 5
- containers
- text
- pretty-parse
ghc-options:
- -Wall

View file

@ -1,8 +1,6 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE DeriveGeneric #-}
module Language.Json (Value(..), null, true, false, boolean, buildInteger, number, document) where
import Data.Text (Text)
import Data.Array.IArray (Array)
@ -23,8 +21,6 @@ import qualified Data.Text.Internal.Read as Text
import qualified Debug.Trace as Debug
import qualified Data.Array.IArray as Array
import qualified Data.Map.Strict as Map
import GHC.Generics ( Generic, Generically(..) )
import Pretty.Serialize (PrettySerialize)
data Value
@ -34,8 +30,7 @@ data Value
| Number Rational
| Array (Array Natural Value)
| Object (Map Text Value)
deriving (Show, Generic)
deriving PrettySerialize via Generically Value
deriving Show
null :: Parser Value
null = do

View file

@ -1,8 +1,7 @@
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE InstanceSigs #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE DeriveGeneric #-}
module Language.Json.Type (infer, Type(..)) where
module Language.Json.Type (infer) where
import Data.Map.Strict (Map)
import Data.Text (Text)
import Data.Set (Set)
@ -11,8 +10,6 @@ import qualified Data.Map.Merge.Strict as Map
import qualified Language.Json as Json
import qualified Language.Json as Value
import qualified Data.Foldable as Foldable
import GHC.Generics (Generic, Generically(..))
import Pretty.Serialize (PrettySerialize)
data Type
= Null
@ -23,8 +20,7 @@ data Type
| Array Type
| Union (Set Type) -- multiple types are allowed here
| Object (Map Text Type)
deriving stock (Show, Ord, Eq, Generic)
deriving PrettySerialize via Generically Type
deriving stock (Show, Ord, Eq)
instance Semigroup Type where
(<>) :: Type -> Type -> Type

View file

@ -32,7 +32,6 @@ compiler: ghc-9.12.1
# - wai
packages:
- .
- 3rdparty/pretty-parse
# Dependency packages to be pulled from upstream that are not in the snapshot.
# These entries can reference officially published versions as well as
# forks / in-progress versions pinned to a git hash. For example: