{"action":"created","issue":{"url":"https://api.github.com/repos/CommBank/PLATYPUS/issues/3","repository_url":"https://api.github.com/repos/CommBank/PLATYPUS","labels_url":"https://api.github.com/repos/CommBank/PLATYPUS/issues/3/labels{/name}","comments_url":"https://api.github.com/repos/CommBank/PLATYPUS/issues/3/comments","events_url":"https://api.github.com/repos/CommBank/PLATYPUS/issues/3/events","html_url":"https://github.com/CommBank/PLATYPUS/issues/3","id":144461612,"number":3,"title":"Functors for the \"Generic Extensions to Type Operators\"","user":{"login":"CMCDragonkai","id":640797,"avatar_url":"https://avatars.githubusercontent.com/u/640797?v=3","gravatar_id":"","url":"https://api.github.com/users/CMCDragonkai","html_url":"https://github.com/CMCDragonkai","followers_url":"https://api.github.com/users/CMCDragonkai/followers","following_url":"https://api.github.com/users/CMCDragonkai/following{/other_user}","gists_url":"https://api.github.com/users/CMCDragonkai/gists{/gist_id}","starred_url":"https://api.github.com/users/CMCDragonkai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CMCDragonkai/subscriptions","organizations_url":"https://api.github.com/users/CMCDragonkai/orgs","repos_url":"https://api.github.com/users/CMCDragonkai/repos","events_url":"https://api.github.com/users/CMCDragonkai/events{/privacy}","received_events_url":"https://api.github.com/users/CMCDragonkai/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2016-03-30T04:32:57Z","updated_at":"2016-03-31T03:59:36Z","closed_at":null,"body":"I sometimes find it easier to understand if I relate the PFPL to equivalent constructs in Haskell.\r\n\r\nRegarding today's meeting for page 123. We have a 5 polynomial type operators. Here are some equivalences I've found:\r\n\r\nFor 14.3.a:\r\n\r\n```\r\nmap{t.t}(x.e')(e) -> [e/x]e'\r\n```\r\n\r\n```hs\r\n> import Data.Functor.Identity\r\n> instance (Show a) => Show (Identity a) where\r\n> |     show (Identity a) = \"Identity \" ++ show a\r\n> |\r\n> fmap (\\x -> x + 1) (Identity 3)\r\nIdentity 4\r\n> :info Identity\r\nnewtype Identity a = Identity {runIdentity :: a}\r\n        -- Defined in ‘Data.Functor.Identity’\r\ninstance Show a => Show (Identity a)\r\n  -- Defined at <interactive>:24:10\r\ninstance Monad Identity -- Defined in ‘Data.Functor.Identity’\r\ninstance Functor Identity -- Defined in ‘Data.Functor.Identity’\r\n```\r\n\r\nFor 14.3b:\r\n\r\n```\r\nmap{t.unit}(x.e')(e) -> e\r\n```\r\n\r\n```hs\r\n> import Data.Proxy\r\n> fmap (\\x -> x) Proxy\r\nProxy\r\nit :: Proxy b\r\n> :info Proxy\r\ntype role Proxy phantom\r\ndata Proxy (t :: k) = Proxy\r\n        -- Defined in ‘Data.Proxy’\r\ninstance Bounded (Proxy s) -- Defined in ‘Data.Proxy’\r\ninstance Enum (Proxy s) -- Defined in ‘Data.Proxy’\r\ninstance Eq (Proxy s) -- Defined in ‘Data.Proxy’\r\ninstance Monad Proxy -- Defined in ‘Data.Proxy’\r\ninstance Functor Proxy -- Defined in ‘Data.Proxy’\r\ninstance Ord (Proxy s) -- Defined in ‘Data.Proxy’\r\ninstance Read (Proxy s) -- Defined in ‘Data.Proxy’\r\ninstance Show (Proxy s) -- Defined in ‘Data.Proxy’\r\n```\r\n\r\nThere used to be a `Data.Unit` in category-extras package, but it was removed.\r\n\r\nFor 14.3c:\r\n\r\n```\r\nmap{t.tau1 * tau2}(x.e')(e) -> <map{t.tau1}(x.e')(e.l),map{t.tau2}(x.e')(e.r)>\r\n```\r\n\r\nUnknown. Originally I thought it was a tuple. But it isn't. Also this is close `data Pair a = Pair a a` but it doesn't exactly match `{t.tau1 * tau2}`, it would be more like `{t.t * t}`.\r\n\r\nFor 14.3d:\r\n\r\n```\r\nmap{t.void}(x.e')(e) -> abort(e)\r\n```\r\n\r\nCould be `Data.Void`, but it's not an instance of the Functor type class. Also I couldn't make it an instance of Functor because the kind is `*` and Functor needs a kind of  `* -> *`.\r\n\r\n```\r\n> import Data.Void\r\n> instance Functor Void where\r\n> |     fmap _ v = absurd v\r\n> |\r\n    The first argument of ‘Functor’ should have kind ‘* -> *’,\r\n      but ‘Void’ has kind ‘*’\r\n    In the instance declaration for ‘Functor Void’\r\n```\r\n\r\nThe closest thing to the same behaviour is...\r\n\r\n```hs\r\n> fmap (\\x -> x) undefined\r\n*** Exception: Prelude.undefined\r\n```\r\n\r\nFor 14.3e:\r\n\r\n```\r\nmap{t.tau1 + tau2}(x.e')(e) -> case e { l.x1 -> l.map{t.tau1}(x.e')(x1) | r.x2 -> r.map{t.tau2}(x.e')(x2) }\r\n```\r\n\r\nNot sure, could it be the `Either` functor?"},"comment":{"url":"https://api.github.com/repos/CommBank/PLATYPUS/issues/comments/203741383","html_url":"https://github.com/CommBank/PLATYPUS/issues/3#issuecomment-203741383","issue_url":"https://api.github.com/repos/CommBank/PLATYPUS/issues/3","id":203741383,"user":{"login":"mjhopkins","id":2715128,"avatar_url":"https://avatars.githubusercontent.com/u/2715128?v=3","gravatar_id":"","url":"https://api.github.com/users/mjhopkins","html_url":"https://github.com/mjhopkins","followers_url":"https://api.github.com/users/mjhopkins/followers","following_url":"https://api.github.com/users/mjhopkins/following{/other_user}","gists_url":"https://api.github.com/users/mjhopkins/gists{/gist_id}","starred_url":"https://api.github.com/users/mjhopkins/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mjhopkins/subscriptions","organizations_url":"https://api.github.com/users/mjhopkins/orgs","repos_url":"https://api.github.com/users/mjhopkins/repos","events_url":"https://api.github.com/users/mjhopkins/events{/privacy}","received_events_url":"https://api.github.com/users/mjhopkins/received_events","type":"User","site_admin":false},"created_at":"2016-03-31T03:59:36Z","updated_at":"2016-03-31T03:59:36Z","body":"It's perhaps more common (and a little nicer) in Haskell land to use infix operators `:+:` and `:*:` for sum and product of functors."}}