git.iko.soy/typeable/servant
on master help sign in
Another Day instance removed
ef3cf9fJulian K. Arni
servant-examples/tutorial/T1.hs+1−6
@@ -17,17 +17,12 @@ data User = User
17 , registration_date :: Day
17 , registration_date :: Day
18 } deriving (Eq, Show, Generic)
18 } deriving (Eq, Show, Generic)
19
19
20−-- orphan ToJSON instance for Day. necessary to derive one for User
21−instance ToJSON Day where
22− -- display a day in YYYY-mm-dd format
23− toJSON d = toJSON (showGregorian d)
24−
25instance ToJSON User
20instance ToJSON User
26
21
27type UserAPI = "users" :> Get '[JSON] [User]
22type UserAPI = "users" :> Get '[JSON] [User]
28
23
29users :: [User]
24users :: [User]
30−users =
25+users =
31 [ User "Isaac Newton" 372 "isaac@newton.co.uk" (fromGregorian 1683 3 1)
26 [ User "Isaac Newton" 372 "isaac@newton.co.uk" (fromGregorian 1683 3 1)
32 , User "Albert Einstein" 136 "ae@mc2.org" (fromGregorian 1905 12 1)
27 , User "Albert Einstein" 136 "ae@mc2.org" (fromGregorian 1905 12 1)
33 ]
28 ]