Couldn’t Match Expected Type Against Inferred Type, Rigid Type Variable Error

test :: Foo a => a means “for any type which is an instance of Foo, test is a value of that type”. So in any place where you can use a value of type X where X is an instance Foo, you can use a value of type Foo a => a.

Something like test :: Num a => a; test = 42 works because 42 can be a value of type Int or Integer or Float or anything else that is an instance of Num.

However "asdasd" can’t be an Int or anything else that is an instance of Show – it can only ever be a String. As a consequence it does not match the type Show s => s.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)