packages feed

parentheses-less-0.0.1: parentheses-less.cabal

cabal-version: 3.0
name:          parentheses-less
version:       0.0.1

synopsis:      left associative dollar operator
description:
    Built-in
    <https://hackage-content.haskell.org/package/base-4.22.0.0/docs/Prelude.html#v:-36- $>
    (dollar operator) in Haskell has the lowest priotity possible - 0 and
    this requires using parentheses in situations like follows, because even
    a custom comparison operator cannot go lower than 0.
    
    > tests =
    >   [ pure (3 + 2) == Just 5
    >   , runReader (pure 3) 0 == 3
    >   , runReader ask (1 + 2) == 3
    >   , runReader ((+4) <$> ask) 1 + 2 == 7
    >   , s3 (8 `div` 3) (2 * 2) (2 + 2) == 10
    >   , s4 (11 `mod` 3) (8 `div` 3) (2 * 2) (2 + 2) == 12
    >   ]
    
    Flipping associativity of the operator from right to left helps with
    reducing parentheses:
    
    > import ParenthesesLess
    >
    > go = (==)
    > infixl 0 go
    >
    > tests =
    >   [ s3 % 8 `div` 3 % 2 * 2 % 2 + 2 `go` 10
    >   , s3 % 8 `div` 3 + 1 % 2 * 2 % 2 + 2 `go` 11
    >   , s4 % 11 `mod` 3 % 8 `div` 3 % 2 * 2 % 2 + 2 `go` 12 
    >   ]
    
    === Unicode comma-like operator
    #unicode-comma-like-operator#
    
    Percent is easy to type, but it mixes with arithmetic expressions it is
    coined to separate. A Unicode comma-like symbol, such as cedilla, offers
    better visual perception.
    
    > import ParenthesesLess
    >
    > go = (==)
    > infixl 1 go
    >
    > tests =
    >   [ s3 ¸ 8 `div` 3 ¸ 2 * 2 ¸ 2 + 2 `go` 10
    >   , s3 ¸ 8 `div` 3 + 1 ¸ 2 * 2 ¸ 2 + 2 `go` 11
    >   , s4 ¸ 11 `mod` 3 ¸ 8 `div` 3 ¸ 2 * 2 ¸ 2 + 2 `go` 12
    >   
    >   , runExcept ¸ when ¸¸ 3 < 4 ¸¸ throwE () `go` Left ()
    >   , runExcept ¸ when ¸¸ 3 > 4 ¸¸ throwE () `go` Right ()
    >   , runWriter ¸ tell [True] >> tell [False] `go` ((), [True, False])
    >   , runReader ¸ runWriterT ¸¸ tell [True] >>> lift ask ¸ 3 `go` (3, [True])
    >   
    >   ]
    
    == Development environment
    #development-environment#
    
    HLS should be available inside the default dev shell.
    
    > $ nix develop
    > $ cabal build
    > $ cabal test
homepage:      http://github.com/yaitskov/parentheses-less
license:       BSD-3-Clause
license-file:  LICENSE
author:        Daniil Iaitskov
maintainer:    dyaitskov@gmail.com
copyright:     Daniil Iaitkov 2026
category:      System
build-type:    Simple
bug-reports:   https://github.com/yaitskov/parentheses-less/issues
extra-doc-files:
  changelog.md
tested-with:
  GHC == 9.14.1

source-repository head
  type:
    git
  location:
    https://github.com/yaitskov/parentheses-less.git

common base
  default-language: GHC2024
  ghc-options: -Wall
  default-extensions:
    DefaultSignatures
    NoImplicitPrelude
    OverloadedStrings
  build-depends:
    , base >=4.7 && < 5

library
  import: base
  hs-source-dirs: src
  exposed-modules:
    ParenthesesLess
  build-depends:

test-suite test
  import: base
  type: exitcode-stdio-1.0
  main-is: Driver.hs
  hs-source-dirs:
    test
  ghc-options: -Wall -Wno-missing-signatures -rtsopts -threaded -main-is Driver
  build-depends:
    , parentheses-less
    , transformers
    , mtl