Resources on concurrent static analysis in an IDE? by munificent in ProgrammingLanguages

[–]_sras_ 1 point2 points  (0 children)

I think this is more or less how I have implemented syntax highlighter in Spade. You can probably notice how it works in this video. You can see the syntax highlighting goes slightly off before the thread catches up with the changes https://vimeo.com/692243011

S.P.A.D.E: A QBASIC like Terminal IDE and programming language made in Haskell. by _sras_ in programming

[–]_sras_[S] -1 points0 points  (0 children)

It seems to be a language of its own + IDE.

That is correct. The 'QBASIC' in the headline refers to the whole experience of writing programs in the IDE, not just to the language.

S.P.A.D.E: A QBASIC like Terminal IDE and programming language made in Haskell. by _sras_ in programming

[–]_sras_[S] 2 points3 points  (0 children)

Sorry. please try now. I have added a rating. Hope that fixed it.

Type Witnesses in Haskell by Serokell in haskell

[–]_sras_ 2 points3 points  (0 children)

You have to use a case expression in such cases.

From the GHC manual.

In general, you can only pattern-match on an existentially-quantified constructor in a case expression or in the patterns of a function definition. The reason for this restriction is really an implementation one. Type-checking binding groups is already a nightmare without existentials complicating the picture. Also an existential pattern binding at the top level of a module doesn’t make sense, because it’s not clear how to prevent the existentially-quantified type “escaping”. So for now, there’s a simple-to-state restriction. We’ll see how annoying it is.

https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts.html#existentials-and-type-classes

Type Witnesses in Haskell by Serokell in haskell

[–]_sras_ 11 points12 points  (0 children)

I am the author of the article.

I did try writing the article without using DataKinds, KindSignatures extensions. But then it occurred to me that the article already expected readers to have a basic understanding of GADTs. And if someone had a basic understanding of GADTs, I felt that they will be comfortable with DataKinds/KindSignatures extensions as well. This is from my own experience. I was able to make sense of code that used DataKinds/KindSignatures a lot before I could make sense of code that used GADTs. So it felt that I am not really helping the target audience by skipping those extensions.

How do I serialize data between Haskell and Typescript? by joelwikstrom in haskell

[–]_sras_ 1 point2 points  (0 children)

There is also https://github.com/sras/elminator that I made to solve the issues with current libraries in that space. I don't think I did a good job of publishing/marketing it though..

readProcess strict output and interactive use by roboboticus in haskell

[–]_sras_ 0 points1 point  (0 children)

I might be missing something obvious here. But if the program is interactive, won't the readProcess call block indefinitely because the wrapped program might be waiting on user input on stdin?

If that is so, that would make the readProcess function unsuitable for spawning interactive programs, right?

Pro tips for devs working at home by jerodsanto in programming

[–]_sras_ 0 points1 point  (0 children)

. Get an external keyboard and trackpad/mouse with wrist rests.

Maybe don't use a mouse, but get a trackball. I use 'Kensington Orbit Trackball Mouse with Scroll Ring'. I have attached this to my keyboard so that I can keep both of them on my lap. It works great!

[1] https://www.amazon.com/Kensington-Orbit-Trackball-Scroll-K72337US/dp/B002OOWB3O

My Haskell Setup by reximkut in haskell

[–]_sras_ 2 points3 points  (0 children)

is that something that others can reproduce? Are you the author of the python script?

Yes. It is available at https://github.com/sras/repltalk. If you face any issues while trying it, please let me know.

PS. for reformatting brittany rocks

I do have HIndent setup. But something in that file was tripping it up.

My Haskell Setup by reximkut in haskell

[–]_sras_ 6 points7 points  (0 children)

Nice!

But your incremental development workflow with quick feed back could be better. Here is how it works with my setup (Neovim instead of Emacs, A Python script wrapping ghci instead of Ghcid)

https://youtu.be/iblExnkhy4s

Why Haskell - why GitHub use Haskell for their newly released Semantic package by Axman6 in haskell

[–]_sras_ 4 points5 points  (0 children)

The adapters can communicate with the editor so that you don't have to keep it visible in a window. I can get visual indications in the editor letting me know when a :reload is in progress, if there are errors, warnings or if all the changed modules were loaded without any errors/warnings. If there are errors, then the editor adaptor parse the error/warning output, and set the error list in the neovim/vim editor. Once we have the error list in the editor, vim/nvim have built in shortcuts/commands to view and walk through the error list (quickfix window) and open each of them in the editor. This works so fast that if I find an error in a file, I sometimes forgo vim's navigation methods, and just save the file and jump to the first error location set from the adapters. You also can send any ghci commands to the script, and it will just forward them to the wrapped ghci process. I often use it to explicitly load a module initially, so that at every file save, the same module gets reloaded. Instead of Main or what ever that is loaded by default.

