Type signature requires a type that is not exported by the library

So, I used the aeson library and thought it would be very useful to have the following function:

v .:! f = liftM (fromMaybe mempty) (v .:? f) 

When I ask GHCi for a type, I get:

 (.:!) :: (Monoid r, FromJSON r) => Object -> T.Text -> aeson-0.7.0.6:Data.Aeson.Types.Internal.Parser r 

However, Parser itself is not actually exported, either Data.Aeson or Data.Aeson.Types . Am I forced to not have a type signature for the function that I defined?

Alternatively, if someone knows the best way to accomplish what I'm trying to do, I will be interested in your suggestions.

+6
source share
1 answer

At present, in Haskell it is quite possible to write code that will have a type of output that you cannot write to yourself because of unexcited characters. In April 2014, there was a discussion on the Haskell library mailing list, where there was no firm conclusion, but the general idea was to maintain the current behavior.

However, the general rule is that if you need a language extension to record the type signature that will be output, then you need to enable this extension, even if you did not specify the signature explicitly.

+3
source

Source: https://habr.com/ru/post/972045/


All Articles