[Haskell-beginners] How to use Text.Printf w/ custom types
Norbert Melzer
timmelzer at gmail.com
Fri Nov 24 13:23:54 UTC 2017
Which methods?
Just doing this should be sufficient:
```
instance PrintfArg YourType where
formatArg _ _ = Text.pack "It works (well, nearly)"
```
Baa <aquagnu at gmail.com> schrieb am Fr., 24. Nov. 2017 um 14:20 Uhr:
> But how to do it if "methods" are not exporting?
>
> > According to
> >
> https://hackage.haskell.org/package/base-4.10.0.0/docs/Text-Printf.html#g:2
> ,
> > you only need to implement `PrintfArg`. There is also an example for
> > `()`.
> >
> > Baa <aquagnu at gmail.com> schrieb am Fr., 24. Nov. 2017 um 13:33 Uhr:
> >
> > > Hello All!
> > >
> > > As I understand to use Text.Printf.printf with custom types or to
> > > return result as Text instead of String I must implement some
> > > class instances: PrintfType, PrintfArg. But how to do this if they
> > > are exported from module as type-names only - without its methods
> > > (i.e. not "Printf (..)", but "Printf") ?
> > >
> > > I tried to import Text.Printf.Internal but seems that no such
> > > submodule...
> > >
> > > Any ideas?
> > >
> > > ===
> > > Best regards, Paul
> > > _______________________________________________
> > > Beginners mailing list
> > > Beginners at haskell.org
> > > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
> > >
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20171124/1611c374/attachment.html>
More information about the Beginners
mailing list