<commit_before>{-# LANGUAGE FlexibleContexts, FlexibleInstances, RankNTypes #-}
module Vimus
( Vimus
, ProgramState (..)
, CurrentView (..)
, SongListWidget
, getCurrentView
, setCurrentView
, modifyCurrentSongList
, withCurrentSongList
, withCurrentSong
, renderMainWindow
, renderToMainWindow
)
where

import Control.Monad.State (get, put, modify, liftM, lift, StateT, MonadState)

import Network.MPD.Core
import qualified Network.MPD as MPD hiding (withMPD)

import UI.Curses (Window)

import Widget (Widget, SongListWidget)
import qualified Widget

import TextWidget (TextWidget)

import qualified ListWidget

data CurrentView = Playlist | Library | Help | SearchResult

data ProgramState = ProgramState {
  currentView       :: CurrentView
, playlistWidget    :: SongListWidget
, libraryWidget     :: SongListWidget
, searchResult      :: SongListWidget
, helpWidget        :: TextWidget
, mainWindow        :: Window
, statusLine        :: Window
, getLastSearchTerm :: String
}


instance MonadMPD (StateT ProgramState MPD) where
  open        = lift open
  close       = lift close
  send        = lift . send
  getPassword = lift getPassword

type Vimus a = StateT ProgramState MPD a

{-
newtype Vimus a = Vimus {
  runVimus :: StateT ProgramState MPD a
} deriving (Monad, Functor, MonadIO, MonadState ProgramState, MonadError MPDError, MonadMPD)
-}


setCurrentView :: CurrentView -> Vimus ()
setCurrentView v = modify (\state -> state { currentView = v })

getCurrentView :: Vimus CurrentView
getCurrentView = currentView `liftM` get
<commit_msg>Get rid of some warnings<commit_after>{-# LANGUAGE FlexibleContexts, FlexibleInstances, RankNTypes #-}
module Vimus
( Vimus
, ProgramState (..)
, CurrentView (..)
, SongListWidget
, getCurrentView
, setCurrentView
, modifyCurrentSongList
, withCurrentSongList
, withCurrentSong
, renderMainWindow
, renderToMainWindow
)
where

import Control.Monad.State (get, put, modify, liftM, lift, StateT, MonadState)

import Network.MPD.Core
import qualified Network.MPD as MPD hiding (withMPD)

import UI.Curses (Window)

import Widget (Widget, SongListWidget)
import qualified Widget

import TextWidget (TextWidget)

import qualified ListWidget

data CurrentView = Playlist | Library | Help | SearchResult

data ProgramState = ProgramState {
  currentView       :: CurrentView
, playlistWidget    :: SongListWidget
, libraryWidget     :: SongListWidget
, searchResult      :: SongListWidget
, helpWidget        :: TextWidget
, mainWindow        :: Window
, statusLine        :: Window
, getLastSearchTerm :: String
}


instance MonadMPD (StateT ProgramState MPD) where
  getVersion  = lift getVersion
  open        = lift open
  close       = lift close
  send        = lift . send
  getHandle   = lift getHandle
  setPassword = lift . setPassword
  getPassword = lift getPassword

type Vimus a = StateT ProgramState MPD a

{-
newtype Vimus a = Vimus {
  runVimus :: StateT ProgramState MPD a
} deriving (Monad, Functor, MonadIO, MonadState ProgramState, MonadError MPDError, MonadMPD)
-}


setCurrentView :: CurrentView -> Vimus ()
setCurrentView v = modify (\state -> state { currentView = v })

getCurrentView :: Vimus CurrentView
getCurrentView = currentView `liftM` get

{'fraction_non_alphanumeric': 0.08067018305926156, 'fraction_numerical': 0.0, 'mean_word_length': 4.117460317460317, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3162312', 'n_tokens_mistral': 980, 'n_tokens_neox': 953, 'n_words': 289}