takino takayuki
extencibleに関する質問です
scrapboxのプログラムを試していましたが、エラーの修正方法が見付かりませんので、御教授願います。
type Person = Record '[ "personId" :> Int, "name" :> String]
type Address = Record '[ "personId" :> Int, "address" :> String]
-- Associate??
getPersonId :: Associate "personId" Int xs => Record xs -> Int
getPersonId = view #personId
-- エラーメッセージ
-- [1 of 1] Compiling Main ( src/extensible.hs, interpreted )
--
-- src/extensible.hs:83:16: error:
-- Not in scope: type constructor or class ‘Associate’
-- Perhaps you meant one of these:
-- ‘Associated’ (imported from Data.Extensible),
-- ‘Associated'’ (imported from Data.Extensible)
-- |
-- 83 | getPersonId :: Associate "personId" Int xs => Record xs -> Int
-- | ^^^^^^^^^
-- Failed, no modules loaded.
-- 参考にしているサイト
https://scrapbox.io/haskell-shoen/extensible%2F%E5%88%9D%E5%BF%83%E8%80%85%E5%90%91%E3%81%91%E6%94%BB%E7%95%A5%E6%83%85%E5%A0%B1
scrapboxのプログラムを試していましたが、エラーの修正方法が見付かりませんので、御教授願います。
type Person = Record '[ "personId" :> Int, "name" :> String]
type Address = Record '[ "personId" :> Int, "address" :> String]
-- Associate??
getPersonId :: Associate "personId" Int xs => Record xs -> Int
getPersonId = view #personId
-- エラーメッセージ
-- [1 of 1] Compiling Main ( src/extensible.hs, interpreted )
--
-- src/extensible.hs:83:16: error:
-- Not in scope: type constructor or class ‘Associate’
-- Perhaps you meant one of these:
-- ‘Associated’ (imported from Data.Extensible),
-- ‘Associated'’ (imported from Data.Extensible)
-- |
-- 83 | getPersonId :: Associate "personId" Int xs => Record xs -> Int
-- | ^^^^^^^^^
-- Failed, no modules loaded.
-- 参考にしているサイト
https://scrapbox.io/haskell-shoen/extensible%2F%E5%88%9D%E5%BF%83%E8%80%85%E5%90%91%E3%81%91%E6%94%BB%E7%95%A5%E6%83%85%E5%A0%B1