I've used the Scrap Your Boilerplate and Uniplate libraries in the Haskell programming language, and I would find that form of generic programming over discriminated unions to be really useful. Is there an equivalent library in the f# programming language?
相关问题
- F#: Storing and mapping a list of functions
- Caugth ClassCastException in my Java application
- Get the result of Func<object> when object i
- Multiplying a list of tuples by a tuple in F#
- Multiplying a string in F#
相关文章
- FSharp.Data.JsonProvider - Getting json from types
- Signing an F# Assembly (Strong name component)
- Learning F#: What books using other programming la
- fsc.exe is very slow because it tries to access cr
- Extension methods for specific generic types
- F# Object Initialization with a Constructor
- F# Lazy Evaluation vs Non-Lazy
- When to use interfaces, and when to use higher ord
Not that I know of; without support built-in to the language/compiler, I expect the only alternative is a reflection-based version. (I don't know how Uniplate is implemented - do you?)
Here's the code for a reflection-based version based on the example from the original presentation. I have not thought deeply about its limitations, but this was much simpler to write than I would have guessed.
The
everywhere
function traverses the entire structure of an arbitrary DU and applies the functionf
to each node that is the type thatf
works on, leaving all other nodes as-is.