Skip to content
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

Monadic code #16

Open
pshc opened this issue May 16, 2017 · 2 comments
Open

Monadic code #16

pshc opened this issue May 16, 2017 · 2 comments

Comments

@pshc
Copy link
Collaborator

pshc commented May 16, 2017

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
Copy link
Collaborator Author

pshc commented May 16, 2017

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

@pshc
Copy link
Collaborator Author

pshc commented May 17, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant