acme-pointful-numbers (empty) → 0.1.2.3
raw patch · 4 files changed
+133/−0 lines, 4 filesdep +basedep +splitsetup-changed
Dependencies added: base, split
Files
- Acme/Pointful.hs +70/−0
- LICENSE +30/−0
- Setup.hs +2/−0
- acme-pointful-numbers.cabal +31/−0
+ Acme/Pointful.hs view
@@ -0,0 +1,70 @@+-- |+-- Module : Acme.Pointful+-- Copyright : (c) 2014 Antonio Nikishaev+--+-- License : BSD-style+-- Maintainer : a@lelf.me+-- +-- This module allows you to make more points in your numbers+-- +-- > import Prelude hiding ((.))+-- > import Acme.Pointful -- re-exports Control.Category's (.)+-- >+-- >+-- > ghc, ip ∷ Pointful+-- >+-- > ghc = 7.8.2 -- ≡ Pointful [7,8,2]+-- > ip = 192.168.100.1+-- +-- It won't work with big numbers (and it won't even try to prevent incorrect results).+-- Up to 7 digits is ok.+--+-- Don't use if your code is not pointless enough.++{-# LANGUAGE UndecidableInstances #-}+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE TypeOperators #-}+++module Acme.Pointful (Pointful,+ id,(.)) where++import Prelude hiding (id,(.))+import Numeric+import Control.Category+import Data.List.Split+++data Chuwabra a b = Pointful [Integer]+ deriving Show++type (+) = Chuwabra+type Pointful = () + ((),())+++instance Num (Chuwabra a b) where+ fromInteger = Pointful . (:[])+ abs = undefined+ signum = undefined+ negate = undefined+ (+) = undefined+ (*) = undefined+++instance Category Chuwabra where+ id = Pointful []+ Pointful a . Pointful b = Pointful $ a++b++instance Num (Chuwabra a b) => Fractional (Chuwabra a b) where+ fromRational = Pointful . map read . splitOn "." . flip (showFFloat Nothing) "" . fromRational+ recip = undefined+++-- So how in the hell this bloody magic works+--+-- 1 is fromInteger 1 ∷ Pointful+-- 3.14 is fromRational (157 % 50)+-- 3.14.159 is 3.14 . 159+-- etc+--+
+ LICENSE view
@@ -0,0 +1,30 @@+Copyright (c) 2014, Anton Nikishaev++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++ * Redistributions of source code must retain the above copyright+ notice, this list of conditions and the following disclaimer.++ * Redistributions in binary form must reproduce the above+ copyright notice, this list of conditions and the following+ disclaimer in the documentation and/or other materials provided+ with the distribution.++ * Neither the name of Anton Nikishaev nor the names of other+ contributors may be used to endorse or promote products derived+ from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ acme-pointful-numbers.cabal view
@@ -0,0 +1,31 @@+-- Initial acme-pointful-nums.cabal generated by cabal init. For further +-- documentation, see http://haskell.org/cabal/users-guide/++name: acme-pointful-numbers+version: 0.1.2.3+synopsis: Make more than one point in numeric literals+description: Allows use to write more pointful than usual numbers. Example: @3.14.159@.+ .+ This is very useful for various obvious undisclosed reasons.+license: BSD3+license-file: LICENSE+author: Antonio Nikishaev+maintainer: Antonio Nikishaev <a@lelf.me>+category: ACME+build-type: Simple+cabal-version: >=1.10++library+ exposed-modules: Acme.Pointful+ other-extensions: UndecidableInstances, FlexibleContexts+ build-depends: base >=4.6 && <5, split >=0.2+ default-language: Haskell2010++source-repository head+ type: darcs+ location: http://hub.darcs.net/lelf/acme-pointful-numbers++source-repository head+ type: git+ location: https://github.com/llelf/acme-pointful-numbers+