{"action":"created","issue":{"url":"https://api.github.com/repos/goldfirere/singletons/issues/136","labels_url":"https://api.github.com/repos/goldfirere/singletons/issues/136/labels{/name}","comments_url":"https://api.github.com/repos/goldfirere/singletons/issues/136/comments","events_url":"https://api.github.com/repos/goldfirere/singletons/issues/136/events","html_url":"https://github.com/goldfirere/singletons/issues/136","id":119259969,"number":136,"title":"Promoting Enum instance","user":{"login":"vladfi1","id":691536,"avatar_url":"https://avatars.githubusercontent.com/u/691536?v=3","gravatar_id":"","url":"https://api.github.com/users/vladfi1","html_url":"https://github.com/vladfi1","followers_url":"https://api.github.com/users/vladfi1/followers","following_url":"https://api.github.com/users/vladfi1/following{/other_user}","gists_url":"https://api.github.com/users/vladfi1/gists{/gist_id}","starred_url":"https://api.github.com/users/vladfi1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vladfi1/subscriptions","organizations_url":"https://api.github.com/users/vladfi1/orgs","repos_url":"https://api.github.com/users/vladfi1/repos","events_url":"https://api.github.com/users/vladfi1/events{/privacy}","received_events_url":"https://api.github.com/users/vladfi1/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-11-28T00:36:55Z","updated_at":"2015-11-28T21:20:02Z","closed_at":"2015-11-28T15:15:45Z","body":"I have a type for which Enum is not derivable, but I have instead written my own Enum instance. Is there a way to get singletons to promote this instance, giving me the PEnum, SEnum, and Apply instances I want?"},"comment":{"url":"https://api.github.com/repos/goldfirere/singletons/issues/comments/160336015","html_url":"https://github.com/goldfirere/singletons/issues/136#issuecomment-160336015","issue_url":"https://api.github.com/repos/goldfirere/singletons/issues/136","id":160336015,"user":{"login":"goldfirere","id":1958003,"avatar_url":"https://avatars.githubusercontent.com/u/1958003?v=3","gravatar_id":"","url":"https://api.github.com/users/goldfirere","html_url":"https://github.com/goldfirere","followers_url":"https://api.github.com/users/goldfirere/followers","following_url":"https://api.github.com/users/goldfirere/following{/other_user}","gists_url":"https://api.github.com/users/goldfirere/gists{/gist_id}","starred_url":"https://api.github.com/users/goldfirere/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/goldfirere/subscriptions","organizations_url":"https://api.github.com/users/goldfirere/orgs","repos_url":"https://api.github.com/users/goldfirere/repos","events_url":"https://api.github.com/users/goldfirere/events{/privacy}","received_events_url":"https://api.github.com/users/goldfirere/received_events","type":"User","site_admin":false},"created_at":"2015-11-28T21:20:02Z","updated_at":"2015-11-28T21:20:02Z","body":"This worked for me:\r\n\r\n```\r\n{-# LANGUAGE DataKinds,\r\n             PolyKinds,\r\n             TypeOperators,\r\n             TypeFamilies,\r\n             GADTs,\r\n             UndecidableInstances,\r\n             KindSignatures,\r\n             InstanceSigs,\r\n             ScopedTypeVariables,\r\n             TemplateHaskell\r\n             #-}\r\n\r\nmodule SingletonsTH where\r\n\r\nimport Data.Singletons.Prelude\r\nimport Data.Singletons.TH\r\nimport Data.Singletons.Prelude.Enum\r\n\r\n$(singletons [d|\r\n  data Nat = Z | S Nat\r\n    deriving (Eq, Ord, Show)\r\n\r\n  instance Enum Nat where\r\n    succ n = S n\r\n\r\n    pred Z = error \"pred Z\"\r\n    pred (S n) = n\r\n\r\n    toEnum n = if n == 0 then Z else S $ toEnum (n-1)\r\n\r\n    fromEnum Z = 0\r\n    fromEnum (S n) = 1 + (fromEnum n)\r\n\r\n  |])\r\n```\r\n\r\nI identify three problems here:\r\n1. `Enum` stuff should be exported from `Data.Singletons.Prelude`.\r\n2. Literal patterns are not supported, so I had to change `toEnum`.\r\n3. The eta-reduced `succ` (that is, declared in point-free style) wasn't accepted.\r\n\r\n(1) and (3) are proper bugs. (2) is essentially a feature request. But, if I recall, (2) is trickier than you would think. (1) and (3) should be possible though. In the meantime, (1) and (3) are very easy to work around."}}