Re: [Haskell-cafe] Are there arithmetic composition of functions?

At present we can easily express different flavors of conjunction, but expressing disjunction is hard.
Disjunction is not particularly difficult. See, for example, http://okmij.org/ftp/Haskell/TTypeable/TTypeable.hs and search for ORELSE. The code demonstrates higher-order type-level programming (for example, higher-order function Member with the equality predicate as the argument). The file implements closed-world negation for type predicates. See http://okmij.org/ftp/Haskell/typeEQ.html for explanations. Incidentally, one application of that machinery is precisely your original problem. The code http://okmij.org/ftp/Haskell/TTypeable/NotAFunctionT.hs implements vector spaces as function spaces, so you can use the same operation <+> :: Vspace v => v -> v -> v to add arguments of the type (Num n =>n), Num n => a -> n, Num n => a -> b -> n, etc. (there is also a scalar-vector multiplication).
participants (1)
-
oleg@okmij.org