YK
Увидеть как применяют хаскель для одной из самых частых задач - реализации rest API.
Size: a a a
YK
AP
AP
AP
YK
AP
AP
data Routes route = Routes
{ _get :: route :- Capture "id" Int :> Get '[JSON] String
, _put :: route :- ReqBody '[JSON] Int :> Put '[JSON] Bool
}
deriving (Generic)
api :: Proxy (ToServantApi Routes)
api = genericApi (Proxy :: Proxy Routes)
AP
YK
AP
data Example = Exampleвот ещё "пишешь тип, получаешь CLI"
{ foo :: Int <?> "Documentation for the foo flag"
, bar :: Double <?> "Documentation for the bar flag"
} deriving (Generic, Show)
instance ParseRecord Example
main = do
x <- getRecord "Test program"
print (x :: Example)
Test program
Usage: Example.hs --foo INT --bar DOUBLE
Available options:
-h,--help Show this help text
--foo INT Documentation for the foo flag
--bar DOUBLE Documentation for the bar flag
AP
AP
data Example
= Create { name :: Text, duration :: Maybe Int }
| Kill { name :: Text }
deriving (Generic, Show)
позволит писать$ app create --name foo --duration=60
YK
DK
DK
AP
WriterT [Error] (MaybeT IO Conn)
AP