Skip to content

Annotationless exact-printer #9385

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

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
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
137 changes: 137 additions & 0 deletions Cabal-layout/Cabal-layout.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
cabal-version: 2.2
name: Cabal-layout
version: 3.11.0.0
copyright: 2003-2023, Cabal Development Team (see AUTHORS file)
license: BSD-3-Clause
license-file: LICENSE
author: Cabal Development Team <[email protected]>
maintainer: [email protected]
homepage: http://www.haskell.org/cabal/
bug-reports: https://github.com/haskell/cabal/issues
synopsis: Cabal format manipulation
description:
Cabal format manipulation.

category: Distribution
build-type: Simple

extra-source-files:
README.md ChangeLog.md


source-repository head
type: git
location: https://github.com/haskell/cabal/
subdir: Cabal-layout


library
default-language: Haskell2010

hs-source-dirs: src

build-depends:
base >= 4.9 && < 5
, bytestring
, parsec
, text

ghc-options: -Wall -fno-ignore-asserts -fwarn-tabs -fwarn-incomplete-uni-patterns -fwarn-incomplete-record-updates

if impl(ghc >= 8.0)
ghc-options: -Wcompat -Wnoncanonical-monad-instances

if impl(ghc >= 8.0) && impl(ghc < 8.8)
ghc-options: -Wnoncanonical-monadfail-instances

exposed-modules:
Codec.Manifest.Cabal.Layout

exposed-modules:
Codec.Manifest.Cabal.Internal.Layout
Codec.Manifest.Cabal.Internal.Parse
Codec.Manifest.Cabal.Internal.Render



test-suite sanity
type: exitcode-stdio-1.0

main-is: Main.hs

default-language: Haskell2010

hs-source-dirs: src
, test/sanity

build-depends:
base >= 4.9 && < 5
, bytestring
, parsec
, tasty
, tasty-hunit
, text

ghc-options: -Wall -fno-ignore-asserts -fwarn-tabs -fwarn-incomplete-uni-patterns -fwarn-incomplete-record-updates

if impl(ghc >= 8.0)
ghc-options: -Wcompat -Wnoncanonical-monad-instances

if impl(ghc >= 8.0) && impl(ghc < 8.8)
ghc-options: -Wnoncanonical-monadfail-instances



test-suite hackage
type: exitcode-stdio-1.0

main-is: Main.hs

default-language: Haskell2010

hs-source-dirs: src
, test/hackage
, test/strictness

build-depends:
base >= 4.9 && < 5
, bytestring
, directory
, filepath
, nothunks
, parsec
, text

ghc-options: -Wall -fno-ignore-asserts -fwarn-tabs -fwarn-incomplete-uni-patterns -fwarn-incomplete-record-updates

if impl(ghc >= 8.0)
ghc-options: -Wcompat -Wnoncanonical-monad-instances

if impl(ghc >= 8.0) && impl(ghc < 8.8)
ghc-options: -Wnoncanonical-monadfail-instances



test-suite patches
type: exitcode-stdio-1.0

main-is: Main.hs

default-language: Haskell2010

hs-source-dirs: src
, test/patches

build-depends:
base >= 4.9 && < 5
, bytestring
, parsec
, process

ghc-options: -Wall -fno-ignore-asserts -fwarn-tabs -fwarn-incomplete-uni-patterns -fwarn-incomplete-record-updates

if impl(ghc >= 8.0)
ghc-options: -Wcompat -Wnoncanonical-monad-instances

if impl(ghc >= 8.0) && impl(ghc < 8.8)
ghc-options: -Wnoncanonical-monadfail-instances
120 changes: 120 additions & 0 deletions Cabal-layout/src/Codec/Manifest/Cabal/Internal/Layout.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
{-# LANGUAGE DerivingStrategies
, GeneralizedNewtypeDeriving
, QuantifiedConstraints
, StandaloneDeriving
, UndecidableInstances #-}

module Codec.Manifest.Cabal.Internal.Layout where

import Data.Text (Text)



-- | Context-dependent whitespace.
newtype Offset = Offset Int
deriving newtype Show

-- | Context-independent whitespace.
newtype Whitespace = Whitespace Int
deriving newtype Show

-- | Anything that follows two consecutive hyphens. Lasts until the end of the line.
data Comment = Comment
Whitespace -- ^ Before double hyphens
Whitespace -- ^ Between double hyphens and text
Text
Whitespace -- ^ Between end of comment and end of line
deriving Show



-- | Any Unicode characters, excluding '\x00'..'\x1F'
-- ('\r' and '\t' are allowed), '\DEL', '{', '}', ':'.
newtype Heading = Heading Text
deriving newtype Show

-- | Any Unicode characters, excluding '\x00'..'\x1F', '\DEL', '{', '}', ':' and spaces.
newtype Name = Name Text
deriving newtype Show




-- | Field contents at the declaration line.
data Inline = Inline
Whitespace -- ^ Between colon and start of text
Text
Whitespace -- ^ Between end of text and end of line

| EmptyI Whitespace

deriving Show

-- | Field contents at the lines following the declaration.
data Line = Line
Offset
Text
Whitespace -- ^ Between end of text and end of line

| CommentL Comment

| EmptyL Whitespace

deriving Show



-- | Non-meaningful information.
data Filler = CommentF Comment
| EmptyF Whitespace
deriving Show



-- | Section contents with the curly bracket alternative.
data Section = CurlS
[Filler] -- ^ Between heading and left curly
[Node]

| NormalS
Filler -- ^ Inline comment
[Node]
deriving Show



-- | Field contents.
data Contents = Contents Inline [Line]
deriving Show

-- | Field contents with the curly bracket alternative.
data Field = CurlF
[Filler] -- ^ Between colon and left curly
Contents

| NormalF Contents
deriving Show



data Node = Section
Offset
Heading
Section

| Field
Offset
Name
Whitespace -- ^ Between field name and colon
Field

| CommentN Comment

| EmptyN Whitespace

deriving Show



newtype Layout = Layout [Node]
deriving newtype Show
Loading