Skip to content

Commit 02d7acc

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

File tree

4 files changed

+34
-2
lines changed

4 files changed

+34
-2
lines changed

dhall/src/Dhall/Marshal/Decode.hs

-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@ import Data.Functor.Contravariant
146146
, Predicate (..)
147147
)
148148
import Data.Hashable (Hashable)
149-
import Data.Int (Int16, Int32, Int64, Int8)
150149
import Data.List.NonEmpty (NonEmpty (..))
151150
import Data.Typeable (Proxy (..), Typeable)
152151
import Dhall.Parser (Src (..))

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)

stack.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
resolver: lts-18.0
1+
resolver: lts-18.18
22
packages:
33
- dhall
44
- dhall-bash

0 commit comments

Comments
 (0)