Created
August 7, 2015 01:45
-
-
Save wavebeem/294674365091a5baa35f 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
-- Also note, it seems people generally reach for positional types unless the data has many fields. | |
-- data BTNode t = BTNode t (BTNode t) (BTNode t) | BTNil | |
-- as opposed to: | |
-- data BTNode t = BTNode { data :: t, left :: BTNode, right :: BTnode } | BTNil | |
data Car2 = Car2 { make :: Maybe String } deriving (Show) | |
-- Haskell automatically makes a function in this scope: | |
-- make :: Car2 -> Maybe String | |
-- So you can just say `make c1` to get the make of the Car2 called `c1`. | |
carMake :: Car2 -> Maybe String | |
carMake (Car2 x) = x | |
c1 = Car2 Nothing | |
definitelyTrue = carMake c1 == make c1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment