Code Monkey home page Code Monkey logo

diagnose's Introduction

Oh hello there! 👋

I'm Ghilain, nice to meet you! Well obviously we cannot talk here (unfortunately?). Let me just summarize who I am.

So, I'm just a young guy, really interested in the programming language theory and everything it comes with (parsers, type systems, etc). I got into it at around 2018, when I started thinking about creating my own programming language.

I further evolved into making more unfinished programming languages! 🎉

Here are some of my projects:

  • Back in 2018, I implemented a small assembly language-like programming language running on a Virtual Machine (much like Java). It was originally named “#*”, but was later renamed into “Snow*”. The repository is available here.

    At that time I didn't know C++ really well, but I think I ended up with something not quite bad.

    sharpstar repository

  • After upgrading the language for about 2 months, I decided to restart the project from scratch, into another direction. That's where the last Snow* got to life. It was still C++, but much less crappy than before. It used ANTLR for the parsing, and LLVM for the code generation and executable creation. The code is available here.

    snowstar repository

  • I then stopped Snow*, especially from lack of motivation...and started a new programming language about 4 months after. It was named “Blob”, and was meant to guarantee type- and data-safety through the use of complex types (see “Quantitative Type Theory” on google). It was the first time I used Haskell, because someone recommended it to me. I ended up enjoying my time with this new programming language I didn't know.

    The language (Blob) got to a stage where I dropped some features, even before trying to implement them (like the QTT), because of how complicated things would become. I later renamed the language “Nihil”, in reference to the fact that's there nothing usable in this programming language.

    The repository (this one) is currently the holder of the most ⭐ on my profile!

    nihil repository

  • My new project, Zilch is mostly a rework of Nihil. Things did not end well for it (the code is still available here). To keep things short:

    • my motivation decreased quite a lot
    • I worked on another project
    • the code written was undocumented and not necessarily easy to maintain if ever I had to
    • I worked alone
    • nobody had interest anymore in it.

    So I restarted everything, again... I am now creating another monstrosity: a low-level functional programming language inspired by Haskell and Rust, featuring type- and data-safety through linear types and such, and compiling to N*, a low-level typed assembly language. I'm also trying to formalize the language as can be seen here.

    zilch repository nstar repository specification repository

I also have some other side projects, like my custom virtual CPU or my Haskell assembly DSL. But there is even more to see here! (where in fact most of the projects have been left behind)

Just a little bit of statistics:

And I do have some other hobbies!

Even though I waste most of my time in front of my screen, on my keyboard, I also enjoy eating, tinkering (I like to make rings for no reason), and playing games like BeamNG.Drive or World of Tanks. 🎮

Anything to add?

The "place" you belong to is not necessarily a physical place. Some people may find that they feel well on Discord in some specific servers, others may find that living close to their close friends is what makes them enjoy life.

But I believe that you should not have to find this "place". This place should first be your heart. You are the only one able to love you as much as you may want to. Loving yourself is not about loving every single part of you, every little part that makes you what you are. It instead is about knowing that you are not flawless, and accepting those flaws, accepting those as parts of yourself. Self-hatred is not what you should feel. Self-hatred is some kind of disease, but one you cannot cure easily (if even at all). Just learn to love yourself (or at least try), instead of relying on "how you always felt like" and giving you blame for it. This is more important than everything else.

Learn to love yourself as you are, and people will start loving yourself for who you really are, and not the one you pretend to be.

diagnose's People

Contributors

byorgey avatar expipiplus1 avatar jaspa avatar luc-tielen avatar mesabloo avatar spacekitteh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

diagnose's Issues

Consider exporting `prettyDiagnostic`

The current functionality requires an output to a file handle, but allowing the conversion to a Prettyprinter.Doc format would enable this to be embedded in other Doc output and managed as needed by client applications. Would exporting prettyDiagnostic be a reasonable update?

Incorrect bounds for prettyprinter-ansi-terminal

The bounds for prettyprinter-ansi-terminal are given as ">=1.1.0 && <2":

, prettyprinter-ansi-terminal >=1.1.0 && <2

However, these bounds are incorrect: diagnose requires prettyprinter-ansi-terminal >= 1.1.2, and compilation will fail if versions of prettyprinter-ansi-terminal lower than that are used.

Specifically, in module Error.Diagnose.Diagnostic.Internal, Prettyprinter.Render.Terminal is imported:

import Prettyprinter.Render.Terminal (hPutDoc)

This module does not exist in versions of prettyprinter-ansi-terminal < 1.2 (see e.g. prettyprinter-ansi-terminal-1.1.1.2).

[Bug] Duplicated markers with Error.Diagnose.Compat.Parsec

Repro

When using parsec-diagnose 1.7.1 and parsec 3.1.14.0 and GHC version 9.0.2 I get duplicated markers with the simple code here:

{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}

import Error.Diagnose
import Error.Diagnose.Compat.Parsec
import Text.Parsec

import Data.Void
instance HasHints Void String where hints _ = []

type Parser = Parsec String ()

diagParse :: Parser a -> SourceName -> String -> Either (Diagnostic String) a
diagParse p filename content =
    either (Left . diag) Right (parse p filename content)
  where
    diag e = addFile (errorDiagnosticFromParseError Nothing "Parse error on input" Nothing e) filename content

parser :: Parser Char
parser = op' "\\" *> letter

main :: IO ()
main = either (printDiagnostic stderr True True) print $
  diagParse parser "issues/2.txt" "\\1"

-- smaller example
op' :: String -> Parser String
op' name = string name <* spaces

Output

[error]: Parse error on input
     ╭──▶ issues/2.txt@1:2-1:3
     │
   1 │ \1
     •  ┬ 
     •  ├╸ unexpected "1"
     •  ├╸ unexpected "1"
     •  ╰╸ expecting any of white space, letter
─────╯

Description

I stumbled on this while using the TokenParser from parsec:

import Text.Parsec.Token

op :: String -> Parser ()
op = reservedOp $ makeTokenParser LanguageDef {
    commentStart   = "{-"
  , commentEnd     = "-}"
  , commentLine    = "--"
  , reservedOpNames = ["\\"]
  , opStart        = oneOf "\\"
  , opLetter       = oneOf "\\"
  }

Using op as defined above I get:

[error]: Parse error on input
     ╭──▶ issues/2.txt@1:2-1:3
     │
   1 │ \1
     •  ┬ 
     •  ├╸ unexpected "1"
     •  ├╸ unexpected "1"
     •  ├╸ unexpected "1"
     •  ├╸ unexpected "1"
     •  ├╸ unexpected "1"
     •  ╰╸ expecting any of end of "\\", , letter
─────╯

Expected

I expect the above to only print a single line containing unexpected "1" for both cases.

Incorrect bounds for unordered-containers

The bounds for unordered-containers are given as "==0.2.*":

, unordered-containers ==0.2.*

But this is incorrect: diagnose will not build with versions of unordered-containers < 0.2.11. It uses the !? function from Data.HashMap.Lazy, here:

case safeArrayIndex (line - 1) =<< (HashMap.!?) files . file . fst =<< List.safeHead markers of

and that function was not introduced into unordered-containers until version 0.2.11 (see here).

Multiline spans look weird

Here's my output:
image

  1. The middle row does not get highlighted
  2. I think the text associated with the multiline span would look better right under it's source, as opposed to the very bottom. It's also weird because there are no dots indicating there's a jump in lines between the first and the second source spans..

Thanks for making this awesome library!

What do columns in `Position` mean?

"Columns" of text are not well-defined in the presence of unicode input. I'd suggest specifying that it means unicode code points, and maybe testing with some awkward unicode text.

Unexpected addReport ordering

Currently addReport will prepend new reports to the report list. This causes the report generation to show the reports in the reverse order generated.

Here's a modified version of test/megaparsec/Spec.hs that captures multiple parse errors:

