5 ms·
I'm interested in .NET ecosystem languages, as well as functional programming. How is the parsing and meta-programming toolset? How easy or hard would it be for
by stcredzero 10y ago
I'm interested in .NET ecosystem languages, as well as functional programming. How is the parsing and meta-programming toolset? How easy or hard would it be for me to implement a subset of F# that only allows pure functions?
- drbradley 10y agoVery strong on the parsing front - FSharp.Data contains parsers and type providers for a variety of common formats and FParsec is a mature parser combinators library.
- VoiceOfWisdom 10y agoFParsec is fantastic. I have implemented a parser that supports a indentation based language in it. FParsec makes it very productive, and very fun.
- mamcx 10y agoIs published? I have tried to use FParsec before for the same kind of language and failed.
- VoiceOfWisdom 10y agoIts currently in a private bitbucket repo. I can give you the parser though, MIT licensed. ParserUtils is where maybeIndented and indented are. They make indentation just work. There currently overzealous with backtracking though, makes errors kinda shit. Working on that at somepoint. https://gist.github.com/xavierzwirtz/99479a11f1eefd3215467f7ea26b5c46 https://gist.github.com/xavierzwirtz/99479a11f1eefd3215467f7...
- mamcx 10y agoOk, thanks. But this not look more easy than just do it as TopDown Parser. But I don't know your language so it maybe have provided you with some benefits more than just lines of code?
- VoiceOfWisdom 10y agoBig benefit to me was being able to do it all with parser combinators, and without having to drop into another language like lex and yacc.
- UK-AL 10y agoParser combinators are top down parsers.
- VoiceOfWisdom 10y agoVery poor. You would pretty much have to build a language from scratch. I am working on doing that with a language called emly, supports effect tracking as opposed to haskell style purity. I am having to basicly do everything from scratch.
- bbcbasic 10y agoLike purescript?
- tpetricek 10y agoIf you wanted to create a version of F# that only allows pure functions, your best option is probably to modify the F# compiler (which is open source). However, that sounds like something that might not be all that useful. A more useful thing could potentially be to use the "F# Compiler Service" (which is the compiler API, exposed via a nice F# library) and create some tool that checks purity. I think many people might actually be interested in something like this.
- stcredzero 10y agoMy purpose would be to create a multiplayer game programming platform. Basically, it would come with a game loop already running, with communications already working. Then you could modify the game by changing functions that transform game tick N to game tick N+1.
- moomin 10y agoThere's another way to do this. Just scan the compiled code for access to anything other than a fairly short whitelist of functions. This is how Terrarium worked.
- evincarofautumn 10y agoYup, this is the better approach to sandboxing. You can always expand a whitelist, but it’s not so easy to play black-a-mole.
- mamcx 10y agoEasy? If we are talking about building a language in F#, remember that is possible to use any language for that. In fact is make support for side-efects and mutating that complicate the build of a compiler/interpreter.