Specific procedures for derived types
milancurcic opened this issue · 1 comments
It will be beneficial to implement many of the functions (head
, tail
, map
, filter
, fold
, unfold
, and others) for a derived type. Within functional fortran, this could be an empty type:
type :: basetype
endtype basetype
The user would then extend this type when implementing their own:
type,extends(basetype) :: mytype
! mytype components
! mytype methods
endtype mytype
This approach can't work because the specific functions must return either a scalar or array of the extended type, which is not available from the library itself. This at first wasn't obvious, however it becomes obvious when you try to do it.
Alternative approach could be via metaprogramming, for example with macros. In that case, all existing specific functions could be generated this way. Could be an interesting project on its own, however I don't want to pursue it myself in the interest of keeping functional-fortran simple.
As of right now, this is out of scope for FF, but this may change in the future.