Commit fa16f707 authored by Jan Rasmus Tikovsky 's avatar Jan Rasmus Tikovsky
Browse files

Now the comment regarding the export expansion of records matches the...

Now the comment regarding the export expansion of records matches the behaviour implemented in the frontend
parent fe83ac4d
......@@ -233,17 +233,15 @@ exportType t = ExportTypeWith tc xs
where tc = origName t
xs = elements t
-- For compatibility with Haskell, we allow exporting field labels but
-- not constructors individually as well as together with their types.
-- In contrast to Haskell, the export of field labels and record constructors
-- without their types is NOT allowed.
-- Thus, given the declaration @data T a = C { l :: a }@
-- the export lists @(T(C,l))@ and @(T(C),l)@ are equivalent and both
-- export the constructor @C@ and the field label @l@ together with the
-- type @T@. However, it is also possible to export the label @l@
-- without exporting its type @T@. In this case, the label is exported
-- just like a top-level function (namely the implicit record selection
-- function corresponding to the label). In order to avoid ambiguities
-- in the interface, we convert an individual export of a label @l@ into
-- the form @T(l)@ whenever its type @T@ occurs in the export list as well.
-- the label @l@ and the constructor @C@ can only be exported together with the
-- type @T@, i.e., @(T(C,l))@.
-- Since record update operations are desugared to case expressions matching the
-- corresponding constructors of the record, the export of a label without its
-- type could result in a type error, when it is used for an update operation in
-- another module.
canonExports :: TCEnv -> [Export] -> [Export]
canonExports tcEnv es = map (canonExport (canonLabels tcEnv es)) es
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment