Lisplog

Blogging in Lisp

Search

Feed Aggregator Page 651

Rendered on Sun, 27 Sep 2020 20:33:25 GMT  newer latest older 

Alexander Artemenko: common-lisp-jupyter

via Planet Lisp by on Sun, 27 Sep 2020 17:48:13 GMT

This library provides a Common Lisp kernel for Jupyter.

Jupyter is a scientific environment for experiments. It is good when you want to play with data, to plot graphics and provides some comments in markdown.

Jupyter saves your programming session along with results in one file allowing to share your results with other programmers or analytics.

Maybe you didn't know, but GitHub is able to render such notebooks. Here I found a large list of interesting notebooks. Take a look at this one, for example:

https://github.com/mqlaql/geospatial-data/blob/master/Geospatial-Data-with-Python.ipynb

Now, let's return to the Common Lisp. Jupyter is using a protocol allowing to write backends in different programming languages. They are called "kernels".

Here is how we can install Common Lisp Jupyter kernel on OSX. I'm using Homebrew and Roswell because they are making everything so easy!

[poftheday] brew install zeromq

[poftheday] brew install jupyterlab

[poftheday] ros install common-lisp-jupyter

Now we can start a notebook in console mode:

[poftheday] jupyter console --kernel=common-lisp
Jupyter console 6.2.0

common-lisp-jupyter: a Common Lisp Jupyter kernel
(C) 2019 Tarn Burton (MIT)
In [1]: (lisp-implementation-type)
Out[1]: "SBCL"

In [2]: (lisp-implementation-version)
Out[2]: "2.0.8"

In [3]: (values 1 2 3)
Out[3]: 1
Out[3]: 2
Out[3]: 3

In [4]: (jupyter:file "/Users/art/Desktop/Screenshot 2020-09-25 at 23.50.02.png")
Out[4]: /Users/art/Desktop/Screenshot 2020-09-25 at 23.50.02.png

And this command will start a webserver with full Jupyter Notebook:

# To start a web UI, run
[poftheday] jupyter notebook

When the browser will open Jupyter, choose this menu to start Common Lisp Jupyter kernel:

Now if you enter the same code as we did before in console, you'll see, that web version is able to render our "screenshot" file below the "code cell":

It is also very easy to render formulas and to request an input from the user:

Also, you can render any HTML along with styles:

Or you might define functions which will return HTML or files:

This way, libraries extending common-lisp-jupyter may be created. They can do plotting for example, or render graphs, etc.

Here how you can make you own classes renderable by Jupyter:

Though, it would be nice to make it possible to define render method for object not inherited from the jupyter:result.

The developer of this library did a very good job documenting it and providing examples. You will find all of them here.

This project is in active development phase. For example, right now support for Jupyter widgets is added.

Please, join this effort and make your pull requests to this repository, if you are interested in building CL environment for data science!

Can the compiler skip virtual DOM?

via Elm - Latest posts by @evancz Evan on Sun, 27 Sep 2020 14:25:46 GMT

No problem! I think Svelte was saying “faster than virtual DOM” in a lot of their public communication, so I think many people have this impression.

My understanding is that they knew Elm had similar perf numbers to them, but they assumed Elm must be using the same techniques. I told them that was not the case in June 2019 so hopefully they saw it and changed how they talk about things since then :man_shrugging:

Discussion: How much to pipeline

via Elm - Latest posts by @lydell Simon Lydell on Sun, 27 Sep 2020 09:00:38 GMT

Another thing to think about … do you pipeline the first call in a chain?

Do you use |> only to avoid parens:

Dict.get "content-length" metadata.headers
    |> Maybe.andThen String.toInt
    |> Result.fromMaybe (BadHeader "Content-Length header not found or invalid")

Or do you go “all the way”?

metadata.headers
    |> Dict.get "content-length"
    |> Maybe.andThen String.toInt
    |> Result.fromMaybe (BadHeader "Content-Length header not found or invalid")

Elm in a nutshell

via Elm - Latest posts by @Laurent Laurent Payot on Sun, 27 Sep 2020 07:56:15 GMT

To a non-technical person:
Less bugs, lower maintenance cost, no fear of changing things. And eventually (at least at NoRedInk) easier recruiting, of better coders who are reluctant to “foot-shooting” programming styles.

[off my chest] omg elm is so fun

via Elm - Latest posts by @DullBananas on Sun, 27 Sep 2020 07:02:11 GMT

For a few weeks I have mostly been writing rust and j****script. I forgot exactly what I was doing with rust and j****script because I only remember the fun parts of my life.

Today I was working on port stuff in elm and damn it was so fun and satisfying. I thought I was starting to loose interest in Elm from spending so much time using other programming languages but I just forgot the joy of elm. I had lots of fun fixing those compile errors. If I said the same thing about j****script then it would be sarcasm.

Does Elm have a religion? Emacs has one

Discussion: How much to pipeline

via Elm - Latest posts by @opsb Oliver Searle Barnes on Sat, 26 Sep 2020 11:34:26 GMT

My rule a thumb is

For non view code:

  • Use <| or parens for one liners
  • Use |> when more than 1 function is applied to a value

For view code:

  • Favour <| for building html hierarchies (I like the code to fit the html structure as far as possible)
  • Only use |> when assigning values in let blocks, never in the body of the let or any other expressions. Put another way, I only use |> to calculate values which are then used to express the html.

Extracting type metadata from Elm code?

via Elm - Latest posts by @system system on Sat, 26 Sep 2020 10:58:51 GMT

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.

Discussion: How much to pipeline

via Elm - Latest posts by @lydell Simon Lydell on Sat, 26 Sep 2020 09:39:02 GMT

I only pizza if there are two or more values in the chain

I think error messages are better when you do someList |> List.map (\item -> whatever) rather than List.map (\item -> whatever) someList. It’s almost always the lambda that is wrong so I like when it is marked as the error rather than someList.

-- TYPE MISMATCH - src/Example.elm

This function cannot handle the argument sent through the (|>) pipe:

182|     someList |> List.map (\( _, x ) -> x + 1)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The argument is:

    List number

But (|>) is piping it to a function that expects:

    List ( a, number )

Hint: Only Int and Float values work as numbers.

-- TYPE MISMATCH - src/Example.elm

The 2nd argument to `map` is not what I expect:

186|     List.map (\( _, x ) -> x + 1) someList
                                       ^^^^^^^^
This `someList` value is a:

    List number

But `map` needs the 2nd argument to be:

    List ( a, number )

Hint: I always figure out the argument types from left to right. If an argument
is acceptable, I assume it is “correct” and move on. So the problem may actually
be in one of the previous arguments!

Hint: Only Int and Float values work as numbers.

Can the compiler skip virtual DOM?

via Elm - Latest posts by @berend Berend de Boer on Sat, 26 Sep 2020 05:45:26 GMT

Although true, in order to sell Elm it really helps to claim Elm is faster!

Can the compiler skip virtual DOM?

via Elm - Latest posts by @Naserdin Naserdin on Sat, 26 Sep 2020 04:52:16 GMT

Hi, Evan, thanks for this detailed explanation, surprised me! I naively thought precise dom manipulation is better than virtual DOM diffing update. seems like svelte has some advantages over other freamwork, and it’s all due to the compile process. so this question just came to my head. I think you are right, performance is not a big deal to most people because the hardware nowadays is to good to let user perceive the difference between freamworks. as a developer, it’s easy for me to just think about something is maybe can bring performance benefit. You maybe thought about is too before. so hey, keep up your good work, I like Elm, hope it will become more widely used.

Alexander Artemenko: which

via Planet Lisp by on Fri, 25 Sep 2020 20:48:31 GMT

This is a tiny library by Fernando Borretti. It implements analogue of the UNIX utility which:

POFTHEDAY> (which:which "ls")
#P"/bin/ls"

POFTHEDAY> (which:which "sbcl")
#P"/Users/art/.bin/sbcl"

POFTHEDAY> (which:which "python3")
#P"/usr/bin/python3"

POFTHEDAY> (which:which "missing-binary")
NIL

That is it. No more, no less. What do you think, when this library can be useful?

By the way, there are many other trivial (but useful) libraries. All of them are marked with a trivial tag on #pofthedday site.

Discussion: How much to pipeline

via Elm - Latest posts by @brian Brian on Fri, 25 Sep 2020 20:23:30 GMT

I follow a few rules since it’s so easy to get overzealous with pipelining. I’m gonna call these pizza rules here for fun.

  1. I only pizza if there are two or more values in the chain
  2. If the code is short enough to be subjectively fine on one line, I get suspicious and probably will refactor it to use parens
  3. I try to never pizza in HTML code[1]
  4. I never use left pizza except when I’m avoiding parens around a function (in, say, elm-test tests)

[1]: I gave a talk at Elm in the Spring where I recommended people do that and now I kinda regret making such a strong recommendation! I think it’s fine but the HTML-like pattern is fine and has well-understood syntax and semantics such that it’s maybe a better pattern. Still depends highly on the team.

Discussion: How much to pipeline

via Elm - Latest posts by @stephenreddek Stephen Reddekopp on Fri, 25 Sep 2020 20:04:43 GMT

I tend to follow your first snippet. I share your sentiment about wanting view functions to feel more like the resulting HTML. In general, my opinion is to use |> for data transformations and use parentheses and the occasional <| for view logic. It might feel even better if you just pull the items |> ... part into its own value so that you don’t have to use the parens at all. I’ve found that writing view functions that way helps me and my team understand the HTML hierarchy better and visualize the results.

Quicklisp news: September 2020 Quicklisp dist update now available

via Planet Lisp by on Fri, 25 Sep 2020 19:40:00 GMT

 New projects

  • cl-base16 — Common Lisp implementation of base16 — GPLv2
  • cl-bcrypt — Common Lisp system for generating and parsing of bcrypt password hashes — BSD 2-Clause
  • cl-getx — This is a naive, persisted, in memory (lazy loading) data store for Common Lisp. — MIT
  • cl-indentify — A code beautifier for Common Lisp. — MIT
  • cl-kaputt — A Simple Interactive Test Framework for Common Lisp — MIT
  • cl-mango — A minimalist CouchDB 2.x database client. — BSD3
  • cl-minify-css — To minify css with common lisp. — GPLv3
  • cl-rfc4251 — Common Lisp library for encoding and decoding data in RFC 4251 compliant format — BSD 2-Clause
  • cl-setlocale — FFI to setlocale and ncurses locale helper — 2-clause BSD
  • cl-ssh-keys — Common Lisp system for generating and parsing of OpenSSH keys — BSD 2-Clause
  • cl-wave-file-writer — A wave file writer — MIT
  • class-options — Provides easy access to the defining class and its options during initialization. — Unlicense
  • compatible-metaclasses — Validates superclasses according to a simple substitution model, thereby greatly simplifying the definition of class mixins. — Unlicense
  • enhanced-find-class — Provides a canonical way of converting class designators to classes. — Unlicense
  • evaled-when — Provides a way of extracting and replicating the compile-time side-effects of forms. — Unlicense
  • file-attributes — Access to file attributes (uid, gid, atime, mtime, mod) — zlib
  • gadgets — Ben McGunigle's utility collection — Apache License, version 2.0
  • gooptest — A microcontroller testing framework. — GPL-3.0
  • kekule-clj — A Kekule widget for Common Lisp Jupyter — MIT
  • magicffi — cffi interface to libmagic(3) — Simplified BSD License
  • math —это математическая библиотека, реализующая некоторые алгоритмы: - линейной алгебры; - операций работы с матрицами; - статистические функции; - линейной и билинейной интерполяции; - нахождения приближающих многочленов, реализованная на Common Lisp — GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 or later
  • messagebox — A library to show a native message box dialog. — zlib
  • metalock — A metaclass that makes building parallel systems easier by providing each slot within a class a lock which is grabbed automatically. — MIT
  • nbd — Network Block Device server library. — MIT
  • object-class — Ensures that special subclasses of standard-object cluster right in front of standard-object in the class precedence list. — Unlicense
  • picl — Python Itertools in Common Lisp — MIT
  • pkg-doc — View package documentation in a clim-treeview — BSD Simplified
  • py4cl2 — Some improvements over py4cl — MIT
  • shasht — JSON reading and writing for the Kzinti. — MIT
  • simple-guess — Defines a simple extensible protocol for computing a guess using advisors. — Unlicense
  • trivial-do — Looping extensions that follow the style of the core DO functions. — MIT
  • uncursed — Another TUI library, this time without curses. — BSD 3-Clause
  • xcat — XCAT mass LAN big file distributor — MIT
  • zippy — A fast zip archive library — zlib

Updated projects3b-hdr3bmdacclimationalexandriaalgaeanypoolaprilatomicsbabelbdefbstci-utilscity-hashcl-allcl-aristidcl-autowrapcl-base64cl-bnfcl-cffi-gtkcl-collidercl-conllucl-covid19cl-dotcl-erlang-termcl-fixcl-formscl-fusecl-gamepadcl-gservercl-html-parsecl-krakencl-liballegrocl-liballegro-nuklearcl-marklesscl-migratumcl-mixedcl-mpg123cl-naive-storecl-patternscl-pngcl-pslibcl-rabbitcl-readlinecl-rediscl-renderdoccl-rrtcl-rsvg2cl-sdl2-ttfcl-steamworkscl-stompcl-storecl-strcl-unificationcl-utilscl-webkitcl-zyreclack-pretendclastclawkclcs-codeclimacscljcloser-mopclunit2com-oncom.google.basecommon-lisp-jupytercommonqtcroatoandeploydiff-match-patchdjulaeasy-audioeasy-routeseazy-processeclectoreosexscribef2clfare-quasiquotefast-iofile-selectfiveamflareflexi-streamsflexichainfloat-featuresfont-discoveryfsetfunctional-treesgendlgeneric-clglacierglsl-toolkitgolden-utilsgtirbgtirb-capstoneharmonyhu.dwim.asdfhu.dwim.delicohu.dwim.walkerhunchentoot-multi-acceptorhyperluminal-memhyperobjectinferior-shellinner-conditionalironcladjingohjonathanjpeg-turbokmrcllazylinear-programminglisp-binarylisp-gflagslispcordliterate-lisplocal-timelog4clmaidenmarkupmcclimmethod-hooksmgl-paxmodfmutilitynamed-readtablesnibblesnodguinull-packageopticloriginosicatoverlordparen6parsepathname-utilsperceptual-hashespetalispphoe-toolboxpngloadportable-condition-systempostmodernprotobufpsychiqpy4clquilcquux-hunchentootrandom-stateread-as-stringreplicroanrpcqs-graphvizsanity-clausesc-extensionsscalplselserapeumshadowsheepleshellpoolsimple-actorsslimeslysnoozestumpwmsxqltootertrace-dbtriviatrivial-argumentstrivial-clipboardtrivial-custom-debuggertrivial-garbagetrivial-gray-streamstrivial-utf-8trucleruax-14umbraunix-optsvernacular.

Removed projects: unicly.

To get this update, use (ql:update-dist "quicklisp").

Enjoy!

Elm in a nutshell

via Elm - Latest posts by @wolfadex Wolfgang Schuster on Fri, 25 Sep 2020 19:48:54 GMT

When I speak to my wife or other friends and family who don’t know much if anything about programming I usually talk about how Elm is a programming language for building web sites or web apps. I don’t explain how it works usually as that’s not really important for them. I explain how it provides a way for being more expressive about the information you’re working with. An example I’ve used before is that most web site programming allows "horse" + 5, but Elm won’t. There’s probably a better way to get across the idea of types, but this is where I’m at in my explanation right now. I also talk about how Elm is relatively simple compared to javascript. How it’s a lot easier to talk about. How it’s friendlier with its error messages, I really like to highlight the friendliness.

From a business perspective I talk about how I find it very quick to work in Elm, quick but also secure. How its expressiveness (its type system makes this easier). I also bring up that it’s easier to refactor large amounts of code which is important for business, being able to change quickly.

As far as community I’d highlight the Slack and the conferences. I’ve referred to the Elm Slack in a few other of my Slack communities because I think it excels at being welcoming. I don’t go too much into specifics about the conferences with people who aren’t programming.

Also, when it comes to business I’ve started to try and use Elm’s stability more as a good thing. I know there was a big todo when Elm went from 0.18 to 0.19 but compared to working in other front end frameworks it’s been quite stable. As I explained to some coworkers the other day, the Elm I was writing 2 years ago is identical to the Elm I write today and will most likely be the same Elm I’m writing 2 years from now. The Ember I write today isn’t the same Ember I was writing 6 months ago, or 6 months before that, etc. The same is also true for React https://twitter.com/kadikraman/status/1308390711809789959?s=19, though slightly closer to Elm.

Discussion: How much to pipeline

via Elm - Latest posts by @Lucas_Payr Lucas Payr on Fri, 25 Sep 2020 16:33:42 GMT

Personally, I love to use the |> pipe as much as possible, even in the view.
Something like

items
    |> List.map viewItem
    |> Element.column [ Element.spacing 8 ]

Seems very normal to me.

I also use <| but rather rarely, trying to keep it at a minimum. I try to use it only for math or for type conversion:

Element.spacing <| toInt <| 17 / 4

Discussion: How much to pipeline

via Elm - Latest posts by @lydell Simon Lydell on Fri, 25 Sep 2020 15:55:02 GMT

I really like |> pipelines. My brain now recognizes the a (b |> c) pattern and is tempted to convert it into b |> c |> a.

But sometimes I’m not sure if that’s actually better. For example:

Element.column [ Element.spacing 8 ]
    (items
        |> List.map viewItem
    )

Refactoring that to:

items
    |> List.map viewItem
    |> Element.column [ Element.spacing 8 ]

… while beautiful, it feels a bit like writing HTML like this (invalid HTML, I know):

<div>
  {{ loop viewItem items }}
</div class="spacing-8">

I kind of like when going through a view function is like going through the HTML inspector in the browser. Pipelines stray away from that a bit.

|> keeps execution order, but reverses structure order.
<| keeps structure order, but reverses execution order.

Anyone else thought about this?

Elm in a nutshell

via Elm - Latest posts by @eimfach Robin G. on Fri, 25 Sep 2020 14:45:34 GMT

Hi Folks !

I was wondering on how to think, write and tell about elm holistically. How would you think, write and tell about Elm to someone completely unaware of technological topics or someone who is not too much experienced with programming or comes from another perspective of programming ?

I think of things like:

  • What is Elm ?
  • How does it work ?
  • What are the Pro’s and Con’s ?
  • How to you get deeper into it ?
  • Are there challenges ?
  • How does it evolve in simple terms ?
  • What do you think about it’s future ?
  • Is it more than just about programming ?
  • What are the principles of Elm ?
  • How do you keep an overview of it’s resources and which resources are actually helpful ?
  • How to you introduce and learn advanced Elm topics simply ?
  • How does one participate in the development of Elm ?
  • What does organic advancement mean in terms of Elm ?
  • Where to find a central Resource of Documentation either from community or official ?
  • What can Elm do from a Business perspective ?
  • What about the Web APIs in Elm ?
  • Where can you find scaffolds for your Elm project ? (e.g. the default architecture, games, packages…)
  • How does the community make impact on elm development ? Can it ?
  • How to keep and overview of different useful Patterns in Elm ? Even if you are not working with it day by day ?
  • Which Elm Meetups exist and where can I join ?
  • Which conferences are planned and how can I attend ?

Largest-Triangle-Three-Buckets downsampling algorithm package and demo

via Elm - Latest posts by @system system on Fri, 25 Sep 2020 14:00:02 GMT

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.

Parsers with Error Recovery

via Elm - Latest posts by @rupert Rupert Smith on Fri, 25 Sep 2020 08:50:07 GMT

I tried to keep the API idential to Parser.Advanced, so switching over to it should be relatively easy. All the functions should behave the same way as the corresponding functions in Parser.Advanced. The behaviour should only change when you apply one of the recovery tactics.

I cannot export (|.) and (|=) though, due to kernel code restrictions :-(. So you have to re-write those:

import Parser.Advanced as PA exposing ((|=), (|.))

parser = 
    PA.succeed identity
        |. PA.spaces
        |= PA.int
        |. PA.spaces

to

import Parser.Recoverable as PR

parser = 
    PR.succeed identity
        |> PR.ignore PR.spaces
        |> PR.keep PR.int
        |> PR.ignore PR.spaces

Another difference is that where functions like Parser.Advanced.keyword take a Token argument, I thought just passing in the String and problem without wrapping as a Token was neater:

PA.keyword (PA.Token "let" ExpectingLet)

PR.keyword "let" ExpectingLet

I’ll likely make a release soon - I’m trying to figure out how to make a recoverable version of sequence first. The fast-forward recovery at the moment fast forwards to a sentinal Char, then continues. But sequence uses Strings as separators not Chars, so I need to implement a slightly different fast-forward mechanism, then it will be good to go. I’ll just push it out with the recovery tactics I implemented so far, it will be interesting to hear if they work for you, or if you find they need to be modified to cover situations you are encountering.

 newer latest older