Skip to content
This repository has been archived by the owner on Jun 15, 2023. It is now read-only.

Commit

Permalink
Merge pull request #25 from cryogenian/compiler/0.12
Browse files Browse the repository at this point in the history
updates for 0.12, also removed argonaut dep
  • Loading branch information
cryogenian authored Jun 28, 2018
2 parents c1632be + a35f287 commit d83ca24
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 218 deletions.
19 changes: 9 additions & 10 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,16 @@
"package.json"
],
"dependencies": {
"purescript-argonaut": "^3.0.0",
"purescript-bifunctors": "^3.0.0",
"purescript-datetime": "^3.0.0",
"purescript-maps": "^3.0.0",
"purescript-matryoshka": "^0.3.0",
"purescript-newtype": "^2.0.0",
"purescript-parsing": "^4.1.0",
"purescript-precise": "^2.0.0",
"purescript-profunctor-lenses": "^3.2.0"
"purescript-ordered-collections": "^1.0.0",
"purescript-matryoshka": "^0.4.0",
"purescript-bifunctors": "^4.0.0",
"purescript-newtype": "^3.0.0",
"purescript-parsing": "^5.0.1",
"purescript-precise": "^3.0.1",
"purescript-profunctor-lenses": "^4.0.0",
"purescript-datetime": "^4.0.0"
},
"devDependencies": {
"purescript-quickcheck": "^4.4.0"
"purescript-quickcheck": "^5.0.0"
}
}
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
"test": "pulp test"
},
"devDependencies": {
"pulp": "^11.0.0",
"purescript": "^0.11.4",
"purescript-psa": "^0.5.1",
"pulp": "^12.0.0",
"purescript": "^0.12.0",
"purescript-psa": "^0.6.0",
"rimraf": "^2.6.1"
}
}
36 changes: 3 additions & 33 deletions src/Data/Json/Extended.purs
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,11 @@ module Data.Json.Extended
, number
, string
, map
, map'
, array

, renderEJson
, parseEJson
, decodeEJson
, encodeEJson

, arbitraryEJsonOfSize

, getType

, _Null
, _String
, _Boolean
Expand All @@ -28,41 +21,28 @@ module Data.Json.Extended
, _Number
, _Array
, _Map
, _Map'
) where

import Prelude hiding (map)

import Control.Lazy as Lazy
import Data.Argonaut as JS
import Data.Bitraversable (bitraverse)
import Control.Monad.Gen (class MonadGen)
import Control.Monad.Rec.Class (class MonadRec)
import Data.Either as E
import Data.Functor as F
import Data.Functor.Mu as Mu
import Data.HugeInt as HI
import Data.HugeNum as HN
import Data.Json.Extended.Signature as Sig
import Data.Json.Extended.Signature hiding (getType) as Exports
import Data.Json.Extended.Type (EJsonType)
import Data.Lens (Prism', preview, prism')
import Data.Lens (Prism', prism')
import Data.Map as Map
import Data.Maybe as M
import Data.StrMap as SM
import Data.Traversable (for)
import Data.Tuple as T
import Matryoshka (class Corecursive, class Recursive, anaM, cata, embed, project)
import Control.Monad.Gen (class MonadGen)
import Control.Monad.Rec.Class (class MonadRec)
import Text.Parsing.Parser as P

type EJson = Mu.Mu Sig.EJsonF

decodeEJson t. Corecursive t Sig.EJsonF JS.Json E.Either String t
decodeEJson = anaM Sig.decodeJsonEJsonF

encodeEJson t. Recursive t Sig.EJsonF t JS.Json
encodeEJson = cata Sig.encodeJsonEJsonF

arbitraryEJsonOfSize
m t
. MonadGen m
Expand Down Expand Up @@ -103,11 +83,6 @@ array = embed <<< Sig.Array
map t. Corecursive t Sig.EJsonF Map.Map t t t
map = embed <<< Sig.Map <<< Sig.EJsonMap <<< Map.toUnfoldable

map' t. Corecursive t Sig.EJsonF SM.StrMap t t
map' = embed <<< Sig.Map <<< Sig.EJsonMap <<< F.map go <<< SM.toUnfoldable
where
go (T.Tuple a b) = T.Tuple (string a) b

getType t. Recursive t Sig.EJsonF t EJsonType
getType = Sig.getType <<< project

Expand Down Expand Up @@ -151,8 +126,3 @@ _Map ∷ ∀ t. Corecursive t Sig.EJsonF ⇒ Recursive t Sig.EJsonF ⇒ Ord t
_Map = prism' map $ project >>> case _ of
Sig.Map (Sig.EJsonMap kvs) → M.Just $ Map.fromFoldable kvs
_ → M.Nothing

_Map' t. Corecursive t Sig.EJsonF Recursive t Sig.EJsonF Prism' t (SM.StrMap t)
_Map' = prism' map' $ project >>> case _ of
Sig.Map (Sig.EJsonMap kvs) → SM.fromFoldable <$> for kvs (bitraverse (preview _String) pure)
_ → M.Nothing
11 changes: 3 additions & 8 deletions src/Data/Json/Extended/Cursor.purs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import Data.Functor.Mu (Mu)
import Data.Json.Extended (EJson)
import Data.Json.Extended as EJ
import Data.Maybe (Maybe(..), maybe)
import Data.Monoid (mempty)
import Data.Ord (class Ord1)
import Data.TacitString (TacitString)
import Data.Traversable (class Traversable, traverse)
Expand Down Expand Up @@ -48,12 +47,8 @@ data CursorF a
derive instance functorCursorFFunctor CursorF
derive instance eqCursorEq a Eq (CursorF a)
derive instance ordCursorOrd a Ord (CursorF a)

