PureScriptの型クラス
PureScriptの型クラス
docs
PureScriptの型クラスの継承ツリー
Instance Chains
multi-parameter type class
Functional Dependencies
Orphan Instances
PureScriptのderiving
基本的なclassとinstanceの構文
code:purs(hs)
class Show a where
show :: a -> String
instance Show String where
show s = s
instance (Show a) => Show (Array a) where
show xs = "<> joinWith ", " (map show xs) <> ""
hsと異なり、showStringのように名前を付ける必要があった
がPureScript v.0.14.2から付けなくて良くなった ref
継承の<=の向きがhsと逆
code:purs(hs)
class (Monad m) <= MonadFail m where
fail :: forall a. String -> m a
含意とみなせばいいmrsekut.icon
class A <= B where
Bが存在するならば、Aが存在する
BはAを継承する
Type Classes with Functional Dependenciesにも
In this particular context, the ⇒ symbol should not be read as implication; infact reverse implication would be a more accurate reading, the intention beingthat every instance of Ord is also an instance of Eq.
みたいに書かれてる
Plus型クラス
Alt型クラスを継承する
https://pursuit.purescript.org/packages/purescript-control/5.0.0/docs/Control.Plus
emtpyってなに?
Alt型クラス
Functor型クラスを継承する
https://pursuit.purescript.org/packages/purescript-control/5.0.0/docs/Control.Alt
Bind型クラス
Profunctor型クラス
Newtype型クラス
MonadAsk型クラス
MonadEffect型クラス
MonadThrow型クラス
MonadError型クラス
monad
PureScriptのEffモナド
Effectモナド
Affモナド
https://aratama.github.io/purescript/chapter06.html
https://book.purescript.org/chapter6.html