Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chadtech/dependent-text
A dependent text type (sorta)
https://github.com/chadtech/dependent-text
dependent-types elm text
Last synced: 1 day ago
JSON representation
A dependent text type (sorta)
- Host: GitHub
- URL: https://github.com/chadtech/dependent-text
- Owner: Chadtech
- License: bsd-3-clause
- Created: 2018-09-24T21:41:16.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-09-24T23:20:57.000Z (over 6 years ago)
- Last Synced: 2024-11-06T04:40:59.634Z (about 2 months ago)
- Topics: dependent-types, elm, text
- Language: Elm
- Homepage: https://package.elm-lang.org/packages/Chadtech/dependent-text/1.0.0/
- Size: 6.84 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Dependent Text
A dependent type is a type that is dependent on certain values. A dependent list type might depend on the list containing at least one element.
Elm doesnt really have dependent types as far as I can tell. But what you can do as an alternative to dependent types is put more information into your type signatures, which seems to share the same mission as dependent types. By making your types more particular and descriptive, you add conditions on which the compiler might error. If the conditions are things you dont want to happen, that means youve also made those bad things impossible to appear in your code. Often times this is practical.
In this package however, I am not being practical. This is just a fun experiment. I wanted to see if one could express the exact content of a string in a type signature. Looks like you can!
```elm
import Text exposing (..)chadtech : Text (C (H (A (D (T (E (C (H ()))))))))
chadtech =
c (h (a (d (t (e (c (h textEnd)))))))-- Text.toString chadtech == "CHADTECH"
```