I am looking through some Haskell documentation and found a statement
You can declare a constructor ( for type and data ) as an infix operator, and this can make your code more readable.
I can use the data constructor in the infix form as shown below:
Prelude> data List a = Empty | a :-> (List a) deriving Show Prelude> Prelude> let var1 = 10 :-> Empty Prelude> let var2 = 20 :-> var1 Prelude> let var3 = 30 :-> var2 Prelude> Prelude> var1 10 :-> Empty Prelude> Prelude> var2 20 :-> (10 :-> Empty) Prelude> Prelude> var3 30 :-> (20 :-> (10 :-> Empty))
My question is how to use type constructor in infix form, can anyone give me an example to figure this out?
source share