You could try elm-generic-dict to have arbitrary keys in dicts.

On Monday, January 16, 2017 at 6:31:28 AM UTC-8, Austin Bingham wrote:
>
> Ah ha! That bit of syntax is exactly what I was looking for. That get's me 
> a lot of what I was hoping for.
>
> Regarding the use of helper functions, I agree in principle. But in my 
> particular case, at least, I think it's mostly an academic issue. I want to 
> distinguish between various "classes" of strings using the type system, but 
> mostly all I do with them is store them and use them as keys. 
>
> One interesting issue I've run into is the use of single-contructor unions 
> as e.g. the key-type in a dict. As far as I can tell, I can't do something 
> like this:
>
>     type Foo = Foo String
>     type alias FooDict = Dict Foo String
>
> because Foo isn't "comparable" and can't be made so. Is there some way to 
> do this, or is this just a limitation of elm?
>
> On Monday, January 16, 2017 at 2:49:46 PM UTC+1, Ian Mackenzie wrote:
>>
>> I agree with the point about adding helper functions for your data type 
>> so you can treat it as opaque in most places. For the rest, though, you can 
>> also use the slightly obscure 'as' syntax 'foo ((Foo s) as f) = ...' which 
>> allows you to use both 's' and 'f' in your function body (with the 
>> additional bonus of avoiding an extra object allocation).
>
>

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to