Skip to content

Instantly share code, notes, and snippets.

@abuiles
Created July 17, 2009 16:42
Show Gist options
  • Save abuiles/149152 to your computer and use it in GitHub Desktop.
Save abuiles/149152 to your computer and use it in GitHub Desktop.
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