Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jan 30 2019 14:37
    bhaskarmelkani starred lihaoyi/Ammonite
  • Jan 29 2019 04:27
    JYInMyHeart starred lihaoyi/Ammonite
  • Jan 29 2019 04:27
    JYInMyHeart starred lihaoyi/Ammonite
  • Jan 28 2019 15:07
    ishubelko starred lihaoyi/Ammonite
  • Jan 25 2019 22:38
    borissmidt starred lihaoyi/Ammonite
  • Jan 25 2019 17:12

    alexarchambault on 1.6.3

    (compare)

  • Jan 25 2019 17:11

    alexarchambault on master

    1.6.3 (compare)

  • Jan 25 2019 15:48
    alexarchambault commented #923
  • Jan 25 2019 01:15

    lihaoyi on gh-pages

    5ad9ae5538f23cab92ccd8c6b1617d8… (compare)

  • Jan 25 2019 00:50

    alexarchambault on master

    Partly revert 84d48542 (#923) … (compare)

  • Jan 25 2019 00:50
    alexarchambault closed #923
  • Jan 25 2019 00:50
    alexarchambault closed #920
  • Jan 25 2019 00:50
    alexarchambault closed #922
  • Jan 24 2019 23:13
    lihaoyi commented #923
  • Jan 24 2019 22:39
    alexarchambault closed #921
  • Jan 24 2019 22:39
    alexarchambault commented #921
  • Jan 24 2019 22:39
    alexarchambault edited #923
  • Jan 24 2019 22:38
    alexarchambault opened #923
  • Jan 24 2019 22:37
    david-bouyssie commented #919
  • Jan 24 2019 21:33
    nksureshkumar commented #922
Peter Aaser
@PeterAaser
I'll investigate some more
Li Haoyi
@lihaoyi
I've definitely hit compiled script caching issues on my laptop before
haven't bothered minimizing it yet
but I definitely know such bugs exist
Peter Aaser
@PeterAaser
I'm now calling a lot of processes wrapped in fs2 Streams. If I want to stop the compile, is there a good way to do this in ammonite?
I'm suspecting that I should make a regular scala program using your os and file libraries instead
Then I can just do the whole IOApp rigmarole
and then interrupt the processes by sending in <Ctrl-C> to their stdin
Does that sound somewhat coherent?
Peter Aaser
@PeterAaser
Actually, I think the only part of the question that was relevant for this channel was if I can kill a process with Ctrl-C, and I should've tried that before asking :D
Li Haoyi
@lihaoyi
Ctrl-C is tricky, but generally should be properly propagated to child processes when you Ctrl-C a parent (e.g. the thing you run from the terminal)
you can also kill the os.SubProcesses programmatically
Peter Aaser
@PeterAaser
Oh, of course
Tim Spence
@TimWSpence

This is my current predef:

//See https://gist.github.com/mpilquist/0b1cc1926bddd31c70ad40663acfec8e
// Save as ~/.ammonite/predef.sc
// To use fs2 from ammonite repl, type `load.fs2` from repl prompt.
// You'll get all fs2 & cats imports, ContextShift and Timer instances
// for IO, and a globalBlocker

import $plugin.$ivy.`org.typelevel:::kind-projector:0.11.0`

if (!repl.compiler.settings.isScala213)
  repl.load.apply("interp.configureCompiler(_.settings.YpartialUnification.value = true)")

interp.configureCompiler(_.settings.Ydelambdafy.tryToSetColon(List("inline")))

object load {
  def fs2Version(version: String) = {
    //import $ivy.`org.scalacheck::scalacheck:1.14.1`, org.scalacheck._
    //import $ivy.`io.chrisdavenport::cats-scalacheck:0.3.0`, org.scalacheck.cats.implicits._
    repl.load.apply(s"""
      import $$ivy.`co.fs2::fs2-io:$version`, fs2._, fs2.concurrent._, cats._, cats.implicits._, cats.effect._, cats.effect.implicits._, scala.concurrent.duration._


      implicit val ioContextShift: ContextShift[IO] = IO.contextShift(scala.concurrent.ExecutionContext.Implicits.global)
      implicit val ioTimer: Timer[IO] = IO.timer(scala.concurrent.ExecutionContext.Implicits.global)
    """)
    if (!version.startsWith("1")) repl.load.apply("""
      val globalBlocker: Blocker = cats.effect.Blocker.liftExecutionContext(scala.concurrent.ExecutionContext.Implicits.global)
    """)
  }

  def fs2 = fs2Version("2.4.0")
}

When I run amm the first time I can run load.fs2 and it works perfectly. However, if I quit and run amm again then I get:

Loading...
java.lang.NullPointerException
  ammonite.repl.Repl$$anon$1.compiler(Repl.scala:105)
  ammonite.predef.predef$.<clinit>(predef.sc:9)

?

Tim Spence
@TimWSpence
PS I also get the same error with this simpler predef that I would also be happy with:
//See https://gist.github.com/mpilquist/0b1cc1926bddd31c70ad40663acfec8e
// Save as ~/.ammonite/predef.sc
// To use fs2 from ammonite repl, type `load.fs2` from repl prompt.
// You'll get all fs2 & cats imports, ContextShift and Timer instances
// for IO, and a globalBlocker

import $plugin.$ivy.`org.typelevel:::kind-projector:0.11.0`

if (!repl.compiler.settings.isScala213)
  repl.load.apply("interp.configureCompiler(_.settings.YpartialUnification.value = true)")

interp.configureCompiler(_.settings.Ydelambdafy.tryToSetColon(List("inline")))

//import $ivy.`org.scalacheck::scalacheck:1.14.1`, org.scalacheck._
//import $ivy.`io.chrisdavenport::cats-scalacheck:0.3.0`, org.scalacheck.cats.implicits._
import $ivy.`co.fs2::fs2-io:2.4.0`, fs2._, fs2.concurrent._, cats._, cats.implicits._, cats.effect._, cats.effect.implicits._, scala.concurrent.duration._

implicit val ioContextShift: ContextShift[IO] = IO.contextShift(scala.concurrent.ExecutionContext.Implicits.global)
implicit val ioTimer: Timer[IO] = IO.timer(scala.concurrent.ExecutionContext.Implicits.global)
val globalBlocker: Blocker = cats.effect.Blocker.liftExecutionContext(scala.concurrent.ExecutionContext.Implicits.global)
Nathaniel Fischer
@kag0
what's a common editor for ammonite scripts?
just opening a file in vs code with metals doesn't seem to pick up anything aside from syntax highlighting
Li Haoyi
@lihaoyi
I use intellij, but code navigation only seems to work sometimes
Nathaniel Fischer
@kag0
do imports usually work? they've been dodgy for me, even when intellij prompts me to add dependencies for $ivy imports
Anton Sviridov
@keynmol
I use VS code with Metals - imports work much better, but there are occasional quirks with autocomplete.
Nathaniel Fischer
@kag0
@keynmol how do you set it up/get it to recognize the file as ammonite?
Olivier Mélois
@Baccata
With the latest version, metals prompts you to "import an ammonite build" whenever you open a .sc file.
@kag0 the way I used to edit ammonite scripts would be to piggyback on mill's GenIdea task. As in, I'd create a build.sc in which I'd import my script and would call GenIdea on that and would open Intellij in that folder. It's pretty lame but it worked much better than Intellij's built in <airquote> ammonite support </airquote>
Nathaniel Fischer
@kag0
That's a good trick. After some tinkering around I found that in VS code you can't just open a .sc file and have it be recognized, you need to open the parent folder (similar to intellij) and then it works fine.
Andrey Ivanov
@a_nigredo_twitter
Hi guys, are there any article how to configure ammonite on Windows 10?
Andrey Ivanov
@a_nigredo_twitter
never mind, my fault
Kostas Kougios
@kostaskougios

Hi all, I would like to use ammonite as a library. I want to do two things:
1) parse a script file (or code string) and get the compiled class (or something that I can get a list of methods)
2) run methods within a .sc file (but not the file itself)

Are the above possible? So far I am trying code like:

ammonite.Main().runCode(code)

But it runs the whole code. If the code has an ivy import, it runs only the ivy import. Also tried ammonite.Main().instantiateInterpreter() but can't see how to achieve what I want.
Thanks

Kostas Kougios
@kostaskougios

I am using com.lihaoyi:ammonite_2.13.3:2.2.0-4-4bd225e lib. Debugging it I can see it uses these folders:

cacheDir: /home/ariskk/.ammonite/cache/2.2.0-4-4bd225e
compileCacheDir: /home/ariskk/.ammonite/cache/2.2.0-4-4bd225e/compile
But the folder 2.2.0-4-4bd225e doesn't exist

Matthew Hoggan
@mehoggan

Why is it that when I run the following code in a jupyter notebook:

import coursierapi.Credentials
import coursierapi.MavenRepository

interp.repositories() ++= Seq()

I get the following error

cmd1.sc:4: object repositories is not a member of package ammonite.interp
val res1_2 = interp.repositories() ++= Seq()
                    ^Compilation Failed
Anton Sviridov
@keynmol
are you using Almond?
Matthew Hoggan
@mehoggan
Yes
@keynmol according to https://almond.sh/docs/api-ammonite this should work.
Anton Sviridov
@keynmol

what if you try something like

import $repo.`ivy:https://dl.bintray.com/typesafe/ivy-releases/[defaultPattern]`

?

Matthew Hoggan
@mehoggan
That line works. But I need to add a repository internal to company.

The current notebook I have was doing something like:

val unidata = Resolver.Http(
        "Unidata",
        "https://artifacts.unidata.ucar.edu/content/repositories/unidata-releases/",
        MavenPattern,
        true
    )

I need to migrate over to almond. I have no idea what kernel allowed enabled the Resolver api.

Anton Sviridov
@keynmol

this should work, too - we use it internally. just change the URL, it should support most formats

Otherwise I'd recommend checking in almond-sh/almond room because Almond manually instantiates Ammonite interpreter so there might be some version quirks and such

Matthew Hoggan
@mehoggan
okay thanks will do.
Anton Sviridov
@keynmol
checked in the docs and yeah, Maven repos don't need anything special to add, just the URL: https://ammonite.io/#import$repo
Matthew Hoggan
@mehoggan
We have a xdeps repo that I am trying to pull out and use Artifactory in its place.
Anton Sviridov
@keynmol
then $repo syntax is all you need, assuming you're using latest Almond - we also use artifactory :)
import $repo.`https://artifacts.unidata.ucar.edu/content/repositories/unidata-releases/`
without the ivy part
Matthew Hoggan
@mehoggan
okay I will give it a go
Matthew Hoggan
@mehoggan
Yes that worked. Thank you.
Rohan Sircar
@rohan-sircar
Is it possible to embed scala for scripting in a larger jvm language application like say lua or groovy?
Paul Snively
@paul-snively
Yes. The Ammonite REPL docs explain how.
Tushar Mathur
@tusharmath
I installed ammonite via brew brew install ammonite-repl but there is nothing available at ~/amm . What did I miss?
Just going thru the documentation
Rohan Sircar
@rohan-sircar
@paul-snively Are you referring to the embedding section? That talks about an interactive ammonite session as I understand. I was asking about scripts that are loaded into the program at runtime. For example groovy has this - http://www.groovy-lang.org/integrating.html
Paul Snively
@paul-snively
You don’t have to use the REPL and can load script.
Rohan Sircar
@rohan-sircar
So I just need to use runScript right?
Rohan Sircar
@rohan-sircar
runScript does work :)