11module Data.HTTP.Method
22 ( Method (..)
3- , CustomMethod ()
4- , runCustomMethod
3+ , CustomMethod
4+ , unCustomMethod
55 , fromString
66 , print
77 ) where
88
99import Prelude
1010
1111import Data.Either (Either (..), either )
12- import Data.Generic (Generic , gCompare )
12+ import Data.Generic (class Generic )
1313import Data.String as Str
1414
1515data Method
@@ -35,30 +35,10 @@ data Method
3535 -- RFC5789
3636 | PATCH
3737
38+ derive instance eqMethod :: Eq Method
39+ derive instance ordMethod :: Ord Method
3840derive instance genericMethod :: Generic Method
3941
40- instance eqMethod :: Eq Method where
41- eq OPTIONS OPTIONS = true
42- eq GET GET = true
43- eq HEAD HEAD = true
44- eq POST POST = true
45- eq PUT PUT = true
46- eq DELETE DELETE = true
47- eq TRACE TRACE = true
48- eq CONNECT CONNECT = true
49- eq PROPFIND PROPFIND = true
50- eq PROPPATCH PROPPATCH = true
51- eq MKCOL MKCOL = true
52- eq COPY COPY = true
53- eq MOVE MOVE = true
54- eq LOCK LOCK = true
55- eq UNLOCK UNLOCK = true
56- eq PATCH PATCH = true
57- eq _ _ = false
58-
59- instance ordMethod :: Ord Method where
60- compare = gCompare
61-
6242instance showMethod :: Show Method where
6343 show OPTIONS = " OPTIONS"
6444 show GET = " GET"
@@ -79,17 +59,13 @@ instance showMethod :: Show Method where
7959
8060newtype CustomMethod = CustomMethod String
8161
82- runCustomMethod :: CustomMethod -> String
83- runCustomMethod (CustomMethod m) = m
62+ unCustomMethod :: CustomMethod -> String
63+ unCustomMethod (CustomMethod m) = m
8464
65+ derive instance eqCustomMethod :: Eq CustomMethod
66+ derive instance ordCustomMethod :: Ord CustomMethod
8567derive instance genericCustomMethod :: Generic CustomMethod
8668
87- instance eqCustomMethod :: Eq CustomMethod where
88- eq (CustomMethod m1) (CustomMethod m2) = m1 == m2
89-
90- instance ordCustomMethod :: Ord CustomMethod where
91- compare = gCompare
92-
9369instance showCustomMethod :: Show CustomMethod where
9470 show (CustomMethod m) = " (CustomMethod " <> show m <> " )"
9571
@@ -114,4 +90,4 @@ fromString s =
11490 m -> Right (CustomMethod m)
11591
11692print :: Either Method CustomMethod -> String
117- print = either show runCustomMethod
93+ print = either show unCustomMethod
0 commit comments