instance eq1CursorFEq1 CursorF where
eq1 = eq

instance ord1CursorFOrd1 CursorF where
compare1 = compare
derive instance eq1CursorFEq1 CursorF
derive instance ord1CursorFOrd1 CursorF

instance showCursorFShow (CursorF TacitString) where
show = case _ of
Expand All @@ -80,7 +75,7 @@ instance traversableCursorF :: Traversable CursorF where
All -> pure All
AtKey k a -> AtKey k <$> f a
AtIndex i a -> AtIndex i <$> f a
sequence = traverse id
sequence = traverse identity

renderEJsonCursor Cursor String
renderEJsonCursor = show
Expand Down
10 changes: 4 additions & 6 deletions src/Data/Json/Extended/Signature.purs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ module Data.Json.Extended.Signature
, module Render
, module Parse
, module Gen
, module Json
) where

import Data.Json.Extended.Signature.Core as Core
import Data.Json.Extended.Signature.Render as Render
import Data.Json.Extended.Signature.Parse as Parse
import Data.Json.Extended.Signature.Gen as Gen
import Data.Json.Extended.Signature.Json as Json
import Data.Json.Extended.Signature.Core (EJsonF(..), EJsonMap(..), getType) as Core
import Data.Json.Extended.Signature.Gen (arbitraryEJsonF) as Gen
import Data.Json.Extended.Signature.Parse (parseArrayLiteral, parseBooleanLiteral, parseDecimalLiteral, parseEJsonF, parseHugeIntLiteral, parseIntLiteral, parseMapLiteral, parseNull, parseStringLiteral) as Parse
import Data.Json.Extended.Signature.Render (renderEJsonF) as Render
3 changes: 1 addition & 2 deletions src/Data/Json/Extended/Signature/Core.purs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ import Prelude
import Data.Bifunctor as BF
import Data.Eq (class Eq1)
import Data.Foldable as F
import Data.HugeNum as HN
import Data.HugeInt as HI
import Data.HugeNum as HN
import Data.Json.Extended.Type as JT
import Data.List as L
import Data.Map as M
import Data.Monoid (mempty)
import Data.Newtype (class Newtype)
import Data.Ord (class Ord1)
import Data.TacitString (TacitString)
Expand Down
115 changes: 0 additions & 115 deletions src/Data/Json/Extended/Signature/Json.purs

This file was deleted.

15 changes: 7 additions & 8 deletions src/Data/Json/Extended/Signature/Parse.purs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ import Data.Int as Int
import Data.Json.Extended.Signature.Core (EJsonF(..), EJsonMap(..))
import Data.List as L
import Data.Maybe as M
import Data.String as S
import Data.String.CodeUnits as SCU
import Data.Traversable (sequence)
import Data.Tuple as T

import Text.Parsing.Parser as P
import Text.Parsing.Parser.Combinators as PC
import Text.Parsing.Parser.String as PS
Expand Down Expand Up @@ -67,7 +66,7 @@ commaSep p = do
pure o

stringInner m . Monad m P.ParserT String m String
stringInner = A.many charAtom <#> S.fromCharArray
stringInner = A.many charAtom <#> SCU.fromCharArray
where
charAtom = PC.tryRethrow do
ch ← PS.anyChar
Expand All @@ -86,10 +85,10 @@ stringInner = A.many charAtom <#> S.fromCharArray
_ → pure ch

hexEscape = do
hex ← S.fromCharArray <$> sequence (A.replicate 4 PT.hexDigit)
case Int.fromStringAs Int.hexadecimal hex of
hex ← SCU.fromCharArray <$> sequence (A.replicate 4 PT.hexDigit)
case Int.fromStringAs Int.hexadecimal hex >>= Char.fromCharCode of
M.NothingP.fail "Expected character escape sequence"
M.Just i → pure $ Char.fromCharCode i
M.Just i → pure i

quoted a m. Monad m P.ParserT String m a P.ParserT String m a
quoted = PC.between quote quote
Expand Down Expand Up @@ -218,7 +217,7 @@ parseHugeNum = do
M.NothingP.fail $ "Failed to parse decimal: " <> str
where
parseDigits =
S.fromCharArray
SCU.fromCharArray
<$> A.many (PS.oneOf ['0','1','2','3','4','5','6','7','8','9'])

parseScientific
Expand All @@ -245,7 +244,7 @@ parseHugeIntLiteral ∷ ∀ m. Monad m ⇒ P.ParserT String m HI.HugeInt
parseHugeIntLiteral = parseSigned (parseNat (HI.fromInt 10) HI.fromInt)

parseIntLiteral m. Monad m P.ParserT String m Int
parseIntLiteral = parseSigned (parseNat 10 id)
parseIntLiteral = parseSigned (parseNat 10 identity)

parseStringLiteral m. Monad m P.ParserT String m String
parseStringLiteral = quoted stringInner
Expand Down
4 changes: 3 additions & 1 deletion src/Data/Json/Extended/Signature/Render.purs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import Data.Foldable as F
import Data.HugeInt as HI
import Data.HugeNum as HN
import Data.Json.Extended.Signature.Core (EJsonF(..), EJsonMap(..))
import Data.String as Str
import Data.String.Pattern (Pattern(..), Replacement(..)) as Str
import Data.String.Common (replaceAll) as Str
import Data.String.CodeUnits (takeWhile) as Str
import Data.Tuple as T
import Matryoshka (Algebra)

Expand Down
Loading

0 comments on commit d83ca24

Please sign in to comment.