{"id":17968662,"url":"https://github.com/weissi/swift-undefined","last_synced_at":"2025-03-25T10:32:30.271Z","repository":{"id":29194842,"uuid":"32726038","full_name":"weissi/swift-undefined","owner":"weissi","description":"Nano framework which defines Haskell's undefined in Swift.","archived":false,"fork":false,"pushed_at":"2020-06-18T07:22:07.000Z","size":7,"stargazers_count":80,"open_issues_count":0,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-20T01:06:39.057Z","etag":null,"topics":["nano-framework","swift","undefined"],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"cthit/pong-bot-client-java","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/weissi.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-03-23T10:42:46.000Z","updated_at":"2024-12-06T16:53:55.000Z","dependencies_parsed_at":"2022-08-02T12:05:52.655Z","dependency_job_id":null,"html_url":"https://github.com/weissi/swift-undefined","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weissi%2Fswift-undefined","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weissi%2Fswift-undefined/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weissi%2Fswift-undefined/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weissi%2Fswift-undefined/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/weissi","download_url":"https://codeload.github.com/weissi/swift-undefined/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245444325,"owners_count":20616360,"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":["nano-framework","swift","undefined"],"created_at":"2024-10-29T14:41:10.845Z","updated_at":"2025-03-25T10:32:27.798Z","avatar_url":"https://github.com/weissi.png","language":"Swift","funding_links":[],"categories":["Libs"],"sub_categories":["Utility"],"readme":"# undefined for Swift\n\n_Micro frameworks_ are popular now, so I'll go _nano framework_ :-). This is all the code:\n\n```\n/**\n * `undefined()` pretends to be able to produce a value of any type `T` which can\n * be very useful whilst writing a program. It happens that you need a value\n * (which can be a function as well) of a certain type but you can't produce it\n * just yet. However, you can always temporarily replace it by `undefined()`.\n *\n * Inspired by Haskell's\n * [undefined](http://hackage.haskell.org/package/base-4.7.0.2/docs/Prelude.html#v:undefined).\n *\n * Invoking `undefined()` will crash your program.\n *\n * Some examples:\n *\n *  - `let x : String = undefined()`\n *  - `let f : String -\u003e Int? = undefined(\"string to optional int function\")`\n *  - `return undefined() /* in any function */`\n *  - `let x : String = (undefined() as Int -\u003e String)(42)`\n *  - ...\n *\n * What a crash looks like:\n *\n * `fatal error: undefined: main.swift, line 131`\n *\n */\npublic func undefined\u003cT\u003e(hint: String = \"\", file: StaticString = #file, line: UInt = #line) -\u003e T {\n    let message = hint == \"\" ? \"\" : \": \\(hint)\"\n    fatalError(\"undefined \\(T.self)\\(message)\", file:file, line:line)\n}\n```\n\n## More information\n\nSee my slides about [`undefined()`][fltts-undef] from my [Further Leveraging the Type System][fltts] talk at [Swift Summit 2015][ss15].\n\n[fltts]: https://speakerdeck.com/johannesweiss/further-leveraging-the-type-system\n[fltts-undef]: https://speakerdeck.com/johannesweiss/further-leveraging-the-type-system?slide=6\n[ss15]: http://www.swiftsummit.com\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweissi%2Fswift-undefined","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fweissi%2Fswift-undefined","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweissi%2Fswift-undefined/lists"}