Implementing a JIT Compiled Language with Haskell and LLVM
stephendiehl.com
Implementing a JIT Compiled Language with Haskell and LLVM
1–10 of 13 posts
Re: Implementing a JIT Compiled Language with Haskell and LLVM
#2 Implementing a JIT Compiled Language with Haskell and LLVM (stephendiehl.com)
195 points by rwosync 53 days ago | flag | comments
https://news.ycombinator.com/item?id=7031998Re: Implementing a JIT Compiled Language with Haskell and LLVM
#3Re: Implementing a JIT Compiled Language with Haskell and LLVM
#4Re: Implementing a JIT Compiled Language with Haskell and LLVM
#5Even if you're not curious about Haskell, have a look at the parser here. Parsing in Haskell feels like cheating.
Re: Implementing a JIT Compiled Language with Haskell and LLVM
#6Even if you're not curious about Haskell, have a look at the parser here. Parsing in Haskell feels like cheating.
(And is a really great example motivating both monads and monad transformers, for the curious!)
Re: Implementing a JIT Compiled Language with Haskell and LLVM
#7Even if you're not curious about Haskell, have a look at the parser here. Parsing in Haskell feels like cheating.
At least a basic understanding of haskell (or similar) is going to be required to appreciate it, and at that point you're obviously someone who was curious enough to have the knowledge to understand it to begin with.
Re: Implementing a JIT Compiled Language with Haskell and LLVM
#8Even if you're not curious about Haskell, have a look at the parser here. Parsing in Haskell feels like cheating.
(And is a really great example motivating both monads and monad transformers, for the curious!)
newtype Parser a = Parser { unParser :: MaybeT (State String) a }
deriving ( Functor, Applicative, Alternative,
Monad, MonadPlus, MonadTrans,
MonadState String )
-- why write boilerplate when the
-- compiler will for you?
runParser :: Parser a -> String -> Maybe a
runParser input = flip evalStateT input . runMaybeT
-- | Parses a single character if it passes a predicate
satisfy :: (Char -> Bool) -> Parser Char
satisfy p = do
(c:cs) Parser Char
char c = satisfy (== c)
-- | Parses a whole string
string :: String -> Parser String
string = mapM char
-- | Converts a parser to be surrounded by parentheses
parens :: Parser a -> Parser a
parens p = char '(' *> p Re: Implementing a JIT Compiled Language with Haskell and LLVM
#9Good job with that trailing / Implementing a JIT Compiled Language with Haskell and LLVM (stephendiehl.com) 195 points by rwosync 53 days ago | flag | comments https://news.ycombinator.com/item?id=7031998
If it's interesting, it's interesting. If it's not worthy of being seen again, it won't be upvoted. By all means link to the previous discussion, but quit the whining.
Re: Implementing a JIT Compiled Language with Haskell and LLVM
#10Earlier quoted context omitted.
(And is a really great example motivating both monads and monad transformers, for the curious!)
The shallow DSL in the LLVM monad is really nice, it looks almost like the IR itself but you can abstract over it and compose it with other code. DSLs are often overlooked when talking about monad use cases.