Binding to C Libraries with Nim
Here's a short little guide to sbt's build structure.
First off, the key you need to investigate how sbt is building things. Here's a snippet from a build.sbt
:
import sbt.Keys._
val bs: sbt.BuildStructure = buildStructure.value
This will give you all the gory details of our build (or builds, as is the case).
Kris Nuttycombe asks:
I genuinely wish I understood the appeal of unityped languages better. Can someone who really knows both well-typed and unityped explain?
I think the terms well-typed and unityped are a bit of question-begging here (you might as well say good-typed versus bad-typed), so instead I will say statically-typed and dynamically-typed.
I'm going to approach this article using Scala to stand-in for static typing and Python for dynamic typing. I feel like I am credibly proficient both languages: I don't currently write a lot of Python, but I still have affection for the language, and have probably written hundreds of thousands of lines of Python code over the years.
import scala.language.experimental.macros | |
import scala.reflect.macros.blackbox.Context | |
trait Mappable[T] { | |
def toMap(t: T): Map[String, Any] | |
def fromMap(map: Map[String, Any]): T | |
} | |
object Mappable { | |
-- Given a list of values, returns a list of the differences between | |
-- neighbouring pairs of values. | |
nextLevelDiffs (a:b:rest) = (b - a):(nextLevelDiffs (b:rest)) | |
nextLevelDiffs _ = [] | |
-- Given a list of values, returns a list of the differences such that the | |
-- first element is the 0-level differences, the second the 1-level and so | |
-- on. | |
nLevelDiffs [] = [] | |
nLevelDiffs elms = elms:(nLevelDiffs (nextLevelDiffs elms)) |
import annotation._ | |
case class Pronunciation(pronounce: String) extends StaticAnnotation | |
case class Law(name: String, denotation: String) extends StaticAnnotation | |
trait ~>[F[_], G[_]] { | |
def apply[A]: F[A] => G[A] | |
} | |
case class Id[A](x: A) |
// Simple Scala-like for comprehension for rust | |
macro_rules! comp( | |
// base case, using "map" | |
(val $id:ident <- $expr:expr $(,if $cond:expr)* $(,let $assign_id:pat = $assign_val:expr)* ,yield $comp:expr) => | |
( | |
($expr)$(.filtered(|&$id| $cond))*.map(|&$id| { | |
$(let $assign_id = $assign_val;)* $comp | |
} | |
) |
/* | |
* Copyright (c) 2012, Lawrence Livermore National Security, LLC. Produced at | |
* the Lawrence Livermore National Laboratory. Written by Keith Stevens, | |
* [email protected] OCEC-10-073 All rights reserved. | |
* | |
* This file is part of the S-Space package and is covered under the terms and | |
* conditions therein. | |
* | |
* The S-Space package is free software: you can redistribute it and/or modify | |
* it under the terms of the GNU General Public License version 2 as published |