Skip to content

Commit

Permalink
retemplate
Browse files Browse the repository at this point in the history
  • Loading branch information
ejconlon committed May 11, 2023
1 parent 7655895 commit 3f30f85
Show file tree
Hide file tree
Showing 13 changed files with 94 additions and 192 deletions.
84 changes: 0 additions & 84 deletions .circleci/config.yml

This file was deleted.

1 change: 0 additions & 1 deletion .ghci-manual

This file was deleted.

14 changes: 14 additions & 0 deletions .github/workflows/haskell-stack.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: haskell-stack
on:
- push
- pull_request
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: |
if [ -f .github/packages.txt ]; then sudo apt-get update && sudo apt-get install -y $(cat .github/packages.txt); fi
- uses: freckle/stack-action@v4
with:
pedantic: false
41 changes: 0 additions & 41 deletions .stylish-haskell.yaml

This file was deleted.

5 changes: 0 additions & 5 deletions Makefile

This file was deleted.

35 changes: 0 additions & 35 deletions Makefile.base

This file was deleted.

2 changes: 0 additions & 2 deletions Setup.hs

This file was deleted.

15 changes: 15 additions & 0 deletions fourmolu.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
indentation: 2
column-limit: 120
function-arrows: leading
comma-style: leading
import-export-style: leading
indent-wheres: false
record-brace-space: true
newlines-between-decls: 1
haddock-style: single-line
haddock-style-module:
let-style: auto
in-style: left-align
respectful: false
fixities: []
unicode: never
4 changes: 0 additions & 4 deletions hie.yaml

This file was deleted.

42 changes: 42 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
stack_build := "stack build --fast"
src_dirs := "src"

# No default tasks
default:
just --list

# Build and run tests
test:
{{ stack_build }} --test

# Build only
build:
{{ stack_build }} --test --no-run-tests

# Clean stack work
clean:
stack clean --full

# Enter repl
ghci:
stack ghci --test

# Open browser with generated docs
docs:
stack haddock --open

# Install tool deps
deps:
stack build --copy-compiler-tool hlint fourmolu apply-refact

# Format with fourmolu
format:
stack exec -- fourmolu --mode inplace {{ src_dirs }}

# Lint with hlint
lint:
stack exec -- hlint {{ src_dirs }}

# Apply hlint suggestions
lint-apply:
find {{ src_dirs }} -name '*.hs' | xargs -t -I % stack exec -- hlint % --refactor --refactor-options="--inplace"
31 changes: 17 additions & 14 deletions src/LittleRIO.hs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE UndecidableInstances #-}

{- |
Most definitions follow the RIO lib: https://hackage.haskell.org/package/rio-0.1.18.0/docs/RIO.html
The rest follow from orphans: https://hackage.haskell.org/package/rio-orphans-0.1.1.0/docs/src/RIO.Orphans.html
See LICENSE info in the README.
-}
-- |
--Most definitions follow the RIO lib: https://hackage.haskell.org/package/rio-0.1.18.0/docs/RIO.html
--The rest follow from orphans: https://hackage.haskell.org/package/rio-orphans-0.1.1.0/docs/src/RIO.Orphans.html
--See LICENSE info in the README.
module LittleRIO
( HasResourceMap (..)
, HasStateRef (..)
Expand Down Expand Up @@ -35,7 +34,8 @@ module LittleRIO
, unliftRIO
, withResourceMap
, writeSomeRef
) where
)
where

import Control.Applicative (liftA2)
import Control.DeepSeq (NFData (..))
Expand All @@ -54,9 +54,9 @@ import Lens.Micro (Lens', lens)
import Lens.Micro.Mtl (view)
import LittleLogger (LogActionWrapperM (..), MonadLogger)

newtype RIO env a = RIO { unRIO :: ReaderT env IO a }
newtype RIO env a = RIO {unRIO :: ReaderT env IO a}
deriving newtype (Functor, Applicative, Monad, MonadReader env, MonadIO, MonadThrow, MonadFail, MonadCatch, MonadMask, MonadUnliftIO)
deriving MonadLogger via LogActionWrapperM env (RIO env)
deriving (MonadLogger) via LogActionWrapperM env (RIO env)

instance Semigroup a => Semigroup (RIO env a) where
(<>) = liftA2 (<>)
Expand Down Expand Up @@ -115,8 +115,9 @@ instance HasStateRef a (SomeRef a) where
data SimpleStateEnv st env = SimpleStateEnv
{ sseRef :: !(SomeRef st)
, sseEnv :: !env
} deriving stock (Functor, Foldable, Traversable, Generic)
deriving anyclass (NFData)
}
deriving stock (Functor, Foldable, Traversable, Generic)
deriving anyclass (NFData)

instance HasStateRef st (SimpleStateEnv st env) where
stateRefL = lens sseRef (\(SimpleStateEnv _ env) st -> SimpleStateEnv st env)
Expand Down Expand Up @@ -156,8 +157,9 @@ instance HasWriteRef a (SomeRef a) where
data SimpleWriteEnv w env = SimpleWriteEnv
{ sweRef :: !(SomeRef w)
, sweEnv :: !env
} deriving stock (Functor, Foldable, Traversable, Generic)
deriving anyclass (NFData)
}
deriving stock (Functor, Foldable, Traversable, Generic)
deriving anyclass (NFData)

instance HasWriteRef w (SimpleWriteEnv w env) where
writeRefL = lens sweRef (\(SimpleWriteEnv _ env) w -> SimpleWriteEnv w env)
Expand Down Expand Up @@ -212,8 +214,9 @@ instance HasResourceMap (IORef ReleaseMap) where
data SimpleResourceEnv env = SimpleResourceEnv
{ sreMap :: !ResourceMap
, sreEnv :: !env
} deriving stock (Functor, Foldable, Traversable, Generic)
deriving anyclass (NFData)
}
deriving stock (Functor, Foldable, Traversable, Generic)
deriving anyclass (NFData)

instance HasResourceMap (SimpleResourceEnv env) where
resourceMapL = lens sreMap (\(SimpleResourceEnv _ env) m -> SimpleResourceEnv m env)
Expand Down
2 changes: 1 addition & 1 deletion stack.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
resolver: lts-19.17
resolver: lts-20.20

ghc-options:
"$everything": -haddock
Expand Down
10 changes: 5 additions & 5 deletions stack.yaml.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ packages:
- completed:
hackage: little-logger-1.0.1@sha256:3c2bc7a993a74d0ee4afb86ddbe6b246443392384bbd99ee3a7a030cc6d60060,2219
pantry-tree:
size: 318
sha256: 825572cf5c1660f00b2ac1ad35b59534c9d44945d0929dc417c4ee57074db052
size: 318
original:
hackage: little-logger-1.0.1
snapshots:
- completed:
size: 619161
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/19/17.yaml
sha256: 7f47507fd037228a8d23cf830f5844e1f006221acebdd7cb49f2f5fb561e0546
original: lts-19.17
sha256: 126fa33ceb11f5e85ceb4e86d434756bd9a8439e2e5776d306a15fbc63b01e89
size: 650041
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/20/20.yaml
original: lts-20.20

0 comments on commit 3f30f85

Please sign in to comment.