3 ms·
>Yes and no. The type might look different, but it's still a function! The type is different. Functions are a class of types. The output of function compositio
by crimsonalucard 7y ago
>Yes and no. The type might look different, but it's still a function!
The type is different. Functions are a class of types. The output of function composition is absolutely a different type but within the class of function types.
>It's very easy to compose data in Haskell.
I suggest you reread my post, I do not believe you fully understood it. You can compose data in ALL languages.
>Query a b -> Query c a -> Query c b
I mentioned the tuple type in my post which is essentially the same thing as what you're doing sans the constructor. In type theory these things are called "Product types."
Products are commutative, but in Haskell Data composition does not hold this property. See below:
(a,b) != (b,a)
Query a b != Query b a
while
(a * b) == (b * a)
I am saying there is limited power in Data composition in Haskell, it is not as "complete" as function composition. It also brings nothing new to the table as the data compositional patterns are used outside of FP extensively.
- sfvisser 7y ago> The type is different. Functions are a class of types. The output of function composition is absolutely a different type but within the class of function types. I know how types and type constructors work, it's completely irrelevant in the context of what I was trying to say about composition in FP. It seems to me you're probably talking about a very specific technical form of composition. I'm not. To me a simple function like `vertically :: [Ui] -> Ui` is also about composition. The input and output types of the `vertically` function are not the same no, but informally we're still composing UIs into UIs. Which is exactly the level of detail I care for in this discussion.
- crimsonalucard 7y agoTypes can be composed in two ways. This is fundamental to type theory. It can be composed via a product or a sum.
- gowld 7y agoAlmost Every language has data composition if all you mean is "it's possible to wrap two things in a container" or "you can apply a function to two things and get a third thing".