Sunday, February 06, 2011

F# failing the monad adapter test

Crap! I spend this evening re-writing some code from a monad "accessor" concept to a monad adaptor concept. In my terminology:
  • The accessor is a payload of functions that is given to a monadic function to allow it to be compatible with a globally common monadic state type
  • The adaptor is a monad to monad wrapper that allows a monad written for one state type to work for another.
Now I find that as the adaptor works top down it will see different type signatures, so it needs to be polymorphic. As it is passed around as an argument, polymorphism would make it a functor. But F# does not allow functors! Very crappy.

I have two choices: revert back to the accessor or... or pass a tuplet or record of adaptors and use "one per payload type". Note good because it beats the purpose which would be to use the adaptor concept in layers. I am tempted to ditch this adaptor concept in F# for the moment.

No comments: