Created
October 13, 2016 05:52
-
-
Save owickstrom/755fe69a25d21488d857d4c1f213ca65 to your computer and use it in GitHub Desktop.
Idris String with validation?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- A data type wrapping a non-empty string | |
data Name : Type where | |
MkName : (s : String) -> (not (s == "") = True) -> Name | |
-- Some function that expects a valid Name | |
test : Name -> String | |
test (MkName s _) = s | |
-- Usage of that function. Do I need Refl here? Any better way of doing this? | |
foo : String | |
foo = test (MkName "foo" Refl) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment