typeclass and multiple deriving
hs3180 opened this issue · 4 comments
hs3180 commented
typeclass and deriving are very useful for composing interfaces.
and it should be easy mapping typeclass to S3 class in R.
hs3180 commented
ClassA(x) %as% x
ClassB(x) %as% x
MyClass(x) %as% {
ClassB(ClassA(x))
}
hs3180 commented
with magrittr
, it may be more clear.
ClassA(x) %as% x
ClassB(x) %as% x
MyClass(x) %as% {
ClassA(x) %>% ClassB
}
muxspace commented
That's up to you if you want to use the pipe within your type constructor. Let me know if it doesn't work.
hs3180 commented
you are right. pipe breaks lazy evaluation, following code may be better with functional
package.
ClassA(x) %as% x
ClassB(x) %as% x
MyClass(x) %as% {
Compose(ClassA, ClassB)(x)
}