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 a new-style haskell bundle (supports .hs and .cabal files) #584

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
59 changes: 0 additions & 59 deletions bundles/basic_modes/lexers/haskell.lua

This file was deleted.

5 changes: 0 additions & 5 deletions bundles/basic_modes/mode_definitions.moon
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,6 @@ common_auto_pairs = {
auto_pairs: common_auto_pairs
parent: 'curly_mode'

haskell:
extensions: 'hs'
comment_syntax: '--'
auto_pairs: common_auto_pairs

ini:
extensions: { 'cfg', 'cnf', 'inf', 'ini', 'reg' }
comment_syntax: ';'
Expand Down
32 changes: 32 additions & 0 deletions bundles/haskell/cabal/cabal_lexer.moon
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
-- Copyright 2012-2020 The Howl Developers
-- License: MIT (see LICENSE.md at the top-level directory of the distribution)

howl.util.lpeg_lexer ->
c = capture

keyword = c 'keyword', word { 'if', 'else' }

comment = c 'comment', span('--', eol)
operator = c 'operator', S'/.%^#,(){}[]+-=><&|!'
dq_string = c 'string', span('"', '"', P'\\')
sq_string = c 'string', span("'", "'", '\\')
string = any(dq_string, sq_string)
number = c 'number', digit^1 * alpha^-1

delimiter = any { space, S'/.,(){}[]^#' }
name = complement(delimiter)^1
identifier = c 'identifier', name

section = c 'keyword', line_start * name
label = c 'type', (alpha + '-')^1 * (P':' * space^1)

any {
comment,
label,
section,
keyword,
operator
number,
string,
identifier,
}
16 changes: 16 additions & 0 deletions bundles/haskell/cabal/cabal_mode.moon
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
-- Copyright 2012-2020 The Howl Developers
-- License: MIT (see LICENSE.md at the top-level directory of the distribution)

{
lexer: bundle_load('cabal/cabal_lexer')

comment_syntax: '--'

auto_pairs: {
'(': ')'
'[': ']'
'{': '}'
'"': '"'
"'": "'"
}
}
48 changes: 48 additions & 0 deletions bundles/haskell/haskell/haskell_lexer.moon
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
-- Copyright 2012-2020 The Howl Developers
-- License: MIT (see LICENSE.md at the top-level directory of the distribution)

howl.util.lpeg_lexer ->
c = capture

keyword = c 'keyword', word {
'case', 'class', 'data', 'default', 'deriving', 'do', 'else', 'forall', 'if', 'import',
'infixl', 'infixr', 'infix', 'instance', 'in', 'let', 'module', 'newtype',
'of', 'then', 'type', 'where', '_', 'as', 'qualified', 'hiding'
}

constructor = c 'type', upper^1 * (alpha + digit + S"_'#")^0

comment = c 'comment', any {
span('--', eol),
span('{-', '-}')
}

string = c 'string', span('"', '"', P'\\')

normal_char = P"'" * P(1) * P"'"
escaped_char = P"'" * (P"\\" * (alpha + digit + P"\\")^1) * P"'"
char = c 'string', any { normal_char, escaped_char }

operator = c 'operator', S('+-*/%=<>~&^|!(){}[]#@;:,.$?\\')

hexadecimal = P'0' * S'xX' * xdigit^1
octal = P'0' * S'oO'^-1 * R'07'^1
binary = P'0' * S'bB' * R'01'^1
float = digit^1 * '.' * digit^1
integer = digit^1
number = c 'number', any { hexadecimal, octal, binary, float, integer }

delimiter = any { space, S'/.,(){}[]^#@' }
identifier = c 'identifier', complement(delimiter)^1

any {
comment,
keyword,
constructor,
operator
number,
string,
char,
identifier,
}

16 changes: 16 additions & 0 deletions bundles/haskell/haskell/haskell_mode.moon
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
-- Copyright 2012-2020 The Howl Developers
-- License: MIT (see LICENSE.md at the top-level directory of the distribution)

{
lexer: bundle_load('haskell/haskell_lexer')

comment_syntax: '--'

auto_pairs: {
'(': ')'
'[': ']'
'{': '}'
'"': '"'
"'": "'"
}
}
25 changes: 25 additions & 0 deletions bundles/haskell/init.moon
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
-- Copyright 2012-2020 The Howl Developers
-- License: MIT (see LICENSE.md at the top-level directory of the distribution)

howl.mode.register
name: 'haskell'
extensions: 'hs'
create: -> bundle_load('haskell/haskell_mode')

howl.mode.register
name: 'cabal'
extensions: 'cabal'
patterns: { 'cabal.config$', 'cabal.project$', 'cabal.project.local$', 'cabal.project.freeze$' }
create: -> bundle_load('cabal/cabal_mode')

unload = ->
howl.mode.unregister 'haskell'
howl.mode.unregister 'cabal'

return {
info:
author: 'Copyright 2020 The Howl Developers',
description: 'Haskell bundle',
license: 'MIT',
:unload
}
101 changes: 101 additions & 0 deletions bundles/haskell/misc/example.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
name: example
version: 1.0.0.0
license: MIT license
license-file: LICENSE.md
category: Text, Web
copyright: (c) 2012-2020 Howl developers
author: John Author <[email protected]>
maintainer: John Author <[email protected]>
stability: experimental
tested-with: GHC == 8.4.4, GHC == 8.6.5, GHC == 8.8.3, GHC == 8.10.1
synopsis: Some synopsis
cabal-version: >= 1.10
homepage: https://github.com/author/example
bug-reports: https://github.com/author/example/issues
build-type: Simple
description:
A text parsing and encoding library optimized for ease of use
and high performance.

extra-source-files:
README.markdown
changelog.md

-- Enable the 'fast' flag to speed up compilation
flag fast
description: compile without optimizations
default: False
manual: True

library
default-language: Haskell2010
hs-source-dirs: . another-source-dir/

exposed-modules:
Data.Example
Data.Example.Encoding
Data.Example.Parser
Data.Example.Text
Data.Example.Types

other-modules:
Data.Example.Encoding.Builder
Data.Example.Internal.Functions
Data.Example.Parser.Unescape
Data.Example.Parser.Time

build-depends:
base >= 4.7.0.0 && < 5,
bytestring >= 0.10.4.0 && < 0.11,
containers == 0.5.5.1

if impl(ghc >= 8.0)
build-depends: bytestring >= 0.10.8.1

if !impl(ghc >= 8.6)
build-depends:
contravariant >=1.4.1 && <1.6

ghc-options: -Wall

if flag(fast)
ghc-options: -O0
else
ghc-options: -O2

test-suite example-tests
default-language: Haskell2010
type: exitcode-stdio-1.0
hs-source-dirs: tests pure
main-is: Tests.hs
ghc-options: -Wall -threaded -rtsopts

other-modules:
Encoders
ErrorMessages
Instances
Options
Types
UnitTests
UnitTests.NullaryConstructors

build-depends:
QuickCheck >= 2.10.0.1 && < 2.15,
example,
integer-logarithms >= 1 && <1.1,
base,
base-compat,
base-orphans >= 0.5.3 && <0.9,
base16-bytestring,
containers,
data-fix,
directory,
dlist,
Diff >= 0.4 && < 0.5,
filepath,
generic-deriving >= 1.10 && < 1.14,
ghc-prim >= 0.2

source-repository head
type: git
location: git://github.com/author/example.git
Loading