<div style="font-family: 'Times New Roman'; font-size: 16px;">Hi<br />Is it reasonable to consider a Haskell class as a loose signature-only-specification (denoting a theory) and an instance as an implementation (denoting a model)?<br />In the example below the specification of the class BUILDING is textually smaller than the specification of the class HOUSE,<br />provided we consider the operation inherited by HOUSE from BUILDING to be part of the signature of HOUSE (this may not be a valid assumption). <br /> Is there a Galois correspondence between a Haskell class hierarchy and a given instance hierarchy for a particular type?<br />So more details are explained as [<a href="http://cstheory.stackexchange.com/questions/18215/is-there-a-model-theory-for-haskell-type-classes">1</a> ,<a href="http://cstheory.stackexchange.com/questions/18549/is-there-a-galois-correspondence-between-a-haskell-class-hierarchy-and-its-insta">2</a> ].<br />Pat<br />--General Idea--<br /><br /> Theory subTheory Theory' <=> Model' subModel Model<br /><br />--A specific example with Haskell class-to-instance relation --<br /><br />class(BUILDING) subTheory class(HOUSE) <=> instance(HOUSE)} subModel instance(BUILDING)<br /><br />----------------<br /><br /><br /><br /><br /> data House = House deriving Show<br /> data Building = Building deriving Show<br /><br /> class BUILDING building where<br /> -- specify the behavior of buildings here, if any<br /> supportRoof :: building -> String<br /><br /> class BUILDING house => HOUSE house where<br /> -- specify additional behavior of houses here, if any<br /> live::house -> Bool<br /><br /> instance BUILDING Building where<br /> -- specify how the type Building implements the behavior of type class BUILDING<br /> supportRoof b = "BUILDING.Building"<br /> -- A particular b which is a BUILDING.Building.particular can support a roof<br /><br /> instance BUILDING House where <br /> supportRoof h = "BUILDING.House"<br /> -- A particular h which is a BUILDING.House.particular can support a roof<br /><br /> instance HOUSE House where<br /> -- specify how the type House implements the behaviour of type class HOUSE<br /> live h = if ((supportRoof h) == "BUILDING.House") then True else False<br /> -- An particular h HOUSE.House.particular can support a roof in exactly the same way as BUILDING.House.particular can.<br /><br /> instance HOUSE Building where<br /> -- specify how the type Building implements the behaviour of type class HOUSE<br /> live b = if ((supportRoof b) == "BUILDING.Building") then True else False<br /> -- An particular b HOUSE.Building.particular can support a roof in exactly the same way as BUILDING.Building.particular can.<br /><br /><br /></div>
<br clear=all> Tá an teachtaireacht seo scanta ó thaobh ábhar agus víreas ag Seirbhís Scanta Ríomhphost de chuid Seirbhísí Faisnéise, ITBÁC agus meastar í a bheith slán. <a href="http://www.dit.ie">http://www.dit.ie</a><br>
This message has been scanned for content and viruses by the DIT Information Services E-Mail Scanning Service, and is believed to be clean. <a href="http://www.dit.ie">http://www.dit.ie</a>