Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add FromDhall instances for Int{,8,16,32,64} #2349

Merged
merged 1 commit into from
Dec 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion dhall/src/Dhall/Marshal/Decode.hs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ import Data.Functor.Contravariant
, Predicate (..)
)
import Data.Hashable (Hashable)
import Data.Int (Int16, Int32, Int64, Int8)
import Data.List.NonEmpty (NonEmpty (..))
import Data.Typeable (Proxy (..), Typeable)
import Dhall.Parser (Src (..))
Expand Down
28 changes: 28 additions & 0 deletions dhall/src/Dhall/Marshal/Encode.hs
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,34 @@ instance ToDhall Int where

declared = Integer

instance ToDhall Int8 where
injectWith _ = Encoder {..}
where
embed = IntegerLit . toInteger

declared = Integer

instance ToDhall Int16 where
injectWith _ = Encoder {..}
where
embed = IntegerLit . toInteger

declared = Integer

instance ToDhall Int32 where
injectWith _ = Encoder {..}
where
embed = IntegerLit . toInteger

declared = Integer

instance ToDhall Int64 where
injectWith _ = Encoder {..}
where
embed = IntegerLit . toInteger

declared = Integer

{-| Encode a 'Word' to a Dhall @Natural@.

>>> embed inject (12 :: Word)
Expand Down
5 changes: 5 additions & 0 deletions dhall/src/Dhall/Marshal/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ module Dhall.Marshal.Internal
-- * Re-exports
, Fix(..)
, HashMap
, Int8
, Int16
, Int32
, Int64
, Map
, Natural
, Scientific
Expand All @@ -44,6 +48,7 @@ module Dhall.Marshal.Internal
import Control.Monad.Trans.State.Strict
import Data.Fix (Fix (..))
import Data.HashMap.Strict (HashMap)
import Data.Int (Int16, Int32, Int64, Int8)
import Data.Map (Map)
import Data.Scientific (Scientific)
import Data.Sequence (Seq)
Expand Down
2 changes: 1 addition & 1 deletion stack.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
resolver: lts-18.0
resolver: lts-18.18
packages:
- dhall
- dhall-bash
Expand Down