<div style="font-family: 'Times New Roman'; font-size: 16px;">Thanks to Roman and Eric for for their clear explanations.<br />Pat<br /><br /><br /><span>On 09/07/13, <b class="name">Roman Cheplyaka </b> <roma@ro-che.info> wrote:</span><blockquote cite="mid:20130709133428.GA5869@sniper" class="iwcQuote" style="border-left: 1px solid #00F; padding-left: 13px; margin-left: 0;" type="cite"><div class="mimepart text plain">The compiler defaults the kind of 'quality' (i.e. the first argument of<br />QUALITIES) to *, not being able to infer it from the class definition<br />itself (and other definitions that it references).<br /><br />Since you want it to have kind * -> *, you should enable KindSignatures<br />and add an annotation, or otherwise disambiguate the kind.<br /><br />This behaviour follows the Haskell Report. The change from previous<br />versions of GHC is documented here:<br /><a href="http://www.haskell.org/ghc/docs/7.4.1/html/users_guide/release-7-4-1.html#id3015054" target="_blank">http://www.haskell.org/ghc/docs/7.4.1/html/users_guide/release-7-4-1.html#id3015054</a><br /><br />Roman<br /><br />* Patrick Browne <patrick.browne@dit.ie> [2013-07-09 12:45:19+0100]<br />> Hi,<br />> The code [1] below compiles and runs with GHCi version 7.0.4.<br />> I get one warning and an error message with GHCi version 7.6.1.<br />> 1) Warning -XDatatypeContexts is deprecated. Unless there are<br />> propagation effects, this is well explained.<br />> 2) foom-1.hs:65:15:<br />> `quality' is applied to too many type arguments<br />> In the type `quality entity -> agent -> IO Observation'<br />> In the class declaration for `OBSERVERS'<br />> Failed, modules loaded: none.<br />> I do not understand the error message from 7.6.1.<br />> I am not too interested actually fixing it, I just want to understand<br />> it.<br />> Thanks,<br />> Pat<br />> [1]The code is from: A Functional Ontology of Observation and<br />> Measurement Werner Kuhn<br />> {-# LANGUAGE DatatypeContexts,MultiParamTypeClasses #-}<br />> module ENDURANTS where<br />> import System.Time<br />> type Id = String<br />> type Position = Integer<br />> type Moisture = Float<br />> type Celsius = String<br />> type Heat = Float<br />> data WeatherStation = WeatherStation Id Position deriving Show<br />> data Value = Boolean Bool | Count Int | Measure Float | Category String<br />> deriving Show<br />> data Observation = Observation Value Position ClockTime deriving Show<br />> data AmountOfAir = AmountOfAir Heat Moisture deriving Show<br />> muensterAir = AmountOfAir 10.0 70.0<br />> class ENDURANTS endurant where<br />> <br />> -- must add instances all down the hierarchy for each instance<br />> instance ENDURANTS WeatherStation where<br />> instance ENDURANTS AmountOfAir where<br />> class ENDURANTS physicalEndurant => PHYSICAL_ENDURANTS physicalEndurant<br />> where<br />> instance PHYSICAL_ENDURANTS WeatherStation where<br />> instance PHYSICAL_ENDURANTS AmountOfAir where<br />> class PHYSICAL_ENDURANTS amountOfMatter => AMOUNTS_OF_MATTER<br />> amountOfMatter where<br />> instance AMOUNTS_OF_MATTER WeatherStation where<br />> class PHYSICAL_ENDURANTS physicalObject => PHYSICAL_OBJECTS<br />> physicalObject where<br />> instance PHYSICAL_OBJECTS WeatherStation where<br />> class PHYSICAL_OBJECTS apo => APOS apo where<br />> getPosition :: apo -> Position<br />> instance APOS WeatherStation where<br />> getPosition (WeatherStation iD pos) = pos + 10<br />> <br />> -- a data type declaration and data type constructor.<br />> data PHYSICAL_ENDURANTS physicalEndurant => Temperature<br />> physicalEndurant = Temperature physicalEndurant deriving Show<br />> -- Qualities the class of all quality types (= properties) is a<br />> constructor class<br />> -- its constructors can be applied to endurants, perdurants, qualities<br />> or abstracts<br />> class QUALITIES quality entity<br />> instance QUALITIES Temperature AmountOfAir<br />> class (APOS agent, QUALITIES quality entity) => OBSERVERS agent quality<br />> entity where<br />> observe :: quality entity -> agent -> IO Observation<br />> express :: quality entity -> agent -> Value<br />> observe quale agent = do<br />> clockTime <- getClockTime<br />> return (Observation (express quale agent)<br />> (getPosition agent) clockTime)<br />> instance OBSERVERS WeatherStation Temperature AmountOfAir where<br />> express (Temperature (AmountOfAir heat moisture)) weatherStation =<br />> Measure heat<br />> {-<br />> -- running the following<br />> express (Temperature (AmountOfAir 40 20)) (WeatherStation "rr" 6)<br />> -- Gives<br />> Measure 40.0 Measure 40.0<br />> -- We can get the type: Value<br />> :t express (Temperature (AmountOfAir 40 20)) (WeatherStation "rr" 6)<br />> -}<br />> <br />> Tá an teachtaireacht seo scanta ó thaobh ábhar agus víreas ag Seirbhís<br />> Scanta Ríomhphost de chuid Seirbhísí Faisnéise, ITBÁC agus meastar í a<br />> bheith slán. [1]<a href="http://www.dit.ie" target="_blank">http://www.dit.ie</a><br />> This message has been scanned for content and viruses by the DIT<br />> Information Services E-Mail Scanning Service, and is believed to be<br />> clean. [2]<a href="http://www.dit.ie" target="_blank">http://www.dit.ie</a><br />> <br />> References<br />> <br />> 1. <a href="http://www.dit.ie/" target="_blank">http://www.dit.ie/</a><br />> 2. <a href="http://www.dit.ie/" target="_blank">http://www.dit.ie/</a><br /><br />> _______________________________________________<br />> Haskell-Cafe mailing list<br />> Haskell-Cafe@haskell.org<br />> <a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br /><br /></div></blockquote></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>