Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I declare an empty tuple?

Tags:

haskell

I can declare empty list as [], but, how can I declare empty tuple?

I have tried:

for ( , ) 
ghci>(1,0 ) : [(,)] 

but it gives me an error!


1 Answers

A tuple is a type that is always the same length and always has the same types. So (Int, Int) is a different type from (Int, Int, Int) and a different type from (Int, String).

With this in mind, you could have an empty tuple. However, this would just be a type with a single value. This type is written as () and pronounced unit. The only value of this type is also ().

like image 162
Tikhon Jelvis Avatar answered Mar 09 '26 01:03

Tikhon Jelvis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!