This repository has been archived by the owner on Mar 25, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Initial work on deriving Show * Add test for Show * Remove import * Travis etc.
- Loading branch information
Showing
8 changed files
with
167 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ | |
/output/ | ||
/.psci* | ||
/src/.webpack.js | ||
.psc-ide-port |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"preset": "grunt", | ||
"disallowSpacesInFunctionExpression": null, | ||
"requireSpacesInFunctionExpression": { | ||
"beforeOpeningRoundBrace": true, | ||
"beforeOpeningCurlyBrace": true | ||
}, | ||
"disallowSpacesInAnonymousFunctionExpression": null, | ||
"requireSpacesInAnonymousFunctionExpression": { | ||
"beforeOpeningRoundBrace": true, | ||
"beforeOpeningCurlyBrace": true | ||
}, | ||
"disallowSpacesInsideObjectBrackets": null, | ||
"requireSpacesInsideObjectBrackets": "all", | ||
"validateQuoteMarks": "\"", | ||
"requireCurlyBraces": null | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"bitwise": true, | ||
"eqeqeq": true, | ||
"forin": true, | ||
"freeze": true, | ||
"funcscope": true, | ||
"futurehostile": true, | ||
"strict": "global", | ||
"latedef": true, | ||
"maxparams": 1, | ||
"noarg": true, | ||
"nocomma": true, | ||
"nonew": true, | ||
"notypeof": true, | ||
"singleGroups": true, | ||
"undef": true, | ||
"unused": true, | ||
"eqnull": true, | ||
"predef": ["exports"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
language: node_js | ||
dist: trusty | ||
sudo: required | ||
node_js: 6 | ||
env: | ||
- PATH=$HOME/purescript:$PATH | ||
install: | ||
- TAG=$(wget -q -O - https://github.com/purescript/purescript/releases/latest --server-response --max-redirect 0 2>&1 | sed -n -e 's/.*Location:.*tag\///p') | ||
- wget -O $HOME/purescript.tar.gz https://github.com/purescript/purescript/releases/download/$TAG/linux64.tar.gz | ||
- tar -xvf $HOME/purescript.tar.gz -C $HOME/ | ||
- chmod a+x $HOME/purescript | ||
- npm install -g bower | ||
- npm install | ||
script: | ||
- bower install --production | ||
- npm run -s build | ||
- bower install | ||
- npm -s test | ||
after_success: | ||
- >- | ||
test $TRAVIS_TAG && | ||
echo $GITHUB_TOKEN | pulp login && | ||
echo y | pulp publish --no-push |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"private": true, | ||
"scripts": { | ||
"clean": "rimraf output && rimraf .pulp-cache", | ||
"build": "jshint src && jscs src && psa \"src/**/*.purs\" \"bower_components/purescript-*/src/**/*.purs\" --censor-lib --strict", | ||
"test": "psc \"src/**/*.purs\" \"bower_components/purescript-*/src/**/*.purs\" \"test/**/*.purs\" && psc-bundle \"output/**/*.js\" --module Test.Main --main Test.Main | node" | ||
}, | ||
"devDependencies": { | ||
"jscs": "^2.8.0", | ||
"jshint": "^2.9.1", | ||
"pulp": "^8.2.0", | ||
"purescript-psa": "^0.3.8", | ||
"rimraf": "^2.5.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
module Data.Generic.Rep.Show | ||
( class GenericShow | ||
, genericShow' | ||
, genericShow | ||
, class GenericShowArgs | ||
, genericShowArgs | ||
, class GenericShowFields | ||
, genericShowFields | ||
) where | ||
|
||
import Prelude (class Show, show, (<>)) | ||
import Data.Foldable (intercalate) | ||
import Data.Generic.Rep | ||
import Data.Symbol (class IsSymbol, SProxy(..), reflectSymbol) | ||
|
||
class GenericShow a where | ||
genericShow' :: a -> String | ||
|
||
class GenericShowArgs a where | ||
genericShowArgs :: a -> Array String | ||
|
||
class GenericShowFields a where | ||
genericShowFields :: a -> Array String | ||
|
||
instance genericShowNoConstructors :: GenericShow NoConstructors where | ||
genericShow' a = genericShow' a | ||
|
||
instance genericShowArgsNoArguments :: GenericShowArgs NoArguments where | ||
genericShowArgs _ = [] | ||
|
||
instance genericShowSum :: (GenericShow a, GenericShow b) => GenericShow (Sum a b) where | ||
genericShow' (Inl a) = genericShow' a | ||
genericShow' (Inr b) = genericShow' b | ||
|
||
instance genericShowArgsProduct | ||
:: (GenericShowArgs a, GenericShowArgs b) | ||
=> GenericShowArgs (Product a b) where | ||
genericShowArgs (Product a b) = genericShowArgs a <> genericShowArgs b | ||
|
||
instance genericShowFieldsProduct | ||
:: (GenericShowFields a, GenericShowFields b) | ||
=> GenericShowFields (Product a b) where | ||
genericShowFields (Product a b) = genericShowFields a <> genericShowFields b | ||
|
||
instance genericShowConstructor | ||
:: (GenericShowArgs a, IsSymbol name) | ||
=> GenericShow (Constructor name a) where | ||
genericShow' (Constructor a) = | ||
case genericShowArgs a of | ||
[] -> ctor | ||
args -> "(" <> intercalate " " ([ctor] <> args) <> ")" | ||
where | ||
ctor :: String | ||
ctor = reflectSymbol (SProxy :: SProxy name) | ||
|
||
instance genericShowArgsArgument :: Show a => GenericShowArgs (Argument a) where | ||
genericShowArgs (Argument a) = [show a] | ||
|
||
instance genericShowArgsRec :: GenericShowFields a => GenericShowArgs (Rec a) where | ||
genericShowArgs (Rec a) = ["{ " <> intercalate ", " (genericShowFields a) <> " }"] | ||
|
||
instance genericShowFieldsField | ||
:: (Show a, IsSymbol name) | ||
=> GenericShowFields (Field name a) where | ||
genericShowFields (Field a) = | ||
[reflectSymbol (SProxy :: SProxy name) <> ": " <> show a] | ||
|
||
-- | A `Generic` implementation of the `show` member from the `Show` type class. | ||
genericShow :: forall a rep. (Generic a rep, GenericShow rep) => a -> String | ||
genericShow x = genericShow' (from x) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters