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
In BibTeX, values can be concatenated to form a new value. BibTeX.Types supports this feature, but the implementation can be more precise: If you look closely, you will see that the set of all possible values forms a monoid together with the contatenation operation defined on it. Here's the proof:
Value is the set of all possible values. Each element v of Value has the data type Value and is constructed using one of the three constructors LiteralValue, ReferencedValue, and ComposedValue.
Also, we define the expansion operation e of a value:
e::Value->String
where e v is the expanded string representation of v (i.e. the meaning of v as ordinary text, with variable references replaced by their definition recursively)
Third, we define the concatenation operation <+> like following:
<+>:V x V-->V
where r = v1 <+> v2 is defined such that e r == e v1 ++ e v2.
The Value type in BibTeX.Types is not the actual value of a field. Semantically, a field's value is equal to the expansion of its Value element. The internal representation of a field's value therefore has to simulate the semantics of its expansion. This means, that concatenating Value elements is semantically equivalent to concatenating their expansions.
Because of that, Values inherit all characteristics from Strings which are based on the String concatenation (++). Strings form a Monoid with their concatenation, and therefore also Values do, q.e.d.
It would be a good idea to adapt the Value type according to Monoid laws and create a corresponding instance of Monoid. This will make the properties of Value easier to see and understand and therefore improve code quality.
The text was updated successfully, but these errors were encountered:
Scope: bibtoxml/src/BibTeX/Types.hs
In BibTeX, values can be concatenated to form a new value. BibTeX.Types supports this feature, but the implementation can be more precise: If you look closely, you will see that the set of all possible values forms a monoid together with the contatenation operation defined on it. Here's the proof:
Value
is the set of all possible values. Each element v ofValue
has the data typeValue
and is constructed using one of the three constructorsLiteralValue
,ReferencedValue
, andComposedValue
.Also, we define the expansion operation e of a value:
where
e v
is the expanded string representation ofv
(i.e. the meaning ofv
as ordinary text, with variable references replaced by their definition recursively)Third, we define the concatenation operation
<+>
like following:where
r = v1 <+> v2
is defined such thate r == e v1 ++ e v2
.The
Value
type in BibTeX.Types is not the actual value of a field. Semantically, a field's value is equal to the expansion of itsValue
element. The internal representation of a field's value therefore has to simulate the semantics of its expansion. This means, that concatenatingValue
elements is semantically equivalent to concatenating their expansions.Because of that,
Value
s inherit all characteristics fromString
s which are based on theString
concatenation(++)
.String
s form a Monoid with their concatenation, and therefore alsoValue
s do, q.e.d.It would be a good idea to adapt the
Value
type according to Monoid laws and create a corresponding instance of Monoid. This will make the properties ofValue
easier to see and understand and therefore improve code quality.The text was updated successfully, but these errors were encountered: