@rae: RebindableSyntax in Haskell

Поділитися
Вставка
  • Опубліковано 3 січ 2025
  • I give an introduction to GHC's RebindableSyntax extension, with examples.
    GHC manual page: downloads.hask...
    Find me at richarde.dev/ or on Twitter at @RaeHaskell
    Video index at richarde.dev/v...

КОМЕНТАРІ • 11

  • @aullvrch
    @aullvrch 2 роки тому

    Awesome! Eventually will all of Haskell's syntax be rebindable?

  • @hellwolf4liberty
    @hellwolf4liberty 2 роки тому +4

    rae casually typed `one,two,three :: Int` in, and I had no idea that was a valid syntax.

  • @MrMomoro123
    @MrMomoro123 2 роки тому +2

    Great video! You can also use MonadComprehensions with RebindableSyntax to get custom list comprehension behavior.

  • @hantuchblau
    @hantuchblau 2 роки тому +1

    I was really surprised how much nicer qualified do felt in practice. Makes me wish for the other features in RebindableSyntax to be more granular and qualifiable as well
    It seems like
    foo = do
    where DoNotation{..} = M.doNotation
    should be similar, but it's a lot less mental overhead for me with the prefixes version.
    Second surprise that there is no qualifiedDo indexed monad package on hackage yet.

  • @Chase-up3do
    @Chase-up3do 2 роки тому

    The `ifThenElse` example makes me wish there was a `QualifiedIfThenElse` language extension!

  • @Dregntael
    @Dregntael 2 роки тому

    How about overloading whitespace (i.e. function application)?😈

  • @露大元
    @露大元 2 роки тому

    really cool!

  • @Ephrones
    @Ephrones 2 роки тому +1

    tbh this sounds horrible for any kind of reader of the code.
    You have to essentially know that the magic language extension is set (it doesn’t stand out), then follow all imports (some might be implicit!) and know all of the magic function names, in order to figure out what any of the code does.
    This is an anti-feature!

    • @Ephrones
      @Ephrones 2 роки тому

      The alternative is: just use plain old functions.
      The code will be easy to read, easy to follow (go to definition works!), not freak out hls, etc etc etc.
      Don’t use RebindableSyntax.

    • @welltypedwitch
      @welltypedwitch 2 роки тому

      RebindableSyntax is not meant for everyday programs. You would only use this if you're working in a really specific setting where you need to override prelude syntax. E.g. you're working with linear or graded monads and would like to use do-notation (pre QualifiedDo).

    • @mathiassven
      @mathiassven 2 роки тому +2

      It seems suitable for making a DSL in haskell though, as long as it is documented I dont see what would be the problem... *as long as it is documented*...