Skip to content

Commit

Permalink
lts-19.24
Browse files Browse the repository at this point in the history
  • Loading branch information
ishiy1993 committed Sep 20, 2022
1 parent a84f58e commit ee75cbd
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ jobs:
- 'lts-13'
- 'lts-14'
- 'lts-15'
- 'lts-16'
- 'lts-17'
- 'lts-18'
- 'lts-19'
- 'nightly'
steps:
- uses: actions/checkout@v2
Expand Down
6 changes: 3 additions & 3 deletions src/Text/Haiji/Dictionary.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ module Text.Haiji.Dictionary
, retrieve
) where

import Data.Aeson
import Data.Aeson (ToJSON(..), Value(..), encode, object, (.=))
import Data.Dynamic
import qualified Data.HashMap.Strict as M
import Data.Maybe
#if MIN_VERSION_base(4,11,0)
#else
import Data.Monoid
#endif
import qualified Data.Text as T
import Data.String (fromString)
import qualified Data.Text.Lazy as LT
import qualified Data.Text.Lazy.Encoding as LT
import Data.Type.Bool
Expand Down Expand Up @@ -74,7 +74,7 @@ instance ToJSON (Dict '[]) where
instance (ToJSON (Dict d), ToJSON v, KnownSymbol k, Typeable v) => ToJSON (Dict ((k :-> v) ': d)) where
toJSON dict = Object (a <> b) where
(x, v, xs) = headKV dict
Object a = object [ T.pack (keyVal x) .= v ]
Object a = object [ fromString (keyVal x) .= v ]
Object b = toJSON xs
headKV :: (KnownSymbol k, Typeable v) => Dict ((k :-> v) ': d) -> (Key k, v, Dict d)
headKV (Dict d) = (k, fromJust $ fromDynamic $ d M.! keyVal k, Dict $ M.delete (keyVal k) d) where
Expand Down
13 changes: 7 additions & 6 deletions src/Text/Haiji/Runtime.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ import Control.Applicative
#endif
import Control.Monad.Trans.Reader
import qualified Data.Aeson as JSON
import qualified Data.Aeson.KeyMap as JSON
import qualified Data.Aeson.Types as JSON
import Data.Maybe
import qualified Data.HashMap.Strict as HM
import Data.Scientific
import Data.String (fromString)
import qualified Data.Text as T
import qualified Data.Text.Lazy as LT
import qualified Data.Vector as V
Expand Down Expand Up @@ -71,8 +72,8 @@ haijiAST env parentBlock children (Foreach k xs loopBody elseBody) =
[ runReader (haijiASTs env parentBlock children loopBody)
(let JSON.Object obj = p
in JSON.Object
$ HM.insert "loop" (loopVariables len ix)
$ HM.insert (T.pack $ show k) x obj)
$ JSON.insert "loop" (loopVariables len ix)
$ JSON.insert (fromString $ show k) x obj)
| (ix, x) <- zip [0..] (V.toList dicts)
]
else maybe (return "") (haijiASTs env parentBlock children) elseBody
Expand All @@ -89,7 +90,7 @@ haijiAST env parentBlock children (Set lhs rhs scopes) =
do val <- eval rhs
p <- ask
return $ runReader (haijiASTs env parentBlock children scopes)
(let JSON.Object obj = p in JSON.Object $ HM.insert (T.pack $ show lhs) val obj)
(let JSON.Object obj = p in JSON.Object $ JSON.insert (fromString $ show lhs) val obj)

loopVariables :: Integer -> Integer -> JSON.Value
loopVariables len ix = JSON.object [ "first" JSON..= (ix == 0)
Expand All @@ -108,7 +109,7 @@ eval (Expression expression) = go expression where
go (ExprIntegerLiteral n) = return $ JSON.Number $ scientific n 0
go (ExprStringLiteral s) = return $ JSON.String $ T.pack $ unwrap s
go (ExprBooleanLiteral b) = return $ JSON.Bool b
go (ExprVariable v) = either error id . JSON.parseEither (JSON.withObject (show v) (JSON..: (T.pack $ show v))) <$> ask
go (ExprVariable v) = either error id . JSON.parseEither (JSON.withObject (show v) (JSON..: (fromString $ show v))) <$> ask
go (ExprParen e) = go e
go (ExprRange [stop]) = do
sstop <- either error id . JSON.parseEither (JSON.withScientific "range" return) <$> go stop
Expand All @@ -130,7 +131,7 @@ eval (Expression expression) = go expression where
_ -> error "range"
go (ExprRange _) = error "unreachable"
go (ExprAttributed e []) = go e
go (ExprAttributed e attrs) = either error id . JSON.parseEither (JSON.withObject (show $ last attrs) (JSON..: (T.pack $ show $ last attrs))) <$> go (ExprAttributed e $ init attrs)
go (ExprAttributed e attrs) = either error id . JSON.parseEither (JSON.withObject (show $ last attrs) (JSON..: (fromString $ show $ last attrs))) <$> go (ExprAttributed e $ init attrs)
go (ExprFiltered e []) = go e
go (ExprFiltered e filters) = applyFilter (last filters) $ ExprFiltered e $ init filters where
applyFilter FilterAbs e' = either error id . JSON.parseEither (JSON.withScientific "abs" (return . JSON.Number . abs)) <$> go e'
Expand Down
2 changes: 1 addition & 1 deletion stack.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# For more information, see: https://github.com/commercialhaskell/stack/blob/release/doc/yaml_configuration.md

# Specifies the GHC version and set of packages available (e.g., lts-3.5, nightly-2015-09-21, ghc-7.10.2)
resolver: lts-15.2
resolver: lts-19.24

# Local packages, usually specified by relative directory name
packages:
Expand Down

0 comments on commit ee75cbd

Please sign in to comment.