Skip to content
This repository was archived by the owner on Apr 1, 2025. It is now read-only.

Commit be842df

Browse files
committed
Represent strings as Text.
1 parent f2a9ebe commit be842df

File tree

6 files changed

+13
-8
lines changed

6 files changed

+13
-8
lines changed

semantic-core/semantic-core.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ library
4747
, prettyprinter-ansi-terminal ^>= 1.1.1
4848
, recursion-schemes ^>= 5.1
4949
, semigroupoids ^>= 5.3
50+
, text ^>= 1.2.3.1
5051
, transformers ^>= 0.5.6
5152
, trifecta ^>= 2
5253
, unordered-containers ^>= 0.2.10

semantic-core/src/Analysis/Concrete.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import Data.Loc
2929
import qualified Data.Map as Map
3030
import Data.Monoid (Alt(..))
3131
import Data.Name
32+
import Data.Text (Text)
3233
import Prelude hiding (fail)
3334

3435
type Precise = Int
@@ -41,7 +42,7 @@ data Concrete
4142
= Closure Loc Name Core.Core Precise
4243
| Unit
4344
| Bool Bool
44-
| String String
45+
| String Text
4546
| Obj Frame
4647
deriving (Eq, Ord, Show)
4748

semantic-core/src/Analysis/Eval.hs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import Data.Functor
2121
import Data.Loc
2222
import Data.Maybe (fromJust)
2323
import Data.Name
24+
import Data.Text (Text, unpack)
2425
import GHC.Stack
2526
import Prelude hiding (fail)
2627

@@ -42,7 +43,7 @@ eval Analysis{..} eval = \case
4243
String s -> string s
4344
Load p -> do
4445
path <- eval p >>= asString
45-
lookupEnv' (Path path) >>= deref' (Path path)
46+
lookupEnv' (Path (unpack path)) >>= deref' (Path (unpack path))
4647
Edge e a -> ref a >>= edge e >> unit
4748
Frame -> frame
4849
a :. b -> do
@@ -207,8 +208,8 @@ data Analysis address value m = Analysis
207208
, unit :: m value
208209
, bool :: Bool -> m value
209210
, asBool :: value -> m Bool
210-
, string :: String -> m value -- FIXME: Text
211-
, asString :: value -> m String
211+
, string :: Text -> m value -- FIXME: Text
212+
, asString :: value -> m Text
212213
, frame :: m value
213214
, edge :: Edge -> address -> m ()
214215
, (...) :: forall a . address -> m a -> m a

semantic-core/src/Analysis/ImportGraph.hs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import Data.Loc
2222
import qualified Data.Map as Map
2323
import Data.Name
2424
import qualified Data.Set as Set
25+
import Data.Text (Text)
2526
import Prelude hiding (fail)
2627

2728
type ImportGraph = Map.Map FilePath (Set.Set FilePath)
@@ -41,7 +42,7 @@ instance Monoid Value where
4142
data Semi
4243
= Closure Loc Name Core.Core Name
4344
-- FIXME: Bound String values.
44-
| String String
45+
| String Text
4546
| Abstract
4647
deriving (Eq, Ord, Show)
4748

@@ -98,7 +99,7 @@ importGraphAnalysis = Analysis{..}
9899
asBool _ = pure True <|> pure False
99100
string s = pure (Value (String s) mempty)
100101
asString (Value (String s) _) = pure s
101-
asString _ = pure ""
102+
asString _ = pure mempty
102103
frame = pure mempty
103104
edge Core.Import (Path to) = do
104105
Loc{locPath=from} <- ask

semantic-core/src/Analysis/Typecheck.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ typecheckingAnalysis = Analysis{..}
160160
bool _ = pure MBool
161161
asBool b = unify MBool b >> pure True <|> pure False
162162
string _ = pure MString
163-
asString s = unify MString s *> pure ""
163+
asString s = unify MString s *> pure mempty
164164
frame = fail "unimplemented"
165165
edge _ _ = pure ()
166166
_ ... m = m

semantic-core/src/Data/Core.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import Data.Foldable (foldl')
2020
import Data.Loc
2121
import Data.Name
2222
import Data.Stack
23+
import Data.Text (Text)
2324
import GHC.Stack
2425

2526
data Edge = Lexical | Import
@@ -36,7 +37,7 @@ data Core
3637
| Unit
3738
| Bool Bool
3839
| If Core Core Core
39-
| String String -- FIXME: Text
40+
| String Text
4041
-- | Load the specified file (by path).
4142
| Load Core
4243
| Edge Edge Core

0 commit comments

Comments
 (0)