Skip to content

Instantly share code, notes, and snippets.

@jfmengels
Last active December 10, 2020 21:16
Show Gist options
  • Save jfmengels/966c086eb79244ca55cf362fc2dd60cf to your computer and use it in GitHub Desktop.
Save jfmengels/966c086eb79244ca55cf362fc2dd60cf to your computer and use it in GitHub Desktop.
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