Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
earldouglas committed Feb 2, 2025
0 parents commit 8bafa2f
Show file tree
Hide file tree
Showing 15 changed files with 149 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: build

on: [push, pull_request]

jobs:
build:

runs-on: ubuntu-24.04

steps:

- uses: actions/checkout@v4

- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '11'
cache: 'sbt'
cache-dependency-path: |
sub-project/build.sbt
sub-project/project/build.properties
- uses: sbt/setup-sbt@v1

- run: sbt test
13 changes: 13 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Copyright 2025 James Earl Douglas

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
![Build Status](https://github.com/earldouglas/sbt-frege.g8/workflows/build/badge.svg)

This is a [Giter8][g8] template for [sbt-frege].

[g8]: http://www.foundweekends.org/giter8/
[sbt-frege]: https://github.com/earldouglas/sbt-frege

## Usage

```
sbt new earldouglas/sbt-frege.g8
```
11 changes: 11 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// This build is for this Giter8 template.
// To test the template run `g8` or `g8Test` from the sbt session.
// See https://www.foundweekends.org/giter8/testing.html#Using+the+Giter8Plugin for more details.
lazy val root = (project in file("."))
.settings(
name := "sbt-frege Template Project",
Test / test := {
val _ = (Test / g8Test).toTask("").value
},
resolvers += Resolver.url("typesafe", url("https://repo.typesafe.com/typesafe/ivy-releases/"))(Resolver.ivyStylePatterns)
)
1 change: 1 addition & 0 deletions project/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sbt.version=1.10.7
2 changes: 2 additions & 0 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
addSbtPlugin("org.foundweekends.giter8" %% "sbt-giter8" % "0.17.0")
libraryDependencies += { "org.scala-sbt" %% "scripted-plugin" % sbtVersion.value }
13 changes: 13 additions & 0 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{ pkgs ? import <nixpkgs> {} }:
let
jdk = pkgs.jdk11;
in
pkgs.mkShell {
nativeBuildInputs = [
(pkgs.sbt.override { jre = jdk; })
];
shellHook = ''
export JAVA_HOME=${jdk}
PATH="${jdk}/bin:$PATH"
'';
}
3 changes: 3 additions & 0 deletions src/main/g8/.scalafmt.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
version = 3.4.3 // https://scalameta.org/scalafmt/docs/installation.html#sbt
runner.dialect = scala3 // https://scalameta.org/scalafmt/docs/configuration.html#scala-3
maxColumn = 72 // RFC 678: https://datatracker.ietf.org/doc/html/rfc678
14 changes: 14 additions & 0 deletions src/main/g8/build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
val scala3Version = "3.6.3"

lazy val root = project
.in(file("."))
.settings(
name := "my-sbt-frege",
version := "0.1.0-SNAPSHOT",

fork := true,

scalaVersion := scala3Version,

libraryDependencies += "org.scalameta" %% "munit" % "1.0.0" % Test
)
2 changes: 2 additions & 0 deletions src/main/g8/default.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
name=My Frege Project
description=A project built with sbt-frege
1 change: 1 addition & 0 deletions src/main/g8/project/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sbt.version=1.10.7
1 change: 1 addition & 0 deletions src/main/g8/project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
addSbtPlugin("com.earldouglas" % "sbt-frege" % "3.0.3")
22 changes: 22 additions & 0 deletions src/main/g8/src/main/frege/example/HelloWorld.fr
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package example.HelloWorld where

multiply :: Int -> Int -> Int
multiply x y = x * y

showMultiply :: Int -> Int -> String
showMultiply x y =
let
result = multiply x y
in
unwords [
show x,
"*",
show y,
"=",
show result,
]

main :: [String] -> IO ()
main _ = do
x = showMultiply 6 7
println x
27 changes: 27 additions & 0 deletions src/main/g8/src/test/scala/example/HelloWorldSuite.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package example

import frege.run8.Thunk
import munit.FunSuite

class HelloWorldSuite extends FunSuite {

test("multiply") {

val obtained = HelloWorld.multiply(6, 7)
val expected = 42

assertEquals(obtained, expected)
}

test("showWork") {

val x = Thunk.`lazy`(6)
val y = Thunk.`lazy`(7)

val obtained = HelloWorld.showMultiply(x, y)
val expected = "6 * 7 = 42"

assertEquals(obtained, expected)
}

}
2 changes: 2 additions & 0 deletions src/test/g8/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
> test
> run

0 comments on commit 8bafa2f

Please sign in to comment.