
On Fri, Mar 28, 2014 at 01:58:11AM -0500, John M. Dlugosz wrote:
On 3/28/2014 1:41 AM, Tony Morris wrote:
It is the constructor for a non-empty list (Data.List.NonEmpty).
http://hackage.haskell.org/package/semigroups-0.12.2/docs/Data-List-NonEmpty...
Interesting— this is the page I had found: http://www.haskell.org/haskellwiki/Non-empty_list
So why do we need both :| and <| (or cons) ?
Look at the definitions and type signatures: (<|) :: a -> NonEmpty a -> NonEmpty a a <| ~(b :| bs) = a :| b : bs (:|) :: a -> [a] -> NonEmpty a data NonEmpty a = a :| [a] (I found the type-sig for (:|) using ghci ":t"). It is now evident that the constructor (:|) takes element/list to build |NonEmpty a|, while (<|) appends an |a| to a |NonEmpty a|.