Skip to content

Point free stuff gives nullpointer when referenced from another assembly which is a console app with no explicit main method.

License

Notifications You must be signed in to change notification settings

bjartwolf/fsharpnull

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Summary

I think the TIL is that exposing functions in the point free style accross assemblies is not a good idea, but there is something wrong in here with top-level statements and fsharpfunc where something is not initialized properly and throws null pointer. This is the case when referencing a console app without a main method (the default now in dotnet) from a xunit project. If one then exposes something like a let parselines = Array.map parseline unit tests will crash with null pointer.

https://learn.microsoft.com/en-us/dotnet/fsharp/style-guide/conventions#partial-application-and-point-free-programming

F# supports partial application, and thus, various ways to program in a point-free style. This can be beneficial for code reuse within a module or the implementation of something, but it is not something to expose publicly. In general, point-free programming is not a virtue in and of itself, and can add a significant cognitive barrier for people who are not immersed in the style.

fsharpnull

Point free function gives nullpointer when referenced from an project, when the project with the point free function is a console app without an explicit main method.

dotnet run --project .\console_host\console_host.fsproj

The point free version gets compiled to a FSharpFunc and that somehow gives null pointer when there is no main method explictly defined.

image

The code does work when running from the project itself, just when refernced, as with a unit test project it fails. image

About

Point free stuff gives nullpointer when referenced from another assembly which is a console app with no explicit main method.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages