Tags down


Why don't we write haskell in LISP syntax? (we can!)

By : Weiheng Lee
Date : July 30 2020, 12:00 PM
like below fixes the issue The syntax of Haskell is historically derived from that of ISWIM, a language which appeared not much later than LISP and which is described in Peter J. Landin's 1966 article The Next 700 Programming Languages.
Section 6 is devoted to the relationship with LISP:
code :

Share : facebook icon twitter icon

Haskell Syntax - How to write let in bracketed do block?

By : Steven Withey
Date : March 29 2020, 07:55 AM
will help you The following code got "parse error" on the let clause (in GHC 7.8.3):
code :
someFunction = do {
    let foo = bar
  ; return foo
someFunction = do {
    let { foo = bar };
    return foo

can lisp implement such a sugar syntax in lisp?

By : user2294481
Date : March 29 2020, 07:55 AM
will help you Yes. It can be implemented as a reader macro, but you should know (lambda x: x + 1) and (lambda x, y: x + y) does not make any sense in lisp. It looks like python syntax with parentheses.
Now reader macros are the stuff that turns '(3) into (quote (3)) and `` (a b ,(+ a b)) into (quasiquote (a b (unquote (+ a b))))

How to write a function in a Lisp. Compile that Lisp file. and then run that Lisp program

By : Sara
Date : March 29 2020, 07:55 AM
To fix this issue Write, compile, and test a funtion in Common Lisp that takes a list and counts the total of positive integers in the List. Must compile then execute .lisp file containing the function. after compilation of that file start to pass it list where after the results for the result to be produced therefore testing the correctness of the function. , Write a file:
code :
$ echo "(defun test () (print :test))" > test.lisp
? (compile-file "test.lisp")
? (load "test")
? (test)

:TEST ;; what the function printed
:TEST ;; the returned value, automatically printed by the REPL

How to define infix notation macro in Lisp, without enclosing it in Lisp like syntax

By : Anupama Gupta
Date : March 29 2020, 07:55 AM
wish help you to fix your issue Of course you can implement what you're talking about in Lisp.
One big difference between Lisp and other languages is that nothing is fixed and you've control on what the reader does on every single character of the input source code. Literally.

How to write a lisp parser in Haskell?

Date : March 29 2020, 07:55 AM
I wish this helpful for you The question being homework/exercise, what follows is an explanation that attempts to avoid spoiling a solution; it does so by being written in Common Lisp (that, and because I don't know Haskell ;-) ).
In Common Lisp there is an intermediate function called READ-DELIMITED-LIST, which reads multiple forms as a list until the reader reaches an ending character. When encountering an opening parenthesis, the reader grabs all forms until the closing parenthesis, and then continue parsing from there. The difference is that it works on streams of characters, not on tokens, and that the stream is used for side-effects.
code :
(defun parse (tokens)
  (when tokens
    (destructuring-bind (head . tail) tokens
      (case head
        (> (error "unmatched closing parenthesis"))
        (< (parse-until-close tail))
        (otherwise (values head tail))))))
(defun parse-until-close (tokens)
  (when tokens
    (case (first tokens)
      (> (values nil (rest tokens)))
       ;; first read the element in head of tokens
       (multiple-value-bind (head tokens) (parse tokens)
         ;; then recurse to read the remaining items in list
         (multiple-value-bind (tail tokens) (parse-until-close tokens)
           (values (cons head tail) tokens)))))))
(parse '(one token))
=> ONE

(parse '(< abc < x > y >))
=> (ABC (X) Y)

(parse '(< abc def >))
=> (ABC DEF)

;; incomplete input
(parse '(< < < abc))
=> (((ABC)))
Related Posts Related Posts :
  • newtype-like operational semantics for a GADT where the type fully determines the constructor
  • Make Postgresql.Simple query results available to rest of .hs file
  • How to "rearrange" an Aeson.Object using lenses?
  • Pattern matching with Alternative empty or Applicative pure
  • Text data in Haskell
  • Type-level induction on KnownNats: Overlapping instances
  • Stuck with "Configurable" haskell class
  • Parsing user input string to UTCTime type
  • Writing a map for this Monad transformer
  • How to make a list out of all second elements of a tuple in haskell
  • In GHC.Prim, why can pointer operations fail with an unchecked exception?
  • How can I express this Constraint?
  • How to use "BinaryString.uncons()" but with a type distinct from Word8?
  • Convert Maybe String to (Maybe?) Integer
  • Haskell - Automatic Monad instance
  • Implement a self-reference/pointer in a pure/functional language (Elm/Haskell)
  • shadow
    Privacy Policy - Terms - Contact Us © voile276.org