You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
I tried the code for makePropertyObj at 13.3. USING GENERIC METADATA, page 183
it gives type error. Also checked the code on github it is left as undefined
the original code is (shown as on the book)
makePropertyObj :: forall name . (KnownSymbol name) => Value -> Value
makePropertyObj v = object [pack (symbolVal $ Proxy @name) .= v ]
I noticed the error was due to Haskell could not infer the type as Key from the code pack (symbolVal $ Proxy @name) and was giving below error (which worked for makeTypeObj function)
• Couldn't match expected type ‘Key’ with actual type ‘Text’
• In the first argument of ‘(.=)’, namely
‘pack (symbolVal $ Proxy @name)’
In the expression: pack (symbolVal $ Proxy @name) .= v
In the first argument of ‘object’, namely
‘[pack (symbolVal $ Proxy @name) .= v]’typecheck(-Wdeferred-type-errors)
I made some small changes and Key to import list from aeson package also used fromText and imported Data.Aeson.Key (fromText) and used fromText to convert Text to key and it works i believe if it is the intent;
here is the slightly modified code;
makePropertObj :: forall name . KnownSymbol name => Value -> Value
makePropertObj v = object [fromText (pack (symbolVal $ Proxy @name)) .= v ]
and just did a quick check on it if it works as it is
I think this must be bit-rotten, unfortunately! Another thing to tackle if a second edition ever happens. Thanks for the report!
i started learning Haskell couple of months ago . your book really helped me a lot to get into Type level programming but a newer version would be awesome.
Learning so much from you.. Thank you so much
Hi,
I tried the code for
makePropertyObj
at13.3. USING GENERIC METADATA, page 183
it gives type error. Also checked the code on github it is left as undefined
the original code is (shown as on the book)
I noticed the error was due to Haskell could not infer the type as Key from the code
pack (symbolVal $ Proxy @name)
and was giving below error (which worked for makeTypeObj function)I made some small changes and Key to import list from aeson package also used fromText and imported
Data.Aeson.Key (fromText)
and usedfromText
to convert Text to key and it works i believe if it is the intent;here is the slightly modified code;
and just did a quick check on it if it works as it is
also the changes on the import list I made ;
The text was updated successfully, but these errors were encountered: