Skip to content

Commit

Permalink
Merge pull request #78 from Nemocas/blub
Browse files Browse the repository at this point in the history
Fix the composition
  • Loading branch information
wbhart authored Apr 20, 2018
2 parents da8670a + 7a87865 commit 92d04a6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/generic/GenericTypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -658,8 +658,8 @@ mutable struct CompositeMap{D, C} <: AbstractAlgebra.Map{D, C, AbstractAlgebra.S
map1::AbstractAlgebra.Map
map2::AbstractAlgebra.Map

function CompositeMap(map1::AbstractAlgebra.Map{U, C}, map2::AbstractAlgebra.Map{D, U}) where {D, U, C}
return new{D, C}(domain(map2), codomain(map1), map1, map2)
function CompositeMap(map1::AbstractAlgebra.Map{D, U}, map2::AbstractAlgebra.Map{U, C}) where {D, U, C}
return new{D, C}(domain(map1), codomain(map2), map1, map2)
end
end

Expand Down Expand Up @@ -699,7 +699,7 @@ mutable struct FunctionalCompositeMap{D, C} <: AbstractAlgebra.Map{D, C, Abstrac
fn_cache::Function

function FunctionalCompositeMap(map1::Map(AbstractAlgebra.FunctionalMap){U, C}, map2::Map(AbstractAlgebra.FunctionalMap){D, U}) where {D, U, C}
return new{D, C}(domain(map2), codomain(map1), map1, map2)
return new{D, C}(domain(map1), codomain(map2), map1, map2)
end
end

Expand Down
10 changes: 5 additions & 5 deletions src/generic/Map.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ set_field!(M, f) = setfield(M, f) # fall back to Julia builtin
domain(f::AbstractAlgebra.Map) = get_field(f, :domain)
codomain(f::AbstractAlgebra.Map) = get_field(f, :codomain)

function check_composable(a::AbstractAlgebra.Map{U, C}, b::AbstractAlgebra.Map{D, U}) where {C, U, D}
domain(a) != codomain(b) && error("Incompatible maps")
function check_composable(a::AbstractAlgebra.Map{D, U}, b::AbstractAlgebra.Map{U, C}) where {D, U, C}
codomain(a) != domain(b) && error("Incompatible maps")
end

*(f::Map, g::Map) = compose(f, g)
Expand All @@ -37,7 +37,7 @@ function (f::CompositeMap{D, C})(a) where {D, C}
return f.map2(f.map1(a))::elem_type(C)
end

function compose(f::AbstractAlgebra.Map{U, C}, g::AbstractAlgebra.Map{D, U}) where {D, U, C}
function compose(f::AbstractAlgebra.Map{D, U}, g::AbstractAlgebra.Map{U, C}) where {D, U, C}
check_composable(f, g)
return CompositeMap(f, g)
end
Expand Down Expand Up @@ -74,12 +74,12 @@ function show(io::IO, M::IdentityMap)
println(io, domain(M))
end

function compose(f::AbstractAlgebra.Map(AbstractAlgebra.IdentityMap){C, C}, g::AbstractAlgebra.Map{D, C}) where {D, C}
function compose(f::AbstractAlgebra.Map(AbstractAlgebra.IdentityMap){D, D}, g::AbstractAlgebra.Map{C, D}) where {D, C}
check_composable(f, g)
return g
end

function compose(f::AbstractAlgebra.Map{D, C}, g::AbstractAlgebra.Map(AbstractAlgebra.IdentityMap){D, D}) where {D, C}
function compose(f::AbstractAlgebra.Map{D, C}, g::AbstractAlgebra.Map(AbstractAlgebra.IdentityMap){C, C}) where {D, C}
check_composable(f, g)
return f
end
Expand Down

0 comments on commit 92d04a6

Please sign in to comment.