Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add effectful-th package #56

Closed
wants to merge 11 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .github/workflows/haskell-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ jobs:
touch cabal.project
echo "packages: $GITHUB_WORKSPACE/source/effectful" >> cabal.project
echo "packages: $GITHUB_WORKSPACE/source/effectful-core" >> cabal.project
echo "packages: $GITHUB_WORKSPACE/source/effectful-th" >> cabal.project
cat cabal.project
- name: sdist
run: |
Expand All @@ -186,20 +187,25 @@ jobs:
echo "PKGDIR_effectful=${PKGDIR_effectful}" >> "$GITHUB_ENV"
PKGDIR_effectful_core="$(find "$GITHUB_WORKSPACE/unpacked" -maxdepth 1 -type d -regex '.*/effectful-core-[0-9.]*')"
echo "PKGDIR_effectful_core=${PKGDIR_effectful_core}" >> "$GITHUB_ENV"
PKGDIR_effectful_th="$(find "$GITHUB_WORKSPACE/unpacked" -maxdepth 1 -type d -regex '.*/effectful-th-[0-9.]*')"
echo "PKGDIR_effectful_th=${PKGDIR_effectful_th}" >> "$GITHUB_ENV"
rm -f cabal.project cabal.project.local
touch cabal.project
touch cabal.project.local
echo "packages: ${PKGDIR_effectful}" >> cabal.project
echo "packages: ${PKGDIR_effectful_core}" >> cabal.project
echo "packages: ${PKGDIR_effectful_th}" >> cabal.project
echo "package effectful" >> cabal.project
echo " ghc-options: -Werror=missing-methods" >> cabal.project
echo "package effectful-core" >> cabal.project
echo " ghc-options: -Werror=missing-methods" >> cabal.project
echo "package effectful-th" >> cabal.project
echo " ghc-options: -Werror=missing-methods" >> cabal.project
cat >> cabal.project <<EOF
package effectful
flags: +benchmark-foreign-libraries
EOF
$HCPKG list --simple-output --names-only | perl -ne 'for (split /\s+/) { print "constraints: $_ installed\n" unless /^(effectful|effectful-core)$/; }' >> cabal.project.local
$HCPKG list --simple-output --names-only | perl -ne 'for (split /\s+/) { print "constraints: $_ installed\n" unless /^(effectful|effectful-core|effectful-th)$/; }' >> cabal.project.local
cat cabal.project
cat cabal.project.local
- name: dump install plan
Expand Down Expand Up @@ -239,6 +245,8 @@ jobs:
${CABAL} -vnormal check
cd ${PKGDIR_effectful_core} || false
${CABAL} -vnormal check
cd ${PKGDIR_effectful_th} || false
${CABAL} -vnormal check
- name: haddock
run: |
$CABAL v2-haddock $ARG_COMPILER --with-haddock $HADDOCK $ARG_TESTS $ARG_BENCH all
Expand Down
1 change: 1 addition & 0 deletions cabal.project
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
packages:
effectful/effectful.cabal
effectful-core/effectful-core.cabal
effectful-th/effectful-th.cabal
2 changes: 2 additions & 0 deletions effectful-th/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# effectful-th-0.0.0.0 (2022-02-03)
* Initial alpha release.
30 changes: 30 additions & 0 deletions effectful-th/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Copyright (c) 2021-2022, Andrzej Rybczak

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 Andrzej Rybczak 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.
87 changes: 87 additions & 0 deletions effectful-th/effectful-th.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
cabal-version: 2.4
build-type: Simple
name: effectful-th
version: 0.1
license: BSD-3-Clause
license-file: LICENSE
category: Control
maintainer: [email protected]
author: Andrzej Rybczak
synopsis: Template Haskell utilities for the effectful library.

description: This package provides several Template Haskell helper functions to
aid the development of effects for the
@<https://hackage.haskell.org/package/effectful effectful>@
library.

extra-source-files: CHANGELOG.md

tested-with: GHC ==8.8.4 || ==8.10.7 || ==9.0.2 || ==9.2.1

bug-reports: https://github.com/arybczak/effectful/issues
source-repository head
type: git
location: https://github.com/arybczak/effectful.git

common language
ghc-options: -Wall -Wcompat

default-language: Haskell2010

default-extensions: BangPatterns
ConstraintKinds
DataKinds
DeriveFunctor
DeriveGeneric
FlexibleContexts
FlexibleInstances
GADTs
GeneralizedNewtypeDeriving
LambdaCase
MultiParamTypeClasses
NoStarIsType
RankNTypes
RecordWildCards
RoleAnnotations
ScopedTypeVariables
StandaloneDeriving
TupleSections
TypeApplications
TypeFamilies
TypeOperators

library
import: language

build-depends: base >= 4.13 && < 5
, containers
, effectful-core
, template-haskell >= 2.15 && < 2.19
, th-abstraction

hs-source-dirs: src

exposed-modules: Effectful.TH

test-suite effectful-th-test
import: language

ghc-options: -threaded -rtsopts -with-rtsopts=-N4

build-depends: base
, effectful-core
, effectful-th

hs-source-dirs: tests examples

type: exitcode-stdio-1.0
main-is: Main.hs

other-modules: Error
Fail
Reader
State
Writer
-- These are examples; We do not actually run them but list
-- them here in order to check if they compile.
MyReader
21 changes: 21 additions & 0 deletions effectful-th/examples/MyReader.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
-- These extensions are needed for the definition of the effect.
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE TypeFamilies #-}
-- These extensions are needed for the generation of the functions.
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeApplications #-}
module MyReader where

import Effectful (Dispatch(Dynamic), DispatchOf)
import Effectful.TH

data Reader r :: Effect where
Ask :: Reader r m r
Local :: (r -> r) -> m a -> Reader r m a

type instance DispatchOf (Reader r) = 'Dynamic

makeEffect ''Reader
Loading