Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Haskell data definition - what does :| mean?

Tags:

haskell

I was reading this excellent blog post, and came across the following line that I'm not sure what it does:

data NonEmpty a = a :| [a]

What is :| doing here? I tried this out in ghci but wasn't actually able to construct anything of this type.

like image 517
MLavrentyev Avatar asked Oct 19 '25 13:10

MLavrentyev


1 Answers

Compare it to this line:

data PrefixNonEmpty a = MkNonEmpty a [a]

Just like that line defines the (prefix) MkNonEmpty data constructor, your line defines the (infix) :| data constructor.

like image 60
Joseph Sible-Reinstate Monica Avatar answered Oct 22 '25 04:10

Joseph Sible-Reinstate Monica