corollary icon indicating copy to clipboard operation
corollary copied to clipboard

Monadic code

Open pshc opened this issue 8 years ago • 2 comments

The elephant in the room.

-- | lookup an object, function or enumerator
lookupObject :: (MonadCError m, MonadSymtab m) => Ident -> m (Maybe IdentDecl)
lookupObject ident = do
    old_decl <- liftM (lookupIdent ident) getDefTable
    mapMaybeM old_decl $ \obj ->
        case obj of
        Right objdef -> addRef ident objdef >> return objdef
        Left _tydef  -> astError (nodeInfo ident) (mismatchErr "lookupObject" "an object" "a typeDef")

Right now I'm going to assume we're going to special-case every monad in the codebase so we can get some somewhat reasonable output...?

pshc avatar May 16 '17 03:05 pshc

Maybe we can take a page out of futures's book and actually construct monadic values, 🤷

pshc avatar May 16 '17 05:05 pshc

Suggestion from IRC: https://github.com/TeXitoi/rust-mdo

pshc avatar May 17 '17 18:05 pshc