Skip to content

Commit

Permalink
fixup: many small cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
nicuveo committed Feb 23, 2025
1 parent 3282c67 commit 95bb4a5
Show file tree
Hide file tree
Showing 12 changed files with 103 additions and 229 deletions.
77 changes: 56 additions & 21 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,44 +10,79 @@ permissions:
contents: read

jobs:
build:
# Generates a list of files to analyze. The output depends on the type of event:
# - for a push request, this is the list of modified files;
# - for a pushe, it's all Haskell files in the repo.
# There are two outputs to this job:
# - haskell-files-text: a string in which files are separated by a space
# - haskell-files-json: a string that represents a JSON array of file-names
generate-file-list:
name: "generate: haskell file list"
runs-on: ubuntu-latest
outputs:
haskell-files-text: ${{ steps[format('{0}-files', github.event_name)].outputs.text }}
haskell-files-json: ${{ steps[format('{0}-files', github.event_name)].outputs.json }}
steps:
- uses: actions/checkout@v4
- uses: freckle/stack-action@v5
- id: pr_changed_files
if: ${{ github.event_name == 'pull_request' }}
uses: tj-actions/changed-files@v45
with:
stack-build-arguments: ""
test: false
files: "**/*.hs"
- name: Export haskell files
id: pull_request-files
if: ${{ github.event_name == 'pull_request' }}
env:
FILES: "${{ steps.pr_changed_files.outputs.all_changed_and_modified_files }}"
run: |
echo "text=$FILES" | tee -a "$GITHUB_OUTPUT"
echo "json=$(jq -c --null-input --arg str "$FILES" '$str | split(" ")')" | tee -a "$GITHUB_OUTPUT"
- name: Export haskell files
id: push-files
if: ${{ github.event_name == 'push' }}
run: |
echo "text=$(git ls-files '*.hs' '*.hs-boot' | tr '\n' ' ')" | tee -a "$GITHUB_OUTPUT"
echo "json=$(jq -c --null-input --arg str "$(git ls-files '*.hs')" '$str | split("\n")')" | tee -a "$GITHUB_OUTPUT"
lint:
# Runs linters on the code.
# In the case of a pull-request, only lint modified files.
check-lint:
name: "check: lint"
runs-on: ubuntu-latest
needs: generate-file-list
if: needs.generate-file-list.outputs.haskell-files-text
steps:
- uses: actions/checkout@v4
- id: changed-files
uses: tj-actions/changed-files@v45
with:
files: "**/*.hs"
json: true
escape_json: false
- uses: haskell-actions/hlint-setup@v2
- if: steps.changed-files.outputs.all_changed_and_modified_files != '[]'
uses: haskell-actions/hlint-run@v2
- uses: haskell-actions/hlint-run@v2
with:
path: ${{ steps.changed-files.outputs.all_changed_and_modified_files }}
path: ${{ needs.generate-file-list.outputs.haskell-files-json }}

formatting:
# Check formatting.
# In the case of a pull-request, only check modified files.
check-format:
name: "check: format"
runs-on: ubuntu-latest
needs: generate-file-list
if: needs.generate-file-list.outputs.haskell-files-text
steps:
- uses: actions/checkout@v4
- id: changed-files
uses: tj-actions/changed-files@v45
with:
files: "**/*.hs"
- if: steps.changed-files.outputs.all_changed_and_modified_files
- name: "Run stylish-haskell"
env:
TARGETS: ${{ steps.changed-files.outputs.all_changed_and_modified_files }}
TARGETS: ${{ needs.generate-file-list.outputs.haskell-files-text }}
run: |
curl -sL https://raw.github.com/haskell/stylish-haskell/main/scripts/latest.sh | sh -s -- --inplace $TARGETS
for f in $(git diff --name-only --diff-filter=M); do
echo "::error file=$f::File is not formatted properly."
done
# Builds the code, builds the documentation, runs the test.
build:
name: "build"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: freckle/stack-action@v5
with:
stack-build-arguments: ""
test: false
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Once the project has made enough progress, a roadmap to 1.0 will be detailed her
- [ ] announce the project on social media
- [ ] schedule a first stream

<br />
<br />

[ActionM]: https://github.com/nicuveo/pietre/actions/workflows/validate.yml?query=branch%3Amain
Expand Down
2 changes: 0 additions & 2 deletions Setup.hs

This file was deleted.

4 changes: 2 additions & 2 deletions lib/Lang/Pietre/Stages/Parsing/Monad.hs
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,12 @@ alexInputPrevChar = view parserPrevChar
alexError :: Parser a
alexError = do
Position _ line column <- use parserPosition
throwError $ "lexical error at line " ++ (show line) ++ ", column " ++ (show column)
throwError $ "lexical error at line " ++ show line ++ ", column " ++ show column


-- happy functions

happyError :: Token -> Parser a
happyError _ = do
Position _ line column <- use parserPosition
throwError $ "parse error at line " ++ (show line) ++ ", column " ++ (show column)
throwError $ "parse error at line " ++ show line ++ ", column " ++ show column
62 changes: 20 additions & 42 deletions package.yaml
Original file line number Diff line number Diff line change
@@ -1,72 +1,58 @@
name: pietre
version: 0.0.0.1
github: "nicuveo/pietre"
license: BSD-3-Clause
author: "Antoine Leblanc"
maintainer: "[email protected]"
copyright: "2025 Antoine Leblanc"
name: pietre
version: 0.0.0.1
github: "nicuveo/pietre"
license: BSD-3-Clause
author: "Antoine Leblanc"
maintainer: "[email protected]"
copyright: "2025 Antoine Leblanc"
category: Language, Compiler
synopsis: Compiler for a stack-based imperative language targeting Piet
description: Please see the README on GitHub at <https://github.com/nicuveo/pietre#readme>

extra-source-files:
- README.md

description: Please see the README on GitHub at <https://github.com/githubuser/pietre#readme>

language: GHC2021

ghc-options:
- -Wcompat
- -Werror
- -Wall
- -Werror
- -Wcompat
- -Widentities
- -Wincomplete-uni-patterns
- -Wpartial-fields
- -Wredundant-constraints
- -Wtabs
- -Wno-unused-do-bind
- -fwarn-tabs
- -fhide-source-paths
- -foptimal-applicative-do
- -funbox-small-strict-fields
- -fwrite-ide-info

default-extensions:
- AllowAmbiguousTypes
- ApplicativeDo
- BangPatterns
- BlockArguments
- ConstraintKinds
- DataKinds
- DefaultSignatures
- DeriveDataTypeable
- DeriveFoldable
- DeriveFunctor
- DeriveGeneric
- DeriveLift
- DeriveTraversable
- DerivingVia
- FlexibleContexts
- FlexibleInstances
- FunctionalDependencies
- GADTs
- GeneralizedNewtypeDeriving
- ImportQualifiedPost
- InstanceSigs
- LambdaCase
- MultiParamTypeClasses
- MultiWayIf
- NamedFieldPuns
- NoImplicitPrelude
- OverloadedStrings
- PackageImports
- RankNTypes
- RecordWildCards
- RoleAnnotations
- ScopedTypeVariables
- StandaloneDeriving
- StrictData
- TupleSections
- TypeApplications
- TypeFamilies
- TypeOperators
- ViewPatterns

dependencies:
- base
- array
- containers
# - extra
- hashable
- lens
- mtl
Expand All @@ -76,8 +62,6 @@ dependencies:

library:
source-dirs: [common, lib]
other-modules:
- Prelude
build-tools:
- alex
- happy
Expand All @@ -92,11 +76,6 @@ executables:
- -with-rtsopts=-N
dependencies:
- pietre
# - filepath
# - directory
# - haskeline
# - monad-loops
# - pretty-simple

gramviz:
main: Main.hs
Expand Down Expand Up @@ -125,6 +104,5 @@ tests:
- tasty
- tasty-hunit
- tasty-quickcheck
# - tasty-golden
- tasty-autocollect
- template-haskell
2 changes: 2 additions & 0 deletions pc/Main.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
module Main where

import "this" Prelude

import System.Exit
Expand Down
Loading

0 comments on commit 95bb4a5

Please sign in to comment.