Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trying to use Cons function in Purescript

Tags:

purescript

Heres my code:

print 1: [2,3]

When I run it I get

  Cannot unify type
    Data.List.List
  with type
    Prim.Array

Whats going on?

like image 872
dopatraman Avatar asked Aug 03 '26 01:08

dopatraman


1 Answers

[2, 3] has type Array Int. (:) has type a -> List a -> List a in Data.List. You need to convert to a List. Also, what you have will parse as

(print 1) : [2, 3]

I think you want

print (1 : toList [2, 3])

or

print $ 1 : toList [2, 3]
like image 196
Phil Freeman Avatar answered Aug 06 '26 02:08

Phil Freeman



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!