Created
July 17, 2009 16:42
-
-
Save abuiles/149152 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
data Perro = Chan {altura :: Int , muerde :: Bool} | |
| Labrador {altura::Int , muerde :: Bool} | |
deriving (Show) | |
c = Chan 4 True | |
l = Labrador 1 True | |
--Aseguro que lo que estoy recibiendo es un perro con el type signature | |
test :: Perro -> String | |
test a = case a of | |
Labrador _ _ -> " Es un Labrador " | |
Chan _ _ -> "Es un Chan" | |
{-Este no funciona, hace el matching respecto al constructor , de hecho no compilaría | |
test2 a = case a of | |
Perro -> "Es un perro" | |
-} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment