Skip to content

Instantly share code, notes, and snippets.

@ahalbert
Created December 12, 2015 16:48
Show Gist options
  • Select an option

  • Save ahalbert/e52965052c3b35187b9e to your computer and use it in GitHub Desktop.

Select an option

Save ahalbert/e52965052c3b35187b9e to your computer and use it in GitHub Desktop.
showUnitString :: Unit -> String
showUnitString Unit m u
| (null posUnits) && (null negUnits) = ms
| null posUnits = ms ++ " 1/" ++ (showall negUnits)
| null negUnits = ms ++ (showall posUnits)
| otherwise = ms ++ (showall negUnits) ++ "/" ++ (showall negUnits)
where negUnits = Map.map (abs) (Map.filter (\ x -> x < 0.0) u)
posUnits = Map.filter (\ x -> x > 0.0) u
ms = show m
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment