JJ chips
JJ chips

Reputation: 97

What's the difference between (function (x :< _)) = x and (function (x :_)) = x

What is the less than symbol used in the notation x:<_? I know that (function (x :< xs))=x would mean, a function that takes a string and gives the head of the string as output. Then I suppose x:_ and x:xs in this function would be interchangeble, but im not familiar with the notation < in this expression.

Upvotes: 1

Views: 104

Answers (1)

Lee
Lee

Reputation: 144206

:< is just a constructor for some type in the same way : is for lists e.g.

data Stream a = a :< (Stream a)

in this case you could have a function to get the first item in the stream as

streamHead :: Stream a -> a
streamHead (a :< _) = a

Upvotes: 4

Related Questions