I'm working on a project and I want to create a really compact method for creating Entities and Attributes.
I want to do this with the pipeline operator. But I want to add extra functionality to this operator.
Like for example :
let entity = (entity "name")
|>> (attribute "attr" String)
|>> (attribute "two" String)
In this example |>> would be a pipeline operator together with the functionality to add an attribute to the entity.
I know that this works:
let entity = (entity "name")
|> addAttr (attribute "attr" String)
So what I want to know is, if it's possible to replace
|> addAttr
with
|>>
Thanks for the help
(I don't know if this is even possible)
You can simply define it like this:
let (|>>) e a = e |> addAttr a
For readability, I would strongly discourage adding custom operators when a simple function will do. You could change the way addAttr
is written to make it easier to use in a pipeline:
let addAttr name attrType entity = () // return an updated entity
let e =
entity "name"
|> addAttr "attr" String
|> addAttr "two" String
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With