ColoredPrintf icon indicating copy to clipboard operation
ColoredPrintf copied to clipboard

F# 5 string interpolation

Open AlexZeitler opened this issue 4 years ago • 4 comments

👋 Is ColoredPrintf expected to work with F# 5 string interpolation?

(tasks
   |> Array.iter (fun t -> colorprintf $"$gray[{t.Title}]"))

throws this error

Unhandled exception. System.Exception: Expected function with 1 arguments
   at BlackFox.MasterOfFoo.Core.PrintfBuilding.go@356-3(Int32 n, Type[] buf, Type ty, Int32 i)
   at BlackFox.MasterOfFoo.Core.PrintfBuilding.extractCurriedArguments(Type ty, Int32 n)
   at BlackFox.MasterOfFoo.Core.PrintfBuilding.PrintfBuilder`3.parseFromFormatSpecifier(PrintableElement prefix, String s, Type funcTy, Int32 i)
   at BlackFox.MasterOfFoo.Core.PrintfBuilding.PrintfBuilder`3.parseFormatString(String s, Type funcTy)
   at BlackFox.MasterOfFoo.Core.PrintfBuilding.PrintfBuilder`3.Build[T](String s)
   at BlackFox.MasterOfFoo.Core.PrintfCache.Cache`4.generate(String fmt)
   at [email protected](String delegateArg0)
   at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
   at BlackFox.MasterOfFoo.MasterOfFooModule.doPrintfFromEnv[Printer,State,Residue,Result,a](PrintfFormat`4 format, a env)

AlexZeitler avatar May 04 '21 11:05 AlexZeitler

Hi, not really this would need to essentially bump MasterOfFoo I think.

The principle of MasterOfFoo is that it's pretty much part of the code of the F# compiler extracted in a library. And for that to work the new code in the F# 5 compiler with string interpolation support need to be integrated into MasterOfFoo.

vbfox avatar May 04 '21 12:05 vbfox

Thanks, understood. Do you plan to support it in the future?

AlexZeitler avatar May 04 '21 23:05 AlexZeitler

I took a stab at it and it seem to work but need more testing especially around version compatibility as it isn't very documented how FSharp.Core / Compiler / Runtime interacts here.

Anyway you can follow the progress on https://github.com/vbfox/MasterOfFoo/pull/5

vbfox avatar May 10 '21 07:05 vbfox

Thanks

AlexZeitler avatar May 10 '21 14:05 AlexZeitler