質問
モナディデータ型を設計するのに役立つ、私はその考えの周りに頭を包むのに苦労しているようですが、私はかなり間違いなく私が欲しいものを知っています。タイプチェッカーだけがその問題に説得する必要があるようです。
私が欲しいのは、Monadになることができるいくつかのデータ型Primitive
です。その機能は基本的にプリミティブを描画しており、ライブラリーのParser
のparsec
型と同じように、それらとプリミティブである組み合わせと組み合わせることができます。しかし、実際の図面はIO
Monadで行われなければなりません。
ちなみに、私はこのような一般的なDrawable a
も持っています:
class Drawable a where
draw :: (MonadIO m) => Pos -> a -> m ()
.
そして私はもちろんすべての原始的なものが描かれて欲しいのですが。入力に感謝します。
解決
I don't understand why you think this should be a monad. What's monadic about it?
You should design the API you want first, and incrementally think about how to abstract it.
Incidentally, Brent's diagrams library has a very nice compositional API that could provide some good ideas: http://byorgey.wordpress.com/2008/04/30/new-haskell-diagrams-library/
所属していません StackOverflow