@@ -68,29 +68,31 @@ addMain mode graph home _ state =
6868-- GENERATE FOR REPL
6969
7070
71−generateForRepl :: Opt.Graph -> I.Interface -> ModuleName.Canonical -> N.Name -> B.Builder
72−generateForRepl (Opt.Graph _ graph _) iface home name =
71+generateForRepl :: Bool -> Opt.Graph -> I.Interface -> ModuleName.Canonical -> N.Name -> B.Builder
72+generateForRepl ansi (Opt.Graph _ graph _) iface home name =
7373 let
7474 mode = Mode.dev Mode.Client
7575 debugState = addGlobal mode graph emptyState (Opt.Global ModuleName.debug "toString")
7676 evalState = addGlobal mode graph debugState (Opt.Global home name)
7777 in
78− stateToBuilder evalState <> print home name (I._types iface ! name)
78+ stateToBuilder evalState <> print ansi home name (I._types iface ! name)
7979
8080
81−print :: ModuleName.Canonical -> N.Name -> Can.Annotation -> B.Builder
82−print home name annotation =
81+print :: Bool -> ModuleName.Canonical -> N.Name -> Can.Annotation -> B.Builder
82+print ansi home name annotation =
8383 let
8484 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")
8686 tipe = Type.toDoc Type.None (Extract.fromAnnotation annotation)
87+ bool = if ansi then "true" else "false"
8788 in
88− "var _value = " <> toString <> "(" <> value <> ");\n" <>
89− "var _type = " <> B.stringUtf8 (show (D.toString tipe)) <> ";\n\
89+ "var _value = " <> toString <> "(" <> bool <> ", " <> value <> ");\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\
9092 \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\
9294 \} else {\n\
93− \ console.log(_value + ' : ' + _type);\n\
95+ \ _print(' : ' + _type);\n\
9496 \}\n"
9597
9698