Added https://learn.microsoft.com/en-us/aspnet/core/tutorials/min-web-api?view=aspnetcore-7.0&tabs=visual-studio#examine-the-get-endpoints - minimal clojure-clr example to potion. https://github.com/Dangercoder/potion/tree/master/examples/dotnet-api.
I think the new .NET framework and how things are built makes things way more easier to consume from a functional programming language like clojure-clr. No more classes and inheritance is needed.
We need some better interop, the only thing that's "blocking me" from using this in anger is async/await.
• There's no way to await a task. Sometimes the frameworks/libraries gives you a task. example: https://github.com/Dangercoder/potion/blob/master/examples/dotnet-api/src/dotnet_api/main.cljr#L69
Imagine this:
C#
app.MapGet("/todoitems", async (TodoDb db) =>
await db.Todos.ToListAsync());
Clojure-CLR (with better interop capabilities)
(.MapGet app "/todoitems", ^:async (fn [^TodoDb db]
(await (-> db
.-Todos
(.ToListAsync)))))
I'm trying to get it ClojureCLR to work in Linqpad (5 - the .NET Framework version) because I think this could be a really good playground for it. I'm getting this error with the latest Clojure + Spec:
Here is the Linqpad file:
I tried adding this code before the call to the clojure api, since it looked the files are not the folder the clojure code expects, but I get the same error.
string baseDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
foreach (var nugetRef in Util.CurrentQuery.NuGetReferences) {
foreach (var asmPath in nugetRef.GetAssemblyReferences()) {
var filename = Path.GetFileName(asmPath);
try {
File.Copy(asmPath, Path.Combine(baseDir, filename));
} catch (IOException ex) when (ex.HResult == -2147024816 /* file exists */) {
}
}
}Just tested with Linqpad 7 (the .NET 5+ , non-framework version), and that does work. Very cool.