aboutsummaryrefslogtreecommitdiff
path: root/bwrap-files/workdir/initdefs.hs
blob: 7083fe05d073fb5d188cfe91dabf22e9076b6144 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
:{
data Nat = Z | S Nat deriving (Show, Eq, Ord)

instance Num Nat where
  Z + n = n
  S m + n = S (m + n)
  Z * _ = Z
  S m * n = n + m * n
  negate _ = error "negate on Nat"
  abs = id
  signum Z = Z
  signum _ = 1
  fromInteger n
    | n < 0 = error "fromInteger to Nat on negative number"
    | otherwise =
        let go 0 = Z
            go m = S (go (m-1))
        in go n
:}