# Advice on using singleton types for dispatch

**URL:** <https://discourse.julialang.org/t/advice-on-using-singleton-types-for-dispatch/24245>\
**Category:** General Usage\
**Created:** [May 15, 2019, 4:29pm UTC](https://discourse.julialang.org/t/advice-on-using-singleton-types-for-dispatch/24245 "2019-05-15T16:29:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jbmuir](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jbmuir/32/4798_2.png) [@jbmuir](https://discourse.julialang.org/u/jbmuir)\
**Post date:** [May 15, 2019, 4:29pm UTC](https://discourse.julialang.org/t/advice-on-using-singleton-types-for-dispatch/24245/1 "2019-05-15T16:29:47Z")

</div>

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

```julia
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()
end

function eik_solve(..., norm::L1Norm) 
\\code
end

function eik_solve(..,norm::L2Norm)
\\code
end

function eik_solve(...,norm::LInfNorm)
\\code
end

end

```

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?

---

<div class="post-metadata">

**Author:** ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)\
**Post date:** [May 15, 2019, 4:41pm UTC](https://discourse.julialang.org/t/advice-on-using-singleton-types-for-dispatch/24245/2 "2019-05-15T16:41:02Z")

</div>

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.
