Skip to content

Commit 82cd63d

Browse files
committed
Add FromDhall instances for Int{,8,16,32,64}
1 parent 6726361 commit 82cd63d

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

dhall/src/Dhall/Marshal/Encode.hs

+28
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,34 @@ instance ToDhall Int where
206206

207207
declared = Integer
208208

209+
instance ToDhall Int8 where
210+
injectWith _ = Encoder {..}
211+
where
212+
embed = IntegerLit . toInteger
213+
214+
declared = Integer
215+
216+
instance ToDhall Int16 where
217+
injectWith _ = Encoder {..}
218+
where
219+
embed = IntegerLit . toInteger
220+
221+
declared = Integer
222+
223+
instance ToDhall Int32 where
224+
injectWith _ = Encoder {..}
225+
where
226+
embed = IntegerLit . toInteger
227+
228+
declared = Integer
229+
230+
instance ToDhall Int64 where
231+
injectWith _ = Encoder {..}
232+
where
233+
embed = IntegerLit . toInteger
234+
235+
declared = Integer
236+
209237
{-| Encode a 'Word' to a Dhall @Natural@.
210238
211239
>>> embed inject (12 :: Word)

dhall/src/Dhall/Marshal/Internal.hs

+5
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ module Dhall.Marshal.Internal
2727
-- * Re-exports
2828
, Fix(..)
2929
, HashMap
30+
, Int8
31+
, Int16
32+
, Int32
33+
, Int64
3034
, Map
3135
, Natural
3236
, Scientific
@@ -44,6 +48,7 @@ module Dhall.Marshal.Internal
4448
import Control.Monad.Trans.State.Strict
4549
import Data.Fix (Fix (..))
4650
import Data.HashMap.Strict (HashMap)
51+
import Data.Int (Int16, Int32, Int64, Int8)
4752
import Data.Map (Map)
4853
import Data.Scientific (Scientific)
4954
import Data.Sequence (Seq)

0 commit comments

Comments
 (0)