|
1 |
| -module Data.URI where |
2 |
| - |
3 |
| -import Prelude |
4 |
| - |
5 |
| -import Data.Either (Either) |
6 |
| -import Data.Generic.Rep (class Generic) |
7 |
| -import Data.Generic.Rep.Show (genericShow) |
8 |
| -import Data.List (List) |
9 |
| -import Data.Maybe (Maybe) |
10 |
| -import Data.Monoid (class Monoid) |
11 |
| -import Data.Newtype (class Newtype) |
12 |
| -import Data.Path.Pathy (Path, File, Dir, Abs, Rel, Sandboxed, Unsandboxed) |
13 |
| -import Data.Tuple (Tuple) |
14 |
| - |
15 |
| --- | A generic URI |
16 |
| -data URI = URI (Maybe Scheme) HierarchicalPart (Maybe Query) (Maybe Fragment) |
17 |
| - |
18 |
| -derive instance eqURI ∷ Eq URI |
19 |
| -derive instance ordURI ∷ Ord URI |
20 |
| -derive instance genericURI ∷ Generic URI _ |
21 |
| -instance showURI ∷ Show URI where show = genericShow |
22 |
| - |
23 |
| --- | An absolute URI. |
24 |
| -data AbsoluteURI = AbsoluteURI (Maybe Scheme) HierarchicalPart (Maybe Query) |
25 |
| - |
26 |
| -derive instance eqAbsoluteURI ∷ Eq AbsoluteURI |
27 |
| -derive instance ordAbsoluteURI ∷ Ord AbsoluteURI |
28 |
| -derive instance genericAbsoluteURI ∷ Generic AbsoluteURI _ |
29 |
| -instance showAbsoluteURI ∷ Show AbsoluteURI where show = genericShow |
30 |
| - |
31 |
| --- | A relative reference for a URI. |
32 |
| -data RelativeRef = RelativeRef RelativePart (Maybe Query) (Maybe Fragment) |
33 |
| - |
34 |
| -derive instance eqRelativeRef ∷ Eq RelativeRef |
35 |
| -derive instance ordRelativeRef ∷ Ord RelativeRef |
36 |
| -derive instance genericRelativeRef ∷ Generic RelativeRef _ |
37 |
| -instance showRelativeRef ∷ Show RelativeRef where show = genericShow |
38 |
| - |
39 |
| --- | A general URI path, can be used to represent relative or absolute paths |
40 |
| --- | that are sandboxed or unsandboxed. |
41 |
| -type URIPath a s = Either (Path a Dir s) (Path a File s) |
42 |
| - |
43 |
| --- | The path part for a generic or absolute URI. |
44 |
| -type URIPathAbs = URIPath Abs Sandboxed |
45 |
| - |
46 |
| --- | The path part for a relative reference. |
47 |
| -type URIPathRel = URIPath Rel Unsandboxed |
48 |
| - |
49 |
| --- | An alias for the most common use case of resource identifiers. |
50 |
| -type URIRef = Either URI RelativeRef |
51 |
| - |
52 |
| --- | The scheme part of an absolute URI. For example: `http`, `ftp`, `git`. |
53 |
| -newtype Scheme = Scheme String |
54 |
| - |
55 |
| -derive newtype instance eqScheme ∷ Eq Scheme |
56 |
| -derive newtype instance ordScheme ∷ Ord Scheme |
57 |
| -derive instance genericScheme ∷ Generic Scheme _ |
58 |
| -derive instance newtypeScheme ∷ Newtype Scheme _ |
59 |
| -instance showScheme ∷ Show Scheme where show = genericShow |
60 |
| - |
61 |
| --- | The "hierarchical part" of a generic or absolute URI. |
62 |
| -data HierarchicalPart = HierarchicalPart (Maybe Authority) (Maybe URIPathAbs) |
63 |
| - |
64 |
| -derive instance eqHierarchicalPart ∷ Eq HierarchicalPart |
65 |
| -derive instance ordHierarchicalPart ∷ Ord HierarchicalPart |
66 |
| -derive instance genericHierarchicalPart ∷ Generic HierarchicalPart _ |
67 |
| -instance showHierarchicalPart ∷ Show HierarchicalPart where show = genericShow |
68 |
| - |
69 |
| --- | The "relative part" of a relative reference. |
70 |
| -data RelativePart = RelativePart (Maybe Authority) (Maybe URIPathRel) |
71 |
| - |
72 |
| -derive instance eqRelativePart ∷ Eq RelativePart |
73 |
| -derive instance ordRelativePart ∷ Ord RelativePart |
74 |
| -derive instance genericRelativePart ∷ Generic RelativePart _ |
75 |
| -instance showRelativePart ∷ Show RelativePart where show = genericShow |
76 |
| - |
77 |
| --- | The authority part of a URI. For example: `purescript.org`, |
78 |
| --- | `localhost:3000`, `[email protected]` |
79 |
| -data Authority = Authority (Maybe UserInfo) (Array (Tuple Host (Maybe Port))) |
80 |
| - |
81 |
| -derive instance eqAuthority ∷ Eq Authority |
82 |
| -derive instance ordAuthority ∷ Ord Authority |
83 |
| -derive instance genericAuthority ∷ Generic Authority _ |
84 |
| -instance showAuthority ∷ Show Authority where show = genericShow |
85 |
| - |
86 |
| --- | The user info part of an `Authority`. For example: `user`, `foo:bar`. |
87 |
| -newtype UserInfo = UserInfo String |
88 |
| - |
89 |
| -derive newtype instance eqUserInfo ∷ Eq UserInfo |
90 |
| -derive newtype instance ordUserInfo ∷ Ord UserInfo |
91 |
| -derive instance genericUserInfo ∷ Generic UserInfo _ |
92 |
| -derive instance newtypeUserInfo ∷ Newtype UserInfo _ |
93 |
| -instance showUserInfo ∷ Show UserInfo where show = genericShow |
94 |
| - |
95 |
| --- | A host address. |
96 |
| -data Host |
97 |
| - = IPv6Address String |
98 |
| - | IPv4Address String |
99 |
| - | NameAddress String |
100 |
| - |
101 |
| -derive instance eqHost ∷ Eq Host |
102 |
| -derive instance ordHost ∷ Ord Host |
103 |
| -derive instance genericHost ∷ Generic Host _ |
104 |
| -instance showHost ∷ Show Host where show = genericShow |
105 |
| - |
106 |
| --- | A port number. |
107 |
| -newtype Port = Port Int |
108 |
| - |
109 |
| -derive newtype instance eqPort ∷ Eq Port |
110 |
| -derive newtype instance ordPort ∷ Ord Port |
111 |
| -derive instance genericPort ∷ Generic Port _ |
112 |
| -derive instance newtypePort ∷ Newtype Port _ |
113 |
| -instance showPort ∷ Show Port where show = genericShow |
114 |
| - |
115 |
| --- | The query component of a URI. |
116 |
| -newtype Query = Query (List (Tuple String (Maybe String))) |
117 |
| - |
118 |
| -derive newtype instance eqQuery ∷ Eq Query |
119 |
| -derive newtype instance ordQuery ∷ Ord Query |
120 |
| -derive instance genericQuery ∷ Generic Query _ |
121 |
| -derive instance newtypeQuery ∷ Newtype Query _ |
122 |
| -instance showQuery ∷ Show Query where show = genericShow |
123 |
| -derive newtype instance semigroupQuery ∷ Semigroup Query |
124 |
| -derive newtype instance monoidQuery ∷ Monoid Query |
125 |
| - |
126 |
| --- | The hash fragment of a URI. |
127 |
| -newtype Fragment = Fragment String |
128 |
| - |
129 |
| -derive newtype instance eqFragment ∷ Eq Fragment |
130 |
| -derive newtype instance ordFragment ∷ Ord Fragment |
131 |
| -derive instance genericFragment ∷ Generic Fragment _ |
132 |
| -derive instance newtypeFragment ∷ Newtype Fragment _ |
133 |
| -instance showFragment ∷ Show Fragment where show = genericShow |
| 1 | +module Data.URI |
| 2 | + ( module Data.URI.AbsoluteURI |
| 3 | + , module Data.URI.Authority |
| 4 | + , module Data.URI.Fragment |
| 5 | + , module Data.URI.HierarchicalPart |
| 6 | + , module Data.URI.Host |
| 7 | + , module Data.URI.Path |
| 8 | + , module Data.URI.Port |
| 9 | + , module Data.URI.Query |
| 10 | + , module Data.URI.RelativePart |
| 11 | + , module Data.URI.RelativeRef |
| 12 | + , module Data.URI.Scheme |
| 13 | + , module Data.URI.URI |
| 14 | + , module Data.URI.URIRef |
| 15 | + , module Data.URI.UserInfo |
| 16 | + ) where |
| 17 | + |
| 18 | +import Data.URI.AbsoluteURI (AbsoluteURI(..)) |
| 19 | +import Data.URI.Authority (Authority(..)) |
| 20 | +import Data.URI.Fragment (Fragment(..)) |
| 21 | +import Data.URI.HierarchicalPart (HierarchicalPart(..)) |
| 22 | +import Data.URI.Host (Host(..)) |
| 23 | +import Data.URI.Path (URIPath, URIPathAbs, URIPathRel) |
| 24 | +import Data.URI.Port (Port(..)) |
| 25 | +import Data.URI.Query (Query(..)) |
| 26 | +import Data.URI.RelativePart (RelativePart(..)) |
| 27 | +import Data.URI.RelativeRef (RelativeRef(..)) |
| 28 | +import Data.URI.Scheme (Scheme(..)) |
| 29 | +import Data.URI.URI (URI(..)) |
| 30 | +import Data.URI.URIRef (URIRef) |
| 31 | +import Data.URI.UserInfo (UserInfo(..)) |
0 commit comments