Hacker News new | ask | show | jobs
by legopelle 3036 days ago
1) Maybe monad

  getData :: Maybe Data1
  getMoreData :: Data1 -> Maybe Data2
Note: the monad is probably not just Maybe if it talks to the outside world but more in 2)

List monad

  getData :: [Data1]
  getMoreData :: Data1 -> [Data2]
Dont' know about continuations.

2) There are a few approaches but the most popular are monad transformers, building stacks to combine the effects. For example, to speak with the outside world we need 'IO'. To add failure we might use the Maybe transformer

  MaybeT m a
to build

  type IOMaybe a = MaybeT IO a
1 comments

For the list example: I don't get why that loops over the content of the list (I don't understand this in the OP either). Wouldn't it need to be:

  getMoreData :: [Data1] -> [Data2]
at least? As I understand the OP, wouldn't the function signature for the non-monadic example be:

  getMoreData :: Data1 -> [Data2]
and the function body fundamentally different for that reason?