module Main where
import Prelude
import Effect.Console (log)
type KeywordRow =
-- ( ado :: String -- parser error
( "ado" :: String -- ok
, as :: String
-- , case :: String -- parser error
, "case" :: String -- ok
, class :: String
, data :: String
, derive :: String
-- , do :: String -- parser error
, "do" :: String -- ok
, else :: String
, false :: String
-- , forall :: String -- parser error
-- , "forall" :: String -- ok
, foreign :: String
, hiding :: String
, import :: String
-- , if :: String -- parser error
, "if" :: String -- ok
, in :: String
, infix :: String
, infixl :: String
, infixr :: String
, instance :: String
-- , let :: String
, "let" :: String
, module :: String
, newtype :: String
, nominal :: String
, of :: String
, phantom :: String
, representational :: String
, role :: String
, then :: String
, true :: String
, type :: String
-- , where :: String -- parser error
, "where" :: String -- ok
)
type KeywordRecord =
-- { ado :: String -- I assume cannot use
{ "ado" :: String -- ok
, as :: String
-- , case :: String -- I assume we cannot use
, "case" :: String -- ok
, class :: String
, data :: String
, derive :: String
-- , do :: String -- I assume we cannot use
, "do" :: String -- ok
, else :: String
, false :: String
-- , forall :: String -- I assume we cannot use
-- , "forall" :: String -- ok
, foreign :: String
, hiding :: String
, import :: String
-- , if :: String -- I assume we cannot use
, "if" :: String -- ok
, in :: String
, infix :: String
, infixl :: String
, infixr :: String
, instance :: String
-- , let :: String
, "let" :: String
, module :: String
, newtype :: String
, nominal :: String
, of :: String
, phantom :: String
, representational :: String
, role :: String
, then :: String
, true :: String
, type :: String
-- , where :: String -- I assume we cannot use
, "where" :: String -- ok
}
keywordUsage :: KeywordRecord -> KeywordRecord
keywordUsage
-- { ado
r@
{ as
, class
, data
, derive
, forall
, foreign
, hiding
, import
, infix
, infixl
, infixr
, instance
, module
, newtype
, nominal
, phantom
, representational
, role
, type
} =
{ "ado": r.ado
, as: as
, case: r.case
, class: class
, data: data
, derive: derive
, "do": r.do
, else: r.else
, false: r.false
, forall: r.forall
, foreign: r.foreign
, hiding: r.hiding
, import: r.import
, if: r.if
, in: r.in
, infix: r.infix
, infixl: infixl
, infixr: infixr
, instance: instance
, let: r.let
, module: module
, newtype: newtype
, nominal: nominal
, of: r.of
, phantom: phantom
, representational: representational
, role: role
, then: r.then
, true: r.true
, type: type
, where: r.where
}
keywordUpdate :: KeywordRecord -> KeywordRecord
keywordUpdate r = r
{ ado: r.ado <> "foo"
, as: r.as <> "foo"
, case: r.case <> "foo"
, class: r.class <> "foo"
, data: r.data <> "foo"
, derive: r.derive <> "foo"
, do: r.do <> "foo"
, else: r.else <> "foo"
, false: r.false <> "foo"
, forall: r.forall <> "foo"
, foreign: r.foreign <> "foo"
, hiding: r.hiding <> "foo"
, import: r.import <> "foo"
, if: r.if <> "foo"
, in: r.in <> "foo"
, infix: r.infix <> "foo"
, infixl: r.infixl <> "foo"
, infixr: r.infixr <> "foo"
, instance: r.instance <> "foo"
, let: r.let <> "foo"
, module: r.module <> "foo"
, newtype: r.newtype <> "foo"
, nominal: r.nominal <> "foo"
, of: r.of <> "foo"
, phantom: r.phantom <> "foo"
, representational: r.representational <> "foo"
, role: r.role <> "foo"
, then: r.then <> "foo"
, true: r.true <> "foo"
, type: r.type <> "foo"
, where: r.where <> "foo"
}
main = log "Done"
Description
Keywords like
typeandclassaren't useable as record puns. The below code produces a parser error:foo { class, bar } = { class }To Reproduce
Ideally, this file should compile fine rather than failing with a parser error:
The file
PureScript version
0.15.7