[Haskell-beginners] How to make instance of MonoFunctor

Baa aquagnu at gmail.com
Thu Aug 10 08:35:52 UTC 2017


Hello, Dear List!

I want to make functor of my type like

  newtype UserName = UserName { unName :: Text }

sure, it's impossible, so I will make MonoFunctor instead of (from
library mono-traversable). So, I try:

  instance MonoFunctor UserName where
    omap fn (UserName n) = UserName $ fn $ n

but I get error

        • Couldn't match expected type ‘Element UserName’
                      with actual type ‘Text’
        • In the second argument of ‘($)’, namely ‘unName an’
          In the second argument of ‘($)’, namely ‘fn $ unName an’
          In the expression: UserName $ fn $ unName an

interesting is that Text "type Element Text" of "type family Element
mono" (instance?). So, how to make mono-functor for such `UserName`
structure?


--
Best regards, Paul


More information about the Beginners mailing list