Skip to content

Instantly share code, notes, and snippets.

@jfmengels
Last active Dec 10, 2020
Embed
What would you like to do?
removeRange : Node TypeAnnotation -> Node TypeAnnotation
removeRange (Node _ value) =
Node Range.emptyRange
(case value of
TypeAnnotation.FunctionTypeAnnotation input output ->
TypeAnnotation.FunctionTypeAnnotation (removeRange input) (removeRange output)
TypeAnnotation.Typed (Node _ nameNode) params ->
TypeAnnotation.Typed (Node Range.emptyRange nameNode) (List.map removeRange params)
TypeAnnotation.GenericType string ->
TypeAnnotation.GenericType string
TypeAnnotation.Unit ->
TypeAnnotation.Unit
TypeAnnotation.Tupled nodes ->
TypeAnnotation.Tupled (List.map removeRange nodes)
TypeAnnotation.Record recordDefinition ->
TypeAnnotation.Record (removeRangeOfRecordDefinition recordDefinition)
TypeAnnotation.GenericRecord (Node _ var) (Node _ recordDefinition) ->
TypeAnnotation.GenericRecord
(Node Range.emptyRange var)
(Node Range.emptyRange (removeRangeOfRecordDefinition recordDefinition))
)
removeRangeOfRecordDefinition : List (Node ( Node a, Node b )) -> List (Node ( Node a, Node b ))
removeRangeOfRecordDefinition recordDefinition =
List.map
(Node.value
>> (\( Node _ field, Node _ type_ ) ->
Node Range.emptyRange ( Node Range.emptyRange field, Node Range.emptyRange type_ )
)
)
recordDefinition
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment