@@ -54,7 +54,8 @@ FinSet(n::Int) = FinSetInt(n)
5454
5555Base. iterate (set:: FinSetInt , args... ) = iterate (1 : set. n, args... )
5656Base. length (set:: FinSetInt ) = set. n
57- Base. in (set:: FinSetInt , elem) = in (elem, 1 : set. n)
57+ # Code review note: the arguments seem to have been placed backwards originally
58+ Base. in (elem, set:: FinSetInt ) = in (elem, 1 : set. n)
5859
5960Base. show (io:: IO , set:: FinSetInt ) = print (io, " FinSet($(set. n) )" )
6061
@@ -285,12 +286,27 @@ Base.collect(f::SetFunction) = force(f).func
285286
286287""" Function in **FinSet** represented explicitly by a vector.
287288"""
288- const FinFunctionVector{S,T,V<: AbstractVector{T} } =
289- FinDomFunctionVector{T,V,<: FinSet{S,T} }
290-
291- Base. show (io:: IO , f:: FinFunctionVector ) =
289+ # Code review note: This type declaration is regarded by Julia
290+ # as equal (i.e. ==) to the extant declaration. I feel that giving
291+ # `FinFunctionVector` an explicit parameter to represent the type of the
292+ # codomain improves the self-documentation aspect of the code.
293+ const FinFunctionVector{S,T,V<: AbstractVector{T} ,Codom<: FinSet{S,T} } =
294+ FinDomFunctionVector{T,V,Codom}
295+
296+ # Code review note: showing just the length of the codomain is not ideal when
297+ # the codomain is not a `FinSetInt`
298+ Base. show (io:: IO , f:: FinFunctionVector{Int} ) =
292299 print (io, " FinFunction($(f. func) , $(length (dom (f))) , $(length (codom (f))) )" )
293300
301+ function Base. show (io:: IO , f:: F ) where {F<: FinFunctionVector }
302+ Sets. show_type_constructor (io, F)
303+ print (io, " (" )
304+ show (io, f. func)
305+ print (io, " , $(length (dom (f))) , " )
306+ Sets. show_domains (io, f, domain= false )
307+ print (io, " )" )
308+ end
309+
294310Sets. do_compose (f:: FinFunctionVector , g:: FinDomFunctionVector ) =
295311 FinDomFunctionVector (g. func[f. func], codom (g))
296312
@@ -542,8 +558,10 @@ force(f::FinDomFunctionDict) = f
542558
543559""" Function in **FinSet** represented by a dictionary.
544560"""
545- const FinFunctionDict{K,D<: AbstractDict{K} ,Codom<: FinSet } =
561+ const FinFunctionDict{K,D<: AbstractDict{K} ,S, Codom<: FinSet{S} } =
546562 FinDomFunctionDict{K,D,Codom}
563+ # Code review note: The additional parameter `S` allows `FinFunctionDict` to be
564+ # recognized as a subtype of `FinFunction`
547565
548566FinFunctionDict (d:: AbstractDict , codom:: FinSet ) = FinDomFunctionDict (d, codom)
549567FinFunctionDict (d:: AbstractDict{K,V} ) where {K,V} =
0 commit comments