Advice on using singleton types for dispatch


I’m writing an extension for LightGraphs.jl to calculate solutions of the eikonal equation over weighted graphs; I would like to provide for the option to use different norms when calculating solutions. Currently my setup looks like

module GraphEikonal

export graph_eikonal
export L1Norm, L2Norm, LInfNorm

using LightGraphs: AbstractGraph, outneighbors, nv
using DataStructures: PriorityQueue, dequeue!

abstract type LPNorm end
struct L1Norm <: LPNorm end
struct L2Norm <: LPNorm end
struct LInfNorm <: LPNorm end

function graph_eikonal(...; norm::LPNorm = L2Norm())
\\code calling eik_solve()

function eik_solve(..., norm::L1Norm) 

function eik_solve(..,norm::L2Norm)

function eik_solve(...,norm::LInfNorm)


My question is basically - it seems like overkill to define these imposingly named LPNorm types, cluttering up the user’s set of imported types, just so that I can use them for dispatch, especially when the current names have nothing to do with graphs in particular - it seems like I might be stepping on other modules toes. Is there a more idiomatic way to structure the code to avoid this issue? Or should I just rename the types / not worry about it?


I would not worry about it, users can always import your package instead of using it if they don’t want to make all exported names available.