File tree Expand file tree Collapse file tree 1 file changed +33
-2
lines changed Expand file tree Collapse file tree 1 file changed +33
-2
lines changed Original file line number Diff line number Diff line change 1
1
module Code.Definition.Reference exposing (..)
2
2
3
- import Code.FullyQualifiedName exposing (FQN )
4
- import Code.Hash exposing (Hash )
3
+ import Code.FullyQualifiedName as FQN exposing (FQN )
4
+ import Code.Hash as Hash exposing (Hash )
5
5
import Code.HashQualified as HQ exposing (HashQualified )
6
+ import List.Nonempty as NEL
6
7
import UI.Icon as Icon exposing (Icon )
7
8
import Url.Parser
8
9
@@ -199,3 +200,33 @@ map f ref =
199
200
200
201
DataConstructorReference hq ->
201
202
DataConstructorReference ( f hq)
203
+
204
+
205
+ toUrlPath : Reference -> List String
206
+ toUrlPath ref =
207
+ let
208
+ hqToPath hq =
209
+ case hq of
210
+ HQ . NameOnly fqn_ ->
211
+ fqn_ |> FQN . toUrlSegments |> NEL . toList
212
+
213
+ HQ . HashOnly h ->
214
+ [ Hash . toUrlString h ]
215
+
216
+ HQ . HashQualified _ h ->
217
+ -- TODO: Currently not supported, since we favor the hash
218
+ -- because HashQualified url parsing is broken
219
+ [ Hash . toUrlString h ]
220
+ in
221
+ case ref of
222
+ TypeReference hq ->
223
+ " types" :: hqToPath hq
224
+
225
+ TermReference hq ->
226
+ " terms" :: hqToPath hq
227
+
228
+ AbilityConstructorReference hq ->
229
+ " ability-constructors" :: hqToPath hq
230
+
231
+ DataConstructorReference hq ->
232
+ " data-constructors" :: hqToPath hq
You can’t perform that action at this time.
0 commit comments