@@ -22,13 +22,15 @@ import Control.Effect.State
22
22
import Control.Monad ((<=<) , guard )
23
23
import qualified Data.Core as Core
24
24
import Data.File
25
+ import Data.Foldable (foldl' )
25
26
import Data.Function (fix )
26
27
import qualified Data.IntMap as IntMap
27
28
import qualified Data.IntSet as IntSet
28
29
import Data.Loc
29
30
import qualified Data.Map as Map
30
31
import Data.Monoid (Alt (.. ))
31
- import Data.Name
32
+ import Data.Name hiding (fresh )
33
+ import Data.Term
32
34
import Data.Text (Text , pack )
33
35
import Prelude hiding (fail )
34
36
@@ -39,7 +41,7 @@ newtype FrameId = FrameId { unFrameId :: Precise }
39
41
deriving (Eq , Ord , Show )
40
42
41
43
data Concrete
42
- = Closure Loc Name Core. Core Precise
44
+ = Closure Loc Name ( Term Core. Core Name ) Precise
43
45
| Unit
44
46
| Bool Bool
45
47
| String Text
@@ -61,22 +63,24 @@ type Heap = IntMap.IntMap Concrete
61
63
62
64
-- | Concrete evaluation of a term to a value.
63
65
--
64
- -- >>> map fileBody (snd (concrete [File (Loc "bool" emptySpan) (Core.Bool True)]))
66
+ -- >>> map fileBody (snd (concrete [File (Loc "bool" emptySpan) (Core.bool True)]))
65
67
-- [Right (Bool True)]
66
- concrete :: [File Core. Core ] -> (Heap , [File (Either (Loc , String ) Concrete )])
68
+ concrete :: [File ( Term Core. Core Name ) ] -> (Heap , [File (Either (Loc , String ) Concrete )])
67
69
concrete
68
70
= run
69
71
. runFresh
72
+ . runNaming
70
73
. runHeap
71
74
. traverse runFile
72
75
73
76
runFile :: ( Carrier sig m
74
77
, Effect sig
75
78
, Member Fresh sig
79
+ , Member Naming sig
76
80
, Member (Reader FrameId ) sig
77
81
, Member (State Heap ) sig
78
82
)
79
- => File Core. Core
83
+ => File ( Term Core. Core Name )
80
84
-> m (File (Either (Loc , String ) Concrete ))
81
85
runFile file = traverse run file
82
86
where run = runReader (fileLoc file)
@@ -200,10 +204,7 @@ addressStyle heap = (G.defaultStyle vertex) { G.edgeAttributes }
200
204
Obj _ -> " {}"
201
205
showPos (Pos l c) = pack (show l) <> " :" <> pack (show c)
202
206
fromName (User s) = s
203
- fromName (Gen sym) = fromGensym sym
204
- fromName (Path p) = pack $ show p
205
- fromGensym (Root s) = s
206
- fromGensym (ss :/ (s, i)) = fromGensym ss <> " ." <> s <> pack (show i)
207
+ fromName (Gen (Gensym ss i)) = foldl' (\ ss s -> ss <> " ." <> s) (pack (show i)) ss
207
208
208
209
data EdgeType
209
210
= Edge Core. Edge
0 commit comments