> Are we assigning here with the =?
Kindof you are assigning what the type `Tree a` is.
> What does the pipe symbol mean?
The pipe is symbolizing or/either here. A tree is either a Leaf or it is a Node with two subtrees.
> Why pipe instead of another =?
You are building up a single type with the pipes, having an extra = wouldn't really make sense when you are thinking about building a type algebraically.
> Why the weird formatting?
The formatting is optional. It is free to be all in one line if you want it that way. For the given example, I would probably make it a single line, but I'm not a Haskell veteran.
You could ask many of the same questions of Python's non-C/non-Java like syntax:
- What is "def"?
- Why the weird formatting? (And unlike Haskell, Python's tends to be stricter!)
- Why do I need to write ":" after some lines but not others? It doesn't work like the semicolon in C-like languages!
- What's with the "if __name__ == '__main__'" weirdness I see in some Python programs?
- What's this weird [f(x) for x in ...] syntax? It doesn't look like anything in C. What's with the brackets anyway?
Etc.
Yet Python with its "weird" syntax and constructs is a hugely popular language...
https://www.google.com/search?q=haskell+pipe+operator&oq=has...
https://www.google.com/search?q=__name__+%3D%3D+%27__main__&...
Do note Haskell tutorials and communities abound, and you have excellent online tools such as Hoogle (in which you write the type of what you think you want and it responds with "these are functions with a similar type signature, with their documentation"). It's easy to google Haskell things, just not as easy as googling Python things :)
Do note the type definitions from the example are Haskell 101 and will be covered very early in almost every tutorial, for example Learn you a Haskell.
PS: it's not a "pipe operator" you're looking for. This isn't an operator at all! The "|" you're looking for it's in a definition, and it means a union of alternatives (this type can be "this" or "that" or "this other thing"). If you think about it, this "union-or" is written the same as the bitwise-or from more popular languages :)
Are we assigning here with the =? What does the pipe symbol mean? Why pipe instead of another =? Why the weird formatting?
To me Haskell's look is too off-putting. With the Rust example I have a good guess what will the resulting object will look like.
But I know it's just a learning experience. Once I would know Haskell your example looks more elegant to me. I just don't get it from looking at it :)