{"id":15759129,"url":"https://github.com/nwtgck/to-string-haskell","last_synced_at":"2025-03-31T08:48:43.644Z","repository":{"id":87735906,"uuid":"126663446","full_name":"nwtgck/to-string-haskell","owner":"nwtgck","description":"toString in Haskell","archived":false,"fork":false,"pushed_at":"2018-03-25T07:19:34.000Z","size":17,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"develop","last_synced_at":"2025-02-06T13:29:53.349Z","etag":null,"topics":["haskell","haskell-library","haskell-stack"],"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/nwtgck.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-03-25T04:07:40.000Z","updated_at":"2018-05-13T07:57:22.000Z","dependencies_parsed_at":"2024-01-22T06:40:30.317Z","dependency_job_id":null,"html_url":"https://github.com/nwtgck/to-string-haskell","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nwtgck%2Fto-string-haskell","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nwtgck%2Fto-string-haskell/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nwtgck%2Fto-string-haskell/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nwtgck%2Fto-string-haskell/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nwtgck","download_url":"https://codeload.github.com/nwtgck/to-string-haskell/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246443527,"owners_count":20778247,"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":["haskell","haskell-library","haskell-stack"],"created_at":"2024-10-04T10:03:24.886Z","updated_at":"2025-03-31T08:48:43.623Z","avatar_url":"https://github.com/nwtgck.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# to-string\n\nA `toString` converter for String-like types and any `Show a =\u003e a` type.\n\n| branch | Travis status|\n| --- | --- |\n| [`master`](https://github.com/nwtgck/to-string-haskell/tree/master) | [![Build Status](https://travis-ci.org/nwtgck/to-string-haskell.svg?branch=master)](https://travis-ci.org/nwtgck/to-string-haskell) |\n| [`develop`](https://github.com/nwtgck/to-string-haskell/tree/develop) | [![Build Status](https://travis-ci.org/nwtgck/to-string-haskell.svg?branch=develop)](https://travis-ci.org/nwtgck/to-string-haskell) |\n\n\n## Installation\n\nAdd this library to `extra-deps` in your `stack.yaml` like the following if you use [Stack](https://docs.haskellstack.org/en/stable/README/).\n\n```yaml\n...\nextra-deps: \n- git: https://github.com/nwtgck/to-string-haskell.git\n  commit: 0c8f2951606e185feacddb28983b30c527c3eb17\n...\n```\n\n## Usages\n\n```hs\ntoString 89 == \"89\"\n```\n\n```hs\ntoString \"hello\" == \"hello\"\n```\n\n```hs\n{-# LANGUAGE OverloadedStrings #-}\ntoString (\"I'm a ByteString\" :: BS.ByteString) == (\"I'm a ByteString\" :: String)\n```\n\n```hs\n{-# LANGUAGE OverloadedStrings #-}\n\ntoString (\"I'm a Text\" :: T.Text) == (\"I'm a Text\" :: String)\n```\n\n## Supported String-like types\n\n* `String`\n* `Data.ByteString.Char8.ByteString`\n* `Data.ByteString.Lazy.Char8.ByteString`\n* `Data.ByteString.Short.ShortByteString`\n* `Data.ByteString.UTF8.ByteString`\n* `Data.ByteString.Lazy.UTF8.ByteString`\n* `Data.Text.Text`\n* `Data.Text.Lazy.Text`\n\n### Any `Show a =\u003e a`\n\nAny `Show a =\u003e a` type is also an instance of type class `ToString`.  \nSo `Int`, `Double`, `Maybe a` ... which are `Show` instances are also instances of `ToString`\n\n## Executable example\n\n```hs\n{-# LANGUAGE OverloadedStrings #-}\n\nimport Data.String.ToString\nimport qualified Data.ByteString as BS\nimport qualified Data.Text as T\n\n-- (This is an orignal type deriving `Show`)\ndata MyMaybe a = \n    MyJust a\n  | MyNothing\n  deriving Show\n\nmain :: IO ()\nmain = do\n  let i :: Int\n      i = 10\n  putStrLn (toString i)\n  -- =\u003e 10\n\n  let ch :: Char\n      ch = 'd'\n  putStrLn (toString ch)\n  -- =\u003e 'd'\n\n  let myMay1 :: MyMaybe Double\n      myMay1 = MyJust 1.89 \n  putStrLn (toString myMay1)\n  -- =\u003e MyJust 1.89\n\n  let bs :: BS.ByteString\n      bs = \"I'm a ByteString!\"\n  putStrLn (toString bs)\n  -- =\u003e I'm a ByteString!\n\n  let text :: T.Text\n      text = \"I'm a Text!\"\n  putStrLn (toString text)\n  -- =\u003e I'm a Text!\n```\n\n### Output\n\n```txt\n10\n'd'\nMyJust 1.89\nI'm a ByteString!\nI'm a Text!\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnwtgck%2Fto-string-haskell","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnwtgck%2Fto-string-haskell","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnwtgck%2Fto-string-haskell/lists"}