Copyright | (C) 2017 Csongor Kiss |
---|---|
License | BSD3 |
Maintainer | Csongor Kiss <kiss.csongor.kiss@gmail.com> |
Stability | experimental |
Portability | non-portable |
Safe Haskell | Safe |
Language | Haskell2010 |
Structural subtyping
- class Subtype sub sup where
Documentation
class Subtype sub sup where Source #
Structural subtype relationship
module Test where import GHC.Generics import Record.Generic data Human = Human { name :: String , age :: Int , address :: String } deriving (Generic, Show) data Animal = Animal { name :: String , age :: Int } deriving (Generic, Show) human :: Human human = Human "Tunyasz" 50 "London"
>>>
human
Human {name = "Tunyasz", age = 50, address = "London"}
>>>
upcast human :: Animal
Animal {name = "Tunyasz", age = 50}