Skip to content

Commit

Permalink
This refactor removes reliance on Prelude in favour of using it only …
Browse files Browse the repository at this point in the history
…where appropriate and re-implementing it otherwise.

Prelude is appropriate for `instance Show` (and therefore, String), since GHCi relies heavily on this type-class.

There is now only one top-level module (`Course`), since the others were poorly categorised. A reasonable categorisation is desirable, but needs more work to determine.

Some exercises have been removed.

Version number is bumped to indicate no compatiblity.
  • Loading branch information
tonymorris committed Nov 16, 2013
1 parent dbf96cf commit 9171af3
Show file tree
Hide file tree
Showing 40 changed files with 2,076 additions and 2,268 deletions.
3 changes: 2 additions & 1 deletion .ghci
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
:set -fno-warn-unused-do-bind
:set -fno-warn-unused-imports
:set -fno-warn-type-defaults

:set -XNoImplicitPrelude
:set -XSafe
41 changes: 23 additions & 18 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ instructions are not contained herein.
You may need to set permissions on a file, `chmod 600 .ghci`.

4. The `Intro` module does not contain exercises. Its purpose is to demonstrate
the structure of a project. The first recommend exercise is `Structure.List`.
the structure of a project. The first recommend exercise is `Course.List`.

5. Edit a source file to a proposed solution to an exercise. At the `ghci`
prompt, issue the command `:reload`. This will compile your solution and
Expand Down Expand Up @@ -131,26 +131,31 @@ compiler error.

### Progression

It is recommended to perform some exercises before others. The first step is to inspect the `Intro` modules. They
contain examples of data structures and Haskell syntax. The next step is to complete the exercises in `Structure.List`.
It is recommended to perform some exercises before others. The first step is to inspect the introduction modules.

* `Course.Id`
* `Course.Optional`
* `Course.Validation`

They contain examples of data structures and Haskell syntax. The next step is to complete the exercises in `Course.List`.

After this, the following progression of modules is recommended:

* `Monad.Functor`
* `Monad.Monad`
* `Monad.State`
* `Monad.StateT`
* `Structure.ListZipper`
* `Parser.Parser`
* `Parser.MoreParser`
* `Parser.JsonParser`
* `IO.Interactive`
* `Structure.Lens`
* `Algorithm.Anagrams`
* `Algorithm.FastAnagrams`
* `Algorithm.EditDistance`
* `Structure.BKTree`
* `Algorithm.Cheque`
* `Course.Functor`
* `Course.Monad`
* `Course.State`
* `Course.StateT`
* `Course.ListZipper`
* `Course.Parser`
* `Course.MoreParser`
* `Course.JsonParser`
* `Course.Interactive`
* `Course.Lens`
* `Course.Anagrams`
* `Course.FastAnagrams`
* `Course.EditDistance`
* `Course.BKTree`
* `Course.Cheque`

After these are completed, complete the exercises in the `projects` directory.

Expand Down
53 changes: 28 additions & 25 deletions course.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: course
version: 0.0.9
version: 0.1.0
license: BSD3
license-file: etc/LICENCE
author: Tony Morris <[email protected]>
Expand Down Expand Up @@ -43,34 +43,37 @@ library
-fno-warn-type-defaults

default-extensions: Safe
NoImplicitPrelude

hs-source-dirs: src

exposed-modules: Course
Core
Algorithm.Anagrams
Algorithm.Cheque
Algorithm.EditDistance
Algorithm.FastAnagrams
Intro.Id
Intro.Optional
Intro.Validation
IO.Interactive
Monad.Compose
Monad.Functor
Monad.Monad
Monad.State
Monad.StateT
Parser.JsonParser
Parser.JsonValue
Parser.MoreParser
Parser.Parser
Parser.Person
Structure.BKTree
Structure.Lens
Structure.List
Structure.ListZipper
Structure.MetricSpace
Course.Anagrams
Course.Applicative
Course.Apply
Course.Bind
Course.Cheque
Course.Comonad
Course.Compose
Course.Core
Course.Extend
Course.FastAnagrams
Course.Functor
Course.Id
Course.Interactive
Course.JsonParser
Course.JsonValue
Course.List
Course.ListZipper
Course.Monad
Course.MoreParser
Course.Optional
Course.Parser
Course.Person
Course.State
Course.StateT
Course.Traversable
Course.Validation

test-suite doctests
type:
Expand Down
67 changes: 0 additions & 67 deletions src/Algorithm/EditDistance.hs

This file was deleted.

97 changes: 0 additions & 97 deletions src/Core.hs

This file was deleted.

50 changes: 26 additions & 24 deletions src/Course.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,29 @@

module Course (module X) where

import Core as X
import Algorithm.Anagrams as X
import Algorithm.Cheque as X
import Algorithm.EditDistance as X
import Algorithm.FastAnagrams as X
import Intro.Id as X
import Intro.Optional as X
import Intro.Validation as X
import IO.Interactive as X
import Monad.Compose as X
import Monad.Functor as X
import Monad.Monad as X
import Monad.State as X
import Monad.StateT as X
import Parser.JsonParser as X
import Parser.JsonValue as X
import Parser.MoreParser as X
import Parser.Parser as X
import Parser.Person as X
import Structure.BKTree as X
import Structure.Lens as X
import Structure.List as X
import Structure.ListZipper as X
import Structure.MetricSpace as X
import Course.Anagrams as X
import Course.Applicative as X
import Course.Apply as X
import Course.Bind as X
import Course.Cheque as X
import Course.Comonad as X
import Course.Compose as X
import Course.Core as X
import Course.Extend as X
import Course.FastAnagrams as X
import Course.Functor as X
import Course.Id as X
import Course.Interactive as X
import Course.JsonParser as X
import Course.JsonValue as X
import Course.List as X
import Course.ListZipper as X
import Course.Monad as X
import Course.MoreParser as X
import Course.Optional as X
import Course.Parser as X
import Course.Person as X
import Course.State as X
import Course.StateT as X
import Course.Traversable as X
import Course.Validation as X
22 changes: 14 additions & 8 deletions src/Algorithm/Anagrams.hs → src/Course/Anagrams.hs
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
module Algorithm.Anagrams where
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}

module Course.Anagrams where

import Course.Core
import Course.List
import Course.Functor

{-
Functions you will need
--
* fmap :: (a -> b) -> IO a -> IO b
* readFile :: FilePath -> IO String
* lines :: String -> [String]
* readFile :: FilePath -> IO Str
* lines :: Str -> [Str]
* permutations :: [a] -> [[a]]
* intersectBy :: (a -> a -> Bool) -> [a] -> [a] -> [a]
* toLower :: Char -> Char
Expand All @@ -22,16 +28,16 @@ Functions that might help
-- Return all anagrams of the given string
-- that appear in the given dictionary file.
anagrams ::
String
-> FilePath
-> IO [String]
Str
-> Filename
-> IO (List Str)
anagrams =
error "todo"

-- Compare two strings for equality, ignoring case
equalIgnoringCase ::
String
-> String
Str
-> Str
-> Bool
equalIgnoringCase =
error "todo"
Loading

0 comments on commit 9171af3

Please sign in to comment.