# Division by Zero

**URL:** <https://discourse.elm-lang.org/t/division-by-zero/5037>\
**Category:** Request Feedback\
**Created:** [January 21, 2020, 8:29pm UTC](https://discourse.elm-lang.org/t/division-by-zero/5037 "2020-01-21T20:29:23Z")\
**Posts on this page:** 1\
**Showing post:** 20

<div class="post-metadata">

**Author:** ![MartinS](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/martins/32/3137_2.png) [@MartinS](https://discourse.elm-lang.org/u/MartinS)\
**Post date:** [January 26, 2020, 8:10am UTC](https://discourse.elm-lang.org/t/division-by-zero/5037/20 "2020-01-26T08:10:34Z")

</div>

@Lucas_Payr proposed adding refinement types a while back [Elm-Refine: Proposal](https://discourse.elm-lang.org/t/elm-refine-proposal/3857). I’m guessing nothing came of it but the idea would be that, for example, modBy’s type signature would be changed from  
`modBy: Int -> Int -> Int` to `modBy: IntWithoutZero -> Int -> Int` and IntWithoutZero would be defined with a special syntax (there’s more discussion in the thread about what that could look like)

```elm
{-| @refine \int -> int /= 0
-}
type alias IntWithoutZero =
    Int

```

The compiler would then verify that this condition holds everywhere modBy is called. I guess in cases where it can’t be proven, the user would need to write `if value == 0 then ... else modBy value n` or something.

---

_[View the full topic](https://discourse.elm-lang.org/t/division-by-zero/5037)._
