Skip to content

Commit

Permalink
Add Dhall language support. (#4539)
Browse files Browse the repository at this point in the history
Fixes dhall-lang/dhall-lang#198.

There’s not yet a Dhall grammar in a supported format, so it uses Haskell for now.
  • Loading branch information
sellout authored and lildude committed May 31, 2019
1 parent 071e04a commit 7e1a5e8
Show file tree
Hide file tree
Showing 4 changed files with 317 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/linguist/languages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1080,6 +1080,16 @@ DataWeave:
ace_mode: text
tm_scope: source.data-weave
language_id: 974514097
Dhall:
type: programming
color: "#dfafff"
extensions:
- ".dhall"
tm_scope: source.haskell
ace_mode: haskell
codemirror_mode: haskell
codemirror_mime_type: text/x-haskell
language_id: 793969321
Diff:
type: data
extensions:
Expand Down
254 changes: 254 additions & 0 deletions samples/Dhall/largeExpressionA.dhall
Original file line number Diff line number Diff line change
@@ -0,0 +1,254 @@
λ ( xs
: List
{ cores : Natural
, host : Text
, key : Text
, mandatoryFeatures : List Text
, platforms :
List
< AArch64_Linux : {}
| ARMv5tel_Linux : {}
| ARMv7l_Linux : {}
| I686_Cygwin : {}
| I686_Linux : {}
| MIPS64el_Linux : {}
| PowerPC_Linux : {}
| X86_64_Cygwin : {}
| X86_64_Darwin : {}
| X86_64_FreeBSD : {}
| X86_64_Linux : {}
| X86_64_Solaris : {}
>
, speedFactor : Natural
, supportedFeatures : List Text
, user : Optional Text
}
)
List/fold
{ cores : Natural
, host : Text
, key : Text
, mandatoryFeatures : List Text
, platforms :
List
< AArch64_Linux : {}
| ARMv5tel_Linux : {}
| ARMv7l_Linux : {}
| I686_Cygwin : {}
| I686_Linux : {}
| MIPS64el_Linux : {}
| PowerPC_Linux : {}
| X86_64_Cygwin : {}
| X86_64_Darwin : {}
| X86_64_FreeBSD : {}
| X86_64_Linux : {}
| X86_64_Solaris : {}
>
, speedFactor : Natural
, supportedFeatures : List Text
, user : Optional Text
}
xs
Text
( λ ( x
: { cores : Natural
, host : Text
, key : Text
, mandatoryFeatures : List Text
, platforms :
List
< AArch64_Linux : {}
| ARMv5tel_Linux : {}
| ARMv7l_Linux : {}
| I686_Cygwin : {}
| I686_Linux : {}
| MIPS64el_Linux : {}
| PowerPC_Linux : {}
| X86_64_Cygwin : {}
| X86_64_Darwin : {}
| X86_64_FreeBSD : {}
| X86_64_Linux : {}
| X86_64_Solaris : {}
>
, speedFactor : Natural
, supportedFeatures : List Text
, user : Optional Text
}
)
λ(y : Text)
( Optional/fold
Text
x.user
Text
(λ(user : Text) user ++ "@" ++ x.host ++ "")
x.host
++ " "
++ ( merge
{ Empty = λ(_ : {}) ""
, NonEmpty = λ(result : Text) result
}
( List/fold
< AArch64_Linux : {}
| ARMv5tel_Linux : {}
| ARMv7l_Linux : {}
| I686_Cygwin : {}
| I686_Linux : {}
| MIPS64el_Linux : {}
| PowerPC_Linux : {}
| X86_64_Cygwin : {}
| X86_64_Darwin : {}
| X86_64_FreeBSD : {}
| X86_64_Linux : {}
| X86_64_Solaris : {}
>
x.platforms
< Empty : {} | NonEmpty : Text >
( λ ( element
: < AArch64_Linux : {}
| ARMv5tel_Linux : {}
| ARMv7l_Linux : {}
| I686_Cygwin : {}
| I686_Linux : {}
| MIPS64el_Linux : {}
| PowerPC_Linux : {}
| X86_64_Cygwin : {}
| X86_64_Darwin : {}
| X86_64_FreeBSD : {}
| X86_64_Linux : {}
| X86_64_Solaris : {}
>
)
λ(status : < Empty : {} | NonEmpty : Text >)
merge
{ Empty =
λ(_ : {})
< Empty : {} | NonEmpty : Text >.NonEmpty (
merge
{ AArch64_Linux = λ(_ : {}) "aarch64-linux"
, ARMv5tel_Linux =
λ(_ : {}) "armv5tel-linux"
, ARMv7l_Linux = λ(_ : {}) "armv7l-linux"
, I686_Cygwin = λ(_ : {}) "i686-cygwin"
, I686_Linux = λ(_ : {}) "i686-linux"
, MIPS64el_Linux =
λ(_ : {}) "mips64el-linux"
, PowerPC_Linux = λ(_ : {}) "powerpc-linux"
, X86_64_Cygwin = λ(_ : {}) "x86_64-cygwin"
, X86_64_Darwin = λ(_ : {}) "x86_64-darwin"
, X86_64_FreeBSD =
λ(_ : {}) "x86_64-freebsd"
, X86_64_Linux = λ(_ : {}) "x86_64-linux"
, X86_64_Solaris =
λ(_ : {}) "x86_64-solaris"
}
element
)
, NonEmpty =
λ(result : Text)
< Empty : {} | NonEmpty : Text >.NonEmpty (
( merge
{ AArch64_Linux =
λ(_ : {}) "aarch64-linux"
, ARMv5tel_Linux =
λ(_ : {}) "armv5tel-linux"
, ARMv7l_Linux =
λ(_ : {}) "armv7l-linux"
, I686_Cygwin =
λ(_ : {}) "i686-cygwin"
, I686_Linux =
λ(_ : {}) "i686-linux"
, MIPS64el_Linux =
λ(_ : {}) "mips64el-linux"
, PowerPC_Linux =
λ(_ : {}) "powerpc-linux"
, X86_64_Cygwin =
λ(_ : {}) "x86_64-cygwin"
, X86_64_Darwin =
λ(_ : {}) "x86_64-darwin"
, X86_64_FreeBSD =
λ(_ : {}) "x86_64-freebsd"
, X86_64_Linux =
λ(_ : {}) "x86_64-linux"
, X86_64_Solaris =
λ(_ : {}) "x86_64-solaris"
}
element
)
++ ","
++ result
)
}
status
: < Empty : {} | NonEmpty : Text >
)
(< Empty : {} | NonEmpty : Text >.Empty {=})
)
: Text
)
++ " "
++ x.key
++ " "
++ Integer/show (Natural/toInteger x.cores)
++ " "
++ Integer/show (Natural/toInteger x.speedFactor)
++ " "
++ ( merge
{ Empty = λ(_ : {}) ""
, NonEmpty = λ(result : Text) result
}
( List/fold
Text
x.supportedFeatures
< Empty : {} | NonEmpty : Text >
( λ(element : Text)
λ(status : < Empty : {} | NonEmpty : Text >)
merge
{ Empty =
λ(_ : {})
(< Empty : {} | NonEmpty : Text >.NonEmpty element)
, NonEmpty =
λ(result : Text)
< Empty : {} | NonEmpty : Text >.NonEmpty (
element ++ "," ++ result
)
}
status
: < Empty : {} | NonEmpty : Text >
)
(< Empty : {} | NonEmpty : Text >.Empty {=})
)
: Text
)
++ " "
++ ( merge
{ Empty = λ(_ : {}) ""
, NonEmpty = λ(result : Text) result
}
( List/fold
Text
x.mandatoryFeatures
< Empty : {} | NonEmpty : Text >
( λ(element : Text)
λ(status : < Empty : {} | NonEmpty : Text >)
merge
{ Empty =
λ(_ : {})
< Empty : {} | NonEmpty : Text >.NonEmpty element
, NonEmpty =
λ(result : Text)
< Empty : {} | NonEmpty : Text >.NonEmpty (
element ++ "," ++ result
)
}
status
: < Empty : {} | NonEmpty : Text >
)
(< Empty : {} | NonEmpty : Text >.Empty {=})
)
: Text
)
++ "\n"
)
++ y
)
""
52 changes: 52 additions & 0 deletions samples/Dhall/remoteSystemsA.dhall
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
let Text/concatMap = ../../../Prelude/Text/concatMap

let Text/concatSep = ../../../Prelude/Text/concatSep

let Row =
{ cores :
Natural
, host :
Text
, key :
Text
, mandatoryFeatures :
List Text
, platforms :
List Text
, speedFactor :
Natural
, supportedFeatures :
List Text
, user :
Optional Text
}

let renderRow =
λ ( row
: Row
)
let host =
Optional/fold
Text
row.user
Text
(λ(user : Text) "${user}@${row.host}")
row.host

let platforms = Text/concatSep "," row.platforms

let key = row.key

let cores = Integer/show (Natural/toInteger row.cores)

let speedFactor = Integer/show (Natural/toInteger row.speedFactor)

let supportedFeatures = Text/concatSep "," row.supportedFeatures

let mandatoryFeatures = Text/concatSep "," row.mandatoryFeatures

in ''
${host} ${platforms} ${key} ${cores} ${speedFactor} ${supportedFeatures} ${mandatoryFeatures}
''

in Text/concatMap Row renderRow
1 change: 1 addition & 0 deletions vendor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ This is a list of grammars that Linguist selects to provide syntax highlighting
- **DTrace:** [textmate/c.tmbundle](https://github.com/textmate/c.tmbundle)
- **Dart:** [dart-atom/dartlang](https://github.com/dart-atom/dartlang)
- **DataWeave:** [mulesoft-labs/data-weave-tmLanguage](https://github.com/mulesoft-labs/data-weave-tmLanguage)
- **Dhall:** [atom-haskell/language-haskell](https://github.com/atom-haskell/language-haskell)
- **Diff:** [textmate/diff.tmbundle](https://github.com/textmate/diff.tmbundle)
- **Dockerfile:** [asbjornenge/Docker.tmbundle](https://github.com/asbjornenge/Docker.tmbundle)
- **Dylan:** [textmate/dylan.tmbundle](https://github.com/textmate/dylan.tmbundle)
Expand Down

0 comments on commit 7e1a5e8

Please sign in to comment.