-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
APIRequest型クラス #10
Labels
enhancement
New feature or request
Comments
class APIRequest a => FromUserId a where
fromUserId :: UserId -> a
class APIRequest a => FromNoteId a where
fromUserId :: NoteId -> a みたいに作る?? |
思ったんですが、なんか「 もしあるとすれば、APIRequest型クラスの型引数を増やして(ghc拡張にはなる)対応できるかも。 |
Data families若しくはtype familyでできそう |
class APIRequest a where
_id :: Text -> Maybe a
_id = Nothing
sinceId :: Id -> Maybe a
sinceId _ = Nothing
untilId :: Id -> Maybe a
untilId _ = Nothing
... などと全ての「引数にとりうるもの」からAPIRequestを実装している型を作り出すクラスにすると楽かも? |
Lensでよくないですか?????? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
概要
型クラスを使う事で、明示的に各API用のRequestを作らなくてよくなる(伝われ)
実装例
メリット
qualified import
してUN.APIRequest ...
としなくて済むようになる課題
fromMinimum
の型が決まらないfromUserID
などとしたいが、 userIDを使用しないAPIもあるので悩ましいThe text was updated successfully, but these errors were encountered: