irc-fun-types (empty) → 0.1.0.0
raw patch · 10 files changed
+1170/−0 lines, 10 filesdep +basedep +textsetup-changed
Dependencies added: base, text
Files
- AUTHORS +1/−0
- COPYING +121/−0
- ChangeLog +17/−0
- INSTALL +13/−0
- NEWS.md +23/−0
- README.md +12/−0
- Setup.hs +2/−0
- irc-fun-types.cabal +52/−0
- src/Network/IRC/Fun/Types.hs +833/−0
- src/Network/IRC/Fun/Types/Base.hs +96/−0
+ AUTHORS view
@@ -0,0 +1,1 @@+fr33domlover <fr33domlover@riseup.net>
+ COPYING view
@@ -0,0 +1,121 @@+Creative Commons Legal Code++CC0 1.0 Universal++ CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE+ LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN+ ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS+ INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES+ REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS+ PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM+ THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED+ HEREUNDER.++Statement of Purpose++The laws of most jurisdictions throughout the world automatically confer+exclusive Copyright and Related Rights (defined below) upon the creator+and subsequent owner(s) (each and all, an "owner") of an original work of+authorship and/or a database (each, a "Work").++Certain owners wish to permanently relinquish those rights to a Work for+the purpose of contributing to a commons of creative, cultural and+scientific works ("Commons") that the public can reliably and without fear+of later claims of infringement build upon, modify, incorporate in other+works, reuse and redistribute as freely as possible in any form whatsoever+and for any purposes, including without limitation commercial purposes.+These owners may contribute to the Commons to promote the ideal of a free+culture and the further production of creative, cultural and scientific+works, or to gain reputation or greater distribution for their Work in+part through the use and efforts of others.++For these and/or other purposes and motivations, and without any+expectation of additional consideration or compensation, the person+associating CC0 with a Work (the "Affirmer"), to the extent that he or she+is an owner of Copyright and Related Rights in the Work, voluntarily+elects to apply CC0 to the Work and publicly distribute the Work under its+terms, with knowledge of his or her Copyright and Related Rights in the+Work and the meaning and intended legal effect of CC0 on those rights.++1. Copyright and Related Rights. A Work made available under CC0 may be+protected by copyright and related or neighboring rights ("Copyright and+Related Rights"). Copyright and Related Rights include, but are not+limited to, the following:++ i. the right to reproduce, adapt, distribute, perform, display,+ communicate, and translate a Work;+ ii. moral rights retained by the original author(s) and/or performer(s);+iii. publicity and privacy rights pertaining to a person's image or+ likeness depicted in a Work;+ iv. rights protecting against unfair competition in regards to a Work,+ subject to the limitations in paragraph 4(a), below;+ v. rights protecting the extraction, dissemination, use and reuse of data+ in a Work;+ vi. database rights (such as those arising under Directive 96/9/EC of the+ European Parliament and of the Council of 11 March 1996 on the legal+ protection of databases, and under any national implementation+ thereof, including any amended or successor version of such+ directive); and+vii. other similar, equivalent or corresponding rights throughout the+ world based on applicable law or treaty, and any national+ implementations thereof.++2. Waiver. To the greatest extent permitted by, but not in contravention+of, applicable law, Affirmer hereby overtly, fully, permanently,+irrevocably and unconditionally waives, abandons, and surrenders all of+Affirmer's Copyright and Related Rights and associated claims and causes+of action, whether now known or unknown (including existing as well as+future claims and causes of action), in the Work (i) in all territories+worldwide, (ii) for the maximum duration provided by applicable law or+treaty (including future time extensions), (iii) in any current or future+medium and for any number of copies, and (iv) for any purpose whatsoever,+including without limitation commercial, advertising or promotional+purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each+member of the public at large and to the detriment of Affirmer's heirs and+successors, fully intending that such Waiver shall not be subject to+revocation, rescission, cancellation, termination, or any other legal or+equitable action to disrupt the quiet enjoyment of the Work by the public+as contemplated by Affirmer's express Statement of Purpose.++3. Public License Fallback. Should any part of the Waiver for any reason+be judged legally invalid or ineffective under applicable law, then the+Waiver shall be preserved to the maximum extent permitted taking into+account Affirmer's express Statement of Purpose. In addition, to the+extent the Waiver is so judged Affirmer hereby grants to each affected+person a royalty-free, non transferable, non sublicensable, non exclusive,+irrevocable and unconditional license to exercise Affirmer's Copyright and+Related Rights in the Work (i) in all territories worldwide, (ii) for the+maximum duration provided by applicable law or treaty (including future+time extensions), (iii) in any current or future medium and for any number+of copies, and (iv) for any purpose whatsoever, including without+limitation commercial, advertising or promotional purposes (the+"License"). The License shall be deemed effective as of the date CC0 was+applied by Affirmer to the Work. Should any part of the License for any+reason be judged legally invalid or ineffective under applicable law, such+partial invalidity or ineffectiveness shall not invalidate the remainder+of the License, and in such case Affirmer hereby affirms that he or she+will not (i) exercise any of his or her remaining Copyright and Related+Rights in the Work or (ii) assert any associated claims and causes of+action with respect to the Work, in either case contrary to Affirmer's+express Statement of Purpose.++4. Limitations and Disclaimers.++ a. No trademark or patent rights held by Affirmer are waived, abandoned,+ surrendered, licensed or otherwise affected by this document.+ b. Affirmer offers the Work as-is and makes no representations or+ warranties of any kind concerning the Work, express, implied,+ statutory or otherwise, including without limitation warranties of+ title, merchantability, fitness for a particular purpose, non+ infringement, or the absence of latent or other defects, accuracy, or+ the present or absence of errors, whether or not discoverable, all to+ the greatest extent permissible under applicable law.+ c. Affirmer disclaims responsibility for clearing rights of other persons+ that may apply to the Work or any use thereof, including without+ limitation any person's Copyright and Related Rights in the Work.+ Further, Affirmer disclaims responsibility for obtaining any necessary+ consents, permissions or other rights required for any use of the+ Work.+ d. Affirmer understands and acknowledges that Creative Commons is not a+ party to this document and has no duty or obligation with respect to+ this CC0 or use of the Work.
+ ChangeLog view
@@ -0,0 +1,17 @@+The changes are recorded by the version control system, Darcs. To see a log+quickly from the terminal, run:++ $ darcs changes --repo http://hub.darcs.net/fr33domlover/irc-fun-types++There is also a web interface at <http://hub.darcs.net> which, among other+things, can display the history log.++To see the log in a local clone, first get a copy of the repository if you+haven't yet:++ $ darcs get http://hub.darcs.net/fr33domlover/irc-fun-types++Then move into the newly created directory and run darcs:++ $ cd irc-fun-types+ $ darcs changes
+ INSTALL view
@@ -0,0 +1,13 @@+Install from Hackage:++ $ cabal install irc-fun-types++Install from unpacked release tarball or source repo:++ $ cd irc-fun-types+ $ cabal install++Just play with it without installing:++ $ cabal build+ $ cabal repl
+ NEWS.md view
@@ -0,0 +1,23 @@+This file lists the user-visible interesting changes between releases. For a+full list of changes to the source, see the ChangeLog.++++irc-fun-types 0.1.0.0 -- 2016-01-27+===================================++General, build and documentation changes:++* (This is the first release, so everything is new)++New APIs, features and enhancements:++* (This is the first release, so everything is a new feature)++Bug fixes:++* (This is just the first release, many bugs haven't been discovered yet)++Dependency changes:++* (This is the first release)
+ README.md view
@@ -0,0 +1,12 @@+See the .cabal file for more info and link to project website the version+control.++The official download location is Hackage.++This library is free software, and is committed to software freedom. It is+released to the public domain using the CC0 Public Domain Dedication. For the+boring "legal" details see the file `COPYING`.++See the file `INSTALL` for hints on installation. The file `ChangeLog` explains+how to see the history log of the changes done in the code. `NEWS.md` provides+a friendly overview of the changes for each release.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ irc-fun-types.cabal view
@@ -0,0 +1,52 @@+name: irc-fun-types+version: 0.1.0.0+synopsis: Common types for IRC related packages+description:+ This library provides types useful to programs and libraries working with+ Internet Relay Chat (IRC). It allows basic IRC concepts like channel,+ nickname, message and so on to be used by IRC parsers and IRC clients and IRC+ servers without unnecessary duplication of type definitions.+ .+ Note that the library possibly doesn't yet fully handle all the types related+ to the various IRC messages types, for example user and channel modes. These+ are added gradually, and patches are welcome.+ .+ All the text based types use strict 'Data.Text.Text'. This allows efficient+ processing of message text while supporting character-based operations that+ require recognizing Unicode.+ .+ If you are writing a simple IRC client module, you can probably use+ "Network.IRC.Fun.Types.Base", which contains the subset you'll likely need.+ But if you're writing an IRC message parser or serializer, you'll probably+ want to use "Network.IRC.Fun.Types", which contains all the types.+homepage: http://hub.darcs.net/fr33domlover/irc-fun-types+bug-reports: https://notabug.org/fr33domlover/funbot/issues+license: PublicDomain+license-file: COPYING+author: fr33domlover+maintainer: fr33domlover@riseup.net+copyright: ♡ Copying is an act of love. Please copy, reuse and share.+category: Data, Network, IRC+build-type: Simple+extra-source-files: AUTHORS+ ChangeLog+ COPYING+ INSTALL+ NEWS.md+ README.md+cabal-version: >=1.10++source-repository head+ type: darcs+ location: http://hub.darcs.net/fr33domlover/irc-fun-types++library+ exposed-modules: Network.IRC.Fun.Types+ , Network.IRC.Fun.Types.Base+ -- other-modules: + -- other-extensions: + build-depends: base >=4.7 && <5+ , text+ hs-source-dirs: src+ default-language: Haskell2010+ ghc-options: -Wall
+ src/Network/IRC/Fun/Types.hs view
@@ -0,0 +1,833 @@+{- This file is part of irc-fun-types.+ -+ - Written in 2015, 2016 by fr33domlover <fr33domlover@riseup.net>.+ -+ - ♡ Copying is an act of love. Please copy, reuse and share.+ -+ - The author(s) have dedicated all copyright and related and neighboring+ - rights to this software to the public domain worldwide. This software is+ - distributed without any warranty.+ -+ - You should have received a copy of the CC0 Public Domain Dedication along+ - with this software. If not, see+ - <http://creativecommons.org/publicdomain/zero/1.0/>.+ -}++module Network.IRC.Fun.Types+ ( -- * Type Aliases, Newtypes, Other Basics+ module Network.IRC.Fun.Types.Base+ -- * Message Parts+ , Prefix (..)+ , UserAddress (..)+ , Target (..)+ , Address (..)+ , Host (..)+ , Command (..)+ -- * Mask+ , MaskPart (..)+ , Mask (..)+ , TargetMask (..)+ -- * Message+ , GenericMessage (..)+ , SpecificMessage (..)+ , MessageTarget (..)+ , Query (..)+ , Message (..)+ , AnalysisError (..)+ , ArgSpec (..)+ -- * Modes+ , UserMode (..)+ , ChannelMode (..)+ , ChannelModeType (..)+ -- * Reply+ , GenericReply (..)+ , Reply (..)+ , SpecificReply (..)+ )+where++import Data.Text (Text)+import Network.IRC.Fun.Types.Base++-------------------------------------------------------------------------------+-- Message Parts+-------------------------------------------------------------------------------++-- | IRC message prefix.+data Prefix+ -- | The server which sends the message+ = PrefixServer Hostname+ -- | The user which sends the message (if the message comes from a user)+ | PrefixNick Nickname (Maybe Username) (Maybe Host)+ deriving (Eq, Show)++-- | User address containing a name part (as in "user") and an optional host+-- part (as in "user@host").+data UserAddress = UserAddress Username (Maybe Host) deriving (Eq, Show)++-- | Some IRC commands operate on a target, that is either a single user or an+-- entire IRC server.+data Target = NickTarget Nickname | ServerTarget Hostname deriving (Eq, Show)++-- | An IP address.+data Address = IPv4 Text | IPv6 Text deriving (Eq, Show)++-- | A host, either a hostname (e.g. @irc.freenode.net@) or an IP address, or a+-- cloak assigned by the server.+data Host = HostByName Hostname | HostByAddr Address | HostCloak Text+ deriving (Eq, Show)++-- | An IRC command code. Either a named command, or a numeric one.+data Command = NamedCmd CmdName | NumericCmd CmdNumber+ deriving (Eq, Show)++-------------------------------------------------------------------------------+-- Masks+-------------------------------------------------------------------------------++-- | Part of a 'Mask'.+data MaskPart+ -- | A literal character.+ = MaskChar Char+ -- | A wildcard which matches a single character.+ | MaskWildOne+ -- | A wildcard which matches zero or more characters.+ | MaskWildMany+ deriving (Eq, Show)++-- | A pattern for matching host and server names. A mask in the protocol is a+-- string which consists of literal characters and wildcards. There are two+-- wildcards: @'?'@, which matches a single character; @'*'@, which matches any+-- number of characters (zero or more).+newtype Mask = Mask [MaskPart] deriving (Eq, Show)++-- | Some IRC command parameters are targets, and one way to specify a target+-- is using a 'Mask'.+data TargetMask+ -- | Host mask, prefixed with @'#'@ in the protocol. Selects all the users+ -- whose host matches the mask.+ = HostMask Mask+ -- | Server mask, prefixed with @'$'@ in the protocol. Selects all the+ -- users connected to a server which matches the mask.+ | ServerMask Mask+ deriving (Eq, Show)++-------------------------------------------------------------------------------+-- Message+-------------------------------------------------------------------------------++-- | A generic IRC message. It consists of a sender prefix, command name+-- (string or numeric) and optionally a list of parameters.+data GenericMessage = GenericMessage+ { gmPrefix :: Maybe Prefix+ , gmCommand :: Command+ , gmParams :: [Text]+ }+ deriving Show++-- | An IRC message of a specific type. This includes only messages whose+-- command is a name. Messages with a numeric command are handled in the+-- "Network.IRC.Fun.Messages.Reply" module.+data SpecificMessage = SpecificMessage (Maybe Prefix) Message deriving Show++-- | Some IRC commands have targets. For example, to which channel to send a+-- given text message. Targets are specified as parameters in IRC messages.+data MessageTarget+ -- | An IRC channel.+ = ChannelTarget Channel+ -- | An IRC user. Possible combinations in the protocol are:+ --+ -- * Address (address host is required)+ -- * Address and server (address host is optional)+ -- * Nickname+ -- * Nickname and address (address host is required)+ | UserTarget (Maybe Nickname) (Maybe UserAddress) (Maybe Hostname)+ -- | A mask which matches the server or host of the users to whom the+ -- message should be sent.+ | MaskTarget TargetMask+ deriving Show++-- | A server query. Can be sent through a 'StatsMessage'.+data Query+ -- | TODO+ = Connections+ -- | TODO+ | CommandUsage+ -- | TODO+ | PrivilegedUsers+ -- | TODO+ | Uptime+ -- | TODO+ | OtherQuery Char+ deriving Show++-- TODO in all the either-servername-mask occurences, make sure in the RFC+-- that they are "<target> may contain wildcards" cases, and replace them with+-- plain Hostname - let's treat mask as a user mask (for bans etc.)+-- TODO in all the <target> cases, do they mean a user can be specified too,+-- to mean "the server this user is connected to"? try with some IRC servers+-- over telnet, and change Hostname to Target if yes. Note that servername+-- has '.' chars while a nickname can't, so that's how one tells which is which+-- Also compare with existing irc packages, how they model these messages++-- | An IRC message of specific type (excluding the optional sender prefix, see+-- 'SpecificMessage').+data Message+-- Connection registration+ = PassMessage Password+ | NickMessage Nickname+ -- | first bool = whether invisible, second bool = whether sees wallops+ | UserMessage Username Bool Bool RealName+ | OperMessage Username Password+ -- | first list: modes to remove (-), second list: modes to add (+)+ | UserModeMessage Nickname [UserMode] [UserMode]+ | ServiceMessage Nickname Mask Text+ | QuitMessage (Maybe Comment)+ | SQuitMessage Hostname Comment+-- Channel operations+ | JoinMessage (Maybe ([Channel], [ChannelKey]))+ | PartMessage [Channel] (Maybe Comment)+ -- first: remove (-), second: add/set (+)+ | ChannelModeMessage [ChannelMode] [ChannelMode]+ | TopicMessage Channel (Maybe ChannelTopic)+ | NamesMessage [Channel] (Maybe Hostname)+ | ListMessage [Channel] (Maybe Hostname)+ | InviteMessage Nickname Channel+ | KickMessage [Channel] [Username] (Maybe Comment)+-- Sending messages+ | PrivMsgMessage MessageTarget MsgContent+ | PrivActionMessage MessageTarget MsgContent+ | NoticeMessage MessageTarget MsgContent+-- Server queries and commands+ | MotdMessage (Maybe Hostname)+ | LusersMessage (Maybe (Mask, Maybe Hostname))+ | VersionMessage (Maybe (Either Hostname Mask))+ | StatsMessage (Maybe (Query, Maybe (Either Hostname Mask)))+ | LinksMessage (Maybe (Maybe (Either Hostname Mask), Mask))+ | TimeMessage (Maybe (Either Hostname Mask))+ | ConnectMessage Hostname PortNumber (Either Hostname Mask)+ | TraceMessage (Maybe Target)+ | AdminMessage (Maybe Target)+ | InfoMessage (Maybe Target)+-- Service query and commands+ | ServlistMessage (Maybe (Mask, Maybe Text))+ | SQueryMessage ServiceName MsgContent+-- User based queries+ | WhoMessage (Maybe (Mask, Bool))+ | WhoisMessage (Maybe Hostname) [Mask]+ | WhowasMessage [Nickname] (Maybe (Int, Maybe Hostname))+-- Miscellaneous messages+ | KillMessage Nickname Comment+ | PingMessage Hostname (Maybe Hostname)+ | PongMessage Hostname (Maybe Hostname)+ | ErrorMessage Text+-- Optional features+ | AwayMessage (Maybe MsgContent)+ | RehashMessage+ | DieMessage+ | RestartMessage+ | SummonMessage Username (Maybe (Hostname, Maybe Channel))+ | UsersMessage (Maybe Hostname)+ | WallopsMessage MsgContent+ | UserhostMessage [Nickname]+ | IsonMessage [Nickname]+ deriving Show++-------------------------------------------------------------------------------+-- Modes+-------------------------------------------------------------------------------++-- | TODO+data UserMode+ -- http://toxin.jottit.com/freenode_user_modes+ = UModeInvisible+ | UModeCallerID+ | UModeSeeWallops+ | UModeDeaf+ | UModeNoForwarding+ | UModeBlockUnidentified+ | UModeConnectedViaSSL+ -- from the irc rfc, MODE message (section 3.1.5)+ | UModeAway+ | UModeRestricted+ | UModeOperator+ | UModeLocalOperator+ | UModeSeeNotices+ | UModeOther Char+ deriving (Eq, Show)++-- | TODO+data ChannelMode+ = CModeCreator+ | CModeOperator+ | CModeVoice+ | CModeAnonymous+ | CModeInviteOnly+ | CModeModerated+ | CModeNoMessagesFromOutside+ | CModeQuiet+ | CModePrivate+ | CModeSecret+ | CModeServerReop+ | CModeTopicSettableByChannelOpOnly+ | CModeKey (Maybe ChannelKey)+ | CModeUserLimit (Maybe Int)+ | CModeBanMask (Maybe Mask)+ | CModeExceptionMask (Maybe Mask)+ | CModeInvitationMask (Maybe Mask)+ | CModeOther Char [Text]+ | CModeFreenodeQuiet (Maybe Mask)+ deriving (Eq, Show)++data ChannelModeType+ = ModeTypeList+ | ModeTypeSetting+ | ModeTypeMaybeSetting+ | ModeTypeFlag++-------------------------------------------------------------------------------+-- Reply+-------------------------------------------------------------------------------++-- | TODO+data CommandResponseCode+ -- | TODO+ = ReplyWelcome+ -- | TODO+ | ReplyYourHost+ -- | TODO+ | ReplyCreated+ -- | TODO+ | ReplyMyInfo+ -- | TODO+ | ReplyBounce+ -- | TODO+ | ReplyUserHost+ -- | TODO+ | ReplyIsOn+ -- | TODO+ | ReplyAway+ -- | TODO+ | ReplyUnAway+ -- | TODO+ | ReplyNoAway+ -- | TODO+ | ReplyWhoIsUser+ -- | TODO+ | ReplyWhoIsServer+ -- | TODO+ | ReplyWhoIsOperator+ -- | TODO+ | ReplyWhoIsIdle+ -- | TODO+ | ReplyEndOfWhoIs+ -- | TODO+ | ReplyWhoIsChannels+ -- | TODO+ | ReplyWhoWasUser+ -- | TODO+ | ReplyEndOfWhoWas+ -- | TODO+ | ReplyListStart+ -- | TODO+ | ReplyList+ -- | TODO+ | ReplyListEnd+ -- | TODO+ | ReplyUniqueOpIs+ -- | TODO+ | ReplyChannelModeIs+ -- | TODO+ | ReplyNoTopic+ -- | TODO+ | ReplyTopic+ -- | TODO+ | ReplyInviting+ -- | TODO+ | ReplySummoning+ -- | TODO+ | ReplyInviteList+ -- | TODO+ | ReplyEndOfInviteList+ -- | TODO+ | ReplyExceptList+ -- | TODO+ | ReplyEndOfExceptList+ -- | TODO+ | ReplyVersion+ -- | TODO+ | ReplyWhoReply+ -- | TODO+ | ReplyEndOfWho+ -- | TODO+ | ReplyNameReply+ -- | TODO+ | ReplyEndOfNames+ -- | TODO+ | ReplyLinks+ -- | TODO+ | ReplyEndOfLinks+ -- | TODO+ | ReplyBanList+ -- | TODO+ | ReplyEndOfBanList+ -- | TODO+ | ReplyInfo+ -- | TODO+ | ReplyEndOfInfo+ -- | TODO+ | ReplyMotdStart+ -- | TODO+ | ReplyMessageOfTheDay+ -- | TODO+ | ReplyEndOfMessageOfTheDay+ -- | TODO+ | ReplyYoureOper+ -- | TODO+ | ReplyRehashing+ -- | TODO+ | ReplyYoureService+ -- | TODO+ | ReplyTime+ -- | TODO+ | ReplyUsersStart+ -- | TODO+ | ReplyUsers+ -- | TODO+ | ReplyEndOfUsers+ -- | TODO+ | ReplyNoUsers+ -- | TODO+ | ReplyTraceLink+ -- | TODO+ | ReplyTraceConnecting+ -- | TODO+ | ReplyTraceHandshake+ -- | TODO+ | ReplyTraceUnknown+ -- | TODO+ | ReplyTraceOperator+ -- | TODO+ | ReplyTraceUser+ -- | TODO+ | ReplyTraceServer+ -- | TODO+ | ReplyTraceService+ -- | TODO+ | ReplyTraceNewType+ -- | TODO+ | ReplyTraceClass+ -- | TODO+ | ReplyTraceReconnect+ -- | TODO+ | ReplyTraceLog+ -- | TODO+ | ReplyTraceEnd+ -- | TODO+ | ReplyStatsLinkInfo+ -- | TODO+ | ReplyStatsCommands+ -- | TODO+ | ReplyEndOfStats+ -- | TODO+ | ReplyStatsUptime+ -- | TODO+ | ReplyStatsOLine+ -- | TODO+ | ReplyUModeIs+ -- | TODO+ | ReplyServList+ -- | TODO+ | ReplyServListEnd+ -- | TODO+ | ReplyLuserClient+ -- | TODO+ | ReplyLuserOp+ -- | TODO+ | ReplyLuserUnknown+ -- | TODO+ | ReplyLuserChannels+ -- | TODO+ | ReplyLuserMe+ -- | TODO+ | ReplyAdminMe+ -- | TODO+ | ReplyAdminLocation1+ -- | TODO+ | ReplyAdminLocation2+ -- | TODO+ | ReplyAdminEmail+ -- | TODO+ | ReplyTryAgain+ -- | TODO+ | ReplyFreenodeISupport+ deriving (Eq, Show)++data ErrorReplyCode+ -- | TODO+ = ErrorNoSuchNick+ -- | TODO+ | ErrorNoSuchServer+ -- | TODO+ | ErrorNoSuchChannel+ -- | TODO+ | ErrorCannotSendToChannel+ -- | TODO+ | ErrorTooManyChannels+ -- | TODO+ | ErrorWasNoSuchNick+ -- | TODO+ | ErrorTooManyTargets+ -- | TODO+ | ErrorNoSuchService+ -- | TODO+ | ErrorNoOrigin+ -- | TODO+ | ErrorNoRecipient+ -- | TODO+ | ErrorNoTextToSend+ -- | TODO+ | ErrorNoTopLevel+ -- | TODO+ | ErrorWildTopLevel+ -- | TODO+ | ErrorBadMask+ -- | TODO+ | ErrorUnknownCommand+ -- | TODO+ | ErrorNoMessageOfTheDay+ -- | TODO+ | ErrorNoAdminInfo+ -- | TODO+ | ErrorFileError+ -- | TODO+ | ErrorNoNicknameGiven+ -- | TODO+ | ErrorErroneousNickname+ -- | TODO+ | ErrorNicknameInUse+ -- | TODO+ | ErrorNickCollision+ -- | TODO+ | ErrorUnavailableResource+ -- | TODO+ | ErrorUserNotInChannel+ -- | TODO+ | ErrorNotOnChannel+ -- | TODO+ | ErrorUserOnChannel+ -- | TODO+ | ErrorNoLogin+ -- | TODO+ | ErrorSummonDisabled+ -- | TODO+ | ErrorUsersDisabled+ -- | TODO+ | ErrorNotRegistered+ -- | TODO+ | ErrorNeedMoreParams+ -- | TODO+ | ErrorAlreadyRegistered+ -- | TODO+ | ErrorNoPermissionForHost+ -- | TODO+ | ErrorPasswordMismatch+ -- | TODO+ | ErrorYoureBannedCreep+ -- | TODO+ | ErrorYouWillBeBanned+ -- | TODO+ | ErrorKeySet+ -- | TODO+ | ErrorChannelIsFull+ -- | TODO+ | ErrorUnknownMode+ -- | TODO+ | ErrorInviteOnlyChannel+ -- | TODO+ | ErrorBannedFromChannel+ -- | TODO+ | ErrorBadChannelKey+ -- | TODO+ | ErrorBadChannelMask+ -- | TODO+ | ErrorNoChannelModes+ -- | TODO+ | ErrorBanListFull+ -- | TODO+ | ErrorNoPrivileges+ -- | TODO+ | ErrorChannelOpPrivilegesNeeded+ -- | TODO+ | ErrorCantKillServer+ -- | TODO+ | ErrorRestricted+ -- | TODO+ | ErrorUniqueOpPrivilegesNeeded+ -- | TODO+ | ErrorNoOperHost+ -- | TODO+ | ErrorUModeUnknownFlag+ -- | TODO+ | ErrorUsersDontMatch+ deriving (Eq, Show)++data ReservedReplyCode+ -- | TODO+ = ReservedReplyServiceInfo+ -- | TODO+ | ReservedReplyEndOfServices+ -- | TODO+ | ReservedReplyService+ -- | TODO+ | ReservedReplyNone+ -- | TODO+ | ReservedReplyWhoIsChannelOp+ -- | TODO+ | ReservedReplyKillDone+ -- | TODO+ | ReservedReplyClosing+ -- | TODO+ | ReservedReplyCloseEnd+ -- | TODO+ | ReservedReplyInfoStart+ -- | TODO+ | ReservedReplyMyPortIs+ -- | TODO+ | ReservedReplyStatsCLine+ -- | TODO+ | ReservedReplyStatsNLine+ -- | TODO+ | ReservedReplyStatsILine+ -- | TODO+ | ReservedReplyStatsKLine+ -- | TODO+ | ReservedReplyStatsQLine+ -- | TODO+ | ReservedReplyStatsYLine+ -- | TODO+ | ReservedReplyStatsVLine+ -- | TODO+ | ReservedReplyStatsLLine+ -- | TODO+ | ReservedReplyStatsHLine+ -- | TODO+ | ReservedReplyStatsSLine+ -- | TODO+ | ReservedReplyStatsPing+ -- | TODO+ | ReservedReplyStatsBLine+ -- | TODO+ | ReservedReplyStatsDLine+ deriving (Eq, Show)++-- | TODO+data ReservedErrorCode+ -- | TODO+ = ReservedErrorNoServiceHost+ deriving (Eq, Show)++-- | TODO+data GenericReply = GenericReply+ { grSender :: Hostname+ , grCode :: CmdNumber+ , grTarget :: Target+ , grParams :: [Parameter]+ }+ deriving Show++-- | TODO+data Reply+ -- | TODO+ = WelcomeReply+ -- | TODO+ | YourHostReply+ -- | TODO+ | CreatedReply+ -- | TODO+ | MyInfoReply+ -- | TODO+ | BounceReply+ -- | TODO+ | ISupportReply+ -- | TODO+ | UserHostReply+ -- | TODO+ | IsOnReply+ -- | TODO+ | AwayReply+ -- | TODO+ | UnAwayReply+ -- | TODO+ | NoAwayReply+ -- | TODO+ | WhoIsUserReply+ -- | TODO+ | WhoIsServerReply+ -- | TODO+ | WhoIsOperatorReply+ -- | TODO+ | WhoIsIdleReply+ -- | TODO+ | EndOfWhoIsReply+ -- | TODO+ | WhoIsChannelsReply+ -- | TODO+ | WhoWasUserReply+ -- | TODO+ | EndOfWhoWasReply+ -- | TODO+ | ListStartReply+ -- | TODO+ | ListReply+ -- | TODO+ | ListEndReply+ -- | TODO+ | UniqueOpIsReply+ -- | TODO+ | ChannelModeIsReply+ -- | TODO+ | NoTopicReply+ -- | TODO+ | TopicReply+ -- | TODO+ | InvitingReply+ -- | TODO+ | SummoningReply+ -- | TODO+ | InviteListReply+ -- | TODO+ | EndOfInviteListReply+ -- | TODO+ | ExceptListReply+ -- | TODO+ | EndOfExceptListReply+ -- | TODO+ | VersionReply+ -- | TODO+ | WhoReply+ -- | TODO+ | EndOfWhoReply+ -- | Lists members of IRC channels. Sent when JOINing a channel to list the+ -- users in that channel, or as a response to the NAMES command.+ | NamesReply ChannelPrivacy Channel [(Privilege, Nickname)]+ -- | Sent after a sequence of 0 or more 'NameReply's, to signal that the+ -- list transmission is finished.+ | EndOfNamesReply+ -- | TODO+ | LinksReply+ -- | TODO+ | EndOfLinksReply+ -- | TODO+ | BanListReply+ -- | TODO+ | EndOfBanListReply+ -- | TODO+ | InfoReply+ -- | TODO+ | EndOfInfoReply+ -- | TODO+ | MotdStartReply+ -- | TODO+ | MessageOfTheDayReply+ -- | TODO+ | EndOfMessageOfTheDayReply+ -- | TODO+ | YoureOperReply+ -- | TODO+ | RehashingReply+ -- | TODO+ | YoureServiceReply+ -- | TODO+ | TimeReply+ -- | TODO+ | UsersStartReply+ -- | TODO+ | UsersReply+ -- | TODO+ | EndOfUsersReply+ -- | TODO+ | NoUsersReply+ -- | TODO+ | TraceLinkReply+ -- | TODO+ | TraceConnectingReply+ -- | TODO+ | TraceHandshakeReply+ -- | TODO+ | TraceUnknownReply+ -- | TODO+ | TraceOperatorReply+ -- | TODO+ | TraceUserReply+ -- | TODO+ | TraceServerReply+ -- | TODO+ | TraceServiceReply+ -- | TODO+ | TraceNewTypeReply+ -- | TODO+ | TraceClassReply+ -- | TODO+ | TraceReconnectReply+ -- | TODO+ | TraceLogReply+ -- | TODO+ | TraceEndReply+ -- | TODO+ | StatsLinkInfoReply+ -- | TODO+ | StatsCommandsReply+ -- | TODO+ | EndOfStatsReply+ -- | TODO+ | StatsUptimeReply+ -- | TODO+ | StatsOLineReply+ -- | TODO+ | UModeIsReply+ -- | TODO+ | ServListReply+ -- | TODO+ | ServListEndReply+ -- | TODO+ | LuserClientReply+ -- | TODO+ | LuserOpReply+ -- | TODO+ | LuserUnknownReply+ -- | TODO+ | LuserChannelsReply+ -- | TODO+ | LuserMeReply+ -- | TODO+ | AdminMeReply+ -- | TODO+ | AdminLocation1Reply+ -- | TODO+ | AdminLocation2Reply+ -- | TODO+ | AdminEmailReply+ -- | TODO+ | TryAgainReply+ deriving (Eq, Show)++-- | An IRC server numeric reply of a specific type.+data SpecificReply = SpecificReply Hostname Target Reply deriving Show++-- | Specifies the number of parameter a certain IRC message type accepts.+data ArgSpec+ = Exactly Int+ | AtLeast Int+ | AtMost Int+ | Between Int Int+ | OneOf [Int]+ deriving (Show)++-- | An error occuring while analyzing a parsed IRC protocol message into a+-- specific message type, such as 'JoinMessage'.+data AnalysisError+ = WrongNumArgs Int (Maybe ArgSpec)+ | InvalidArg (Maybe Int) (Maybe Text) (Maybe Text)+ | OtherError Text+ deriving (Show)
+ src/Network/IRC/Fun/Types/Base.hs view
@@ -0,0 +1,96 @@+{- This file is part of irc-fun-types.+ -+ - Written in 2015, 2016 by fr33domlover <fr33domlover@riseup.net>.+ -+ - ♡ Copying is an act of love. Please copy, reuse and share.+ -+ - The author(s) have dedicated all copyright and related and neighboring+ - rights to this software to the public domain worldwide. This software is+ - distributed without any warranty.+ -+ - You should have received a copy of the CC0 Public Domain Dedication along+ - with this software. If not, see+ - <http://creativecommons.org/publicdomain/zero/1.0/>.+ -}++-- For deriving trivial no-op instances for newtypes+{-# LANGUAGE GeneralizedNewtypeDeriving #-}++module Network.IRC.Fun.Types.Base+ ( Hostname (..)+ , ServiceName (..)+ , Username (..)+ , Nickname (..)+ , Channel (..)+ , CmdName (..)+ , CmdNumber (..)+ , Parameter+ , MsgContent (..)+ , Password (..)+ , ChannelKey (..)+ , ChannelTopic (..)+ , RealName (..)+ , Comment (..)+ , PortNumber (..)+ , Privilege (..)+ , ChannelPrivacy (..)+ )+where++import Data.Monoid (Monoid)+import Data.String (IsString)+import Data.Text (Text)++-- | IRC server hostname, e.g. @orwell.freenode.net@+newtype Hostname = Hostname { unHostname :: Text } deriving (Eq, Show)++-- | An IRC service name.+newtype ServiceName = ServiceName { unServiceName :: Text } deriving (Eq, Show)++-- | System user name, i.e. the first part of user\@host.tld+newtype Username = Username { unUsername :: Text } deriving (Eq, Show)++-- | IRC nickname+newtype Nickname = Nickname { unNickname :: Text } deriving (Eq, Show)++-- | IRC channel name (including the prefix character), e.g. @#freepost@+newtype Channel = Channel { unChannel :: Text } deriving (Eq, Show)++-- | IRC protocol command name, i.e. @PRIVMSG@+newtype CmdName = CmdName { unCmdName :: Text } deriving (Eq, Show)++-- | IRC protocol numeric command number+newtype CmdNumber = CmdNumber { unCmdNumber :: Int } deriving (Eq, Show)++-- | IRC message parameter, e.g. second word in @JOIN #freepost@+type Parameter = Text++-- | Chat message content, i.e. a message or a part of a text message meant to+-- be sent or received between people through IRC.+newtype MsgContent = MsgContent { unMsgContent :: Text }+ deriving (Show, Monoid, IsString)++-- | IRC connection password.+newtype Password = Password { unPassword :: Text } deriving (Eq, Show)++-- | IRC channel password.+newtype ChannelKey = ChannelKey { unChannelKey :: Text } deriving (Eq, Show)++-- | IRC channel topic line.+newtype ChannelTopic = ChannelTopic { unChannelTopic :: Text } deriving Show++-- | A user's \"real name\" as kept by the IRC server.+newtype RealName = RealName { unRealName :: Text } deriving Show++-- | An optional comment used by several IRC commands, e.g. a part message,+-- which is a line shown when a user leaves a channel.+newtype Comment = Comment { unComment :: Text } deriving Show++-- | Network port number.+newtype PortNumber = PortNumber { unPortNumber :: Int } deriving (Eq, Show)++-- | IRC privilege status for a user in the context of a specific channel.+data Privilege = Regular | Voice | Operator deriving (Eq, Show)++-- | IRC channel privacy settings.+data ChannelPrivacy = Secret | Private | Public deriving (Eq, Show)