@@ -68,29 +68,31 @@ addMain mode graph home _ state =
68-- GENERATE FOR REPL
68-- GENERATE FOR REPL
71−generateForRepl :: Opt.Graph -> I.Interface -> ModuleName.Canonical -> N.Name -> B.Builder
71+generateForRepl :: Bool -> Opt.Graph -> I.Interface -> ModuleName.Canonical -> N.Name -> B.Builder
72−generateForRepl (Opt.Graph _ graph _) iface home name =
72+generateForRepl ansi (Opt.Graph _ graph _) iface home name =
74 mode = Mode.dev Mode.Client
74 mode = Mode.dev Mode.Client
75 debugState = addGlobal mode graph emptyState (Opt.Global ModuleName.debug "toString")
75 debugState = addGlobal mode graph emptyState (Opt.Global ModuleName.debug "toString")
76 evalState = addGlobal mode graph debugState (Opt.Global home name)
76 evalState = addGlobal mode graph debugState (Opt.Global home name)
78− stateToBuilder evalState <> print home name (I._types iface ! name)
78+ stateToBuilder evalState <> print ansi home name (I._types iface ! name)
81−print :: ModuleName.Canonical -> N.Name -> Can.Annotation -> B.Builder
81+print :: Bool -> ModuleName.Canonical -> N.Name -> Can.Annotation -> B.Builder
82−print home name annotation =
82+print ansi home name annotation =
84 value = Name.toBuilder (Name.fromGlobal home name)
84 value = Name.toBuilder (Name.fromGlobal home name)
85− toString = Name.toBuilder (Name.fromKernel N.debug "toString")
85+ toString = Name.toBuilder (Name.fromKernel N.debug "toAnsiString")
86 tipe = Type.toDoc Type.None (Extract.fromAnnotation annotation)
86 tipe = Type.toDoc Type.None (Extract.fromAnnotation annotation)
87+ bool = if ansi then "true" else "false"
88− "var _value = " <> toString <> "(" <> value <> ");\n" <>
89+ "var _value = " <> toString <> "(" <> bool <> ", " <> value <> ");\n\
89− "var _type = " <> B.stringUtf8 (show (D.toString tipe)) <> ";\n\
90+ \var _type = " <> B.stringUtf8 (show (D.toString tipe)) <> ";\n\
91+ \function _print(t) { console.log(_value + (" <> bool <> " ? '\x1b[90m' + t + '\x1b[0m' : t)); }\n\
90 \if (_value.length + 3 + _type.length >= 80 || _type.indexOf('\\n') >= 0) {\n\
92 \if (_value.length + 3 + _type.length >= 80 || _type.indexOf('\\n') >= 0) {\n\
91− \ console.log(_value + '\\n : ' + _type.split('\\n').join('\\n '));\n\
93+ \ _print('\\n : ' + _type.split('\\n').join('\\n '));\n\
92 \} else {\n\
94 \} else {\n\
93− \ console.log(_value + ' : ' + _type);\n\
95+ \ _print(' : ' + _type);\n\