Last active
September 16, 2017 13:35
-
-
Save zwilias/28da939bc3cbbfdf4af28d6db31c74d3 to your computer and use it in GitHub Desktop.
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
type alias HasAnInt = { foo : Int } | |
badExample : HasAnInt -> HasAnInt | |
badExample record = | |
{ record | foo = toString record.foo } | |
{- Since we're changing the type, we need to give the correct | |
type annotation for the new return value | |
-} | |
thisWorks : HasAnInt -> { foo : String } | |
thisWorks record = | |
{ record | foo = toString record.foo } | |
{- We can also give that new return value a type alias so we | |
can reuse it in other places, too. | |
-} | |
type alias HasAString = { foo : String } | |
thisAlsoWorks : HasAnInt -> HasAString | |
thisAlsoWorks record = | |
{ record | foo = toString record.foo } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment