haskell - functors from partially applied function type -


there quesion in programming in haskell says: complete following declaration:

instance functor ((->) a) 

now functor thing has type definition of:

instance functor thing        --fmap::(a -> b) -> thing -> thing b  

i wondering if reduction makes sense:

instance functor ((->) a)     -- fmap::(a -> b) -> ((->) a) -> ((->) a) b      -- therefore     -- fmap::(a -> b) -> -> -> (a -> b)      -- therefore     -- fmap::b -> b 

-- update --- missed brackets, should have been

instance functor ((->) a)     -- fmap::(a -> b) -> ((->) a) -> ((->) a) b      -- therefore     -- fmap::(a -> b) -> (a -> a) -> (a -> b)      -- therefore     -- should returning function of -> b 

no, because a in instance declaration not same a 1 in type of fmap. need assign type variable in instance declaration avoids "capturing" a in type of fmap:

instance functor ((->) r)   fmap :: (a -> b) -> (r -> a) -> (r -> b) 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -