Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
0rphee committed Jul 13, 2024
0 parents commit fca554d
Show file tree
Hide file tree
Showing 15 changed files with 664 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Set update schedule for GitHub Actions
version: 2
updates:

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
62 changes: 62 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: CI

# Trigger the workflow on push or pull request, but only for the main branch
on:
pull_request:
push:
workflow_dispatch:

jobs:
generate-matrix:
name: "Generate matrix from cabal"
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
runs-on: ubuntu-latest
steps:
- name: Extract the tested GHC versions
id: set-matrix
uses: kleidukos/[email protected]
with:
cabal-file: asmh.cabal
ubuntu-version: latest
macos-version: latest
windows-version: latest
version: 0.1.7.0

tests:
name: ${{ matrix.ghc }} on ${{ matrix.os }}
needs: generate-matrix
runs-on: ${{ matrix.os }}
strategy:
matrix: ${{ fromJSON(needs.generate-matrix.outputs.matrix) }}
steps:
- name: Checkout base repo
uses: actions/checkout@v4

- name: Set up Haskell
id: setup-haskell
uses: haskell-actions/setup@v2
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: "latest"

- name: Configure
run: |
cabal configure --enable-tests
# Generate dist-newstyle/cache/plan.json for the cache key.
cabal build --dry-run
- name: Freeze
run: cabal freeze

- name: Cache ~/.cabal/store
uses: actions/cache@v4
with:
path: ${{ steps.setup-haskell.outputs.cabal-store }}
key: ${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('dist-newstyle/cache/plan.json') }}

- name: Build
run: cabal build all

- name: Test
run: cabal test all --test-show-details=direct
40 changes: 40 additions & 0 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Linting

on:
pull_request:
push:
branches: ["main"]

jobs:
fourmolu:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: haskell-actions/run-fourmolu@v10
with:
pattern: |
src
app
test
hlint:
runs-on: ubuntu-latest
permissions:
security-events: write # Needed to upload results to GitHub code scanning.
steps:
- uses: actions/checkout@v4

- name: 'Set up HLint'
uses: haskell-actions/hlint-setup@v2
with:
version: '3.8'

- name: 'Run HLint Scan'
uses: haskell-actions/hlint-scan@v1

- name: 'Run HLint'
uses: haskell-actions/hlint-run@v2
with:
path: '["app"]'
fail-on: warning
36 changes: 36 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Created by https://www.toptal.com/developers/gitignore/api/haskell
# Edit at https://www.toptal.com/developers/gitignore?templates=haskell

### Assembler ###
*.exe
*.o
*.obj
*.bc

### Haskell ###
dist
dist-*
cabal-dev
*.o
*.hi
*.hie
*.chi
*.chs.h
*.dyn_o
*.dyn_hi
.hpc
.hsenv
.cabal-sandbox/
cabal.sandbox.config
*.prof
*.aux
*.hp
*.eventlog
.stack-work/
cabal.project.local
cabal.project.local~
.HTF/
.ghc.environment.*

# End of https://www.toptal.com/developers/gitignore/api/haskell
*~
10 changes: 10 additions & 0 deletions .helix/languages.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[language-server.haskell-language-server.config.haskell]
"formattingProvider" = "fourmolu"

[[language]]
name = "haskell"
auto-format = true

[[language]]
name = "cabal"
auto-format = true
30 changes: 30 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Copyright 0rphee (c) 2024

All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.

* Neither the name of 0rphee nor the names of other
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# asmh

2 changes: 2 additions & 0 deletions Setup.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import Distribution.Simple
main = defaultMain
45 changes: 45 additions & 0 deletions app/CmdOptions.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{-# LANGUAGE TemplateHaskell #-}

module CmdOptions
( Options (..)
, runCmdOptions
)
where

import Data.Version (showVersion)
import GitHash
import OptEnvConf
import Path
import Paths_asmh (version)

newtype Options = Options
{ sourceCodeFile :: Path Abs File
}

instance HasParser Options where
settingsParser = do
val <-
filePathSetting
[ help "the file to compile"
, argument
]
pure $ Options val

runCmdOptions :: IO Options
runCmdOptions = runSettingsParser version descriptionString
where
descriptionString = concat ["Run asmh - v", showVersion version, gitInfoString]

gitInfoString = case $$tGitInfoCwdTry of
Right gi ->
concat
[ " - "
, giBranch gi
, "@"
, giHash gi
, " ("
, show $ giCommitCount gi
, " commits in HEAD"
, ")"
]
_ -> ""
9 changes: 9 additions & 0 deletions app/Main.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module Main (main) where

import CmdOptions (Options (..), runCmdOptions)
import Path

main :: IO ()
main = do
(Options sourceCodeFile) <- runCmdOptions
putStrLn $ "FILEPATH: " <> toFilePath sourceCodeFile
99 changes: 99 additions & 0 deletions asmh.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
cabal-version: 3.4
name: asmh
version: 0.1.0.0
description: Please see the README on Github at <https://github.com/0rphee/asmh#asmh>
author: 0rphee
maintainer: [email protected]
copyright: 2024 0rphee
license: BSD-3-Clause
license-file: LICENSE
build-type: Simple
extra-source-files:
CHANGELOG.md
README.md

tested-with: ghc ==9.4.8 || ==9.6.5 || ==9.8.2 || ==9.10.1

common common-options
default-language: GHC2021
ghc-options:
-Wall
-Wcompat
-Widentities
-Wincomplete-record-updates
-Wincomplete-uni-patterns
-Wpartial-fields
-Wredundant-constraints
-fhide-source-paths
-Wno-unused-do-bind
-fshow-hole-constraints
-fprint-potential-instances
-Wno-unticked-promoted-constructors
-flate-specialise
-funbox-strict-fields
-fexpose-all-unfoldings
-threaded
-with-rtsopts=-N
-Wunused-packages

default-extensions:
ApplicativeDo
OverloadedStrings
RecordWildCards

library
import:
common-options

hs-source-dirs:
src

exposed-modules:
Expr

build-depends:
attoparsec,
base >=4.7 && <5,
bytestring,
path,

executable asmh
import:
common-options

hs-source-dirs:
app

main-is: Main.hs
other-modules:
CmdOptions
Paths_asmh

default-extensions:
build-depends:
asmh,
base >=4.7 && <5,
bytestring,
githash,
opt-env-conf,
path,

test-suite asmh-test
import:
common-options

type: exitcode-stdio-1.0
hs-source-dirs:
test

main-is: Spec.hs
other-modules:
Paths_asmh

build-depends:
asmh,
base >=4.7 && <5,
bytestring,
tasty,
tasty-hunit,
tasty-quickcheck,
3 changes: 3 additions & 0 deletions cabal.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
packages: ./

tests: False
16 changes: 16 additions & 0 deletions fourmolu.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
indentation: 2 # any non-negative integer (default 4)
column-limit: 80 # (default none), or any non-negative integer
function-arrows: leading # (default trailing), leading, leading-args
comma-style: leading # (default leading), trailing
import-export-style: leading # leading, trailing, (default diff-friendly)
indent-wheres: true # true, (default false)
record-brace-space: true # true, (default false)
newlines-between-decls: 1 # any integer (default 1)
haddock-style: multi-line # single-line, (default multi-line), multi-line-compact
haddock-style-module: # (default same as haddock-style)
let-style: inline # inline, newline, (default auto), mixed
in-style: right-align # left-align, (default right-align), no-space
single-constraint-parens: never # (default always), never, auto
unicode: never # always, detect, (default never)
respectful: false # (default true), false
fixities: [] # list of strings (default [])
3 changes: 3 additions & 0 deletions src/Expr.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module Expr where

fun = 123
Loading

0 comments on commit fca554d

Please sign in to comment.