{-# LANGUAGE CPP #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}

{-# OPTIONS -Wno-orphans #-}

import Data.Bifunctor (first)
import Data.Char (isAlpha)
import Data.Text (Text)
import qualified Data.Text as Text (unpack)
import Data.Void (Void)
import Error.Diagnose
import Error.Diagnose.Compat.Megaparsec
import qualified Text.Megaparsec as MP
import qualified Text.Megaparsec.Char as MP
import qualified Text.Megaparsec.Char.Lexer as MP

instance HasHints Void msg where
  hints _ = mempty

main :: IO ()
main = do
  let filename :: FilePath = "<interactive>"
      content1 :: Text = "0000000123456"
      content2 :: Text = "00000a2223266"
      content3 = "aaa\naab\naba\na\nb\n"

  let res1 = first (errorDiagnosticFromBundle Nothing "Parse error on input" Nothing) $ MP.runParser @Void (MP.some MP.decimal <* MP.eof) filename content1
      res2 = first (errorDiagnosticFromBundle Nothing "Parse error on input" Nothing) $ MP.runParser @Void (MP.some MP.decimal <* MP.eof) filename content2
      res3 = first (errorDiagnosticFromBundle Nothing "Parse error on input" Nothing)
             $
             let a = MP.char 'a'
                 errSkip e = do MP.registerParseError e
                                _ <- MP.takeWhileP Nothing isAlpha <* MP.eol
                                return ""
             in MP.runParser @Void
                (MP.many (MP.withRecovery errSkip (MP.some a <* MP.eol)) <* MP.eof)
                filename content3

  case res1 of
    Left diag -> printDiagnostic stdout True True 4 (addFile diag filename (Text.unpack content1) :: Diagnostic String)
    Right res -> print res
  case res2 of
    Left diag -> printDiagnostic stdout True True 4 (addFile diag filename (Text.unpack content2) :: Diagnostic String)
    Right res -> print res
  putStrLn "------------- res3 ----------------"
  case res3 of
    Left diag -> printDiagnostic stdout True True 4 (addFile diag filename (Text.unpack content3) :: Diagnostic String)
    Right res -> print res

The above updated Megaparsec test demonstrates the inversion:

------------- res3 ----------------
[error]: Parse error on input
     ╭──▶ <interactive>@5:1-5:2
     │
   5 │ b
     • ┬
     • ├╸ unexpected 'b'
     • ╰╸ expecting 'a'
─────╯

[error]: Parse error on input
     ╭──▶ <interactive>@3:2-3:3
     │
   3 │ aba
     •  ┬
     •  ├╸ unexpected "ba"
     •  ╰╸ expecting 'a' or end of line
─────╯

[error]: Parse error on input
     ╭──▶ <interactive>@2:3-2:4
     │
   2 │ aab
     •   ┬
     •   ├╸ unexpected "b<newline>"
     •   ╰╸ expecting 'a' or end of line
─────╯

I would have expected the reports to be in the same order as the lines parsed. Perhaps addReport should append (and use Data.Sequence for performance), or else prettyDiagnostic should reverse the reports before generating them.

Alternative `codespan-reporting` style formatting?

Thanks for your great library!

I use both Rust and Haskell, and have learned about error reporting libraries like ariadne and codespan-reporting for a while. Previously when working on a Rust project, I chose codespan-reporting because I preferred its formatting (formatting of ariadne is also beautiful, but a bit too fancy for me), given their interfaces are pretty similar. Is it possible to extend this library to have an alternative codespan-reporting-style formatting for the diagnostic messages? Or is there some design space to expose an API for custom report formatting?

FYI, here is a comparison of the said two styles (BTW it is amusing to see a more Haskell-like syntax for illustration in codespan-reporting the Rust library but a more Rust-like style here):

Name Illustration
(current) ariadne-style
codespan-reporting-style codespan_reporting_preview

If this is deemed non-trivial, I am willing to work on this, in that case would you please provide some guidance?

Integration with LSP?

The docs mention integration with LSP via the diagnosticToJson function, but no other information is given on how to do this.

I'm new to LSP myself, could you provide some pointers where to start looking for more information?
(Or add a section to Diagnose docs somewhere on how to quickly/easily integrate with LSP?)

Thanks!

How to deal with big content

Hello,

I'm currently testing your library and the diagnostics look really good!

I am just having one issue and it's unclear to me how to solve it from the docs. If I have content that spans over multiple lines and it breaks the layout. Is it possible to use say Docs instead of Text/String to create a Report? Or what would be the way of doing something like this? Say showing actual/expected types in a type error, or having a type that is long ( record type or function types for example ).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.