https://github.com/xich/scotty/issues/26
https://github.com/xich/scotty/pull/27
class ScottyString a where
toContent :: a -> Content
toText :: a -> T.Text
fromScotty :: T.Text -> a
instance ScottyString B.ByteString where
toContent bs = ContentBuilder (fromByteString bs)
toText bs = toText $ BL.fromChunks [bs]
fromScotty = B.concat . BL.toChunks . fromScotty
instance ScottyString BL.ByteString where
toContent bs = ContentBuilder (fromLazyByteString bs)
toText = decodeUtf8
fromScotty = encodeUtf8
instance ScottyString T.Text where
toContent = toContent . encodeUtf8
toText = id
fromScotty = id
instance ScottyString String where
toContent = toContent . T.pack
toText = T.pack
fromScotty = T.unpack
私にとっては問題なく動作しますが、古いコードは壊れています...現在、一部の関数にはデフォルトの型がないためです。
この型クラスのデフォルトの型 ( Textなど) を追加するにはどうすればよいですか?