Skip to content
This repository has been archived by the owner on Mar 4, 2023. It is now read-only.

Commit

Permalink
Move over a few more commands.
Browse files Browse the repository at this point in the history
  • Loading branch information
nominolo committed Jun 18, 2010
1 parent 84b63a2 commit 29474b8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
15 changes: 14 additions & 1 deletion server/Scion/Server/Commands2.hs
@@ -1,6 +1,11 @@
{-# LANGUAGE OverloadedStrings, ExistentialQuantification #-}
{-# LANGUAGE ScopedTypeVariables, PatternGuards #-}
module Scion.Server.Commands2 where
{-# OPTIONS_GHC -fwarn-unused-binds -fwarn-unused-imports #-}
-- Warn unused binds is important, because it allows us to notice when
-- we forgot to add a command to 'allCommands'.
module Scion.Server.Commands2
( handleRequest, KeepGoing )
where

import Scion.Server.Message

Expand Down Expand Up @@ -218,6 +223,9 @@ allCommands =
, cmdListSupportedFlags
, cmdListExposedModules
, cmdLoad
, cmdListCabalComponents
, cmdCurrentComponent
, cmdForceUnload
]

instance Message ModuleName where
Expand Down Expand Up @@ -364,3 +372,8 @@ cmdLoad =
optArg "output" False $
loadComponent'

cmdCurrentComponent :: Cmd
cmdCurrentComponent = Cmd "current-component" $ noArgs $ getActiveComponent

cmdForceUnload :: Cmd
cmdForceUnload = Cmd "force-unload" $ noArgs $ unload
12 changes: 12 additions & 0 deletions server/Scion/Server/Message.hs
Expand Up @@ -212,6 +212,18 @@ instance Message a => Message [a] where
toMsg ls = MsgList $ map toMsg ls
fromMsg MsgNull = pure []
fromMsg (MsgList l) = mapM fromMsg l

-- TODO: Is this instance OK? It does not allow nested Maybe types.
-- It's meant to be more in line with the JSON/BSON data model. I.e.,
--
-- Maybe X = nullable X
--
instance Message a => Message (Maybe a) where
toMsg Nothing = MsgNull
toMsg (Just x) = toMsg x
fromMsg MsgNull = pure Nothing -- Masks 'Just ()' and 'Just Nothing'
-- as 'Nothing'
fromMsg x = Just <$> fromMsg x

------------------------------------------------------------------------
-- * Sending and Receiving Messages
Expand Down

0 comments on commit 29474b8

Please sign in to comment.