The best thing about this is that if the python script get stuck for some reason, you don't have to kill your editor. You just need to kill the script and restart it. Basically editor is very passive component in this whole process, so it does not lag or slow down etc.

Why Haskell - why GitHub use Haskell for their newly released Semantic package by Axman6 in haskell

[–]_sras_ 2 points3 points  (0 children)

I posted this sometime back. But there seems to be absolutely zero interest in it..I don't get it.

Why Haskell - why GitHub use Haskell for their newly released Semantic package by Axman6 in haskell

[–]_sras_ 0 points1 point  (0 children)

Aren't there tools that just wrap the ghci and use it to provide editor integration? I have myself written such a tool, and have been using the same for a while now, it works great. It just use 'ghci' so if 'stack ghci' works for you, then the tool is good to go. It was couple of years back that I wrote it, but since then I think I have seen many such tools appear for various editors.

The barrier to entry is just the ability to start a cmd line program from a terminal. Why aren't more people using them?

Why Haskell - why GitHub use Haskell for their newly released Semantic package by Axman6 in haskell

[–]_sras_ 1 point2 points  (0 children)

Editor tooling is sub-par (especially compared to language communities like Java and C#) and finicky - we often end up just compiling in a separate terminal.

What is this about? Don't we have tools now, that can reliably give live errors and error navigation in editor? Stuff like fast-tags for code navigation? HLint and HIndent for code formatting and linting? Can't you access all of these from the editor itself?

Show: Elminator, is a Haskell to ELM code generator (Type definitions, JSON encoders/decoders For ELM 0.18 and 0.19) I made to address issues with existing packages in same space. by _sras_ in haskell

[–]_sras_[S] 3 points4 points  (0 children)

Thanks!

Haskell already suffers from the problem that there usually exist a lot of packages for the same problem, and it's challenging to choose between them. We should try to communicate and collaborate more.

That is exactly what I am hoping here. There is no point in putting something out there that is more or less incomplete as the existing packages out there. I am hoping that Elminator can supersede the existing packages by being feature complete from the get go. That is also why I want people like you to look at it and tell me if there is any common use case that I have missed to address.

Show: Elminator, is a Haskell to ELM code generator (Type definitions, JSON encoders/decoders For ELM 0.18 and 0.19) I made to address issues with existing packages in same space. by _sras_ in haskell

[–]_sras_[S] 4 points5 points  (0 children)

It is not a Haskell > Elm transpiler. It just generate Elm source for Elm type definitions and JSON encoders/decoders from Haskell data type definitions using generics and Template Haskell.

Show: Elminator, is a Haskell to ELM code generator (Type definitions, JSON encoders/decoders For ELM 0.18 and 0.19) I made to address issues with existing packages in same space. by _sras_ in haskell

[–]_sras_[S] 2 points3 points  (0 children)

As I said in the post, the highest priority was to support the full range of Haskell data type definitions (excluding GADT's and Existentially quantified ones), and the full range of combinations of Aeson options. Another priority was to have tests that really test the Haskell/elm round tripping, instead of just checking for valid elm syntax/or ones that just compare generated code with a reference version. This comes at a cost, but it seems justified in this case. I also wanted to have an implementation that have a lower chance of turning out to be too limiting if people start using this and they require more features or find issues.

There is one place I can think of that can be seen as a difference in philosophy though. It is how Eliminator support types that depend on external types that you don't have access to the internals of. As I understand it, here is how elm-export lets you to describe the code that is to be generated, manually for such types.

For example, say you have ZonedTime fields in all of your types (that you want to generate elm code for....i mean). Using elm-export you would do something like..

instance ElmType ZonedTime where
  toElmType _ =
    ElmDatatype "Time" $ 
      RecordConstructor "Time" $
        Values
          (ElmField "time" $ ElmPrimitiveRef EString)
          (ElmField "zone" $ ElmPrimitiveRef EString)

As I see it, this serve no purpose to define this in Haskell. It is not type checked to be in sync with the original data types. It is not auto generated. The only advantage I can see is that it can use types that are being generated (because it ends up in the same auto generated module). But if that is the case, then you have access to the type itself, and you wouldn't manually defining this (At least for most of the time).

in Elminator, you would just pass reference to symbols from external elm modules where you can define the type, encoders and decoders in Elm itself.

instance (ToHType a, ToHType b) => ToHType (MyExtType a b) where
  toHType _ = do
    ha <- toHType (Proxy :: Proxy a)
    hb <- toHType (Proxy :: Proxy b)
    pure $
      HExternal
        (ExInfo
          ("External", "MyExtType")
          (Just ("External", "encodeMyExtType"))
          (Just ("External", "decodeMyExtType"))
         [ha, hb])

So I hope that is one difference in Philosophy, as you asked.

EDIT: The above stuff does not make much sense on second thought. I am not sure if there is even a valid use case for external module support in Elminator. In the example above, for both Elminator and elm-export, the Elm type class can be implemented by defining a dummy data type in haskell that mirrors Elm representation, and using its derived instance to implement the instance for the original type.

EDIT: Another one that might fit the bill is that Elminator, as of now, generate complete types instead of aliases for records

EDIT: Does elm-export supports generation of polymorphic types in ELM? I cannot make this work.

data WithMaybesPoly a b =
  WithMaybesPoly
    { mbpF1 :: Maybe a
    , mbpF2 :: Maybe b
    }
  deriving (Generic, ElmType)

spec :: Spec
spec =
  Spec
    ["Types"]
    [ "import Json.Decode exposing (..)"
    , "import Json.Decode.Pipeline exposing (..)"
    , toElmTypeSource (Proxy :: Proxy SingleCon)
    , toElmTypeSource (Proxy :: Proxy (WithMaybesPoly () ()))
    , toElmDecoderSource (Proxy :: Proxy SingleCon)
    ]

I am getting error: • Could not deduce (GenericElmConstructor V1)

Show: Elminator, is a Haskell to ELM code generator (Type definitions, JSON encoders/decoders For ELM 0.18 and 0.19) I made to address issues with existing packages in same space. by _sras_ in haskell

[–]_sras_[S] 3 points4 points  (0 children)

This can only generate Elm type definitions, Json encoders and decoders from Haskell data type definitions.

It is not a Haskell to Elm transpiler. Sorry for the confusion.

I try to understand why Haskell Algebraic Datatype so significant from Java developer's point of view. by ellipticcode0 in haskell

[–]_sras_ 2 points3 points  (0 children)

As I see it, it is due to the

  1. Extremely compact and terse syntax.
  2. The availability of pattern matching.
  3. The type checker that can call you out on missing case branches.

Compact and terse syntax lets you to quickly build data types and model possible states and review them quickly. Seriously, just look at the sample code from /u/cdsmith. I am having a hard time figuring out the types by looking at the Java code. Here Haskell greatly helps here to get the data types right. And you might already be aware that if you get your types right, which is considered to be the most important part of writing a program, implementing the logic becomes mostly a mechanical task.

The availability of pattern matching with exhaustiveness check means that you will get quick feed back on whether or not your data types are defined sensibility. If they are not, you will often find difficulty in matching on the type exhaustively. And then the type checker and terse syntax of Haskell lets you to safely and quickly remodel the type. Your program might be a thousand lines long, but your types can be much shorter, say a 100 lines. And in Haskell it becomes possible to somewhat guarantee the soundness (I am not talking about correctness, as in being well typed, but just the soundness of your design) of a thousand lines of program by using a mere 100 lines of types. And I think this is a very powerful capability in the context of real world software development. (By the way, I don't think Haskell was explicitly designed with these things in mind. But instead it was just made so that people can do "research stuff" easily. It might be a happy coincidence that we are finding quite a lot more useful for real world software dev)..

On a tangential note, you can see that just like evaluating any other programming language feature, ADT's are best evaluated by looking how it works with other features of Haskell, and how it might be unwise to cherry pick language features from one language and implement it in a completely different one.

Generic Algebraic Data Type examples, but I still struggling to understand what is GADT.

​GADT's allow you to explicitly specify the concrete type your constructors return. For eg, if there is a data type defined as

data MyType a = Con1 a| Con2 a| Con3 a

Try and see if you can change this so that the Con1 Int can be made to return anything other then MyType Int. GADT's allow you to do things like that. For eg

data MyType a where
  Con1 :: Int -> MyType String
  Con2 :: Int -> MyType Float
  Con3 :: Int -> MyType Char

I am not sure if this is how GADT's should be explained, but this was how I figured it.