F# Data Type Providers in .Net Core (2018)
lukemerrett.com
lukemerrett.com
I still have a lot of love for it though. Especially things like measure types.
I have also been building type providers in Kotlin. Where a gradle plugin scans a file / schema then generates types and DSLs off of it. It's a pragmatic functional language.
The biggest catch to me. Is there are very few places using Kotlin in a fully functional style. On the back end more often than not you'll find Spring. Which undoes a lot of these features / patterns.
Eta might be what you're referring to: https://eta-lang.org/
(there's also Frege, but it's less haskell-y)
Actually this is one of the bytecodes that .NET Native doesn't handle, if I am not mistaken.
I've not seen anything as elegant looking as F# in the .net world before ... What do people think ... -- is F# a good language for a beginner to learn which is also sufficiently well-supported that they could find themselves building useful script-like database (MSSQL) oriented utilities as early project ...?
If your friend is looking into getting into .net for professional purposes, I would steer them towards C# first. That's likely to be much more useful in the long term. Especially since it can be a stepping stone to other C/C++ like languages.
With F# I would bet that they hit some limitation sooner or later where something that could be easily done in C# will take more work in F#. Which could be fine if they have the time/inclination to rough it. I just would not advise F# as a resume builder.
Start with F#. Learn the basics well.
Parent - Checkout
https://fsharpforfunandprofit.com/
https://docs.microsoft.com/en-us/dotnet/fsharp/introduction-...
From my experience of working with both C# and F# for a few years, it's more likely to be the other way around.
It is also not officially supported on UWP, and needs some hacks to the generated MSIL (as .NET Native doesn't cover 100% of all MSIL).
If you attempt to do GUI development, then you are forced to look for community projects like Fabulous, use the XAML type provider with a dummy C#,VB.NET,C++/CLI project for the XAML generation, or actually use one of those languages for the UI, with F# used only for the logic.
So even though I am a big fan of ML language family, at the end of the day, the other .NET languages get the green light from most customers and team.
There's a hope that with F#'s upcoming move to the "shared project system" that a lot of the pains will go away in hopefully the near future.
(That said, Fabulous has piqued my interest and I'm debating rewriting my big F# GUI in it, at least in an exploratory branch.)
For example, try to generate EF 6 Database First code for F#, or use Blend alongside Visual Studio with F#.
> IDE support is much more than just editing text.
In case anyone reading this thread comes away thinking that VS Code + Ionide is only a text editor.
Disclaimer: I'm the author
This will be fixed on Java side, with value specializations as per Valhala roadmap.
Extension methods are also a way to create lots of spaghetti code, trying to track down where the method is actually implemented.
Swift and Kotlin codebases are good examples on how one can go a bit too far with extension methods.
Java's solution is to offer default interface methods as an approach to traits, which was copied by C# 8.
Regarding interfaces, if you mean explicit interface implementations, besides forcing casts everywhere I don't see what is so well thought out about them.
[0] - https://docs.microsoft.com/en-us/archive/blogs/gauravseth/cu...
Extensions methods are great, tracking down the methods that you are calling is super easy in an IDE. The ability to abstract over generic type parameters as well as class subtype is very useful.
Default interface implementations have no connection to extension methods, they solve different problems.
Explicit method implementations are great at avoiding name collisions as well as accidental ones. The coercions needed are not hard casts, though C# could do be improved with a soft cast operator.
In fact, C++/CLI is the only Microsoft language that has full access to all CLR features, not C#.
A language that has a much more expressive OO model than either Java or C#, and requires reiffed generics.
IDEs don't work in code review workflows.
> IDEs don't work in code review workflows.
Use or make better tools.
Thousands of developers use F#, VB.NET, Powershell, C++/CLI every day, and to lesser extent Cobol and Fortran compilers for .NET.
C++/CLI support was a must have requirement for .NET Core adoption, not only because of externals, because all .NET UI Frameworks make use of C++/CLI.
So much for no one really uses.
We use the tools our customers are willing to pay for.
Care to provide a link to a code review tool with IDE like capabilities for code navigation?
The final semantics for specialized value types are not yet set in stone, so what Java might end up supporting is still a guessing game.
Not sure what you're referring to here (you can implement interfaces of other packages in Java), but everything else you mentioned is not related to C#/Java's OO system.
Also, since he is a DBA, he could be introduced to ".NET" via powershell as microsoft has been trying to make powershell the default IT/DBA shell for the windows world. It's like bash for windows but entirely object driven.
You still have to keep that sample updated to handle new runtime data.
Plus, since you can have arbitrary providers, such as a provider that connects to a DB and generates a type-safe "ORM" over your relational database[0] with no configuration other than pointing to the data source you're going to access at runtime. Perfect if you want to write little data transformation scripts.
A "better", certainly more common solution is to generate the type based on whatever source code is generating the JSON, if you have access to it (or have the API provided generate the signature for you).
a) less of a need to deserialize things into specific concrete classes in functional languages
b) it seems to be idiomatic to convert data yourself if you need custom conversions, rather than relying on a library to automagically deduce it. this is helped by how simple doing the manual conversion ends up being in practice.
But anyway - this system feels like when we use T4 to generate types as part of the build process, but more tightly integrated. I wonder if the same could be done for C# using a Roslyn add-in.
Not quite. There's an interface called IProvidedTypes that a component - a Type Provider - is responsible for conforming to. That component reads data of some kind and produces information in that interface. The F# compiler then takes that data and includes it in the set of symbols that it calculates for everything else in your codebase. The end result is that you get typed access to data with zero configuration aside from adding a package, and because this data is exposed to tooling, you get IntelliSense for it in your editor as the blog post shows. The paper about the subject is here: http://tomasp.net/academic/papers/fsharp-data/fsharp-data.pd...
> You still have to keep that sample updated to handle new runtime data.
This is only if you're working with a sample. In most cases, developers just point it at the real data source and program against that - the target URL for a JSON payload, the connection string to the SQL database, etc. There's still issues that can arise, such as a poorly-written Type Provider, but the most popular ones are well-written and won't do silly things like slurp in your whole database into memory.
Honestly, I feel like this should be super cool and I'm just super missing something... but I don't know what right now.
Could you explain the interactive session part more?
Not aware of any mainstream language that provides similar functionality.
This video shows a very advanced and practical way of using "static introspection":
Lambda World 2019 - What FP Can Learn From Static Introspection - Aditya Siram (Deech)
https://www.youtube.com/watch?v=ElHi2h9Ho6M
What if compile time and type level programming in functional programming languages were easy, something you reach for without even thinking about it? What if you could debug type errors with a simple compile time print statement? Write highly flexible systems by being able to introspect into types at compile time? Pre-calculate large portions of your programs for great efficiency?
Typed functional programming is a great and fun way to write resilient software, and as type systems have become more and more expressive in recent years, we are able to program sophisticated and useful properties at the type level for even better compile time safety. Just one problem: It is very difficult, requires advanced knowledge of the type system, the syntax is convoluted, the error messages are impenetrable, and it is nearly impossible to debug.
This talk will dive into why we should steal static introspection from languages like Nim, and D, state-of-the-art imperative programming languages which can solve all these issues, make type systems much more approachable without losing any expressive power, and offer new design possibilities for functional programs.
I would actually remove features from F# not add them if I could.
It’s the perfect language currently available. I use it for low level stuff (working with the new Memory and Span types) and high level stuff (building UIs with FuncUI)
which author of F#, previously, didn't like to add to F#. (Not hating on how he wants the language to evolve)
Default interface methods, not sure about the current support state.
The accessors protected private.
I am also not sure if all low level programming features added to C#, taken from Midori and until C# 7 only usable from C++/CLI, are also exposed to F#.
DIMs are set for .NET 5. Cut from Core 3.0 since quality would have been an issue.
_private_ has been supported in F# for ages; _protected_ is explicitly not supported. I'd personally like to see it supported for interop but this is the language designer's call.
All the low-level programming features added to C# have F# "equivalents", and I use quotes because semantics differ between the languages and so your experience using one or the other is going to be quite different depending on what you're doing. But the performance output will be the same.
Visual Studio tooling support is nowhere to be seen, and the github issue does least some caveats.
[1] https://github.com/louthy/language-ext/blob/master/LanguageE...
If there's a feature that takes time to implement (eg: Type Classes from Haskell or Polymorphic Module from Ocaml), people would rather wait for CLR or IL to support the infrastructures first.
As a result, there are many essential features waiting to be implemented forever.
It's also possible to use F# as a compile-to-js language using Fable. This code would run on Node or the browser.
Then there is https://github.com/dotnet/corert which allows ahead-of-time compilation to native code, but it is a bit more experimental.
https://github.com/jet/JsonSchemaProvider
https://medium.com/jettech/json-schema-type-provider-why-we-...
For example, As a front-end heavy language, talking with other systems is quite ordinary -- a very useful case is reflecting GraphQL or SQL type without code generation.
I picked that article just because it is a very concise explanation, a bit more proper for sharing, than the official documentation, which currently requires a bit of hyperlink-following and generally nonzero familiarity with the language.