Jeroen Engels (Yeuroune)
foobar : String
-> List (Html Msg)
-> Html Msg
foobar title children =
li []
[ pre [] [ text title ]
, ul [] children
]
(a + b) / 2
Integer 2
BinaryExpression
operator +
Variable a
Variable b
BinaryExpression
operator /
{
"type": "Program",
"body": [
{
"type": "ExpressionStatement",
"expression": {
"type": "BinaryExpression",
"left": {
"type": "BinaryExpression",
"left": {
"type": "Identifier",
"name": "a"
},
"operator": "+",
"right": {
"type": "Identifier",
"name": "b"
}
},
"operator": "/",
"right": {
"type": "Literal",
"value": 2,
"raw": "2"
}
}
}
]
}
Integer 2
BinaryExpression
operator +
Variable a
Variable b
BinaryExpression
operator /
expressionFn : Context
-> Direction Expression
-> ( List Error, Context )
expressionFn ctx node =
case node of
Enter (SomeNodeType) ->
if condition then
( [ createError "message" ], ctx )
else
( [], { ctx | data = ctx.data ++ foobar } )
_ ->
( [], ctx )
module SomeRule exposing (rule)
import Lint exposing (lint, doNothing)
import Types exposing (LintRule, Error, Direction(..))
type alias Context =
{ data: List String
}
rule : String -> List Error
rule input =
lint input implementation
implementation : LintRule Context
implementation =
{ statementFn = doNothing
, typeFn = doNothing
, expressionFn = expressionFn
, moduleEndFn = (\ctx -> ( [], ctx ))
, initialContext = Context []
}
-- Could not write this
type Node
= Statement
| Expression
| Type
fn : Context
-> Direction Node
-> ( List Error, Context )
fn ctx node =
( [], ctx )
foo data =
case Debug.log "data" data of
_ -> []
main : Test.Runner.Node.TestProgram
main =
run emit all
port emit : ( String, Value ) -> Cmd msg
all : Test
all =
describe "String.reverse"
[ test "has no effect on a palindrome" testGoesHere
, test "reverses a known string" anotherTest
, fuzz string "restores the original string if you run it again" oneMore
]
|> Test.filter (String.contains "original")