lambdabot

How can i get the type of a polymorphic function for a specific type class instance?

帅比萌擦擦* 提交于 2019-12-19 18:22:13
问题 For example, typing :t ap in GHCi gives the result ap :: Monad m => m (a -> b) -> m a -> m b If I already know the Monad instance I'm going to use is ((->) r) , how can I query for the type of ap for that specific instance? 回答1: You can use visible type application feature to specify parametric types. You can look at functions in more creative way: functions in Haskell can be applied to not only values of some types, but also to types of that values. But to pass type you should somehow

How can i get the type of a polymorphic function for a specific type class instance?

本秂侑毒 提交于 2019-12-01 17:31:58
For example, typing :t ap in GHCi gives the result ap :: Monad m => m (a -> b) -> m a -> m b If I already know the Monad instance I'm going to use is ((->) r) , how can I query for the type of ap for that specific instance? Shersh You can use visible type application feature to specify parametric types. You can look at functions in more creative way: functions in Haskell can be applied to not only values of some types, but also to types of that values. But to pass type you should somehow specify (with prepending @ ) that you're passing types (because types are not first-class objects in