Skip to content
This repository was archived by the owner on Sep 20, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions Core/Strict.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
-- |
-- Module : Core.Strict
-- License : BSD-style
-- Maintainer : Foundatinon
-- Stability : stable
-- Portability : portable
--
-- Enforce strictness when executing lambda
--

module Core.Strict
( strict2
, strict3
, strict4
, strict5
, strict6
) where

strict2 :: (a -> b -> c) -> a -> b -> c
strict2 f !a !b = f a b

strict3 :: (a -> b -> c -> d) -> a -> b -> c -> d
strict3 f !a !b !c = f a b c

strict4 :: (a -> b -> c -> d -> e) -> a -> b -> c -> d -> e
strict4 f !a !b !c !d = f a b c d

strict5 :: (a -> b -> c -> d -> e -> f) -> a -> b -> c -> d -> e -> f
strict5 f !a !b !c !d !e = f a b c d e

strict6 :: (a -> b -> c -> d -> e -> f -> g) -> a -> b -> c -> d -> e -> f -> g
strict6 f !a !b !c !d !e !g = f a b c d e g

10 changes: 8 additions & 2 deletions Core/VFS/FilePath.hs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ module Core.VFS.FilePath
-- ** unsafe
, unsafeFilePath
, unsafeFileName
, extension
) where

import Core
Expand All @@ -40,7 +41,7 @@ import Core.String (Encoding(..), ValidationFailure, toBytes, fromBytes)
import Core.VFS.Path(Path(..))

import qualified Data.List

import Core.Partial
-- ------------------------------------------------------------------------- --
-- System related helpers --
-- ------------------------------------------------------------------------- --
Expand Down Expand Up @@ -148,7 +149,6 @@ instance IsString FilePath where
--
data FileName = FileName ByteArray
deriving (Eq)

-- | errors related to FileName manipulation
data FileName_Invalid
= ContainsNullByte
Expand Down Expand Up @@ -248,3 +248,9 @@ unsafeFilePath = FilePath
-- this is unsafe and is mainly needed for testing purpose
unsafeFileName :: ByteArray -> FileName
unsafeFileName = FileName

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this should be part of this PR; not quite harmful though

extension :: FileName -> Maybe FileName
extension (FileName fn) = case splitOn (\c -> c == 0x2E) fn of
[] -> Nothing
[_] -> Nothing
xs -> Just $ FileName $ fromPartial $ head $ reverse xs
1 change: 1 addition & 0 deletions foundation.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ Library
Core.Collection
Core.Primitive
Core.System.Info
Core.Strict
-- Core.View
Other-modules: Core.String.Internal
Core.String.UTF8
Expand Down