Skip to content

Instantly share code, notes, and snippets.

@dminuoso

dminuoso/f.hs Secret

Created October 12, 2020 09:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dminuoso/0da790d5ac72f0cfab1e451a306ca064 to your computer and use it in GitHub Desktop.
Save dminuoso/0da790d5ac72f0cfab1e451a306ca064 to your computer and use it in GitHub Desktop.
fixup :: AttrDef -> AttrDef
fixup attr@(AttrDef nam num ty opts)
| let nam = attr ^. attrNam
-- Only do this if the type is actually integer.
, TyExtra TyInteger _into _imp <- attr ^. attrTy
-- Check if the dictionary has values for this
-- attribute name.
, isJust (M.lookup nam enums)
-- Overwrite the name and set imported from to nothing
-- because the ADT will reside in the same module.
= attr & (attrTy % tyMappedInto) .~ nam
& (attrTy % tyImportedFrom) .~ []
| otherwise
= attr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment