{"id":16662038,"url":"https://github.com/hvr/hs2010to201x","last_synced_at":"2025-04-09T18:52:39.765Z","repository":{"id":66334069,"uuid":"43600286","full_name":"hvr/Hs2010To201x","owner":"hvr","description":"Automatic H2010 to H201x Refactoring","archived":false,"fork":false,"pushed_at":"2015-11-28T11:49:03.000Z","size":27,"stargazers_count":8,"open_issues_count":2,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-23T20:51:15.286Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hvr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-10-03T13:41:03.000Z","updated_at":"2020-12-12T04:32:14.000Z","dependencies_parsed_at":"2023-03-10T23:50:16.390Z","dependency_job_id":null,"html_url":"https://github.com/hvr/Hs2010To201x","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hvr%2FHs2010To201x","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hvr%2FHs2010To201x/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hvr%2FHs2010To201x/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hvr%2FHs2010To201x/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hvr","download_url":"https://codeload.github.com/hvr/Hs2010To201x/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248093101,"owners_count":21046619,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-12T10:36:46.868Z","updated_at":"2025-04-09T18:52:39.739Z","avatar_url":"https://github.com/hvr.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"Automatic H2010 to H201x Refactoring\n====================================\n\n[![Available on Hackage][badge-hackage]][hackage]\n[![License BSD3][badge-license]][license]\n[![Build Status][badge-travis]][travis]\n\n[badge-travis]: https://travis-ci.org/alanz/Hs2010To201x.png?branch=master\n[travis]: https://travis-ci.org/alanz/Hs2010To201x\n[badge-hackage]: https://img.shields.io/hackage/v/Hs2010To201x.svg?dummy\n[hackage]: https://hackage.haskell.org/package/Hs2010To201x\n[badge-license]: https://img.shields.io/badge/license-BSD3-green.svg?dummy\n[license]: https://github.com/alanz/Hs2010To201x/blob/master/LICENSE\n\nTypeclass Refactoring\n---------------------\n\n### `Monad`-hierarchy\n\n#### Haskell Report Definitions\n\nHaskell 2010 defines only the `Functor` and `Monad` typeclasses:\n\n```haskell\nclass  Functor f  where\n    fmap    :: (a -\u003e b) -\u003e f a -\u003e f b\n\nclass  Monad m  where\n    return  :: a -\u003e m a\n\n    (\u003e\u003e=)   :: m a -\u003e (a -\u003e m b) -\u003e m b\n\n    (\u003e\u003e)    :: m a -\u003e m b -\u003e m b\n    m \u003e\u003e k  =  m \u003e\u003e= \\_ -\u003e k\n    \n    fail    :: String -\u003e m a\n    fail s  = error s\n```\n\nWith Haskell 201x this evolves into\n\n```haskell\nclass  Functor f  where\n    fmap    :: (a -\u003e b) -\u003e f a -\u003e f b\n\nclass Functor f =\u003e Applicative f where\n    -- | Lift a value.\n    pure :: a -\u003e f a\n\n    -- | Sequential application.\n    (\u003c*\u003e) :: f (a -\u003e b) -\u003e f a -\u003e f b\n\n    -- | Sequence actions, discarding the value of the first argument.\n    (*\u003e) :: f a -\u003e f b -\u003e f b\n    (*\u003e) = …\n\n    -- | Sequence actions, discarding the value of the second argument.\n    (\u003c*) :: f a -\u003e f b -\u003e f a\n    (\u003c*) = …\n\nclass Applicative m =\u003e Monad m where\n    -- | Monadic bind\n    (\u003e\u003e=) :: forall a b. m a -\u003e (a -\u003e m b) -\u003e m b\n\nclass Monad m =\u003e MonadFail m where\n    -- | Invoked on pattern-failures in monadic binds\n    fail :: String -\u003e m a\n\n-- Backward-compatible top-level alias bindings\n\n(\u003e\u003e) :: Functor m =\u003e m a -\u003e m b -\u003e m b\n(\u003e\u003e) = (*\u003e)\n\nreturn :: Applicative m =\u003e a -\u003e m a\nreturn = pure\n```\n\n\n#### GHC: Interim Haskell 2010 + `Applicative` definitions\n\nThere are multiple intermediate stages:\n\n - GHC 7.0 to 7.8: Haskell 2010 `Functor`/`Monad` class hierarchy + non-superclass `Applicative`\n - GHC 7.10:       Haskell 201x `Functor`/`Monad`/`Applicative` class hierarchy (sans `MonadFail`) with legacy `return`/`(\u003e\u003e)`/`fail`\n - GHC 8.0 to 8.X: Haskell 201x `Functor`/`Monad`/`Applicative`/`MonadFail` class hierarchy with legacy `return`/`(\u003e\u003e)`/`fail`\n - GHC 8.X+2:      Haskell 201x\n\n#### Rewrite rules\n\nConverting from plain Haskell2010 to Haskell201x is simple:\n\n- Create `Functor` instance if missing with `fmap` defined in terms of `(\u003e\u003e=)` and `pure`\n- Create `Applicative` instance and define `(\u003c*\u003e)` in terms of `(\u003e\u003e=)` and `pure`\n- Rewrite `Monad(return)` implementation into `Applicative(pure)` implementation\n- If exists, rewrite `Monad((\u003e\u003e))` implementation into `Applicative((*\u003e))` implementation\n- If `fail` is defined, create `MonadFail` instance with that `fail` method implementation\n\nTODO: Give rules based on AMP-migration-guide definitions\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhvr%2Fhs2010to201x","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhvr%2Fhs2010to201x","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhvr%2Fhs2010to201x/lists"}