I have come across this:
[<Interface>]
type ILogger =
abstract Debug: string -> unit
abstract Error: string -> unit
[<Interface>] type ILog = abstract Logger: ILogger
module Log =
let debug (env: #ILog) fmt = Printf.kprintf env.Logger.Debug fmt
let error (env: #ILog) fmt = Printf.kprintf env.Logger.Error fmt
from that page: https://bartoszsypytkowski.com/dealing-with-complex-dependency-injection-in-f/
I was wondering what is the '#' symbol doing in front of the type: let debug (env: #ILog)...
the page's explanation is this:
The secret is in #ILog signature, which means that our environment can be any generic type implementing ILog interface.
but I tried to find documentation on this and my google search wasn't successful. Where can I read more about it?
my understanding is that you can pass objects that implement a specific interface and the functions that use the # will auto cast the object to the interface and use it.
But then why do they implement it as 2 interfaces instead of a single one here?