Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Import a type family that is an operator in Haskell

GHC.TypeNats exports type family of the following signature:

type family (m :: Nat) + (n :: Nat) :: Nat 

How can I import it explicitly? import GHC.TypeNats((+)) does not work, because it says that GHC.TypeNats does not export (+)...

Everything compiles okay when I import whole module implicitly, but this really is not what I want to have in my code.


I am using GHC 8.6.5

like image 972
radrow Avatar asked Mar 03 '23 06:03

radrow


1 Answers

From the manual:

There is now some potential ambiguity in import and export lists; for example if you write import M( (+) ) do you mean the function (+) or the type constructor (+)? The default is the former, but with ExplicitNamespaces (which is implied by TypeOperators) GHC allows you to specify the latter by preceding it with the keyword type, thus:

import M( type (+) )
like image 180
Daniel Wagner Avatar answered Mar 11 '23 00:03

Daniel Wagner